babylon.d.ts 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isReady;
  377. /** @hidden */
  378. _currentRenderId: number;
  379. private _parentRenderId;
  380. protected _childRenderId: number;
  381. /** @hidden */
  382. _waitingParentId: Nullable<string>;
  383. /** @hidden */
  384. _scene: Scene;
  385. /** @hidden */
  386. _cache: any;
  387. private _parentNode;
  388. private _children;
  389. /**
  390. * Gets a boolean indicating if the node has been disposed
  391. * @returns true if the node was disposed
  392. */
  393. isDisposed(): boolean;
  394. /**
  395. * Gets or sets the parent of the node
  396. */
  397. parent: Nullable<Node>;
  398. private _animationPropertiesOverride;
  399. /**
  400. * Gets or sets the animation properties override
  401. */
  402. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  403. /**
  404. * Gets a string idenfifying the name of the class
  405. * @returns "Node" string
  406. */
  407. getClassName(): string;
  408. /**
  409. * An event triggered when the mesh is disposed
  410. */
  411. onDisposeObservable: Observable<Node>;
  412. private _onDisposeObserver;
  413. /**
  414. * Sets a callback that will be raised when the node will be disposed
  415. */
  416. onDispose: () => void;
  417. /**
  418. * Creates a new Node
  419. * @param {string} name - the name and id to be given to this node
  420. * @param {BABYLON.Scene} the scene this node will be added to
  421. */
  422. constructor(name: string, scene?: Nullable<Scene>);
  423. /**
  424. * Gets the scene of the node
  425. * @returns a {BABYLON.Scene}
  426. */
  427. getScene(): Scene;
  428. /**
  429. * Gets the engine of the node
  430. * @returns a {BABYLON.Engine}
  431. */
  432. getEngine(): Engine;
  433. private _behaviors;
  434. /**
  435. * Attach a behavior to the node
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. * @param behavior defines the behavior to attach
  438. * @returns the current Node
  439. */
  440. addBehavior(behavior: Behavior<Node>): Node;
  441. /**
  442. * Remove an attached behavior
  443. * @see http://doc.babylonjs.com/features/behaviour
  444. * @param behavior defines the behavior to attach
  445. * @returns the current Node
  446. */
  447. removeBehavior(behavior: Behavior<Node>): Node;
  448. /**
  449. * Gets the list of attached behaviors
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. */
  452. readonly behaviors: Behavior<Node>[];
  453. /**
  454. * Gets an attached behavior by name
  455. * @param name defines the name of the behavior to look for
  456. * @see http://doc.babylonjs.com/features/behaviour
  457. * @returns null if behavior was not found else the requested behavior
  458. */
  459. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  460. /**
  461. * Returns the world matrix of the node
  462. * @returns a matrix containing the node's world matrix
  463. */
  464. getWorldMatrix(): Matrix;
  465. /** @hidden */
  466. _getWorldMatrixDeterminant(): number;
  467. /** @hidden */
  468. _initCache(): void;
  469. /** @hidden */
  470. updateCache(force?: boolean): void;
  471. /** @hidden */
  472. _updateCache(ignoreParentClass?: boolean): void;
  473. /** @hidden */
  474. _isSynchronized(): boolean;
  475. /** @hidden */
  476. _markSyncedWithParent(): void;
  477. /** @hidden */
  478. isSynchronizedWithParent(): boolean;
  479. /** @hidden */
  480. isSynchronized(updateCache?: boolean): boolean;
  481. /** @hidden */
  482. hasNewParent(update?: boolean): boolean;
  483. /**
  484. * Is this node ready to be used/rendered
  485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  486. * @return true if the node is ready
  487. */
  488. isReady(completeCheck?: boolean): boolean;
  489. /**
  490. * Is this node enabled?
  491. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  492. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  493. * @return whether this node (and its parent) is enabled
  494. */
  495. isEnabled(checkAncestors?: boolean): boolean;
  496. /**
  497. * Set the enabled state of this node
  498. * @param value defines the new enabled state
  499. */
  500. setEnabled(value: boolean): void;
  501. /**
  502. * Is this node a descendant of the given node?
  503. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  504. * @param ancestor defines the parent node to inspect
  505. * @returns a boolean indicating if this node is a descendant of the given node
  506. */
  507. isDescendantOf(ancestor: Node): boolean;
  508. /** @hidden */
  509. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  510. /**
  511. * Will return all nodes that have this node as ascendant
  512. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  513. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  514. * @return all children nodes of all types
  515. */
  516. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  517. /**
  518. * Get all child-meshes of this node
  519. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  520. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  521. * @returns an array of {BABYLON.AbstractMesh}
  522. */
  523. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  524. /**
  525. * Get all child-transformNodes of this node
  526. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  527. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  528. * @returns an array of {BABYLON.TransformNode}
  529. */
  530. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  531. /**
  532. * Get all direct children of this node
  533. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  534. * @returns an array of {BABYLON.Node}
  535. */
  536. getChildren(predicate?: (node: Node) => boolean): Node[];
  537. /** @hidden */
  538. _setReady(state: boolean): void;
  539. /**
  540. * Get an animation by name
  541. * @param name defines the name of the animation to look for
  542. * @returns null if not found else the requested animation
  543. */
  544. getAnimationByName(name: string): Nullable<Animation>;
  545. /**
  546. * Creates an animation range for this node
  547. * @param name defines the name of the range
  548. * @param from defines the starting key
  549. * @param to defines the end key
  550. */
  551. createAnimationRange(name: string, from: number, to: number): void;
  552. /**
  553. * Delete a specific animation range
  554. * @param name defines the name of the range to delete
  555. * @param deleteFrames defines if animation frames from the range must be deleted as well
  556. */
  557. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  558. /**
  559. * Get an animation range by name
  560. * @param name defines the name of the animation range to look for
  561. * @returns null if not found else the requested animation range
  562. */
  563. getAnimationRange(name: string): Nullable<AnimationRange>;
  564. /**
  565. * Will start the animation sequence
  566. * @param name defines the range frames for animation sequence
  567. * @param loop defines if the animation should loop (false by default)
  568. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  569. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  570. * @returns the object created for this animation. If range does not exist, it will return null
  571. */
  572. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  573. /**
  574. * Serialize animation ranges into a JSON compatible object
  575. * @returns serialization object
  576. */
  577. serializeAnimationRanges(): any;
  578. /**
  579. * Computes the world matrix of the node
  580. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  581. * @returns the world matrix
  582. */
  583. computeWorldMatrix(force?: boolean): Matrix;
  584. /**
  585. * Releases resources associated with this node.
  586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  588. */
  589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  590. /**
  591. * Parse animation range data from a serialization object and store them into a given node
  592. * @param node defines where to store the animation ranges
  593. * @param parsedNode defines the serialization object to read data from
  594. * @param scene defines the hosting scene
  595. */
  596. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * Define an interface for all classes that will hold resources
  602. */
  603. interface IDisposable {
  604. /**
  605. * Releases all held resources
  606. */
  607. dispose(): void;
  608. }
  609. /**
  610. * Interface used to let developers provide their own mesh selection mechanism
  611. */
  612. interface IActiveMeshCandidateProvider {
  613. /**
  614. * Return the list of active meshes
  615. * @param scene defines the current scene
  616. * @returns the list of active meshes
  617. */
  618. getMeshes(scene: Scene): AbstractMesh[];
  619. /**
  620. * Indicates if the meshes have been checked to make sure they are isEnabled()
  621. */
  622. readonly checksIsEnabled: boolean;
  623. }
  624. /**
  625. * This class is used by the onRenderingGroupObservable
  626. */
  627. class RenderingGroupInfo {
  628. /**
  629. * The Scene that being rendered
  630. */
  631. scene: Scene;
  632. /**
  633. * The camera currently used for the rendering pass
  634. */
  635. camera: Nullable<Camera>;
  636. /**
  637. * The ID of the renderingGroup being processed
  638. */
  639. renderingGroupId: number;
  640. }
  641. /**
  642. * Represents a scene to be rendered by the engine.
  643. * @see http://doc.babylonjs.com/features/scene
  644. */
  645. class Scene extends AbstractScene implements IAnimatable {
  646. private static _uniqueIdCounter;
  647. /** The fog is deactivated */
  648. static readonly FOGMODE_NONE: number;
  649. /** The fog density is following an exponential function */
  650. static readonly FOGMODE_EXP: number;
  651. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  652. static readonly FOGMODE_EXP2: number;
  653. /** The fog density is following a linear function. */
  654. static readonly FOGMODE_LINEAR: number;
  655. /**
  656. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  658. */
  659. static MinDeltaTime: number;
  660. /**
  661. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  663. */
  664. static MaxDeltaTime: number;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  667. */
  668. autoClear: boolean;
  669. /**
  670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  671. */
  672. autoClearDepthAndStencil: boolean;
  673. /**
  674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  675. */
  676. clearColor: Color4;
  677. /**
  678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  679. */
  680. ambientColor: Color3;
  681. /** @hidden */
  682. _environmentBRDFTexture: BaseTexture;
  683. /** @hidden */
  684. protected _environmentTexture: BaseTexture;
  685. /**
  686. * Texture used in all pbr material as the reflection texture.
  687. * As in the majority of the scene they are the same (exception for multi room and so on),
  688. * this is easier to reference from here than from all the materials.
  689. */
  690. /**
  691. * Texture used in all pbr material as the reflection texture.
  692. * As in the majority of the scene they are the same (exception for multi room and so on),
  693. * this is easier to set here than in all the materials.
  694. */
  695. environmentTexture: BaseTexture;
  696. /** @hidden */
  697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  698. /**
  699. * Default image processing configuration used either in the rendering
  700. * Forward main pass or through the imageProcessingPostProcess if present.
  701. * As in the majority of the scene they are the same (exception for multi camera),
  702. * this is easier to reference from here than from all the materials and post process.
  703. *
  704. * No setter as we it is a shared configuration, you can set the values instead.
  705. */
  706. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  707. private _forceWireframe;
  708. /**
  709. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  710. */
  711. forceWireframe: boolean;
  712. private _forcePointsCloud;
  713. /**
  714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  715. */
  716. forcePointsCloud: boolean;
  717. /**
  718. * Gets or sets the active clipplane 1
  719. */
  720. clipPlane: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 2
  723. */
  724. clipPlane2: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 3
  727. */
  728. clipPlane3: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 4
  731. */
  732. clipPlane4: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. private _spritePredicate;
  778. /**
  779. * An event triggered when the scene is disposed.
  780. */
  781. onDisposeObservable: Observable<Scene>;
  782. private _onDisposeObserver;
  783. /** Sets a function to be executed when this scene is disposed. */
  784. onDispose: () => void;
  785. /**
  786. * An event triggered before rendering the scene (right after animations and physics)
  787. */
  788. onBeforeRenderObservable: Observable<Scene>;
  789. private _onBeforeRenderObserver;
  790. /** Sets a function to be executed before rendering this scene */
  791. beforeRender: Nullable<() => void>;
  792. /**
  793. * An event triggered after rendering the scene
  794. */
  795. onAfterRenderObservable: Observable<Scene>;
  796. private _onAfterRenderObserver;
  797. /** Sets a function to be executed after rendering this scene */
  798. afterRender: Nullable<() => void>;
  799. /**
  800. * An event triggered before animating the scene
  801. */
  802. onBeforeAnimationsObservable: Observable<Scene>;
  803. /**
  804. * An event triggered after animations processing
  805. */
  806. onAfterAnimationsObservable: Observable<Scene>;
  807. /**
  808. * An event triggered before draw calls are ready to be sent
  809. */
  810. onBeforeDrawPhaseObservable: Observable<Scene>;
  811. /**
  812. * An event triggered after draw calls have been sent
  813. */
  814. onAfterDrawPhaseObservable: Observable<Scene>;
  815. /**
  816. * An event triggered when physic simulation is about to be run
  817. */
  818. onBeforePhysicsObservable: Observable<Scene>;
  819. /**
  820. * An event triggered when physic simulation has been done
  821. */
  822. onAfterPhysicsObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when the scene is ready
  825. */
  826. onReadyObservable: Observable<Scene>;
  827. /**
  828. * An event triggered before rendering a camera
  829. */
  830. onBeforeCameraRenderObservable: Observable<Camera>;
  831. private _onBeforeCameraRenderObserver;
  832. /** Sets a function to be executed before rendering a camera*/
  833. beforeCameraRender: () => void;
  834. /**
  835. * An event triggered after rendering a camera
  836. */
  837. onAfterCameraRenderObservable: Observable<Camera>;
  838. private _onAfterCameraRenderObserver;
  839. /** Sets a function to be executed after rendering a camera*/
  840. afterCameraRender: () => void;
  841. /**
  842. * An event triggered when active meshes evaluation is about to start
  843. */
  844. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  845. /**
  846. * An event triggered when active meshes evaluation is done
  847. */
  848. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when particles rendering is about to start
  851. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  852. */
  853. onBeforeParticlesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when particles rendering is done
  856. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  857. */
  858. onAfterParticlesRenderingObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when sprites rendering is about to start
  861. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  862. */
  863. onBeforeSpritesRenderingObservable: Observable<Scene>;
  864. /**
  865. * An event triggered when sprites rendering is done
  866. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  867. */
  868. onAfterSpritesRenderingObservable: Observable<Scene>;
  869. /**
  870. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  871. */
  872. onDataLoadedObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when a camera is created
  875. */
  876. onNewCameraAddedObservable: Observable<Camera>;
  877. /**
  878. * An event triggered when a camera is removed
  879. */
  880. onCameraRemovedObservable: Observable<Camera>;
  881. /**
  882. * An event triggered when a light is created
  883. */
  884. onNewLightAddedObservable: Observable<Light>;
  885. /**
  886. * An event triggered when a light is removed
  887. */
  888. onLightRemovedObservable: Observable<Light>;
  889. /**
  890. * An event triggered when a geometry is created
  891. */
  892. onNewGeometryAddedObservable: Observable<Geometry>;
  893. /**
  894. * An event triggered when a geometry is removed
  895. */
  896. onGeometryRemovedObservable: Observable<Geometry>;
  897. /**
  898. * An event triggered when a transform node is created
  899. */
  900. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  901. /**
  902. * An event triggered when a transform node is removed
  903. */
  904. onTransformNodeRemovedObservable: Observable<TransformNode>;
  905. /**
  906. * An event triggered when a mesh is created
  907. */
  908. onNewMeshAddedObservable: Observable<AbstractMesh>;
  909. /**
  910. * An event triggered when a mesh is removed
  911. */
  912. onMeshRemovedObservable: Observable<AbstractMesh>;
  913. /**
  914. * An event triggered when render targets are about to be rendered
  915. * Can happen multiple times per frame.
  916. */
  917. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  918. /**
  919. * An event triggered when render targets were rendered.
  920. * Can happen multiple times per frame.
  921. */
  922. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  923. /**
  924. * An event triggered before calculating deterministic simulation step
  925. */
  926. onBeforeStepObservable: Observable<Scene>;
  927. /**
  928. * An event triggered after calculating deterministic simulation step
  929. */
  930. onAfterStepObservable: Observable<Scene>;
  931. /**
  932. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  933. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  934. * 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)
  935. */
  936. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  937. /**
  938. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  939. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  940. * 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)
  941. */
  942. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  943. private _registeredForLateAnimationBindings;
  944. /**
  945. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  946. */
  947. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  948. /**
  949. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  950. */
  951. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  952. /**
  953. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  954. */
  955. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  956. private _onPointerMove;
  957. private _onPointerDown;
  958. private _onPointerUp;
  959. /** Deprecated. Use onPointerObservable instead */
  960. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  961. /** Deprecated. Use onPointerObservable instead */
  962. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  963. /** Deprecated. Use onPointerObservable instead */
  964. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  965. /** Deprecated. Use onPointerObservable instead */
  966. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  967. /**
  968. * 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).
  969. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  970. */
  971. onPrePointerObservable: Observable<PointerInfoPre>;
  972. /**
  973. * Observable event triggered each time an input event is received from the rendering canvas
  974. */
  975. onPointerObservable: Observable<PointerInfo>;
  976. /**
  977. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  978. */
  979. readonly unTranslatedPointer: Vector2;
  980. /** The distance in pixel that you have to move to prevent some events */
  981. static DragMovementThreshold: number;
  982. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  983. static LongPressDelay: number;
  984. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  985. static DoubleClickDelay: number;
  986. /** If you need to check double click without raising a single click at first click, enable this flag */
  987. static ExclusiveDoubleClickMode: boolean;
  988. private _initClickEvent;
  989. private _initActionManager;
  990. private _delayedSimpleClick;
  991. private _delayedSimpleClickTimeout;
  992. private _previousDelayedSimpleClickTimeout;
  993. private _meshPickProceed;
  994. private _previousButtonPressed;
  995. private _currentPickResult;
  996. private _previousPickResult;
  997. private _totalPointersPressed;
  998. private _doubleClickOccured;
  999. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1000. cameraToUseForPointers: Nullable<Camera>;
  1001. private _pointerX;
  1002. private _pointerY;
  1003. private _unTranslatedPointerX;
  1004. private _unTranslatedPointerY;
  1005. private _startingPointerPosition;
  1006. private _previousStartingPointerPosition;
  1007. private _startingPointerTime;
  1008. private _previousStartingPointerTime;
  1009. private _pointerCaptures;
  1010. private _timeAccumulator;
  1011. private _currentStepId;
  1012. private _currentInternalStep;
  1013. /** @hidden */
  1014. _mirroredCameraPosition: Nullable<Vector3>;
  1015. /**
  1016. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1017. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1018. */
  1019. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1020. /**
  1021. * Observable event triggered each time an keyboard event is received from the hosting window
  1022. */
  1023. onKeyboardObservable: Observable<KeyboardInfo>;
  1024. private _onKeyDown;
  1025. private _onKeyUp;
  1026. private _onCanvasFocusObserver;
  1027. private _onCanvasBlurObserver;
  1028. private _useRightHandedSystem;
  1029. /**
  1030. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1031. */
  1032. useRightHandedSystem: boolean;
  1033. /**
  1034. * Sets the step Id used by deterministic lock step
  1035. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1036. * @param newStepId defines the step Id
  1037. */
  1038. setStepId(newStepId: number): void;
  1039. /**
  1040. * Gets the step Id used by deterministic lock step
  1041. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1042. * @returns the step Id
  1043. */
  1044. getStepId(): number;
  1045. /**
  1046. * Gets the internal step used by deterministic lock step
  1047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1048. * @returns the internal step
  1049. */
  1050. getInternalStep(): number;
  1051. private _fogEnabled;
  1052. /**
  1053. * Gets or sets a boolean indicating if fog is enabled on this scene
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogEnabled: boolean;
  1057. private _fogMode;
  1058. /**
  1059. * Gets or sets the fog mode to use
  1060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1061. */
  1062. fogMode: number;
  1063. /**
  1064. * Gets or sets the fog color to use
  1065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1066. */
  1067. fogColor: Color3;
  1068. /**
  1069. * Gets or sets the fog density to use
  1070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1071. */
  1072. fogDensity: number;
  1073. /**
  1074. * Gets or sets the fog start distance to use
  1075. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1076. */
  1077. fogStart: number;
  1078. /**
  1079. * Gets or sets the fog end distance to use
  1080. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1081. */
  1082. fogEnd: number;
  1083. private _shadowsEnabled;
  1084. /**
  1085. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1086. */
  1087. shadowsEnabled: boolean;
  1088. private _lightsEnabled;
  1089. /**
  1090. * Gets or sets a boolean indicating if lights are enabled on this scene
  1091. */
  1092. lightsEnabled: boolean;
  1093. /** All of the active cameras added to this scene. */
  1094. activeCameras: Camera[];
  1095. /** The current active camera */
  1096. activeCamera: Nullable<Camera>;
  1097. private _defaultMaterial;
  1098. /** The default material used on meshes when no material is affected */
  1099. /** The default material used on meshes when no material is affected */
  1100. defaultMaterial: Material;
  1101. private _texturesEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if textures are enabled on this scene
  1104. */
  1105. texturesEnabled: boolean;
  1106. /**
  1107. * Gets or sets a boolean indicating if particles are enabled on this scene
  1108. */
  1109. particlesEnabled: boolean;
  1110. /**
  1111. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1112. */
  1113. spritesEnabled: boolean;
  1114. /**
  1115. * All of the sprite managers added to this scene
  1116. * @see http://doc.babylonjs.com/babylon101/sprites
  1117. */
  1118. spriteManagers: SpriteManager[];
  1119. private _skeletonsEnabled;
  1120. /**
  1121. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1122. */
  1123. skeletonsEnabled: boolean;
  1124. /**
  1125. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1126. */
  1127. lensFlaresEnabled: boolean;
  1128. /**
  1129. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1131. */
  1132. collisionsEnabled: boolean;
  1133. private _workerCollisions;
  1134. /** @hidden */
  1135. collisionCoordinator: ICollisionCoordinator;
  1136. /**
  1137. * Defines the gravity applied to this scene (used only for collisions)
  1138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1139. */
  1140. gravity: Vector3;
  1141. /**
  1142. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1143. */
  1144. postProcessesEnabled: boolean;
  1145. /**
  1146. * The list of postprocesses added to the scene
  1147. */
  1148. postProcesses: PostProcess[];
  1149. /**
  1150. * Gets the current postprocess manager
  1151. */
  1152. postProcessManager: PostProcessManager;
  1153. /**
  1154. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1155. */
  1156. renderTargetsEnabled: boolean;
  1157. /**
  1158. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1159. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1160. */
  1161. dumpNextRenderTargets: boolean;
  1162. /**
  1163. * The list of user defined render targets added to the scene
  1164. */
  1165. customRenderTargets: RenderTargetTexture[];
  1166. /**
  1167. * Defines if texture loading must be delayed
  1168. * If true, textures will only be loaded when they need to be rendered
  1169. */
  1170. useDelayedTextureLoading: boolean;
  1171. /**
  1172. * Gets the list of meshes imported to the scene through SceneLoader
  1173. */
  1174. importedMeshesFiles: String[];
  1175. /**
  1176. * Gets or sets a boolean indicating if probes are enabled on this scene
  1177. */
  1178. probesEnabled: boolean;
  1179. /**
  1180. * The list of reflection probes added to the scene
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1182. */
  1183. reflectionProbes: ReflectionProbe[];
  1184. /**
  1185. * @hidden
  1186. */
  1187. database: Database;
  1188. /**
  1189. * Gets or sets the action manager associated with the scene
  1190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1191. */
  1192. actionManager: ActionManager;
  1193. private _meshesForIntersections;
  1194. /**
  1195. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1196. */
  1197. proceduralTexturesEnabled: boolean;
  1198. /**
  1199. * The list of procedural textures added to the scene
  1200. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1201. */
  1202. proceduralTextures: ProceduralTexture[];
  1203. private _mainSoundTrack;
  1204. /**
  1205. * The list of sound tracks added to the scene
  1206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1207. */
  1208. soundTracks: SoundTrack[];
  1209. private _audioEnabled;
  1210. private _headphone;
  1211. /**
  1212. * Gets the main soundtrack associated with the scene
  1213. */
  1214. readonly mainSoundTrack: SoundTrack;
  1215. /**
  1216. * Gets or sets the VRExperienceHelper attached to the scene
  1217. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1218. * @ignorenaming
  1219. */
  1220. VRHelper: VRExperienceHelper;
  1221. private _engine;
  1222. private _totalVertices;
  1223. /** @hidden */
  1224. _activeIndices: PerfCounter;
  1225. /** @hidden */
  1226. _activeParticles: PerfCounter;
  1227. /** @hidden */
  1228. _activeBones: PerfCounter;
  1229. private _animationRatio;
  1230. private _animationTimeLast;
  1231. private _animationTime;
  1232. /**
  1233. * Gets or sets a general scale for animation speed
  1234. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1235. */
  1236. animationTimeScale: number;
  1237. /** @hidden */
  1238. _cachedMaterial: Nullable<Material>;
  1239. /** @hidden */
  1240. _cachedEffect: Nullable<Effect>;
  1241. /** @hidden */
  1242. _cachedVisibility: Nullable<number>;
  1243. private _renderId;
  1244. private _executeWhenReadyTimeoutId;
  1245. private _intermediateRendering;
  1246. private _viewUpdateFlag;
  1247. private _projectionUpdateFlag;
  1248. private _alternateViewUpdateFlag;
  1249. private _alternateProjectionUpdateFlag;
  1250. /** @hidden */
  1251. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1252. private _activeRequests;
  1253. private _pendingData;
  1254. private _isDisposed;
  1255. /**
  1256. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1257. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1258. */
  1259. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1260. private _activeMeshes;
  1261. private _processedMaterials;
  1262. private _renderTargets;
  1263. /** @hidden */
  1264. _activeParticleSystems: SmartArray<IParticleSystem>;
  1265. private _activeSkeletons;
  1266. private _softwareSkinnedMeshes;
  1267. private _renderingManager;
  1268. private _physicsEngine;
  1269. /** @hidden */
  1270. _activeAnimatables: Animatable[];
  1271. private _transformMatrix;
  1272. private _sceneUbo;
  1273. private _alternateSceneUbo;
  1274. private _pickWithRayInverseMatrix;
  1275. private _outlineRenderer;
  1276. private _viewMatrix;
  1277. private _projectionMatrix;
  1278. private _alternateViewMatrix;
  1279. private _alternateProjectionMatrix;
  1280. private _alternateTransformMatrix;
  1281. private _useAlternateCameraConfiguration;
  1282. private _alternateRendering;
  1283. /** @hidden */
  1284. _forcedViewPosition: Nullable<Vector3>;
  1285. /** @hidden */
  1286. readonly _isAlternateRenderingEnabled: boolean;
  1287. private _frustumPlanes;
  1288. /**
  1289. * Gets the list of frustum planes (built from the active camera)
  1290. */
  1291. readonly frustumPlanes: Plane[];
  1292. /**
  1293. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1294. * This is useful if there are more lights that the maximum simulteanous authorized
  1295. */
  1296. requireLightSorting: boolean;
  1297. private _selectionOctree;
  1298. private _pointerOverMesh;
  1299. private _pointerOverSprite;
  1300. private _debugLayer;
  1301. private _pickedDownMesh;
  1302. private _pickedUpMesh;
  1303. private _pickedDownSprite;
  1304. private _externalData;
  1305. private _uid;
  1306. /**
  1307. * @hidden
  1308. * Backing store of defined scene components.
  1309. */
  1310. _components: ISceneComponent[];
  1311. /**
  1312. * @hidden
  1313. * Backing store of defined scene components.
  1314. */
  1315. _serializableComponents: ISceneSerializableComponent[];
  1316. /**
  1317. * List of components to register on the next registration step.
  1318. */
  1319. private _transientComponents;
  1320. /**
  1321. * Registers the transient components if needed.
  1322. */
  1323. private _registerTransientComponents;
  1324. /**
  1325. * @hidden
  1326. * Add a component to the scene.
  1327. * Note that the ccomponent could be registered on th next frame if this is called after
  1328. * the register component stage.
  1329. * @param component Defines the component to add to the scene
  1330. */
  1331. _addComponent(component: ISceneComponent): void;
  1332. /**
  1333. * @hidden
  1334. * Gets a component from the scene.
  1335. * @param name defines the name of the component to retrieve
  1336. * @returns the component or null if not present
  1337. */
  1338. _getComponent(name: string): Nullable<ISceneComponent>;
  1339. /**
  1340. * @hidden
  1341. * Defines the actions happening before camera updates.
  1342. */
  1343. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1344. /**
  1345. * @hidden
  1346. * Defines the actions happening before camera updates.
  1347. */
  1348. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1349. /**
  1350. * @hidden
  1351. * Defines the actions happening during the per mesh ready checks.
  1352. */
  1353. _isReadyForMeshStage: Stage<MeshStageAction>;
  1354. /**
  1355. * @hidden
  1356. * Defines the actions happening before evaluate active mesh checks.
  1357. */
  1358. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1359. /**
  1360. * @hidden
  1361. * Defines the actions happening during the evaluate sub mesh checks.
  1362. */
  1363. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1364. /**
  1365. * @hidden
  1366. * Defines the actions happening during the active mesh stage.
  1367. */
  1368. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1369. /**
  1370. * @hidden
  1371. * Defines the actions happening during the per camera render target step.
  1372. */
  1373. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1374. /**
  1375. * @hidden
  1376. * Defines the actions happening just before the active camera is drawing.
  1377. */
  1378. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1379. /**
  1380. * Defines the actions happening just before a rendering group is drawing.
  1381. */
  1382. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening just after a rendering group has been drawn.
  1386. */
  1387. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening just after the active camera has been drawn.
  1391. */
  1392. _afterCameraDrawStage: Stage<CameraStageAction>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening when Geometries are rebuilding.
  1396. */
  1397. _rebuildGeometryStage: Stage<SimpleStageAction>;
  1398. /**
  1399. * Creates a new Scene
  1400. * @param engine defines the engine to use to render this scene
  1401. */
  1402. constructor(engine: Engine);
  1403. /**
  1404. * Gets the debug layer (aka Inspector) associated with the scene
  1405. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1406. */
  1407. readonly debugLayer: DebugLayer;
  1408. /**
  1409. * Gets a boolean indicating if collisions are processed on a web worker
  1410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1411. */
  1412. workerCollisions: boolean;
  1413. /**
  1414. * Gets the octree used to boost mesh selection (picking)
  1415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1416. */
  1417. readonly selectionOctree: Octree<AbstractMesh>;
  1418. /**
  1419. * Gets the mesh that is currently under the pointer
  1420. */
  1421. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1422. /**
  1423. * Gets the current on-screen X position of the pointer
  1424. */
  1425. readonly pointerX: number;
  1426. /**
  1427. * Gets the current on-screen Y position of the pointer
  1428. */
  1429. readonly pointerY: number;
  1430. /**
  1431. * Gets the cached material (ie. the latest rendered one)
  1432. * @returns the cached material
  1433. */
  1434. getCachedMaterial(): Nullable<Material>;
  1435. /**
  1436. * Gets the cached effect (ie. the latest rendered one)
  1437. * @returns the cached effect
  1438. */
  1439. getCachedEffect(): Nullable<Effect>;
  1440. /**
  1441. * Gets the cached visibility state (ie. the latest rendered one)
  1442. * @returns the cached visibility state
  1443. */
  1444. getCachedVisibility(): Nullable<number>;
  1445. /**
  1446. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1447. * @param material defines the current material
  1448. * @param effect defines the current effect
  1449. * @param visibility defines the current visibility state
  1450. * @returns true if one parameter is not cached
  1451. */
  1452. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1453. /**
  1454. * Gets the outline renderer associated with the scene
  1455. * @returns a OutlineRenderer
  1456. */
  1457. getOutlineRenderer(): OutlineRenderer;
  1458. /**
  1459. * Gets the engine associated with the scene
  1460. * @returns an Engine
  1461. */
  1462. getEngine(): Engine;
  1463. /**
  1464. * Gets the total number of vertices rendered per frame
  1465. * @returns the total number of vertices rendered per frame
  1466. */
  1467. getTotalVertices(): number;
  1468. /**
  1469. * Gets the performance counter for total vertices
  1470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1471. */
  1472. readonly totalVerticesPerfCounter: PerfCounter;
  1473. /**
  1474. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1475. * @returns the total number of active indices rendered per frame
  1476. */
  1477. getActiveIndices(): number;
  1478. /**
  1479. * Gets the performance counter for active indices
  1480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1481. */
  1482. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1483. /**
  1484. * Gets the total number of active particles rendered per frame
  1485. * @returns the total number of active particles rendered per frame
  1486. */
  1487. getActiveParticles(): number;
  1488. /**
  1489. * Gets the performance counter for active particles
  1490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1491. */
  1492. readonly activeParticlesPerfCounter: PerfCounter;
  1493. /**
  1494. * Gets the total number of active bones rendered per frame
  1495. * @returns the total number of active bones rendered per frame
  1496. */
  1497. getActiveBones(): number;
  1498. /**
  1499. * Gets the performance counter for active bones
  1500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1501. */
  1502. readonly activeBonesPerfCounter: PerfCounter;
  1503. /** @hidden */
  1504. getInterFramePerfCounter(): number;
  1505. /** @hidden */
  1506. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1507. /** @hidden */
  1508. getLastFrameDuration(): number;
  1509. /** @hidden */
  1510. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1511. /** @hidden */
  1512. getEvaluateActiveMeshesDuration(): number;
  1513. /** @hidden */
  1514. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1515. /**
  1516. * Gets the array of active meshes
  1517. * @returns an array of AbstractMesh
  1518. */
  1519. getActiveMeshes(): SmartArray<AbstractMesh>;
  1520. /** @hidden */
  1521. getRenderTargetsDuration(): number;
  1522. /** @hidden */
  1523. getRenderDuration(): number;
  1524. /** @hidden */
  1525. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1526. /** @hidden */
  1527. getParticlesDuration(): number;
  1528. /** @hidden */
  1529. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getSpritesDuration(): number;
  1532. /** @hidden */
  1533. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1534. /**
  1535. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1536. * @returns a number
  1537. */
  1538. getAnimationRatio(): number;
  1539. /**
  1540. * Gets an unique Id for the current frame
  1541. * @returns a number
  1542. */
  1543. getRenderId(): number;
  1544. /** Call this function if you want to manually increment the render Id*/
  1545. incrementRenderId(): void;
  1546. private _updatePointerPosition;
  1547. private _createUbo;
  1548. private _createAlternateUbo;
  1549. private _pickSpriteButKeepRay;
  1550. private _setRayOnPointerInfo;
  1551. /**
  1552. * Use this method to simulate a pointer move on a mesh
  1553. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1554. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1555. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1556. * @returns the current scene
  1557. */
  1558. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1559. private _processPointerMove;
  1560. private _checkPrePointerObservable;
  1561. /**
  1562. * Use this method to simulate a pointer down on a mesh
  1563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1566. * @returns the current scene
  1567. */
  1568. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1569. private _processPointerDown;
  1570. /**
  1571. * Use this method to simulate a pointer up on a mesh
  1572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1575. * @returns the current scene
  1576. */
  1577. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1578. private _processPointerUp;
  1579. /**
  1580. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1581. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1582. * @returns true if the pointer was captured
  1583. */
  1584. isPointerCaptured(pointerId?: number): boolean;
  1585. /**
  1586. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1587. * @param attachUp defines if you want to attach events to pointerup
  1588. * @param attachDown defines if you want to attach events to pointerdown
  1589. * @param attachMove defines if you want to attach events to pointermove
  1590. */
  1591. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1592. /** Detaches all event handlers*/
  1593. detachControl(): void;
  1594. /**
  1595. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1596. * Delay loaded resources are not taking in account
  1597. * @return true if all required resources are ready
  1598. */
  1599. isReady(): boolean;
  1600. /** Resets all cached information relative to material (including effect and visibility) */
  1601. resetCachedMaterial(): void;
  1602. /**
  1603. * Registers a function to be called before every frame render
  1604. * @param func defines the function to register
  1605. */
  1606. registerBeforeRender(func: () => void): void;
  1607. /**
  1608. * Unregisters a function called before every frame render
  1609. * @param func defines the function to unregister
  1610. */
  1611. unregisterBeforeRender(func: () => void): void;
  1612. /**
  1613. * Registers a function to be called after every frame render
  1614. * @param func defines the function to register
  1615. */
  1616. registerAfterRender(func: () => void): void;
  1617. /**
  1618. * Unregisters a function called after every frame render
  1619. * @param func defines the function to unregister
  1620. */
  1621. unregisterAfterRender(func: () => void): void;
  1622. private _executeOnceBeforeRender;
  1623. /**
  1624. * The provided function will run before render once and will be disposed afterwards.
  1625. * A timeout delay can be provided so that the function will be executed in N ms.
  1626. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1627. * @param func The function to be executed.
  1628. * @param timeout optional delay in ms
  1629. */
  1630. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1631. /** @hidden */
  1632. _addPendingData(data: any): void;
  1633. /** @hidden */
  1634. _removePendingData(data: any): void;
  1635. /**
  1636. * Returns the number of items waiting to be loaded
  1637. * @returns the number of items waiting to be loaded
  1638. */
  1639. getWaitingItemsCount(): number;
  1640. /**
  1641. * Returns a boolean indicating if the scene is still loading data
  1642. */
  1643. readonly isLoading: boolean;
  1644. /**
  1645. * Registers a function to be executed when the scene is ready
  1646. * @param {Function} func - the function to be executed
  1647. */
  1648. executeWhenReady(func: () => void): void;
  1649. /**
  1650. * Returns a promise that resolves when the scene is ready
  1651. * @returns A promise that resolves when the scene is ready
  1652. */
  1653. whenReadyAsync(): Promise<void>;
  1654. /** @hidden */
  1655. _checkIsReady(): void;
  1656. /**
  1657. * Will start the animation sequence of a given target
  1658. * @param target defines the target
  1659. * @param from defines from which frame should animation start
  1660. * @param to defines until which frame should animation run.
  1661. * @param weight defines the weight to apply to the animation (1.0 by default)
  1662. * @param loop defines if the animation loops
  1663. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1664. * @param onAnimationEnd defines the function to be executed when the animation ends
  1665. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1666. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1667. * @returns the animatable object created for this animation
  1668. */
  1669. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1670. /**
  1671. * Will start the animation sequence of a given target
  1672. * @param target defines the target
  1673. * @param from defines from which frame should animation start
  1674. * @param to defines until which frame should animation run.
  1675. * @param loop defines if the animation loops
  1676. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1677. * @param onAnimationEnd defines the function to be executed when the animation ends
  1678. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1679. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1680. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1681. * @returns the animatable object created for this animation
  1682. */
  1683. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1684. /**
  1685. * Begin a new animation on a given node
  1686. * @param target defines the target where the animation will take place
  1687. * @param animations defines the list of animations to start
  1688. * @param from defines the initial value
  1689. * @param to defines the final value
  1690. * @param loop defines if you want animation to loop (off by default)
  1691. * @param speedRatio defines the speed ratio to apply to all animations
  1692. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1693. * @returns the list of created animatables
  1694. */
  1695. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1696. /**
  1697. * Begin a new animation on a given node and its hierarchy
  1698. * @param target defines the root node where the animation will take place
  1699. * @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.
  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 animatables created for all nodes
  1707. */
  1708. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1709. /**
  1710. * Gets the animatable associated with a specific target
  1711. * @param target defines the target of the animatable
  1712. * @returns the required animatable if found
  1713. */
  1714. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1715. /**
  1716. * Gets all animatables associated with a given target
  1717. * @param target defines the target to look animatables for
  1718. * @returns an array of Animatables
  1719. */
  1720. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1721. /**
  1722. * Gets all animatable attached to the scene
  1723. */
  1724. readonly animatables: Animatable[];
  1725. /**
  1726. * Will stop the animation of the given target
  1727. * @param target - the target
  1728. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1729. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1730. */
  1731. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1732. /**
  1733. * Stops and removes all animations that have been applied to the scene
  1734. */
  1735. stopAllAnimations(): void;
  1736. private _animate;
  1737. /** @hidden */
  1738. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1739. private _processLateAnimationBindingsForMatrices;
  1740. private _processLateAnimationBindingsForQuaternions;
  1741. private _processLateAnimationBindings;
  1742. /** @hidden */
  1743. _switchToAlternateCameraConfiguration(active: boolean): void;
  1744. /**
  1745. * Gets the current view matrix
  1746. * @returns a Matrix
  1747. */
  1748. getViewMatrix(): Matrix;
  1749. /**
  1750. * Gets the current projection matrix
  1751. * @returns a Matrix
  1752. */
  1753. getProjectionMatrix(): Matrix;
  1754. /**
  1755. * Gets the current transform matrix
  1756. * @returns a Matrix made of View * Projection
  1757. */
  1758. getTransformMatrix(): Matrix;
  1759. /**
  1760. * Sets the current transform matrix
  1761. * @param view defines the View matrix to use
  1762. * @param projection defines the Projection matrix to use
  1763. */
  1764. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1765. /** @hidden */
  1766. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1767. /**
  1768. * Gets the uniform buffer used to store scene data
  1769. * @returns a UniformBuffer
  1770. */
  1771. getSceneUniformBuffer(): UniformBuffer;
  1772. /**
  1773. * Gets an unique (relatively to the current scene) Id
  1774. * @returns an unique number for the scene
  1775. */
  1776. getUniqueId(): number;
  1777. /**
  1778. * Add a mesh to the list of scene's meshes
  1779. * @param newMesh defines the mesh to add
  1780. * @param recursive if all child meshes should also be added to the scene
  1781. */
  1782. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1783. /**
  1784. * Remove a mesh for the list of scene's meshes
  1785. * @param toRemove defines the mesh to remove
  1786. * @param recursive if all child meshes should also be removed from the scene
  1787. * @returns the index where the mesh was in the mesh list
  1788. */
  1789. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1790. /**
  1791. * Add a transform node to the list of scene's transform nodes
  1792. * @param newTransformNode defines the transform node to add
  1793. */
  1794. addTransformNode(newTransformNode: TransformNode): void;
  1795. /**
  1796. * Remove a transform node for the list of scene's transform nodes
  1797. * @param toRemove defines the transform node to remove
  1798. * @returns the index where the transform node was in the transform node list
  1799. */
  1800. removeTransformNode(toRemove: TransformNode): number;
  1801. /**
  1802. * Remove a skeleton for the list of scene's skeletons
  1803. * @param toRemove defines the skeleton to remove
  1804. * @returns the index where the skeleton was in the skeleton list
  1805. */
  1806. removeSkeleton(toRemove: Skeleton): number;
  1807. /**
  1808. * Remove a morph target for the list of scene's morph targets
  1809. * @param toRemove defines the morph target to remove
  1810. * @returns the index where the morph target was in the morph target list
  1811. */
  1812. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1813. /**
  1814. * Remove a light for the list of scene's lights
  1815. * @param toRemove defines the light to remove
  1816. * @returns the index where the light was in the light list
  1817. */
  1818. removeLight(toRemove: Light): number;
  1819. /**
  1820. * Remove a camera for the list of scene's cameras
  1821. * @param toRemove defines the camera to remove
  1822. * @returns the index where the camera was in the camera list
  1823. */
  1824. removeCamera(toRemove: Camera): number;
  1825. /**
  1826. * Remove a particle system for the list of scene's particle systems
  1827. * @param toRemove defines the particle system to remove
  1828. * @returns the index where the particle system was in the particle system list
  1829. */
  1830. removeParticleSystem(toRemove: IParticleSystem): number;
  1831. /**
  1832. * Remove a animation for the list of scene's animations
  1833. * @param toRemove defines the animation to remove
  1834. * @returns the index where the animation was in the animation list
  1835. */
  1836. removeAnimation(toRemove: Animation): number;
  1837. /**
  1838. * Removes the given animation group from this scene.
  1839. * @param toRemove The animation group to remove
  1840. * @returns The index of the removed animation group
  1841. */
  1842. removeAnimationGroup(toRemove: AnimationGroup): number;
  1843. /**
  1844. * Removes the given multi-material from this scene.
  1845. * @param toRemove The multi-material to remove
  1846. * @returns The index of the removed multi-material
  1847. */
  1848. removeMultiMaterial(toRemove: MultiMaterial): number;
  1849. /**
  1850. * Removes the given material from this scene.
  1851. * @param toRemove The material to remove
  1852. * @returns The index of the removed material
  1853. */
  1854. removeMaterial(toRemove: Material): number;
  1855. /**
  1856. * Removes the given action manager from this scene.
  1857. * @param toRemove The action manager to remove
  1858. * @returns The index of the removed action manager
  1859. */
  1860. removeActionManager(toRemove: ActionManager): number;
  1861. /**
  1862. * Removes the given texture from this scene.
  1863. * @param toRemove The texture to remove
  1864. * @returns The index of the removed texture
  1865. */
  1866. removeTexture(toRemove: BaseTexture): number;
  1867. /**
  1868. * Adds the given light to this scene
  1869. * @param newLight The light to add
  1870. */
  1871. addLight(newLight: Light): void;
  1872. /**
  1873. * Sorts the list list based on light priorities
  1874. */
  1875. sortLightsByPriority(): void;
  1876. /**
  1877. * Adds the given camera to this scene
  1878. * @param newCamera The camera to add
  1879. */
  1880. addCamera(newCamera: Camera): void;
  1881. /**
  1882. * Adds the given skeleton to this scene
  1883. * @param newSkeleton The skeleton to add
  1884. */
  1885. addSkeleton(newSkeleton: Skeleton): void;
  1886. /**
  1887. * Adds the given particle system to this scene
  1888. * @param newParticleSystem The particle system to add
  1889. */
  1890. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1891. /**
  1892. * Adds the given animation to this scene
  1893. * @param newAnimation The animation to add
  1894. */
  1895. addAnimation(newAnimation: Animation): void;
  1896. /**
  1897. * Adds the given animation group to this scene.
  1898. * @param newAnimationGroup The animation group to add
  1899. */
  1900. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1901. /**
  1902. * Adds the given multi-material to this scene
  1903. * @param newMultiMaterial The multi-material to add
  1904. */
  1905. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1906. /**
  1907. * Adds the given material to this scene
  1908. * @param newMaterial The material to add
  1909. */
  1910. addMaterial(newMaterial: Material): void;
  1911. /**
  1912. * Adds the given morph target to this scene
  1913. * @param newMorphTargetManager The morph target to add
  1914. */
  1915. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1916. /**
  1917. * Adds the given geometry to this scene
  1918. * @param newGeometry The geometry to add
  1919. */
  1920. addGeometry(newGeometry: Geometry): void;
  1921. /**
  1922. * Adds the given action manager to this scene
  1923. * @param newActionManager The action manager to add
  1924. */
  1925. addActionManager(newActionManager: ActionManager): void;
  1926. /**
  1927. * Adds the given texture to this scene.
  1928. * @param newTexture The texture to add
  1929. */
  1930. addTexture(newTexture: BaseTexture): void;
  1931. /**
  1932. * Switch active camera
  1933. * @param newCamera defines the new active camera
  1934. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1935. */
  1936. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1937. /**
  1938. * sets the active camera of the scene using its ID
  1939. * @param id defines the camera's ID
  1940. * @return the new active camera or null if none found.
  1941. */
  1942. setActiveCameraByID(id: string): Nullable<Camera>;
  1943. /**
  1944. * sets the active camera of the scene using its name
  1945. * @param name defines the camera's name
  1946. * @returns the new active camera or null if none found.
  1947. */
  1948. setActiveCameraByName(name: string): Nullable<Camera>;
  1949. /**
  1950. * get an animation group using its name
  1951. * @param name defines the material's name
  1952. * @return the animation group or null if none found.
  1953. */
  1954. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1955. /**
  1956. * get a material using its id
  1957. * @param id defines the material's ID
  1958. * @return the material or null if none found.
  1959. */
  1960. getMaterialByID(id: string): Nullable<Material>;
  1961. /**
  1962. * Gets a material using its name
  1963. * @param name defines the material's name
  1964. * @return the material or null if none found.
  1965. */
  1966. getMaterialByName(name: string): Nullable<Material>;
  1967. /**
  1968. * Gets a camera using its id
  1969. * @param id defines the id to look for
  1970. * @returns the camera or null if not found
  1971. */
  1972. getCameraByID(id: string): Nullable<Camera>;
  1973. /**
  1974. * Gets a camera using its unique id
  1975. * @param uniqueId defines the unique id to look for
  1976. * @returns the camera or null if not found
  1977. */
  1978. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1979. /**
  1980. * Gets a camera using its name
  1981. * @param name defines the camera's name
  1982. * @return the camera or null if none found.
  1983. */
  1984. getCameraByName(name: string): Nullable<Camera>;
  1985. /**
  1986. * Gets a bone using its id
  1987. * @param id defines the bone's id
  1988. * @return the bone or null if not found
  1989. */
  1990. getBoneByID(id: string): Nullable<Bone>;
  1991. /**
  1992. * Gets a bone using its id
  1993. * @param name defines the bone's name
  1994. * @return the bone or null if not found
  1995. */
  1996. getBoneByName(name: string): Nullable<Bone>;
  1997. /**
  1998. * Gets a light node using its name
  1999. * @param name defines the the light's name
  2000. * @return the light or null if none found.
  2001. */
  2002. getLightByName(name: string): Nullable<Light>;
  2003. /**
  2004. * Gets a light node using its id
  2005. * @param id defines the light's id
  2006. * @return the light or null if none found.
  2007. */
  2008. getLightByID(id: string): Nullable<Light>;
  2009. /**
  2010. * Gets a light node using its scene-generated unique ID
  2011. * @param uniqueId defines the light's unique id
  2012. * @return the light or null if none found.
  2013. */
  2014. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2015. /**
  2016. * Gets a particle system by id
  2017. * @param id defines the particle system id
  2018. * @return the corresponding system or null if none found
  2019. */
  2020. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2021. /**
  2022. * Gets a geometry using its ID
  2023. * @param id defines the geometry's id
  2024. * @return the geometry or null if none found.
  2025. */
  2026. getGeometryByID(id: string): Nullable<Geometry>;
  2027. /**
  2028. * Add a new geometry to this scene
  2029. * @param geometry defines the geometry to be added to the scene.
  2030. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2031. * @return a boolean defining if the geometry was added or not
  2032. */
  2033. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2034. /**
  2035. * Removes an existing geometry
  2036. * @param geometry defines the geometry to be removed from the scene
  2037. * @return a boolean defining if the geometry was removed or not
  2038. */
  2039. removeGeometry(geometry: Geometry): boolean;
  2040. /**
  2041. * Gets the list of geometries attached to the scene
  2042. * @returns an array of Geometry
  2043. */
  2044. getGeometries(): Geometry[];
  2045. /**
  2046. * Gets the first added mesh found of a given ID
  2047. * @param id defines the id to search for
  2048. * @return the mesh found or null if not found at all
  2049. */
  2050. getMeshByID(id: string): Nullable<AbstractMesh>;
  2051. /**
  2052. * Gets a list of meshes using their id
  2053. * @param id defines the id to search for
  2054. * @returns a list of meshes
  2055. */
  2056. getMeshesByID(id: string): Array<AbstractMesh>;
  2057. /**
  2058. * Gets the first added transform node found of a given ID
  2059. * @param id defines the id to search for
  2060. * @return the found transform node or null if not found at all.
  2061. */
  2062. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2063. /**
  2064. * Gets a list of transform nodes using their id
  2065. * @param id defines the id to search for
  2066. * @returns a list of transform nodes
  2067. */
  2068. getTransformNodesByID(id: string): Array<TransformNode>;
  2069. /**
  2070. * Gets a mesh with its auto-generated unique id
  2071. * @param uniqueId defines the unique id to search for
  2072. * @return the found mesh or null if not found at all.
  2073. */
  2074. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2075. /**
  2076. * Gets a the last added mesh using a given id
  2077. * @param id defines the id to search for
  2078. * @return the found mesh or null if not found at all.
  2079. */
  2080. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2081. /**
  2082. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2083. * @param id defines the id to search for
  2084. * @return the found node or null if not found at all
  2085. */
  2086. getLastEntryByID(id: string): Nullable<Node>;
  2087. /**
  2088. * Gets a node (Mesh, Camera, Light) using a given id
  2089. * @param id defines the id to search for
  2090. * @return the found node or null if not found at all
  2091. */
  2092. getNodeByID(id: string): Nullable<Node>;
  2093. /**
  2094. * Gets a node (Mesh, Camera, Light) using a given name
  2095. * @param name defines the name to search for
  2096. * @return the found node or null if not found at all.
  2097. */
  2098. getNodeByName(name: string): Nullable<Node>;
  2099. /**
  2100. * Gets a mesh using a given name
  2101. * @param name defines the name to search for
  2102. * @return the found mesh or null if not found at all.
  2103. */
  2104. getMeshByName(name: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a transform node using a given name
  2107. * @param name defines the name to search for
  2108. * @return the found transform node or null if not found at all.
  2109. */
  2110. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2111. /**
  2112. * Gets a sound using a given name
  2113. * @param name defines the name to search for
  2114. * @return the found sound or null if not found at all.
  2115. */
  2116. getSoundByName(name: string): Nullable<Sound>;
  2117. /**
  2118. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2119. * @param id defines the id to search for
  2120. * @return the found skeleton or null if not found at all.
  2121. */
  2122. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2123. /**
  2124. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2125. * @param id defines the id to search for
  2126. * @return the found skeleton or null if not found at all.
  2127. */
  2128. getSkeletonById(id: string): Nullable<Skeleton>;
  2129. /**
  2130. * Gets a skeleton using a given name
  2131. * @param name defines the name to search for
  2132. * @return the found skeleton or null if not found at all.
  2133. */
  2134. getSkeletonByName(name: string): Nullable<Skeleton>;
  2135. /**
  2136. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2137. * @param id defines the id to search for
  2138. * @return the found morph target manager or null if not found at all.
  2139. */
  2140. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2141. /**
  2142. * Gets a boolean indicating if the given mesh is active
  2143. * @param mesh defines the mesh to look for
  2144. * @returns true if the mesh is in the active list
  2145. */
  2146. isActiveMesh(mesh: AbstractMesh): boolean;
  2147. /**
  2148. * Return a unique id as a string which can serve as an identifier for the scene
  2149. */
  2150. readonly uid: string;
  2151. /**
  2152. * Add an externaly attached data from its key.
  2153. * This method call will fail and return false, if such key already exists.
  2154. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2155. * @param key the unique key that identifies the data
  2156. * @param data the data object to associate to the key for this Engine instance
  2157. * @return true if no such key were already present and the data was added successfully, false otherwise
  2158. */
  2159. addExternalData<T>(key: string, data: T): boolean;
  2160. /**
  2161. * Get an externaly attached data from its key
  2162. * @param key the unique key that identifies the data
  2163. * @return the associated data, if present (can be null), or undefined if not present
  2164. */
  2165. getExternalData<T>(key: string): Nullable<T>;
  2166. /**
  2167. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2168. * @param key the unique key that identifies the data
  2169. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2170. * @return the associated data, can be null if the factory returned null.
  2171. */
  2172. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2173. /**
  2174. * Remove an externaly attached data from the Engine instance
  2175. * @param key the unique key that identifies the data
  2176. * @return true if the data was successfully removed, false if it doesn't exist
  2177. */
  2178. removeExternalData(key: string): boolean;
  2179. private _evaluateSubMesh;
  2180. /**
  2181. * Clear the processed materials smart array preventing retention point in material dispose.
  2182. */
  2183. freeProcessedMaterials(): void;
  2184. /**
  2185. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2186. */
  2187. freeActiveMeshes(): void;
  2188. /**
  2189. * Clear the info related to rendering groups preventing retention points during dispose.
  2190. */
  2191. freeRenderingGroups(): void;
  2192. /** @hidden */
  2193. _isInIntermediateRendering(): boolean;
  2194. private _activeMeshCandidateProvider;
  2195. /**
  2196. * Defines the current active mesh candidate provider
  2197. * @param provider defines the provider to use
  2198. */
  2199. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2200. /**
  2201. * Gets the current active mesh candidate provider
  2202. * @returns the current active mesh candidate provider
  2203. */
  2204. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2205. private _activeMeshesFrozen;
  2206. /**
  2207. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2208. * @returns the current scene
  2209. */
  2210. freezeActiveMeshes(): Scene;
  2211. /**
  2212. * Use this function to restart evaluating active meshes on every frame
  2213. * @returns the current scene
  2214. */
  2215. unfreezeActiveMeshes(): Scene;
  2216. private _evaluateActiveMeshes;
  2217. private _activeMesh;
  2218. /**
  2219. * Update the transform matrix to update from the current active camera
  2220. * @param force defines a boolean used to force the update even if cache is up to date
  2221. */
  2222. updateTransformMatrix(force?: boolean): void;
  2223. /**
  2224. * 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)
  2225. * @param alternateCamera defines the camera to use
  2226. */
  2227. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2228. /** @hidden */
  2229. _allowPostProcessClear: boolean;
  2230. private _renderForCamera;
  2231. private _processSubCameras;
  2232. private _checkIntersections;
  2233. /**
  2234. * Render the scene
  2235. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2236. */
  2237. render(updateCameras?: boolean): void;
  2238. private _updateAudioParameters;
  2239. /**
  2240. * Gets or sets if audio support is enabled
  2241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2242. */
  2243. audioEnabled: boolean;
  2244. private _disableAudio;
  2245. private _enableAudio;
  2246. /**
  2247. * Gets or sets if audio will be output to headphones
  2248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2249. */
  2250. headphone: boolean;
  2251. private _switchAudioModeForHeadphones;
  2252. private _switchAudioModeForNormalSpeakers;
  2253. /**
  2254. * Freeze all materials
  2255. * A frozen material will not be updatable but should be faster to render
  2256. */
  2257. freezeMaterials(): void;
  2258. /**
  2259. * Unfreeze all materials
  2260. * A frozen material will not be updatable but should be faster to render
  2261. */
  2262. unfreezeMaterials(): void;
  2263. /**
  2264. * Releases all held ressources
  2265. */
  2266. dispose(): void;
  2267. /**
  2268. * Gets if the scene is already disposed
  2269. */
  2270. readonly isDisposed: boolean;
  2271. /**
  2272. * Releases sounds & soundtracks
  2273. */
  2274. disposeSounds(): void;
  2275. /**
  2276. * Call this function to reduce memory footprint of the scene.
  2277. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2278. */
  2279. clearCachedVertexData(): void;
  2280. /**
  2281. * This function will remove the local cached buffer data from texture.
  2282. * It will save memory but will prevent the texture from being rebuilt
  2283. */
  2284. cleanCachedTextureBuffer(): void;
  2285. /**
  2286. * Get the world extend vectors with an optional filter
  2287. *
  2288. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2289. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2290. */
  2291. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2292. min: Vector3;
  2293. max: Vector3;
  2294. };
  2295. /**
  2296. * Creates or updates the octree used to boost selection (picking)
  2297. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2298. * @param maxCapacity defines the maximum capacity per leaf
  2299. * @param maxDepth defines the maximum depth of the octree
  2300. * @returns an octree of AbstractMesh
  2301. */
  2302. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2303. /**
  2304. * Creates a ray that can be used to pick in the scene
  2305. * @param x defines the x coordinate of the origin (on-screen)
  2306. * @param y defines the y coordinate of the origin (on-screen)
  2307. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2308. * @param camera defines the camera to use for the picking
  2309. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2310. * @returns a Ray
  2311. */
  2312. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2313. /**
  2314. * Creates a ray that can be used to pick in the scene
  2315. * @param x defines the x coordinate of the origin (on-screen)
  2316. * @param y defines the y coordinate of the origin (on-screen)
  2317. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2318. * @param result defines the ray where to store the picking ray
  2319. * @param camera defines the camera to use for the picking
  2320. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2321. * @returns the current scene
  2322. */
  2323. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2324. /**
  2325. * Creates a ray that can be used to pick in the scene
  2326. * @param x defines the x coordinate of the origin (on-screen)
  2327. * @param y defines the y coordinate of the origin (on-screen)
  2328. * @param camera defines the camera to use for the picking
  2329. * @returns a Ray
  2330. */
  2331. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2332. /**
  2333. * Creates a ray that can be used to pick in the scene
  2334. * @param x defines the x coordinate of the origin (on-screen)
  2335. * @param y defines the y coordinate of the origin (on-screen)
  2336. * @param result defines the ray where to store the picking ray
  2337. * @param camera defines the camera to use for the picking
  2338. * @returns the current scene
  2339. */
  2340. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2341. private _internalPick;
  2342. private _internalMultiPick;
  2343. private _internalPickSprites;
  2344. private _tempPickingRay;
  2345. /** Launch a ray to try to pick a mesh in the scene
  2346. * @param x position on screen
  2347. * @param y position on screen
  2348. * @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
  2349. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2350. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2351. * @returns a PickingInfo
  2352. */
  2353. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2354. /** Launch a ray to try to pick a sprite in the scene
  2355. * @param x position on screen
  2356. * @param y position on screen
  2357. * @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
  2358. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2359. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2360. * @returns a PickingInfo
  2361. */
  2362. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2363. private _cachedRayForTransform;
  2364. /** Use the given ray to pick a mesh in the scene
  2365. * @param ray The ray to use to pick meshes
  2366. * @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
  2367. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2368. * @returns a PickingInfo
  2369. */
  2370. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2371. /**
  2372. * Launch a ray to try to pick a mesh in the scene
  2373. * @param x X position on screen
  2374. * @param y Y position on screen
  2375. * @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
  2376. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2377. * @returns an array of PickingInfo
  2378. */
  2379. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2380. /**
  2381. * Launch a ray to try to pick a mesh in the scene
  2382. * @param ray Ray to use
  2383. * @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
  2384. * @returns an array of PickingInfo
  2385. */
  2386. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2387. /**
  2388. * Force the value of meshUnderPointer
  2389. * @param mesh defines the mesh to use
  2390. */
  2391. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2392. /**
  2393. * Gets the mesh under the pointer
  2394. * @returns a Mesh or null if no mesh is under the pointer
  2395. */
  2396. getPointerOverMesh(): Nullable<AbstractMesh>;
  2397. /**
  2398. * Force the sprite under the pointer
  2399. * @param sprite defines the sprite to use
  2400. */
  2401. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2402. /**
  2403. * Gets the sprite under the pointer
  2404. * @returns a Sprite or null if no sprite is under the pointer
  2405. */
  2406. getPointerOverSprite(): Nullable<Sprite>;
  2407. /**
  2408. * Gets the current physics engine
  2409. * @returns a PhysicsEngine or null if none attached
  2410. */
  2411. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2412. /**
  2413. * Enables physics to the current scene
  2414. * @param gravity defines the scene's gravity for the physics engine
  2415. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2416. * @return a boolean indicating if the physics engine was initialized
  2417. */
  2418. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2419. /**
  2420. * Disables and disposes the physics engine associated with the scene
  2421. */
  2422. disablePhysicsEngine(): void;
  2423. /**
  2424. * Gets a boolean indicating if there is an active physics engine
  2425. * @returns a boolean indicating if there is an active physics engine
  2426. */
  2427. isPhysicsEnabled(): boolean;
  2428. /**
  2429. * Deletes a physics compound impostor
  2430. * @param compound defines the compound to delete
  2431. */
  2432. deleteCompoundImpostor(compound: any): void;
  2433. /** @hidden */
  2434. _rebuildGeometries(): void;
  2435. /** @hidden */
  2436. _rebuildTextures(): void;
  2437. /**
  2438. * Creates a default light for the scene.
  2439. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2440. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2441. */
  2442. createDefaultLight(replace?: boolean): void;
  2443. /**
  2444. * Creates a default camera for the scene.
  2445. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2446. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2447. * @param replace has default false, when true replaces the active camera in the scene
  2448. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2449. */
  2450. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2451. /**
  2452. * Creates a default camera and a default light.
  2453. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2454. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2455. * @param replace has the default false, when true replaces the active camera/light in the scene
  2456. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2457. */
  2458. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2459. /**
  2460. * Creates a new sky box
  2461. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2462. * @param environmentTexture defines the texture to use as environment texture
  2463. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2464. * @param scale defines the overall scale of the skybox
  2465. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2466. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2467. * @returns a new mesh holding the sky box
  2468. */
  2469. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2470. /**
  2471. * Creates a new environment
  2472. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2473. * @param options defines the options you can use to configure the environment
  2474. * @returns the new EnvironmentHelper
  2475. */
  2476. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2477. /**
  2478. * Creates a new VREXperienceHelper
  2479. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2480. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2481. * @returns a new VREXperienceHelper
  2482. */
  2483. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2484. private _getByTags;
  2485. /**
  2486. * Get a list of meshes by tags
  2487. * @param tagsQuery defines the tags query to use
  2488. * @param forEach defines a predicate used to filter results
  2489. * @returns an array of Mesh
  2490. */
  2491. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2492. /**
  2493. * Get a list of cameras by tags
  2494. * @param tagsQuery defines the tags query to use
  2495. * @param forEach defines a predicate used to filter results
  2496. * @returns an array of Camera
  2497. */
  2498. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2499. /**
  2500. * Get a list of lights by tags
  2501. * @param tagsQuery defines the tags query to use
  2502. * @param forEach defines a predicate used to filter results
  2503. * @returns an array of Light
  2504. */
  2505. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2506. /**
  2507. * Get a list of materials by tags
  2508. * @param tagsQuery defines the tags query to use
  2509. * @param forEach defines a predicate used to filter results
  2510. * @returns an array of Material
  2511. */
  2512. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2513. /**
  2514. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2515. * This allowed control for front to back rendering or reversly depending of the special needs.
  2516. *
  2517. * @param renderingGroupId The rendering group id corresponding to its index
  2518. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2519. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2520. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2521. */
  2522. 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;
  2523. /**
  2524. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2525. *
  2526. * @param renderingGroupId The rendering group id corresponding to its index
  2527. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2528. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2529. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2530. */
  2531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2532. /**
  2533. * Gets the current auto clear configuration for one rendering group of the rendering
  2534. * manager.
  2535. * @param index the rendering group index to get the information for
  2536. * @returns The auto clear setup for the requested rendering group
  2537. */
  2538. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2539. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2540. blockMaterialDirtyMechanism: boolean;
  2541. /**
  2542. * Will flag all materials as dirty to trigger new shader compilation
  2543. * @param flag defines the flag used to specify which material part must be marked as dirty
  2544. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2545. */
  2546. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2547. /** @hidden */
  2548. _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;
  2549. /** @hidden */
  2550. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2551. }
  2552. }
  2553. declare module BABYLON {
  2554. /**
  2555. * Groups all the scene component constants in one place to ease maintenance.
  2556. * @hidden
  2557. */
  2558. class SceneComponentConstants {
  2559. static readonly NAME_EFFECTLAYER: string;
  2560. static readonly NAME_LAYER: string;
  2561. static readonly NAME_LENSFLARESYSTEM: string;
  2562. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2563. static readonly NAME_PARTICLESYSTEM: string;
  2564. static readonly NAME_GAMEPAD: string;
  2565. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2566. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2567. static readonly NAME_DEPTHRENDERER: string;
  2568. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2569. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2570. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2571. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2572. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2573. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2574. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2575. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2576. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2577. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2578. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2579. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2580. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2581. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2582. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2583. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2584. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2585. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2586. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2587. static readonly STEP_REBUILDGEOMETRY_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2588. }
  2589. /**
  2590. * This represents a scene component.
  2591. *
  2592. * This is used to decouple the dependency the scene is having on the different workloads like
  2593. * layers, post processes...
  2594. */
  2595. interface ISceneComponent {
  2596. /**
  2597. * The name of the component. Each component must have a unique name.
  2598. */
  2599. name: string;
  2600. /**
  2601. * The scene the component belongs to.
  2602. */
  2603. scene: Scene;
  2604. /**
  2605. * Register the component to one instance of a scene.
  2606. */
  2607. register(): void;
  2608. /**
  2609. * Rebuilds the elements related to this component in case of
  2610. * context lost for instance.
  2611. */
  2612. rebuild(): void;
  2613. /**
  2614. * Disposes the component and the associated ressources.
  2615. */
  2616. dispose(): void;
  2617. }
  2618. /**
  2619. * This represents a SERIALIZABLE scene component.
  2620. *
  2621. * This extends Scene Component to add Serialization methods on top.
  2622. */
  2623. interface ISceneSerializableComponent extends ISceneComponent {
  2624. /**
  2625. * Adds all the element from the container to the scene
  2626. * @param container the container holding the elements
  2627. */
  2628. addFromContainer(container: AbstractScene): void;
  2629. /**
  2630. * Removes all the elements in the container from the scene
  2631. * @param container contains the elements to remove
  2632. */
  2633. removeFromContainer(container: AbstractScene): void;
  2634. /**
  2635. * Serializes the component data to the specified json object
  2636. * @param serializationObject The object to serialize to
  2637. */
  2638. serialize(serializationObject: any): void;
  2639. }
  2640. /**
  2641. * Strong typing of a Mesh related stage step action
  2642. */
  2643. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2644. /**
  2645. * Strong typing of a Evaluate Sub Mesh related stage step action
  2646. */
  2647. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2648. /**
  2649. * Strong typing of a Active Mesh related stage step action
  2650. */
  2651. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2652. /**
  2653. * Strong typing of a Camera related stage step action
  2654. */
  2655. type CameraStageAction = (camera: Camera) => void;
  2656. /**
  2657. * Strong typing of a RenderingGroup related stage step action
  2658. */
  2659. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2660. /**
  2661. * Strong typing of a simple stage step action
  2662. */
  2663. type SimpleStageAction = () => void;
  2664. /**
  2665. * Strong typing of a render target action.
  2666. */
  2667. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2668. /**
  2669. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2670. * @hidden
  2671. */
  2672. class Stage<T extends Function> extends Array<{
  2673. index: number;
  2674. component: ISceneComponent;
  2675. action: T;
  2676. }> {
  2677. /**
  2678. * Hide ctor from the rest of the world.
  2679. * @param items The items to add.
  2680. */
  2681. private constructor();
  2682. /**
  2683. * Creates a new Stage.
  2684. * @returns A new instance of a Stage
  2685. */
  2686. static Create<T extends Function>(): Stage<T>;
  2687. /**
  2688. * Registers a step in an ordered way in the targeted stage.
  2689. * @param index Defines the position to register the step in
  2690. * @param component Defines the component attached to the step
  2691. * @param action Defines the action to launch during the step
  2692. */
  2693. registerStep(index: number, component: ISceneComponent, action: T): void;
  2694. /**
  2695. * Clears all the steps from the stage.
  2696. */
  2697. clear(): void;
  2698. }
  2699. }
  2700. declare module BABYLON {
  2701. type Nullable<T> = T | null;
  2702. type float = number;
  2703. type double = number;
  2704. type int = number;
  2705. type FloatArray = number[] | Float32Array;
  2706. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2707. /**
  2708. * Alias for types that can be used by a Buffer or VertexBuffer.
  2709. */
  2710. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2711. }
  2712. declare module BABYLON {
  2713. /**
  2714. * The action to be carried out following a trigger
  2715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2716. */
  2717. class Action {
  2718. /** the trigger, with or without parameters, for the action */
  2719. triggerOptions: any;
  2720. /**
  2721. * Trigger for the action
  2722. */
  2723. trigger: number;
  2724. /**
  2725. * Internal only - manager for action
  2726. * @hidden
  2727. */
  2728. _actionManager: ActionManager;
  2729. private _nextActiveAction;
  2730. private _child;
  2731. private _condition?;
  2732. private _triggerParameter;
  2733. /**
  2734. * An event triggered prior to action being executed.
  2735. */
  2736. onBeforeExecuteObservable: Observable<Action>;
  2737. /**
  2738. * Creates a new Action
  2739. * @param triggerOptions the trigger, with or without parameters, for the action
  2740. * @param condition an optional determinant of action
  2741. */
  2742. constructor(
  2743. /** the trigger, with or without parameters, for the action */
  2744. triggerOptions: any, condition?: Condition);
  2745. /**
  2746. * Internal only
  2747. * @hidden
  2748. */
  2749. _prepare(): void;
  2750. /**
  2751. * Gets the trigger parameters
  2752. * @returns the trigger parameters
  2753. */
  2754. getTriggerParameter(): any;
  2755. /**
  2756. * Internal only - executes current action event
  2757. * @hidden
  2758. */
  2759. _executeCurrent(evt?: ActionEvent): void;
  2760. /**
  2761. * Execute placeholder for child classes
  2762. * @param evt optional action event
  2763. */
  2764. execute(evt?: ActionEvent): void;
  2765. /**
  2766. * Skips to next active action
  2767. */
  2768. skipToNextActiveAction(): void;
  2769. /**
  2770. * Adds action to chain of actions, may be a DoNothingAction
  2771. * @param action defines the next action to execute
  2772. * @returns The action passed in
  2773. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2774. */
  2775. then(action: Action): Action;
  2776. /**
  2777. * Internal only
  2778. * @hidden
  2779. */
  2780. _getProperty(propertyPath: string): string;
  2781. /**
  2782. * Internal only
  2783. * @hidden
  2784. */
  2785. _getEffectiveTarget(target: any, propertyPath: string): any;
  2786. /**
  2787. * Serialize placeholder for child classes
  2788. * @param parent of child
  2789. * @returns the serialized object
  2790. */
  2791. serialize(parent: any): any;
  2792. /**
  2793. * Internal only called by serialize
  2794. * @hidden
  2795. */
  2796. protected _serialize(serializedAction: any, parent?: any): any;
  2797. /**
  2798. * Internal only
  2799. * @hidden
  2800. */
  2801. static _SerializeValueAsString: (value: any) => string;
  2802. /**
  2803. * Internal only
  2804. * @hidden
  2805. */
  2806. static _GetTargetProperty: (target: Scene | Node) => {
  2807. name: string;
  2808. targetType: string;
  2809. value: string;
  2810. };
  2811. }
  2812. }
  2813. declare module BABYLON {
  2814. /**
  2815. * ActionEvent is the event being sent when an action is triggered.
  2816. */
  2817. class ActionEvent {
  2818. /** The mesh or sprite that triggered the action */
  2819. source: any;
  2820. /** The X mouse cursor position at the time of the event */
  2821. pointerX: number;
  2822. /** The Y mouse cursor position at the time of the event */
  2823. pointerY: number;
  2824. /** The mesh that is currently pointed at (can be null) */
  2825. meshUnderPointer: Nullable<AbstractMesh>;
  2826. /** the original (browser) event that triggered the ActionEvent */
  2827. sourceEvent?: any;
  2828. /** additional data for the event */
  2829. additionalData?: any;
  2830. /**
  2831. * Creates a new ActionEvent
  2832. * @param source The mesh or sprite that triggered the action
  2833. * @param pointerX The X mouse cursor position at the time of the event
  2834. * @param pointerY The Y mouse cursor position at the time of the event
  2835. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2836. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2837. * @param additionalData additional data for the event
  2838. */
  2839. constructor(
  2840. /** The mesh or sprite that triggered the action */
  2841. source: any,
  2842. /** The X mouse cursor position at the time of the event */
  2843. pointerX: number,
  2844. /** The Y mouse cursor position at the time of the event */
  2845. pointerY: number,
  2846. /** The mesh that is currently pointed at (can be null) */
  2847. meshUnderPointer: Nullable<AbstractMesh>,
  2848. /** the original (browser) event that triggered the ActionEvent */
  2849. sourceEvent?: any,
  2850. /** additional data for the event */
  2851. additionalData?: any);
  2852. /**
  2853. * Helper function to auto-create an ActionEvent from a source mesh.
  2854. * @param source The source mesh that triggered the event
  2855. * @param evt The original (browser) event
  2856. * @param additionalData additional data for the event
  2857. * @returns the new ActionEvent
  2858. */
  2859. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2860. /**
  2861. * Helper function to auto-create an ActionEvent from a source sprite
  2862. * @param source The source sprite that triggered the event
  2863. * @param scene Scene associated with the sprite
  2864. * @param evt The original (browser) event
  2865. * @param additionalData additional data for the event
  2866. * @returns the new ActionEvent
  2867. */
  2868. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2869. /**
  2870. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2871. * @param scene the scene where the event occurred
  2872. * @param evt The original (browser) event
  2873. * @returns the new ActionEvent
  2874. */
  2875. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2876. /**
  2877. * Helper function to auto-create an ActionEvent from a primitive
  2878. * @param prim defines the target primitive
  2879. * @param pointerPos defines the pointer position
  2880. * @param evt The original (browser) event
  2881. * @param additionalData additional data for the event
  2882. * @returns the new ActionEvent
  2883. */
  2884. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2885. }
  2886. /**
  2887. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2888. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2890. */
  2891. class ActionManager {
  2892. private static _NothingTrigger;
  2893. private static _OnPickTrigger;
  2894. private static _OnLeftPickTrigger;
  2895. private static _OnRightPickTrigger;
  2896. private static _OnCenterPickTrigger;
  2897. private static _OnPickDownTrigger;
  2898. private static _OnDoublePickTrigger;
  2899. private static _OnPickUpTrigger;
  2900. private static _OnLongPressTrigger;
  2901. private static _OnPointerOverTrigger;
  2902. private static _OnPointerOutTrigger;
  2903. private static _OnEveryFrameTrigger;
  2904. private static _OnIntersectionEnterTrigger;
  2905. private static _OnIntersectionExitTrigger;
  2906. private static _OnKeyDownTrigger;
  2907. private static _OnKeyUpTrigger;
  2908. private static _OnPickOutTrigger;
  2909. /**
  2910. * Nothing
  2911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2912. */
  2913. static readonly NothingTrigger: number;
  2914. /**
  2915. * On pick
  2916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2917. */
  2918. static readonly OnPickTrigger: number;
  2919. /**
  2920. * On left pick
  2921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2922. */
  2923. static readonly OnLeftPickTrigger: number;
  2924. /**
  2925. * On right pick
  2926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2927. */
  2928. static readonly OnRightPickTrigger: number;
  2929. /**
  2930. * On center pick
  2931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2932. */
  2933. static readonly OnCenterPickTrigger: number;
  2934. /**
  2935. * On pick down
  2936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2937. */
  2938. static readonly OnPickDownTrigger: number;
  2939. /**
  2940. * On double pick
  2941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2942. */
  2943. static readonly OnDoublePickTrigger: number;
  2944. /**
  2945. * On pick up
  2946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2947. */
  2948. static readonly OnPickUpTrigger: number;
  2949. /**
  2950. * On pick out.
  2951. * This trigger will only be raised if you also declared a OnPickDown
  2952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2953. */
  2954. static readonly OnPickOutTrigger: number;
  2955. /**
  2956. * On long press
  2957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2958. */
  2959. static readonly OnLongPressTrigger: number;
  2960. /**
  2961. * On pointer over
  2962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2963. */
  2964. static readonly OnPointerOverTrigger: number;
  2965. /**
  2966. * On pointer out
  2967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2968. */
  2969. static readonly OnPointerOutTrigger: number;
  2970. /**
  2971. * On every frame
  2972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2973. */
  2974. static readonly OnEveryFrameTrigger: number;
  2975. /**
  2976. * On intersection enter
  2977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2978. */
  2979. static readonly OnIntersectionEnterTrigger: number;
  2980. /**
  2981. * On intersection exit
  2982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2983. */
  2984. static readonly OnIntersectionExitTrigger: number;
  2985. /**
  2986. * On key down
  2987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2988. */
  2989. static readonly OnKeyDownTrigger: number;
  2990. /**
  2991. * On key up
  2992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2993. */
  2994. static readonly OnKeyUpTrigger: number;
  2995. /** Gets the list of active triggers */
  2996. static Triggers: {
  2997. [key: string]: number;
  2998. };
  2999. /** Gets the list of actions */
  3000. actions: Action[];
  3001. /** Gets the cursor to use when hovering items */
  3002. hoverCursor: string;
  3003. private _scene;
  3004. /**
  3005. * Creates a new action manager
  3006. * @param scene defines the hosting scene
  3007. */
  3008. constructor(scene: Scene);
  3009. /**
  3010. * Releases all associated resources
  3011. */
  3012. dispose(): void;
  3013. /**
  3014. * Gets hosting scene
  3015. * @returns the hosting scene
  3016. */
  3017. getScene(): Scene;
  3018. /**
  3019. * Does this action manager handles actions of any of the given triggers
  3020. * @param triggers defines the triggers to be tested
  3021. * @return a boolean indicating whether one (or more) of the triggers is handled
  3022. */
  3023. hasSpecificTriggers(triggers: number[]): boolean;
  3024. /**
  3025. * Does this action manager handles actions of a given trigger
  3026. * @param trigger defines the trigger to be tested
  3027. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3028. * @return whether the trigger is handled
  3029. */
  3030. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3031. /**
  3032. * Does this action manager has pointer triggers
  3033. */
  3034. readonly hasPointerTriggers: boolean;
  3035. /**
  3036. * Does this action manager has pick triggers
  3037. */
  3038. readonly hasPickTriggers: boolean;
  3039. /**
  3040. * Does exist one action manager with at least one trigger
  3041. **/
  3042. static readonly HasTriggers: boolean;
  3043. /**
  3044. * Does exist one action manager with at least one pick trigger
  3045. **/
  3046. static readonly HasPickTriggers: boolean;
  3047. /**
  3048. * Does exist one action manager that handles actions of a given trigger
  3049. * @param trigger defines the trigger to be tested
  3050. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3051. **/
  3052. static HasSpecificTrigger(trigger: number): boolean;
  3053. /**
  3054. * Registers an action to this action manager
  3055. * @param action defines the action to be registered
  3056. * @return the action amended (prepared) after registration
  3057. */
  3058. registerAction(action: Action): Nullable<Action>;
  3059. /**
  3060. * Unregisters an action to this action manager
  3061. * @param action defines the action to be unregistered
  3062. * @return a boolean indicating whether the action has been unregistered
  3063. */
  3064. unregisterAction(action: Action): Boolean;
  3065. /**
  3066. * Process a specific trigger
  3067. * @param trigger defines the trigger to process
  3068. * @param evt defines the event details to be processed
  3069. */
  3070. processTrigger(trigger: number, evt?: ActionEvent): void;
  3071. /** @hidden */
  3072. _getEffectiveTarget(target: any, propertyPath: string): any;
  3073. /** @hidden */
  3074. _getProperty(propertyPath: string): string;
  3075. /**
  3076. * Serialize this manager to a JSON object
  3077. * @param name defines the property name to store this manager
  3078. * @returns a JSON representation of this manager
  3079. */
  3080. serialize(name: string): any;
  3081. /**
  3082. * Creates a new ActionManager from a JSON data
  3083. * @param parsedActions defines the JSON data to read from
  3084. * @param object defines the hosting mesh
  3085. * @param scene defines the hosting scene
  3086. */
  3087. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3088. /**
  3089. * Get a trigger name by index
  3090. * @param trigger defines the trigger index
  3091. * @returns a trigger name
  3092. */
  3093. static GetTriggerName(trigger: number): string;
  3094. }
  3095. }
  3096. declare module BABYLON {
  3097. /**
  3098. * A Condition applied to an Action
  3099. */
  3100. class Condition {
  3101. /**
  3102. * Internal only - manager for action
  3103. * @hidden
  3104. */
  3105. _actionManager: ActionManager;
  3106. /**
  3107. * Internal only
  3108. * @hidden
  3109. */
  3110. _evaluationId: number;
  3111. /**
  3112. * Internal only
  3113. * @hidden
  3114. */
  3115. _currentResult: boolean;
  3116. /**
  3117. * Creates a new Condition
  3118. * @param actionManager the manager of the action the condition is applied to
  3119. */
  3120. constructor(actionManager: ActionManager);
  3121. /**
  3122. * Check if the current condition is valid
  3123. * @returns a boolean
  3124. */
  3125. isValid(): boolean;
  3126. /**
  3127. * Internal only
  3128. * @hidden
  3129. */
  3130. _getProperty(propertyPath: string): string;
  3131. /**
  3132. * Internal only
  3133. * @hidden
  3134. */
  3135. _getEffectiveTarget(target: any, propertyPath: string): any;
  3136. /**
  3137. * Serialize placeholder for child classes
  3138. * @returns the serialized object
  3139. */
  3140. serialize(): any;
  3141. /**
  3142. * Internal only
  3143. * @hidden
  3144. */
  3145. protected _serialize(serializedCondition: any): any;
  3146. }
  3147. /**
  3148. * Defines specific conditional operators as extensions of Condition
  3149. */
  3150. class ValueCondition extends Condition {
  3151. /** path to specify the property of the target the conditional operator uses */
  3152. propertyPath: string;
  3153. /** the value compared by the conditional operator against the current value of the property */
  3154. value: any;
  3155. /** the conditional operator, default ValueCondition.IsEqual */
  3156. operator: number;
  3157. /**
  3158. * Internal only
  3159. * @hidden
  3160. */
  3161. private static _IsEqual;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. private static _IsDifferent;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private static _IsGreater;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private static _IsLesser;
  3177. /**
  3178. * returns the number for IsEqual
  3179. */
  3180. static readonly IsEqual: number;
  3181. /**
  3182. * Returns the number for IsDifferent
  3183. */
  3184. static readonly IsDifferent: number;
  3185. /**
  3186. * Returns the number for IsGreater
  3187. */
  3188. static readonly IsGreater: number;
  3189. /**
  3190. * Returns the number for IsLesser
  3191. */
  3192. static readonly IsLesser: number;
  3193. /**
  3194. * Internal only The action manager for the condition
  3195. * @hidden
  3196. */
  3197. _actionManager: ActionManager;
  3198. /**
  3199. * Internal only
  3200. * @hidden
  3201. */
  3202. private _target;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. private _effectiveTarget;
  3208. /**
  3209. * Internal only
  3210. * @hidden
  3211. */
  3212. private _property;
  3213. /**
  3214. * Creates a new ValueCondition
  3215. * @param actionManager manager for the action the condition applies to
  3216. * @param target for the action
  3217. * @param propertyPath path to specify the property of the target the conditional operator uses
  3218. * @param value the value compared by the conditional operator against the current value of the property
  3219. * @param operator the conditional operator, default ValueCondition.IsEqual
  3220. */
  3221. constructor(actionManager: ActionManager, target: any,
  3222. /** path to specify the property of the target the conditional operator uses */
  3223. propertyPath: string,
  3224. /** the value compared by the conditional operator against the current value of the property */
  3225. value: any,
  3226. /** the conditional operator, default ValueCondition.IsEqual */
  3227. operator?: number);
  3228. /**
  3229. * Compares the given value with the property value for the specified conditional operator
  3230. * @returns the result of the comparison
  3231. */
  3232. isValid(): boolean;
  3233. /**
  3234. * Serialize the ValueCondition into a JSON compatible object
  3235. * @returns serialization object
  3236. */
  3237. serialize(): any;
  3238. /**
  3239. * Gets the name of the conditional operator for the ValueCondition
  3240. * @param operator the conditional operator
  3241. * @returns the name
  3242. */
  3243. static GetOperatorName(operator: number): string;
  3244. }
  3245. /**
  3246. * Defines a predicate condition as an extension of Condition
  3247. */
  3248. class PredicateCondition extends Condition {
  3249. /** defines the predicate function used to validate the condition */
  3250. predicate: () => boolean;
  3251. /**
  3252. * Internal only - manager for action
  3253. * @hidden
  3254. */
  3255. _actionManager: ActionManager;
  3256. /**
  3257. * Creates a new PredicateCondition
  3258. * @param actionManager manager for the action the condition applies to
  3259. * @param predicate defines the predicate function used to validate the condition
  3260. */
  3261. constructor(actionManager: ActionManager,
  3262. /** defines the predicate function used to validate the condition */
  3263. predicate: () => boolean);
  3264. /**
  3265. * @returns the validity of the predicate condition
  3266. */
  3267. isValid(): boolean;
  3268. }
  3269. /**
  3270. * Defines a state condition as an extension of Condition
  3271. */
  3272. class StateCondition extends Condition {
  3273. value: string;
  3274. /**
  3275. * Internal only - manager for action
  3276. * @hidden
  3277. */
  3278. _actionManager: ActionManager;
  3279. /**
  3280. * Internal only
  3281. * @hidden
  3282. */
  3283. private _target;
  3284. /**
  3285. * Creates a new StateCondition
  3286. * @param actionManager manager for the action the condition applies to
  3287. * @param target of the condition
  3288. * @param value to compare with target state
  3289. */
  3290. constructor(actionManager: ActionManager, target: any, value: string);
  3291. /**
  3292. * @returns the validity of the state
  3293. */
  3294. isValid(): boolean;
  3295. /**
  3296. * Serialize the StateCondition into a JSON compatible object
  3297. * @returns serialization object
  3298. */
  3299. serialize(): any;
  3300. }
  3301. }
  3302. declare module BABYLON {
  3303. class SwitchBooleanAction extends Action {
  3304. propertyPath: string;
  3305. private _target;
  3306. private _effectiveTarget;
  3307. private _property;
  3308. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3309. /** @hidden */
  3310. _prepare(): void;
  3311. execute(): void;
  3312. serialize(parent: any): any;
  3313. }
  3314. class SetStateAction extends Action {
  3315. value: string;
  3316. private _target;
  3317. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3318. execute(): void;
  3319. serialize(parent: any): any;
  3320. }
  3321. class SetValueAction extends Action {
  3322. propertyPath: string;
  3323. value: any;
  3324. private _target;
  3325. private _effectiveTarget;
  3326. private _property;
  3327. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3328. /** @hidden */
  3329. _prepare(): void;
  3330. execute(): void;
  3331. serialize(parent: any): any;
  3332. }
  3333. class IncrementValueAction extends Action {
  3334. propertyPath: string;
  3335. value: any;
  3336. private _target;
  3337. private _effectiveTarget;
  3338. private _property;
  3339. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3340. /** @hidden */
  3341. _prepare(): void;
  3342. execute(): void;
  3343. serialize(parent: any): any;
  3344. }
  3345. class PlayAnimationAction extends Action {
  3346. from: number;
  3347. to: number;
  3348. loop?: boolean | undefined;
  3349. private _target;
  3350. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3351. /** @hidden */
  3352. _prepare(): void;
  3353. execute(): void;
  3354. serialize(parent: any): any;
  3355. }
  3356. class StopAnimationAction extends Action {
  3357. private _target;
  3358. constructor(triggerOptions: any, target: any, condition?: Condition);
  3359. /** @hidden */
  3360. _prepare(): void;
  3361. execute(): void;
  3362. serialize(parent: any): any;
  3363. }
  3364. class DoNothingAction extends Action {
  3365. constructor(triggerOptions?: any, condition?: Condition);
  3366. execute(): void;
  3367. serialize(parent: any): any;
  3368. }
  3369. class CombineAction extends Action {
  3370. children: Action[];
  3371. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3372. /** @hidden */
  3373. _prepare(): void;
  3374. execute(evt: ActionEvent): void;
  3375. serialize(parent: any): any;
  3376. }
  3377. class ExecuteCodeAction extends Action {
  3378. func: (evt: ActionEvent) => void;
  3379. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3380. execute(evt: ActionEvent): void;
  3381. }
  3382. class SetParentAction extends Action {
  3383. private _parent;
  3384. private _target;
  3385. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3386. /** @hidden */
  3387. _prepare(): void;
  3388. execute(): void;
  3389. serialize(parent: any): any;
  3390. }
  3391. class PlaySoundAction extends Action {
  3392. private _sound;
  3393. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3394. /** @hidden */
  3395. _prepare(): void;
  3396. execute(): void;
  3397. serialize(parent: any): any;
  3398. }
  3399. class StopSoundAction extends Action {
  3400. private _sound;
  3401. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3402. /** @hidden */
  3403. _prepare(): void;
  3404. execute(): void;
  3405. serialize(parent: any): any;
  3406. }
  3407. }
  3408. declare module BABYLON {
  3409. class InterpolateValueAction extends Action {
  3410. propertyPath: string;
  3411. value: any;
  3412. duration: number;
  3413. stopOtherAnimations?: boolean | undefined;
  3414. onInterpolationDone?: (() => void) | undefined;
  3415. private _target;
  3416. private _effectiveTarget;
  3417. private _property;
  3418. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3419. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3420. /** @hidden */
  3421. _prepare(): void;
  3422. execute(): void;
  3423. serialize(parent: any): any;
  3424. }
  3425. }
  3426. declare module BABYLON {
  3427. /**
  3428. * Class used to store an actual running animation
  3429. */
  3430. class Animatable {
  3431. /** defines the target object */
  3432. target: any;
  3433. /** defines the starting frame number (default is 0) */
  3434. fromFrame: number;
  3435. /** defines the ending frame number (default is 100) */
  3436. toFrame: number;
  3437. /** defines if the animation must loop (default is false) */
  3438. loopAnimation: boolean;
  3439. /** defines a callback to call when animation ends if it is not looping */
  3440. onAnimationEnd?: (() => void) | null | undefined;
  3441. private _localDelayOffset;
  3442. private _pausedDelay;
  3443. private _runtimeAnimations;
  3444. private _paused;
  3445. private _scene;
  3446. private _speedRatio;
  3447. private _weight;
  3448. private _syncRoot;
  3449. /**
  3450. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3451. * This will only apply for non looping animation (default is true)
  3452. */
  3453. disposeOnEnd: boolean;
  3454. /**
  3455. * Gets a boolean indicating if the animation has started
  3456. */
  3457. animationStarted: boolean;
  3458. /**
  3459. * Observer raised when the animation ends
  3460. */
  3461. onAnimationEndObservable: Observable<Animatable>;
  3462. /**
  3463. * Gets the root Animatable used to synchronize and normalize animations
  3464. */
  3465. readonly syncRoot: Animatable;
  3466. /**
  3467. * Gets the current frame of the first RuntimeAnimation
  3468. * Used to synchronize Animatables
  3469. */
  3470. readonly masterFrame: number;
  3471. /**
  3472. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3473. */
  3474. weight: number;
  3475. /**
  3476. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3477. */
  3478. speedRatio: number;
  3479. /**
  3480. * Creates a new Animatable
  3481. * @param scene defines the hosting scene
  3482. * @param target defines the target object
  3483. * @param fromFrame defines the starting frame number (default is 0)
  3484. * @param toFrame defines the ending frame number (default is 100)
  3485. * @param loopAnimation defines if the animation must loop (default is false)
  3486. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3487. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3488. * @param animations defines a group of animation to add to the new Animatable
  3489. */
  3490. constructor(scene: Scene,
  3491. /** defines the target object */
  3492. target: any,
  3493. /** defines the starting frame number (default is 0) */
  3494. fromFrame?: number,
  3495. /** defines the ending frame number (default is 100) */
  3496. toFrame?: number,
  3497. /** defines if the animation must loop (default is false) */
  3498. loopAnimation?: boolean, speedRatio?: number,
  3499. /** defines a callback to call when animation ends if it is not looping */
  3500. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3501. /**
  3502. * Synchronize and normalize current Animatable with a source Animatable
  3503. * This is useful when using animation weights and when animations are not of the same length
  3504. * @param root defines the root Animatable to synchronize with
  3505. * @returns the current Animatable
  3506. */
  3507. syncWith(root: Animatable): Animatable;
  3508. /**
  3509. * Gets the list of runtime animations
  3510. * @returns an array of RuntimeAnimation
  3511. */
  3512. getAnimations(): RuntimeAnimation[];
  3513. /**
  3514. * Adds more animations to the current animatable
  3515. * @param target defines the target of the animations
  3516. * @param animations defines the new animations to add
  3517. */
  3518. appendAnimations(target: any, animations: Animation[]): void;
  3519. /**
  3520. * Gets the source animation for a specific property
  3521. * @param property defines the propertyu to look for
  3522. * @returns null or the source animation for the given property
  3523. */
  3524. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3525. /**
  3526. * Gets the runtime animation for a specific property
  3527. * @param property defines the propertyu to look for
  3528. * @returns null or the runtime animation for the given property
  3529. */
  3530. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3531. /**
  3532. * Resets the animatable to its original state
  3533. */
  3534. reset(): void;
  3535. /**
  3536. * Allows the animatable to blend with current running animations
  3537. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3538. * @param blendingSpeed defines the blending speed to use
  3539. */
  3540. enableBlending(blendingSpeed: number): void;
  3541. /**
  3542. * Disable animation blending
  3543. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3544. */
  3545. disableBlending(): void;
  3546. /**
  3547. * Jump directly to a given frame
  3548. * @param frame defines the frame to jump to
  3549. */
  3550. goToFrame(frame: number): void;
  3551. /**
  3552. * Pause the animation
  3553. */
  3554. pause(): void;
  3555. /**
  3556. * Restart the animation
  3557. */
  3558. restart(): void;
  3559. private _raiseOnAnimationEnd;
  3560. /**
  3561. * Stop and delete the current animation
  3562. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3563. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3564. */
  3565. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3566. /**
  3567. * Wait asynchronously for the animation to end
  3568. * @returns a promise which will be fullfilled when the animation ends
  3569. */
  3570. waitAsync(): Promise<Animatable>;
  3571. /** @hidden */
  3572. _animate(delay: number): boolean;
  3573. }
  3574. }
  3575. declare module BABYLON {
  3576. /**
  3577. * Represents the range of an animation
  3578. */
  3579. class AnimationRange {
  3580. /**The name of the animation range**/
  3581. name: string;
  3582. /**The starting frame of the animation */
  3583. from: number;
  3584. /**The ending frame of the animation*/
  3585. to: number;
  3586. /**
  3587. * Initializes the range of an animation
  3588. * @param name The name of the animation range
  3589. * @param from The starting frame of the animation
  3590. * @param to The ending frame of the animation
  3591. */
  3592. constructor(
  3593. /**The name of the animation range**/
  3594. name: string,
  3595. /**The starting frame of the animation */
  3596. from: number,
  3597. /**The ending frame of the animation*/
  3598. to: number);
  3599. /**
  3600. * Makes a copy of the animation range
  3601. * @returns A copy of the animation range
  3602. */
  3603. clone(): AnimationRange;
  3604. }
  3605. /**
  3606. * Composed of a frame, and an action function
  3607. */
  3608. class AnimationEvent {
  3609. /** The frame for which the event is triggered **/
  3610. frame: number;
  3611. /** The event to perform when triggered **/
  3612. action: (currentFrame: number) => void;
  3613. /** Specifies if the event should be triggered only once**/
  3614. onlyOnce?: boolean | undefined;
  3615. /**
  3616. * Specifies if the animation event is done
  3617. */
  3618. isDone: boolean;
  3619. /**
  3620. * Initializes the animation event
  3621. * @param frame The frame for which the event is triggered
  3622. * @param action The event to perform when triggered
  3623. * @param onlyOnce Specifies if the event should be triggered only once
  3624. */
  3625. constructor(
  3626. /** The frame for which the event is triggered **/
  3627. frame: number,
  3628. /** The event to perform when triggered **/
  3629. action: (currentFrame: number) => void,
  3630. /** Specifies if the event should be triggered only once**/
  3631. onlyOnce?: boolean | undefined);
  3632. /** @hidden */
  3633. _clone(): AnimationEvent;
  3634. }
  3635. /**
  3636. * A cursor which tracks a point on a path
  3637. */
  3638. class PathCursor {
  3639. private path;
  3640. /**
  3641. * Stores path cursor callbacks for when an onchange event is triggered
  3642. */
  3643. private _onchange;
  3644. /**
  3645. * The value of the path cursor
  3646. */
  3647. value: number;
  3648. /**
  3649. * The animation array of the path cursor
  3650. */
  3651. animations: Animation[];
  3652. /**
  3653. * Initializes the path cursor
  3654. * @param path The path to track
  3655. */
  3656. constructor(path: Path2);
  3657. /**
  3658. * Gets the cursor point on the path
  3659. * @returns A point on the path cursor at the cursor location
  3660. */
  3661. getPoint(): Vector3;
  3662. /**
  3663. * Moves the cursor ahead by the step amount
  3664. * @param step The amount to move the cursor forward
  3665. * @returns This path cursor
  3666. */
  3667. moveAhead(step?: number): PathCursor;
  3668. /**
  3669. * Moves the cursor behind by the step amount
  3670. * @param step The amount to move the cursor back
  3671. * @returns This path cursor
  3672. */
  3673. moveBack(step?: number): PathCursor;
  3674. /**
  3675. * Moves the cursor by the step amount
  3676. * If the step amount is greater than one, an exception is thrown
  3677. * @param step The amount to move the cursor
  3678. * @returns This path cursor
  3679. */
  3680. move(step: number): PathCursor;
  3681. /**
  3682. * Ensures that the value is limited between zero and one
  3683. * @returns This path cursor
  3684. */
  3685. private ensureLimits;
  3686. /**
  3687. * Runs onchange callbacks on change (used by the animation engine)
  3688. * @returns This path cursor
  3689. */
  3690. private raiseOnChange;
  3691. /**
  3692. * Executes a function on change
  3693. * @param f A path cursor onchange callback
  3694. * @returns This path cursor
  3695. */
  3696. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3697. }
  3698. /**
  3699. * Defines an interface which represents an animation key frame
  3700. */
  3701. interface IAnimationKey {
  3702. /**
  3703. * Frame of the key frame
  3704. */
  3705. frame: number;
  3706. /**
  3707. * Value at the specifies key frame
  3708. */
  3709. value: any;
  3710. /**
  3711. * The input tangent for the cubic hermite spline
  3712. */
  3713. inTangent?: any;
  3714. /**
  3715. * The output tangent for the cubic hermite spline
  3716. */
  3717. outTangent?: any;
  3718. /**
  3719. * The animation interpolation type
  3720. */
  3721. interpolation?: AnimationKeyInterpolation;
  3722. }
  3723. /**
  3724. * Enum for the animation key frame interpolation type
  3725. */
  3726. enum AnimationKeyInterpolation {
  3727. /**
  3728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3729. */
  3730. STEP = 1
  3731. }
  3732. /**
  3733. * Class used to store any kind of animation
  3734. */
  3735. class Animation {
  3736. /**Name of the animation */
  3737. name: string;
  3738. /**Property to animate */
  3739. targetProperty: string;
  3740. /**The frames per second of the animation */
  3741. framePerSecond: number;
  3742. /**The data type of the animation */
  3743. dataType: number;
  3744. /**The loop mode of the animation */
  3745. loopMode?: number | undefined;
  3746. /**Specifies if blending should be enabled */
  3747. enableBlending?: boolean | undefined;
  3748. /**
  3749. * Use matrix interpolation instead of using direct key value when animating matrices
  3750. */
  3751. static AllowMatricesInterpolation: boolean;
  3752. /**
  3753. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3754. */
  3755. static AllowMatrixDecomposeForInterpolation: boolean;
  3756. /**
  3757. * Stores the key frames of the animation
  3758. */
  3759. private _keys;
  3760. /**
  3761. * Stores the easing function of the animation
  3762. */
  3763. private _easingFunction;
  3764. /**
  3765. * @hidden Internal use only
  3766. */
  3767. _runtimeAnimations: RuntimeAnimation[];
  3768. /**
  3769. * The set of event that will be linked to this animation
  3770. */
  3771. private _events;
  3772. /**
  3773. * Stores an array of target property paths
  3774. */
  3775. targetPropertyPath: string[];
  3776. /**
  3777. * Stores the blending speed of the animation
  3778. */
  3779. blendingSpeed: number;
  3780. /**
  3781. * Stores the animation ranges for the animation
  3782. */
  3783. private _ranges;
  3784. /**
  3785. * @hidden Internal use
  3786. */
  3787. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3788. /**
  3789. * Sets up an animation
  3790. * @param property The property to animate
  3791. * @param animationType The animation type to apply
  3792. * @param framePerSecond The frames per second of the animation
  3793. * @param easingFunction The easing function used in the animation
  3794. * @returns The created animation
  3795. */
  3796. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3797. /**
  3798. * Create and start an animation on a node
  3799. * @param name defines the name of the global animation that will be run on all nodes
  3800. * @param node defines the root node where the animation will take place
  3801. * @param targetProperty defines property to animate
  3802. * @param framePerSecond defines the number of frame per second yo use
  3803. * @param totalFrame defines the number of frames in total
  3804. * @param from defines the initial value
  3805. * @param to defines the final value
  3806. * @param loopMode defines which loop mode you want to use (off by default)
  3807. * @param easingFunction defines the easing function to use (linear by default)
  3808. * @param onAnimationEnd defines the callback to call when animation end
  3809. * @returns the animatable created for this animation
  3810. */
  3811. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3812. /**
  3813. * Create and start an animation on a node and its descendants
  3814. * @param name defines the name of the global animation that will be run on all nodes
  3815. * @param node defines the root node where the animation will take place
  3816. * @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
  3817. * @param targetProperty defines property to animate
  3818. * @param framePerSecond defines the number of frame per second to use
  3819. * @param totalFrame defines the number of frames in total
  3820. * @param from defines the initial value
  3821. * @param to defines the final value
  3822. * @param loopMode defines which loop mode you want to use (off by default)
  3823. * @param easingFunction defines the easing function to use (linear by default)
  3824. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3825. * @returns the list of animatables created for all nodes
  3826. * @example https://www.babylonjs-playground.com/#MH0VLI
  3827. */
  3828. 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[]>;
  3829. /**
  3830. * Creates a new animation, merges it with the existing animations and starts it
  3831. * @param name Name of the animation
  3832. * @param node Node which contains the scene that begins the animations
  3833. * @param targetProperty Specifies which property to animate
  3834. * @param framePerSecond The frames per second of the animation
  3835. * @param totalFrame The total number of frames
  3836. * @param from The frame at the beginning of the animation
  3837. * @param to The frame at the end of the animation
  3838. * @param loopMode Specifies the loop mode of the animation
  3839. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3840. * @param onAnimationEnd Callback to run once the animation is complete
  3841. * @returns Nullable animation
  3842. */
  3843. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3844. /**
  3845. * Transition property of an host to the target Value
  3846. * @param property The property to transition
  3847. * @param targetValue The target Value of the property
  3848. * @param host The object where the property to animate belongs
  3849. * @param scene Scene used to run the animation
  3850. * @param frameRate Framerate (in frame/s) to use
  3851. * @param transition The transition type we want to use
  3852. * @param duration The duration of the animation, in milliseconds
  3853. * @param onAnimationEnd Callback trigger at the end of the animation
  3854. * @returns Nullable animation
  3855. */
  3856. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3857. /**
  3858. * Return the array of runtime animations currently using this animation
  3859. */
  3860. readonly runtimeAnimations: RuntimeAnimation[];
  3861. /**
  3862. * Specifies if any of the runtime animations are currently running
  3863. */
  3864. readonly hasRunningRuntimeAnimations: boolean;
  3865. /**
  3866. * Initializes the animation
  3867. * @param name Name of the animation
  3868. * @param targetProperty Property to animate
  3869. * @param framePerSecond The frames per second of the animation
  3870. * @param dataType The data type of the animation
  3871. * @param loopMode The loop mode of the animation
  3872. * @param enableBlendings Specifies if blending should be enabled
  3873. */
  3874. constructor(
  3875. /**Name of the animation */
  3876. name: string,
  3877. /**Property to animate */
  3878. targetProperty: string,
  3879. /**The frames per second of the animation */
  3880. framePerSecond: number,
  3881. /**The data type of the animation */
  3882. dataType: number,
  3883. /**The loop mode of the animation */
  3884. loopMode?: number | undefined,
  3885. /**Specifies if blending should be enabled */
  3886. enableBlending?: boolean | undefined);
  3887. /**
  3888. * Converts the animation to a string
  3889. * @param fullDetails support for multiple levels of logging within scene loading
  3890. * @returns String form of the animation
  3891. */
  3892. toString(fullDetails?: boolean): string;
  3893. /**
  3894. * Add an event to this animation
  3895. * @param event Event to add
  3896. */
  3897. addEvent(event: AnimationEvent): void;
  3898. /**
  3899. * Remove all events found at the given frame
  3900. * @param frame The frame to remove events from
  3901. */
  3902. removeEvents(frame: number): void;
  3903. /**
  3904. * Retrieves all the events from the animation
  3905. * @returns Events from the animation
  3906. */
  3907. getEvents(): AnimationEvent[];
  3908. /**
  3909. * Creates an animation range
  3910. * @param name Name of the animation range
  3911. * @param from Starting frame of the animation range
  3912. * @param to Ending frame of the animation
  3913. */
  3914. createRange(name: string, from: number, to: number): void;
  3915. /**
  3916. * Deletes an animation range by name
  3917. * @param name Name of the animation range to delete
  3918. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3919. */
  3920. deleteRange(name: string, deleteFrames?: boolean): void;
  3921. /**
  3922. * Gets the animation range by name, or null if not defined
  3923. * @param name Name of the animation range
  3924. * @returns Nullable animation range
  3925. */
  3926. getRange(name: string): Nullable<AnimationRange>;
  3927. /**
  3928. * Gets the key frames from the animation
  3929. * @returns The key frames of the animation
  3930. */
  3931. getKeys(): Array<IAnimationKey>;
  3932. /**
  3933. * Gets the highest frame rate of the animation
  3934. * @returns Highest frame rate of the animation
  3935. */
  3936. getHighestFrame(): number;
  3937. /**
  3938. * Gets the easing function of the animation
  3939. * @returns Easing function of the animation
  3940. */
  3941. getEasingFunction(): IEasingFunction;
  3942. /**
  3943. * Sets the easing function of the animation
  3944. * @param easingFunction A custom mathematical formula for animation
  3945. */
  3946. setEasingFunction(easingFunction: EasingFunction): void;
  3947. /**
  3948. * Interpolates a scalar linearly
  3949. * @param startValue Start value of the animation curve
  3950. * @param endValue End value of the animation curve
  3951. * @param gradient Scalar amount to interpolate
  3952. * @returns Interpolated scalar value
  3953. */
  3954. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3955. /**
  3956. * Interpolates a scalar cubically
  3957. * @param startValue Start value of the animation curve
  3958. * @param outTangent End tangent of the animation
  3959. * @param endValue End value of the animation curve
  3960. * @param inTangent Start tangent of the animation curve
  3961. * @param gradient Scalar amount to interpolate
  3962. * @returns Interpolated scalar value
  3963. */
  3964. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3965. /**
  3966. * Interpolates a quaternion using a spherical linear interpolation
  3967. * @param startValue Start value of the animation curve
  3968. * @param endValue End value of the animation curve
  3969. * @param gradient Scalar amount to interpolate
  3970. * @returns Interpolated quaternion value
  3971. */
  3972. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3973. /**
  3974. * Interpolates a quaternion cubically
  3975. * @param startValue Start value of the animation curve
  3976. * @param outTangent End tangent of the animation curve
  3977. * @param endValue End value of the animation curve
  3978. * @param inTangent Start tangent of the animation curve
  3979. * @param gradient Scalar amount to interpolate
  3980. * @returns Interpolated quaternion value
  3981. */
  3982. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3983. /**
  3984. * Interpolates a Vector3 linearl
  3985. * @param startValue Start value of the animation curve
  3986. * @param endValue End value of the animation curve
  3987. * @param gradient Scalar amount to interpolate
  3988. * @returns Interpolated scalar value
  3989. */
  3990. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3991. /**
  3992. * Interpolates a Vector3 cubically
  3993. * @param startValue Start value of the animation curve
  3994. * @param outTangent End tangent of the animation
  3995. * @param endValue End value of the animation curve
  3996. * @param inTangent Start tangent of the animation curve
  3997. * @param gradient Scalar amount to interpolate
  3998. * @returns InterpolatedVector3 value
  3999. */
  4000. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4001. /**
  4002. * Interpolates a Vector2 linearly
  4003. * @param startValue Start value of the animation curve
  4004. * @param endValue End value of the animation curve
  4005. * @param gradient Scalar amount to interpolate
  4006. * @returns Interpolated Vector2 value
  4007. */
  4008. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4009. /**
  4010. * Interpolates a Vector2 cubically
  4011. * @param startValue Start value of the animation curve
  4012. * @param outTangent End tangent of the animation
  4013. * @param endValue End value of the animation curve
  4014. * @param inTangent Start tangent of the animation curve
  4015. * @param gradient Scalar amount to interpolate
  4016. * @returns Interpolated Vector2 value
  4017. */
  4018. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4019. /**
  4020. * Interpolates a size linearly
  4021. * @param startValue Start value of the animation curve
  4022. * @param endValue End value of the animation curve
  4023. * @param gradient Scalar amount to interpolate
  4024. * @returns Interpolated Size value
  4025. */
  4026. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4027. /**
  4028. * Interpolates a Color3 linearly
  4029. * @param startValue Start value of the animation curve
  4030. * @param endValue End value of the animation curve
  4031. * @param gradient Scalar amount to interpolate
  4032. * @returns Interpolated Color3 value
  4033. */
  4034. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4035. /**
  4036. * @hidden Internal use only
  4037. */
  4038. _getKeyValue(value: any): any;
  4039. /**
  4040. * @hidden Internal use only
  4041. */
  4042. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4043. /**
  4044. * Defines the function to use to interpolate matrices
  4045. * @param startValue defines the start matrix
  4046. * @param endValue defines the end matrix
  4047. * @param gradient defines the gradient between both matrices
  4048. * @param result defines an optional target matrix where to store the interpolation
  4049. * @returns the interpolated matrix
  4050. */
  4051. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4052. /**
  4053. * Makes a copy of the animation
  4054. * @returns Cloned animation
  4055. */
  4056. clone(): Animation;
  4057. /**
  4058. * Sets the key frames of the animation
  4059. * @param values The animation key frames to set
  4060. */
  4061. setKeys(values: Array<IAnimationKey>): void;
  4062. /**
  4063. * Serializes the animation to an object
  4064. * @returns Serialized object
  4065. */
  4066. serialize(): any;
  4067. /**
  4068. * Float animation type
  4069. */
  4070. private static _ANIMATIONTYPE_FLOAT;
  4071. /**
  4072. * Vector3 animation type
  4073. */
  4074. private static _ANIMATIONTYPE_VECTOR3;
  4075. /**
  4076. * Quaternion animation type
  4077. */
  4078. private static _ANIMATIONTYPE_QUATERNION;
  4079. /**
  4080. * Matrix animation type
  4081. */
  4082. private static _ANIMATIONTYPE_MATRIX;
  4083. /**
  4084. * Color3 animation type
  4085. */
  4086. private static _ANIMATIONTYPE_COLOR3;
  4087. /**
  4088. * Vector2 animation type
  4089. */
  4090. private static _ANIMATIONTYPE_VECTOR2;
  4091. /**
  4092. * Size animation type
  4093. */
  4094. private static _ANIMATIONTYPE_SIZE;
  4095. /**
  4096. * Relative Loop Mode
  4097. */
  4098. private static _ANIMATIONLOOPMODE_RELATIVE;
  4099. /**
  4100. * Cycle Loop Mode
  4101. */
  4102. private static _ANIMATIONLOOPMODE_CYCLE;
  4103. /**
  4104. * Constant Loop Mode
  4105. */
  4106. private static _ANIMATIONLOOPMODE_CONSTANT;
  4107. /**
  4108. * Get the float animation type
  4109. */
  4110. static readonly ANIMATIONTYPE_FLOAT: number;
  4111. /**
  4112. * Get the Vector3 animation type
  4113. */
  4114. static readonly ANIMATIONTYPE_VECTOR3: number;
  4115. /**
  4116. * Get the Vector2 animation type
  4117. */
  4118. static readonly ANIMATIONTYPE_VECTOR2: number;
  4119. /**
  4120. * Get the Size animation type
  4121. */
  4122. static readonly ANIMATIONTYPE_SIZE: number;
  4123. /**
  4124. * Get the Quaternion animation type
  4125. */
  4126. static readonly ANIMATIONTYPE_QUATERNION: number;
  4127. /**
  4128. * Get the Matrix animation type
  4129. */
  4130. static readonly ANIMATIONTYPE_MATRIX: number;
  4131. /**
  4132. * Get the Color3 animation type
  4133. */
  4134. static readonly ANIMATIONTYPE_COLOR3: number;
  4135. /**
  4136. * Get the Relative Loop Mode
  4137. */
  4138. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4139. /**
  4140. * Get the Cycle Loop Mode
  4141. */
  4142. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4143. /**
  4144. * Get the Constant Loop Mode
  4145. */
  4146. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4147. /** @hidden */
  4148. static _UniversalLerp(left: any, right: any, amount: number): any;
  4149. /**
  4150. * Parses an animation object and creates an animation
  4151. * @param parsedAnimation Parsed animation object
  4152. * @returns Animation object
  4153. */
  4154. static Parse(parsedAnimation: any): Animation;
  4155. /**
  4156. * Appends the serialized animations from the source animations
  4157. * @param source Source containing the animations
  4158. * @param destination Target to store the animations
  4159. */
  4160. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4161. }
  4162. }
  4163. declare module BABYLON {
  4164. /**
  4165. * This class defines the direct association between an animation and a target
  4166. */
  4167. class TargetedAnimation {
  4168. animation: Animation;
  4169. target: any;
  4170. }
  4171. /**
  4172. * Use this class to create coordinated animations on multiple targets
  4173. */
  4174. class AnimationGroup implements IDisposable {
  4175. name: string;
  4176. private _scene;
  4177. private _targetedAnimations;
  4178. private _animatables;
  4179. private _from;
  4180. private _to;
  4181. private _isStarted;
  4182. private _speedRatio;
  4183. onAnimationEndObservable: Observable<TargetedAnimation>;
  4184. /**
  4185. * This observable will notify when all animations have ended.
  4186. */
  4187. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4188. /**
  4189. * This observable will notify when all animations have paused.
  4190. */
  4191. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4192. /**
  4193. * Gets the first frame
  4194. */
  4195. readonly from: number;
  4196. /**
  4197. * Gets the last frame
  4198. */
  4199. readonly to: number;
  4200. /**
  4201. * Define if the animations are started
  4202. */
  4203. readonly isStarted: boolean;
  4204. /**
  4205. * Gets or sets the speed ratio to use for all animations
  4206. */
  4207. /**
  4208. * Gets or sets the speed ratio to use for all animations
  4209. */
  4210. speedRatio: number;
  4211. /**
  4212. * Gets the targeted animations for this animation group
  4213. */
  4214. readonly targetedAnimations: Array<TargetedAnimation>;
  4215. /**
  4216. * returning the list of animatables controlled by this animation group.
  4217. */
  4218. readonly animatables: Array<Animatable>;
  4219. constructor(name: string, scene?: Nullable<Scene>);
  4220. /**
  4221. * Add an animation (with its target) in the group
  4222. * @param animation defines the animation we want to add
  4223. * @param target defines the target of the animation
  4224. * @returns the {BABYLON.TargetedAnimation} object
  4225. */
  4226. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4227. /**
  4228. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4229. * It can add constant keys at begin or end
  4230. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4231. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4232. */
  4233. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4234. /**
  4235. * Start all animations on given targets
  4236. * @param loop defines if animations must loop
  4237. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4238. * @param from defines the from key (optional)
  4239. * @param to defines the to key (optional)
  4240. * @returns the current animation group
  4241. */
  4242. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4243. /**
  4244. * Pause all animations
  4245. */
  4246. pause(): AnimationGroup;
  4247. /**
  4248. * Play all animations to initial state
  4249. * This function will start() the animations if they were not started or will restart() them if they were paused
  4250. * @param loop defines if animations must loop
  4251. */
  4252. play(loop?: boolean): AnimationGroup;
  4253. /**
  4254. * Reset all animations to initial state
  4255. */
  4256. reset(): AnimationGroup;
  4257. /**
  4258. * Restart animations from key 0
  4259. */
  4260. restart(): AnimationGroup;
  4261. /**
  4262. * Stop all animations
  4263. */
  4264. stop(): AnimationGroup;
  4265. /**
  4266. * Set animation weight for all animatables
  4267. * @param weight defines the weight to use
  4268. * @return the animationGroup
  4269. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4270. */
  4271. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4272. /**
  4273. * Synchronize and normalize all animatables with a source animatable
  4274. * @param root defines the root animatable to synchronize with
  4275. * @return the animationGroup
  4276. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4277. */
  4278. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4279. /**
  4280. * Goes to a specific frame in this animation group
  4281. * @param frame the frame number to go to
  4282. * @return the animationGroup
  4283. */
  4284. goToFrame(frame: number): AnimationGroup;
  4285. /**
  4286. * Dispose all associated resources
  4287. */
  4288. dispose(): void;
  4289. private _checkAnimationGroupEnded;
  4290. }
  4291. }
  4292. declare module BABYLON {
  4293. /**
  4294. * Class used to override all child animations of a given target
  4295. */
  4296. class AnimationPropertiesOverride {
  4297. /**
  4298. * Gets or sets a value indicating if animation blending must be used
  4299. */
  4300. enableBlending: boolean;
  4301. /**
  4302. * Gets or sets the blending speed to use when enableBlending is true
  4303. */
  4304. blendingSpeed: number;
  4305. /**
  4306. * Gets or sets the default loop mode to use
  4307. */
  4308. loopMode: number;
  4309. }
  4310. }
  4311. declare module BABYLON {
  4312. interface IEasingFunction {
  4313. ease(gradient: number): number;
  4314. }
  4315. class EasingFunction implements IEasingFunction {
  4316. private static _EASINGMODE_EASEIN;
  4317. private static _EASINGMODE_EASEOUT;
  4318. private static _EASINGMODE_EASEINOUT;
  4319. static readonly EASINGMODE_EASEIN: number;
  4320. static readonly EASINGMODE_EASEOUT: number;
  4321. static readonly EASINGMODE_EASEINOUT: number;
  4322. private _easingMode;
  4323. setEasingMode(easingMode: number): void;
  4324. getEasingMode(): number;
  4325. easeInCore(gradient: number): number;
  4326. ease(gradient: number): number;
  4327. }
  4328. class CircleEase extends EasingFunction implements IEasingFunction {
  4329. easeInCore(gradient: number): number;
  4330. }
  4331. class BackEase extends EasingFunction implements IEasingFunction {
  4332. amplitude: number;
  4333. constructor(amplitude?: number);
  4334. easeInCore(gradient: number): number;
  4335. }
  4336. class BounceEase extends EasingFunction implements IEasingFunction {
  4337. bounces: number;
  4338. bounciness: number;
  4339. constructor(bounces?: number, bounciness?: number);
  4340. easeInCore(gradient: number): number;
  4341. }
  4342. class CubicEase extends EasingFunction implements IEasingFunction {
  4343. easeInCore(gradient: number): number;
  4344. }
  4345. class ElasticEase extends EasingFunction implements IEasingFunction {
  4346. oscillations: number;
  4347. springiness: number;
  4348. constructor(oscillations?: number, springiness?: number);
  4349. easeInCore(gradient: number): number;
  4350. }
  4351. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4352. exponent: number;
  4353. constructor(exponent?: number);
  4354. easeInCore(gradient: number): number;
  4355. }
  4356. class PowerEase extends EasingFunction implements IEasingFunction {
  4357. power: number;
  4358. constructor(power?: number);
  4359. easeInCore(gradient: number): number;
  4360. }
  4361. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4362. easeInCore(gradient: number): number;
  4363. }
  4364. class QuarticEase extends EasingFunction implements IEasingFunction {
  4365. easeInCore(gradient: number): number;
  4366. }
  4367. class QuinticEase extends EasingFunction implements IEasingFunction {
  4368. easeInCore(gradient: number): number;
  4369. }
  4370. class SineEase extends EasingFunction implements IEasingFunction {
  4371. easeInCore(gradient: number): number;
  4372. }
  4373. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4374. x1: number;
  4375. y1: number;
  4376. x2: number;
  4377. y2: number;
  4378. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4379. easeInCore(gradient: number): number;
  4380. }
  4381. }
  4382. declare module BABYLON {
  4383. /**
  4384. * Defines a runtime animation
  4385. */
  4386. class RuntimeAnimation {
  4387. private _events;
  4388. /**
  4389. * The current frame of the runtime animation
  4390. */
  4391. private _currentFrame;
  4392. /**
  4393. * The animation used by the runtime animation
  4394. */
  4395. private _animation;
  4396. /**
  4397. * The target of the runtime animation
  4398. */
  4399. private _target;
  4400. /**
  4401. * The initiating animatable
  4402. */
  4403. private _host;
  4404. /**
  4405. * The original value of the runtime animation
  4406. */
  4407. private _originalValue;
  4408. /**
  4409. * The original blend value of the runtime animation
  4410. */
  4411. private _originalBlendValue;
  4412. /**
  4413. * The offsets cache of the runtime animation
  4414. */
  4415. private _offsetsCache;
  4416. /**
  4417. * The high limits cache of the runtime animation
  4418. */
  4419. private _highLimitsCache;
  4420. /**
  4421. * Specifies if the runtime animation has been stopped
  4422. */
  4423. private _stopped;
  4424. /**
  4425. * The blending factor of the runtime animation
  4426. */
  4427. private _blendingFactor;
  4428. /**
  4429. * The BabylonJS scene
  4430. */
  4431. private _scene;
  4432. /**
  4433. * The current value of the runtime animation
  4434. */
  4435. private _currentValue;
  4436. /** @hidden */
  4437. _workValue: any;
  4438. /**
  4439. * The active target of the runtime animation
  4440. */
  4441. private _activeTarget;
  4442. /**
  4443. * The target path of the runtime animation
  4444. */
  4445. private _targetPath;
  4446. /**
  4447. * The weight of the runtime animation
  4448. */
  4449. private _weight;
  4450. /**
  4451. * The ratio offset of the runtime animation
  4452. */
  4453. private _ratioOffset;
  4454. /**
  4455. * The previous delay of the runtime animation
  4456. */
  4457. private _previousDelay;
  4458. /**
  4459. * The previous ratio of the runtime animation
  4460. */
  4461. private _previousRatio;
  4462. /**
  4463. * Gets the current frame of the runtime animation
  4464. */
  4465. readonly currentFrame: number;
  4466. /**
  4467. * Gets the weight of the runtime animation
  4468. */
  4469. readonly weight: number;
  4470. /**
  4471. * Gets the current value of the runtime animation
  4472. */
  4473. readonly currentValue: any;
  4474. /**
  4475. * Gets the target path of the runtime animation
  4476. */
  4477. readonly targetPath: string;
  4478. /**
  4479. * Gets the actual target of the runtime animation
  4480. */
  4481. readonly target: any;
  4482. /**
  4483. * Create a new RuntimeAnimation object
  4484. * @param target defines the target of the animation
  4485. * @param animation defines the source animation object
  4486. * @param scene defines the hosting scene
  4487. * @param host defines the initiating Animatable
  4488. */
  4489. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4490. /**
  4491. * Gets the animation from the runtime animation
  4492. */
  4493. readonly animation: Animation;
  4494. /**
  4495. * Resets the runtime animation to the beginning
  4496. * @param restoreOriginal defines whether to restore the target property to the original value
  4497. */
  4498. reset(restoreOriginal?: boolean): void;
  4499. /**
  4500. * Specifies if the runtime animation is stopped
  4501. * @returns Boolean specifying if the runtime animation is stopped
  4502. */
  4503. isStopped(): boolean;
  4504. /**
  4505. * Disposes of the runtime animation
  4506. */
  4507. dispose(): void;
  4508. /**
  4509. * Interpolates the animation from the current frame
  4510. * @param currentFrame The frame to interpolate the animation to
  4511. * @param repeatCount The number of times that the animation should loop
  4512. * @param loopMode The type of looping mode to use
  4513. * @param offsetValue Animation offset value
  4514. * @param highLimitValue The high limit value
  4515. * @returns The interpolated value
  4516. */
  4517. private _interpolate;
  4518. /**
  4519. * Apply the interpolated value to the target
  4520. * @param currentValue defines the value computed by the animation
  4521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4522. */
  4523. setValue(currentValue: any, weight?: number): void;
  4524. private _setValue;
  4525. /**
  4526. * Gets the loop pmode of the runtime animation
  4527. * @returns Loop Mode
  4528. */
  4529. private _getCorrectLoopMode;
  4530. /**
  4531. * Move the current animation to a given frame
  4532. * @param frame defines the frame to move to
  4533. */
  4534. goToFrame(frame: number): void;
  4535. /**
  4536. * @hidden Internal use only
  4537. */
  4538. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4539. /**
  4540. * Execute the current animation
  4541. * @param delay defines the delay to add to the current frame
  4542. * @param from defines the lower bound of the animation range
  4543. * @param to defines the upper bound of the animation range
  4544. * @param loop defines if the current animation must loop
  4545. * @param speedRatio defines the current speed ratio
  4546. * @param weight defines the weight of the animation (default is -1 so no weight)
  4547. * @returns a boolean indicating if the animation is running
  4548. */
  4549. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4550. }
  4551. }
  4552. declare module BABYLON {
  4553. /**
  4554. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4556. */
  4557. class Analyser {
  4558. /**
  4559. * Gets or sets the smoothing
  4560. * @ignorenaming
  4561. */
  4562. SMOOTHING: number;
  4563. /**
  4564. * Gets or sets the FFT table size
  4565. * @ignorenaming
  4566. */
  4567. FFT_SIZE: number;
  4568. /**
  4569. * Gets or sets the bar graph amplitude
  4570. * @ignorenaming
  4571. */
  4572. BARGRAPHAMPLITUDE: number;
  4573. /**
  4574. * Gets or sets the position of the debug canvas
  4575. * @ignorenaming
  4576. */
  4577. DEBUGCANVASPOS: {
  4578. x: number;
  4579. y: number;
  4580. };
  4581. /**
  4582. * Gets or sets the debug canvas size
  4583. * @ignorenaming
  4584. */
  4585. DEBUGCANVASSIZE: {
  4586. width: number;
  4587. height: number;
  4588. };
  4589. private _byteFreqs;
  4590. private _byteTime;
  4591. private _floatFreqs;
  4592. private _webAudioAnalyser;
  4593. private _debugCanvas;
  4594. private _debugCanvasContext;
  4595. private _scene;
  4596. private _registerFunc;
  4597. private _audioEngine;
  4598. /**
  4599. * Creates a new analyser
  4600. * @param scene defines hosting scene
  4601. */
  4602. constructor(scene: Scene);
  4603. /**
  4604. * Get the number of data values you will have to play with for the visualization
  4605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4606. * @returns a number
  4607. */
  4608. getFrequencyBinCount(): number;
  4609. /**
  4610. * Gets the current frequency data as a byte array
  4611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4612. * @returns a Uint8Array
  4613. */
  4614. getByteFrequencyData(): Uint8Array;
  4615. /**
  4616. * Gets the current waveform as a byte array
  4617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4618. * @returns a Uint8Array
  4619. */
  4620. getByteTimeDomainData(): Uint8Array;
  4621. /**
  4622. * Gets the current frequency data as a float array
  4623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4624. * @returns a Float32Array
  4625. */
  4626. getFloatFrequencyData(): Float32Array;
  4627. /**
  4628. * Renders the debug canvas
  4629. */
  4630. drawDebugCanvas(): void;
  4631. /**
  4632. * Stops rendering the debug canvas and removes it
  4633. */
  4634. stopDebugCanvas(): void;
  4635. /**
  4636. * Connects two audio nodes
  4637. * @param inputAudioNode defines first node to connect
  4638. * @param outputAudioNode defines second node to connect
  4639. */
  4640. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4641. /**
  4642. * Releases all associated resources
  4643. */
  4644. dispose(): void;
  4645. }
  4646. }
  4647. declare module BABYLON {
  4648. class AudioEngine {
  4649. private _audioContext;
  4650. private _audioContextInitialized;
  4651. canUseWebAudio: boolean;
  4652. masterGain: GainNode;
  4653. private _connectedAnalyser;
  4654. WarnedWebAudioUnsupported: boolean;
  4655. unlocked: boolean;
  4656. onAudioUnlocked: () => any;
  4657. isMP3supported: boolean;
  4658. isOGGsupported: boolean;
  4659. readonly audioContext: Nullable<AudioContext>;
  4660. constructor();
  4661. private _unlockiOSaudio;
  4662. private _initializeAudioContext;
  4663. dispose(): void;
  4664. getGlobalVolume(): number;
  4665. setGlobalVolume(newVolume: number): void;
  4666. connectToAnalyser(analyser: Analyser): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. class Sound {
  4671. name: string;
  4672. autoplay: boolean;
  4673. loop: boolean;
  4674. useCustomAttenuation: boolean;
  4675. soundTrackId: number;
  4676. spatialSound: boolean;
  4677. refDistance: number;
  4678. rolloffFactor: number;
  4679. maxDistance: number;
  4680. distanceModel: string;
  4681. private _panningModel;
  4682. onended: () => any;
  4683. /**
  4684. * Observable event when the current playing sound finishes.
  4685. */
  4686. onEndedObservable: Observable<Sound>;
  4687. private _playbackRate;
  4688. private _streaming;
  4689. private _startTime;
  4690. private _startOffset;
  4691. private _position;
  4692. /** @hidden */
  4693. _positionInEmitterSpace: boolean;
  4694. private _localDirection;
  4695. private _volume;
  4696. private _isReadyToPlay;
  4697. isPlaying: boolean;
  4698. isPaused: boolean;
  4699. private _isDirectional;
  4700. private _readyToPlayCallback;
  4701. private _audioBuffer;
  4702. private _soundSource;
  4703. private _streamingSource;
  4704. private _soundPanner;
  4705. private _soundGain;
  4706. private _inputAudioNode;
  4707. private _outputAudioNode;
  4708. private _coneInnerAngle;
  4709. private _coneOuterAngle;
  4710. private _coneOuterGain;
  4711. private _scene;
  4712. private _connectedMesh;
  4713. private _customAttenuationFunction;
  4714. private _registerFunc;
  4715. private _isOutputConnected;
  4716. private _htmlAudioElement;
  4717. private _urlType;
  4718. /**
  4719. * Create a sound and attach it to a scene
  4720. * @param name Name of your sound
  4721. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4722. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4723. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4724. */
  4725. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4726. dispose(): void;
  4727. isReady(): boolean;
  4728. private _soundLoaded;
  4729. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4730. updateOptions(options: any): void;
  4731. private _createSpatialParameters;
  4732. private _updateSpatialParameters;
  4733. switchPanningModelToHRTF(): void;
  4734. switchPanningModelToEqualPower(): void;
  4735. private _switchPanningModel;
  4736. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4737. /**
  4738. * Transform this sound into a directional source
  4739. * @param coneInnerAngle Size of the inner cone in degree
  4740. * @param coneOuterAngle Size of the outer cone in degree
  4741. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4742. */
  4743. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4744. /**
  4745. * Gets or sets the inner angle for the directional cone.
  4746. */
  4747. /**
  4748. * Gets or sets the inner angle for the directional cone.
  4749. */
  4750. directionalConeInnerAngle: number;
  4751. /**
  4752. * Gets or sets the outer angle for the directional cone.
  4753. */
  4754. /**
  4755. * Gets or sets the outer angle for the directional cone.
  4756. */
  4757. directionalConeOuterAngle: number;
  4758. setPosition(newPosition: Vector3): void;
  4759. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4760. private _updateDirection;
  4761. updateDistanceFromListener(): void;
  4762. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4763. /**
  4764. * Play the sound
  4765. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4766. * @param offset (optional) Start the sound setting it at a specific time
  4767. */
  4768. play(time?: number, offset?: number): void;
  4769. private _onended;
  4770. /**
  4771. * Stop the sound
  4772. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4773. */
  4774. stop(time?: number): void;
  4775. pause(): void;
  4776. setVolume(newVolume: number, time?: number): void;
  4777. setPlaybackRate(newPlaybackRate: number): void;
  4778. getVolume(): number;
  4779. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4780. detachFromMesh(): void;
  4781. private _onRegisterAfterWorldMatrixUpdate;
  4782. clone(): Nullable<Sound>;
  4783. getAudioBuffer(): AudioBuffer | null;
  4784. serialize(): any;
  4785. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4786. }
  4787. }
  4788. declare module BABYLON {
  4789. class SoundTrack {
  4790. private _outputAudioNode;
  4791. private _scene;
  4792. id: number;
  4793. soundCollection: Array<Sound>;
  4794. private _isMainTrack;
  4795. private _connectedAnalyser;
  4796. private _options;
  4797. private _isInitialized;
  4798. constructor(scene: Scene, options?: any);
  4799. private _initializeSoundTrackAudioGraph;
  4800. dispose(): void;
  4801. AddSound(sound: Sound): void;
  4802. RemoveSound(sound: Sound): void;
  4803. setVolume(newVolume: number): void;
  4804. switchPanningModelToHRTF(): void;
  4805. switchPanningModelToEqualPower(): void;
  4806. connectToAnalyser(analyser: Analyser): void;
  4807. }
  4808. }
  4809. declare module BABYLON {
  4810. /**
  4811. * Wraps one or more Sound objects and selects one with random weight for playback.
  4812. */
  4813. class WeightedSound {
  4814. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4815. loop: boolean;
  4816. private _coneInnerAngle;
  4817. private _coneOuterAngle;
  4818. private _volume;
  4819. /** A Sound is currently playing. */
  4820. isPlaying: boolean;
  4821. /** A Sound is currently paused. */
  4822. isPaused: boolean;
  4823. private _sounds;
  4824. private _weights;
  4825. private _currentIndex?;
  4826. /**
  4827. * Creates a new WeightedSound from the list of sounds given.
  4828. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4829. * @param sounds Array of Sounds that will be selected from.
  4830. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4831. */
  4832. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4833. /**
  4834. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4835. */
  4836. /**
  4837. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4838. */
  4839. directionalConeInnerAngle: number;
  4840. /**
  4841. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4842. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4843. */
  4844. /**
  4845. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4846. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4847. */
  4848. directionalConeOuterAngle: number;
  4849. /**
  4850. * Playback volume.
  4851. */
  4852. /**
  4853. * Playback volume.
  4854. */
  4855. volume: number;
  4856. private _onended;
  4857. /**
  4858. * Suspend playback
  4859. */
  4860. pause(): void;
  4861. /**
  4862. * Stop playback
  4863. */
  4864. stop(): void;
  4865. /**
  4866. * Start playback.
  4867. * @param startOffset Position the clip head at a specific time in seconds.
  4868. */
  4869. play(startOffset?: number): void;
  4870. }
  4871. }
  4872. declare module BABYLON {
  4873. /**
  4874. * Interface used to define a behavior
  4875. */
  4876. interface Behavior<T> {
  4877. /** gets or sets behavior's name */
  4878. name: string;
  4879. /**
  4880. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4881. */
  4882. init(): void;
  4883. /**
  4884. * Called when the behavior is attached to a target
  4885. * @param target defines the target where the behavior is attached to
  4886. */
  4887. attach(target: T): void;
  4888. /**
  4889. * Called when the behavior is detached from its target
  4890. */
  4891. detach(): void;
  4892. }
  4893. /**
  4894. * Interface implemented by classes supporting behaviors
  4895. */
  4896. interface IBehaviorAware<T> {
  4897. /**
  4898. * Attach a behavior
  4899. * @param behavior defines the behavior to attach
  4900. * @returns the current host
  4901. */
  4902. addBehavior(behavior: Behavior<T>): T;
  4903. /**
  4904. * Remove a behavior from the current object
  4905. * @param behavior defines the behavior to detach
  4906. * @returns the current host
  4907. */
  4908. removeBehavior(behavior: Behavior<T>): T;
  4909. /**
  4910. * Gets a behavior using its name to search
  4911. * @param name defines the name to search
  4912. * @returns the behavior or null if not found
  4913. */
  4914. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4915. }
  4916. }
  4917. declare module BABYLON {
  4918. /**
  4919. * Class used to store bone information
  4920. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4921. */
  4922. class Bone extends Node {
  4923. /**
  4924. * defines the bone name
  4925. */
  4926. name: string;
  4927. private static _tmpVecs;
  4928. private static _tmpQuat;
  4929. private static _tmpMats;
  4930. /**
  4931. * Gets the list of child bones
  4932. */
  4933. children: Bone[];
  4934. /** Gets the animations associated with this bone */
  4935. animations: Animation[];
  4936. /**
  4937. * Gets or sets bone length
  4938. */
  4939. length: number;
  4940. /**
  4941. * @hidden Internal only
  4942. * Set this value to map this bone to a different index in the transform matrices
  4943. * Set this value to -1 to exclude the bone from the transform matrices
  4944. */
  4945. _index: Nullable<number>;
  4946. private _skeleton;
  4947. private _localMatrix;
  4948. private _restPose;
  4949. private _baseMatrix;
  4950. private _absoluteTransform;
  4951. private _invertedAbsoluteTransform;
  4952. private _parent;
  4953. private _scalingDeterminant;
  4954. private _worldTransform;
  4955. private _localScaling;
  4956. private _localRotation;
  4957. private _localPosition;
  4958. private _needToDecompose;
  4959. private _needToCompose;
  4960. /** @hidden */
  4961. /** @hidden */
  4962. _matrix: Matrix;
  4963. /**
  4964. * Create a new bone
  4965. * @param name defines the bone name
  4966. * @param skeleton defines the parent skeleton
  4967. * @param parentBone defines the parent (can be null if the bone is the root)
  4968. * @param localMatrix defines the local matrix
  4969. * @param restPose defines the rest pose matrix
  4970. * @param baseMatrix defines the base matrix
  4971. * @param index defines index of the bone in the hiearchy
  4972. */
  4973. constructor(
  4974. /**
  4975. * defines the bone name
  4976. */
  4977. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4978. /**
  4979. * Gets the parent skeleton
  4980. * @returns a skeleton
  4981. */
  4982. getSkeleton(): Skeleton;
  4983. /**
  4984. * Gets parent bone
  4985. * @returns a bone or null if the bone is the root of the bone hierarchy
  4986. */
  4987. getParent(): Nullable<Bone>;
  4988. /**
  4989. * Sets the parent bone
  4990. * @param parent defines the parent (can be null if the bone is the root)
  4991. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4992. */
  4993. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4994. /**
  4995. * Gets the local matrix
  4996. * @returns a matrix
  4997. */
  4998. getLocalMatrix(): Matrix;
  4999. /**
  5000. * Gets the base matrix (initial matrix which remains unchanged)
  5001. * @returns a matrix
  5002. */
  5003. getBaseMatrix(): Matrix;
  5004. /**
  5005. * Gets the rest pose matrix
  5006. * @returns a matrix
  5007. */
  5008. getRestPose(): Matrix;
  5009. /**
  5010. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5011. */
  5012. getWorldMatrix(): Matrix;
  5013. /**
  5014. * Sets the local matrix to rest pose matrix
  5015. */
  5016. returnToRest(): void;
  5017. /**
  5018. * Gets the inverse of the absolute transform matrix.
  5019. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5020. * @returns a matrix
  5021. */
  5022. getInvertedAbsoluteTransform(): Matrix;
  5023. /**
  5024. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5025. * @returns a matrix
  5026. */
  5027. getAbsoluteTransform(): Matrix;
  5028. /** Gets or sets current position (in local space) */
  5029. position: Vector3;
  5030. /** Gets or sets current rotation (in local space) */
  5031. rotation: Vector3;
  5032. /** Gets or sets current rotation quaternion (in local space) */
  5033. rotationQuaternion: Quaternion;
  5034. /** Gets or sets current scaling (in local space) */
  5035. scaling: Vector3;
  5036. /**
  5037. * Gets the animation properties override
  5038. */
  5039. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5040. private _decompose;
  5041. private _compose;
  5042. /**
  5043. * Update the base and local matrices
  5044. * @param matrix defines the new base or local matrix
  5045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5046. * @param updateLocalMatrix defines if the local matrix should be updated
  5047. */
  5048. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5049. /** @hidden */
  5050. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5051. /**
  5052. * Flag the bone as dirty (Forcing it to update everything)
  5053. */
  5054. markAsDirty(): void;
  5055. private _markAsDirtyAndCompose;
  5056. private _markAsDirtyAndDecompose;
  5057. /**
  5058. * Copy an animation range from another bone
  5059. * @param source defines the source bone
  5060. * @param rangeName defines the range name to copy
  5061. * @param frameOffset defines the frame offset
  5062. * @param rescaleAsRequired defines if rescaling must be applied if required
  5063. * @param skelDimensionsRatio defines the scaling ratio
  5064. * @returns true if operation was successful
  5065. */
  5066. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5067. /**
  5068. * Translate the bone in local or world space
  5069. * @param vec The amount to translate the bone
  5070. * @param space The space that the translation is in
  5071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5072. */
  5073. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5074. /**
  5075. * Set the postion of the bone in local or world space
  5076. * @param position The position to set the bone
  5077. * @param space The space that the position is in
  5078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5079. */
  5080. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5081. /**
  5082. * Set the absolute position of the bone (world space)
  5083. * @param position The position to set the bone
  5084. * @param mesh The mesh that this bone is attached to
  5085. */
  5086. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5087. /**
  5088. * Scale the bone on the x, y and z axes (in local space)
  5089. * @param x The amount to scale the bone on the x axis
  5090. * @param y The amount to scale the bone on the y axis
  5091. * @param z The amount to scale the bone on the z axis
  5092. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5093. */
  5094. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5095. /**
  5096. * Set the bone scaling in local space
  5097. * @param scale defines the scaling vector
  5098. */
  5099. setScale(scale: Vector3): void;
  5100. /**
  5101. * Gets the current scaling in local space
  5102. * @returns the current scaling vector
  5103. */
  5104. getScale(): Vector3;
  5105. /**
  5106. * Gets the current scaling in local space and stores it in a target vector
  5107. * @param result defines the target vector
  5108. */
  5109. getScaleToRef(result: Vector3): void;
  5110. /**
  5111. * Set the yaw, pitch, and roll of the bone in local or world space
  5112. * @param yaw The rotation of the bone on the y axis
  5113. * @param pitch The rotation of the bone on the x axis
  5114. * @param roll The rotation of the bone on the z axis
  5115. * @param space The space that the axes of rotation are in
  5116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5117. */
  5118. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5119. /**
  5120. * Add a rotation to the bone on an axis in local or world space
  5121. * @param axis The axis to rotate the bone on
  5122. * @param amount The amount to rotate the bone
  5123. * @param space The space that the axis is in
  5124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5125. */
  5126. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5127. /**
  5128. * Set the rotation of the bone to a particular axis angle in local or world space
  5129. * @param axis The axis to rotate the bone on
  5130. * @param angle The angle that the bone should be rotated to
  5131. * @param space The space that the axis is in
  5132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5133. */
  5134. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5135. /**
  5136. * Set the euler rotation of the bone in local of world space
  5137. * @param rotation The euler rotation that the bone should be set to
  5138. * @param space The space that the rotation is in
  5139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5140. */
  5141. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5142. /**
  5143. * Set the quaternion rotation of the bone in local of world space
  5144. * @param quat The quaternion rotation that the bone should be set to
  5145. * @param space The space that the rotation is in
  5146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5147. */
  5148. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5149. /**
  5150. * Set the rotation matrix of the bone in local of world space
  5151. * @param rotMat The rotation matrix that the bone should be set to
  5152. * @param space The space that the rotation is in
  5153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5154. */
  5155. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5156. private _rotateWithMatrix;
  5157. private _getNegativeRotationToRef;
  5158. /**
  5159. * Get the position of the bone in local or world space
  5160. * @param space The space that the returned position is in
  5161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5162. * @returns The position of the bone
  5163. */
  5164. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5165. /**
  5166. * Copy the position of the bone to a vector3 in local or world space
  5167. * @param space The space that the returned position is in
  5168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5169. * @param result The vector3 to copy the position to
  5170. */
  5171. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5172. /**
  5173. * Get the absolute position of the bone (world space)
  5174. * @param mesh The mesh that this bone is attached to
  5175. * @returns The absolute position of the bone
  5176. */
  5177. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5178. /**
  5179. * Copy the absolute position of the bone (world space) to the result param
  5180. * @param mesh The mesh that this bone is attached to
  5181. * @param result The vector3 to copy the absolute position to
  5182. */
  5183. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5184. /**
  5185. * Compute the absolute transforms of this bone and its children
  5186. */
  5187. computeAbsoluteTransforms(): void;
  5188. /**
  5189. * Get the world direction from an axis that is in the local space of the bone
  5190. * @param localAxis The local direction that is used to compute the world direction
  5191. * @param mesh The mesh that this bone is attached to
  5192. * @returns The world direction
  5193. */
  5194. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5195. /**
  5196. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5197. * @param localAxis The local direction that is used to compute the world direction
  5198. * @param mesh The mesh that this bone is attached to
  5199. * @param result The vector3 that the world direction will be copied to
  5200. */
  5201. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5202. /**
  5203. * Get the euler rotation of the bone in local or world space
  5204. * @param space The space that the rotation should be in
  5205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5206. * @returns The euler rotation
  5207. */
  5208. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5209. /**
  5210. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5211. * @param space The space that the rotation should be in
  5212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5213. * @param result The vector3 that the rotation should be copied to
  5214. */
  5215. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5216. /**
  5217. * Get the quaternion rotation of the bone in either local or world space
  5218. * @param space The space that the rotation should be in
  5219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5220. * @returns The quaternion rotation
  5221. */
  5222. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5223. /**
  5224. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5225. * @param space The space that the rotation should be in
  5226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5227. * @param result The quaternion that the rotation should be copied to
  5228. */
  5229. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5230. /**
  5231. * Get the rotation matrix of the bone in local or world space
  5232. * @param space The space that the rotation should be in
  5233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5234. * @returns The rotation matrix
  5235. */
  5236. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5237. /**
  5238. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5239. * @param space The space that the rotation should be in
  5240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5241. * @param result The quaternion that the rotation should be copied to
  5242. */
  5243. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5244. /**
  5245. * Get the world position of a point that is in the local space of the bone
  5246. * @param position The local position
  5247. * @param mesh The mesh that this bone is attached to
  5248. * @returns The world position
  5249. */
  5250. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5251. /**
  5252. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5253. * @param position The local position
  5254. * @param mesh The mesh that this bone is attached to
  5255. * @param result The vector3 that the world position should be copied to
  5256. */
  5257. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5258. /**
  5259. * Get the local position of a point that is in world space
  5260. * @param position The world position
  5261. * @param mesh The mesh that this bone is attached to
  5262. * @returns The local position
  5263. */
  5264. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5265. /**
  5266. * Get the local position of a point that is in world space and copy it to the result param
  5267. * @param position The world position
  5268. * @param mesh The mesh that this bone is attached to
  5269. * @param result The vector3 that the local position should be copied to
  5270. */
  5271. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5272. }
  5273. }
  5274. declare module BABYLON {
  5275. /**
  5276. * Class used to apply inverse kinematics to bones
  5277. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5278. */
  5279. class BoneIKController {
  5280. private static _tmpVecs;
  5281. private static _tmpQuat;
  5282. private static _tmpMats;
  5283. /**
  5284. * Gets or sets the target mesh
  5285. */
  5286. targetMesh: AbstractMesh;
  5287. /** Gets or sets the mesh used as pole */
  5288. poleTargetMesh: AbstractMesh;
  5289. /**
  5290. * Gets or sets the bone used as pole
  5291. */
  5292. poleTargetBone: Nullable<Bone>;
  5293. /**
  5294. * Gets or sets the target position
  5295. */
  5296. targetPosition: Vector3;
  5297. /**
  5298. * Gets or sets the pole target position
  5299. */
  5300. poleTargetPosition: Vector3;
  5301. /**
  5302. * Gets or sets the pole target local offset
  5303. */
  5304. poleTargetLocalOffset: Vector3;
  5305. /**
  5306. * Gets or sets the pole angle
  5307. */
  5308. poleAngle: number;
  5309. /**
  5310. * Gets or sets the mesh associated with the controller
  5311. */
  5312. mesh: AbstractMesh;
  5313. /**
  5314. * 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)
  5315. */
  5316. slerpAmount: number;
  5317. private _bone1Quat;
  5318. private _bone1Mat;
  5319. private _bone2Ang;
  5320. private _bone1;
  5321. private _bone2;
  5322. private _bone1Length;
  5323. private _bone2Length;
  5324. private _maxAngle;
  5325. private _maxReach;
  5326. private _rightHandedSystem;
  5327. private _bendAxis;
  5328. private _slerping;
  5329. private _adjustRoll;
  5330. /**
  5331. * Gets or sets maximum allowed angle
  5332. */
  5333. maxAngle: number;
  5334. /**
  5335. * Creates a new BoneIKController
  5336. * @param mesh defines the mesh to control
  5337. * @param bone defines the bone to control
  5338. * @param options defines options to set up the controller
  5339. */
  5340. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5341. targetMesh?: AbstractMesh;
  5342. poleTargetMesh?: AbstractMesh;
  5343. poleTargetBone?: Bone;
  5344. poleTargetLocalOffset?: Vector3;
  5345. poleAngle?: number;
  5346. bendAxis?: Vector3;
  5347. maxAngle?: number;
  5348. slerpAmount?: number;
  5349. });
  5350. private _setMaxAngle;
  5351. /**
  5352. * Force the controller to update the bones
  5353. */
  5354. update(): void;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /**
  5359. * Class used to make a bone look toward a point in space
  5360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5361. */
  5362. class BoneLookController {
  5363. private static _tmpVecs;
  5364. private static _tmpQuat;
  5365. private static _tmpMats;
  5366. /**
  5367. * The target Vector3 that the bone will look at
  5368. */
  5369. target: Vector3;
  5370. /**
  5371. * The mesh that the bone is attached to
  5372. */
  5373. mesh: AbstractMesh;
  5374. /**
  5375. * The bone that will be looking to the target
  5376. */
  5377. bone: Bone;
  5378. /**
  5379. * The up axis of the coordinate system that is used when the bone is rotated
  5380. */
  5381. upAxis: Vector3;
  5382. /**
  5383. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5384. */
  5385. upAxisSpace: Space;
  5386. /**
  5387. * Used to make an adjustment to the yaw of the bone
  5388. */
  5389. adjustYaw: number;
  5390. /**
  5391. * Used to make an adjustment to the pitch of the bone
  5392. */
  5393. adjustPitch: number;
  5394. /**
  5395. * Used to make an adjustment to the roll of the bone
  5396. */
  5397. adjustRoll: number;
  5398. /**
  5399. * 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)
  5400. */
  5401. slerpAmount: number;
  5402. private _minYaw;
  5403. private _maxYaw;
  5404. private _minPitch;
  5405. private _maxPitch;
  5406. private _minYawSin;
  5407. private _minYawCos;
  5408. private _maxYawSin;
  5409. private _maxYawCos;
  5410. private _midYawConstraint;
  5411. private _minPitchTan;
  5412. private _maxPitchTan;
  5413. private _boneQuat;
  5414. private _slerping;
  5415. private _transformYawPitch;
  5416. private _transformYawPitchInv;
  5417. private _firstFrameSkipped;
  5418. private _yawRange;
  5419. private _fowardAxis;
  5420. /**
  5421. * Gets or sets the minimum yaw angle that the bone can look to
  5422. */
  5423. minYaw: number;
  5424. /**
  5425. * Gets or sets the maximum yaw angle that the bone can look to
  5426. */
  5427. maxYaw: number;
  5428. /**
  5429. * Gets or sets the minimum pitch angle that the bone can look to
  5430. */
  5431. minPitch: number;
  5432. /**
  5433. * Gets or sets the maximum pitch angle that the bone can look to
  5434. */
  5435. maxPitch: number;
  5436. /**
  5437. * Create a BoneLookController
  5438. * @param mesh the mesh that the bone belongs to
  5439. * @param bone the bone that will be looking to the target
  5440. * @param target the target Vector3 to look at
  5441. * @param settings optional settings:
  5442. * * maxYaw: the maximum angle the bone will yaw to
  5443. * * minYaw: the minimum angle the bone will yaw to
  5444. * * maxPitch: the maximum angle the bone will pitch to
  5445. * * minPitch: the minimum angle the bone will yaw to
  5446. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5447. * * upAxis: the up axis of the coordinate system
  5448. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5449. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5450. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5451. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5452. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5453. * * adjustRoll: used to make an adjustment to the roll of the bone
  5454. **/
  5455. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5456. maxYaw?: number;
  5457. minYaw?: number;
  5458. maxPitch?: number;
  5459. minPitch?: number;
  5460. slerpAmount?: number;
  5461. upAxis?: Vector3;
  5462. upAxisSpace?: Space;
  5463. yawAxis?: Vector3;
  5464. pitchAxis?: Vector3;
  5465. adjustYaw?: number;
  5466. adjustPitch?: number;
  5467. adjustRoll?: number;
  5468. });
  5469. /**
  5470. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5471. */
  5472. update(): void;
  5473. private _getAngleDiff;
  5474. private _getAngleBetween;
  5475. private _isAngleBetween;
  5476. }
  5477. }
  5478. declare module BABYLON {
  5479. /**
  5480. * Class used to handle skinning animations
  5481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5482. */
  5483. class Skeleton implements IAnimatable {
  5484. /** defines the skeleton name */
  5485. name: string;
  5486. /** defines the skeleton Id */
  5487. id: string;
  5488. /**
  5489. * Gets the list of child bones
  5490. */
  5491. bones: Bone[];
  5492. /**
  5493. * Gets an estimate of the dimension of the skeleton at rest
  5494. */
  5495. dimensionsAtRest: Vector3;
  5496. /**
  5497. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5498. */
  5499. needInitialSkinMatrix: boolean;
  5500. /**
  5501. * Gets the list of animations attached to this skeleton
  5502. */
  5503. animations: Array<Animation>;
  5504. private _scene;
  5505. private _isDirty;
  5506. private _transformMatrices;
  5507. private _meshesWithPoseMatrix;
  5508. private _animatables;
  5509. private _identity;
  5510. private _synchronizedWithMesh;
  5511. private _ranges;
  5512. private _lastAbsoluteTransformsUpdateId;
  5513. /**
  5514. * Specifies if the skeleton should be serialized
  5515. */
  5516. doNotSerialize: boolean;
  5517. private _animationPropertiesOverride;
  5518. /**
  5519. * Gets or sets the animation properties override
  5520. */
  5521. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5522. /**
  5523. * An observable triggered before computing the skeleton's matrices
  5524. */
  5525. onBeforeComputeObservable: Observable<Skeleton>;
  5526. /**
  5527. * Creates a new skeleton
  5528. * @param name defines the skeleton name
  5529. * @param id defines the skeleton Id
  5530. * @param scene defines the hosting scene
  5531. */
  5532. constructor(
  5533. /** defines the skeleton name */
  5534. name: string,
  5535. /** defines the skeleton Id */
  5536. id: string, scene: Scene);
  5537. /**
  5538. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5539. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5540. * @returns a Float32Array containing matrices data
  5541. */
  5542. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5543. /**
  5544. * Gets the current hosting scene
  5545. * @returns a scene object
  5546. */
  5547. getScene(): Scene;
  5548. /**
  5549. * Gets a string representing the current skeleton data
  5550. * @param fullDetails defines a boolean indicating if we want a verbose version
  5551. * @returns a string representing the current skeleton data
  5552. */
  5553. toString(fullDetails?: boolean): string;
  5554. /**
  5555. * Get bone's index searching by name
  5556. * @param name defines bone's name to search for
  5557. * @return the indice of the bone. Returns -1 if not found
  5558. */
  5559. getBoneIndexByName(name: string): number;
  5560. /**
  5561. * Creater a new animation range
  5562. * @param name defines the name of the range
  5563. * @param from defines the start key
  5564. * @param to defines the end key
  5565. */
  5566. createAnimationRange(name: string, from: number, to: number): void;
  5567. /**
  5568. * Delete a specific animation range
  5569. * @param name defines the name of the range
  5570. * @param deleteFrames defines if frames must be removed as well
  5571. */
  5572. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5573. /**
  5574. * Gets a specific animation range
  5575. * @param name defines the name of the range to look for
  5576. * @returns the requested animation range or null if not found
  5577. */
  5578. getAnimationRange(name: string): Nullable<AnimationRange>;
  5579. /**
  5580. * Gets the list of all animation ranges defined on this skeleton
  5581. * @returns an array
  5582. */
  5583. getAnimationRanges(): Nullable<AnimationRange>[];
  5584. /**
  5585. * Copy animation range from a source skeleton.
  5586. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5587. * @param source defines the source skeleton
  5588. * @param name defines the name of the range to copy
  5589. * @param rescaleAsRequired defines if rescaling must be applied if required
  5590. * @returns true if operation was successful
  5591. */
  5592. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5593. /**
  5594. * Forces the skeleton to go to rest pose
  5595. */
  5596. returnToRest(): void;
  5597. private _getHighestAnimationFrame;
  5598. /**
  5599. * Begin a specific animation range
  5600. * @param name defines the name of the range to start
  5601. * @param loop defines if looping must be turned on (false by default)
  5602. * @param speedRatio defines the speed ratio to apply (1 by default)
  5603. * @param onAnimationEnd defines a callback which will be called when animation will end
  5604. * @returns a new animatable
  5605. */
  5606. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5607. /** @hidden */
  5608. _markAsDirty(): void;
  5609. /** @hidden */
  5610. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5611. /** @hidden */
  5612. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5613. /** @hidden */
  5614. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5615. /**
  5616. * Build all resources required to render a skeleton
  5617. */
  5618. prepare(): void;
  5619. /**
  5620. * Gets the list of animatables currently running for this skeleton
  5621. * @returns an array of animatables
  5622. */
  5623. getAnimatables(): IAnimatable[];
  5624. /**
  5625. * Clone the current skeleton
  5626. * @param name defines the name of the new skeleton
  5627. * @param id defines the id of the enw skeleton
  5628. * @returns the new skeleton
  5629. */
  5630. clone(name: string, id: string): Skeleton;
  5631. /**
  5632. * Enable animation blending for this skeleton
  5633. * @param blendingSpeed defines the blending speed to apply
  5634. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5635. */
  5636. enableBlending(blendingSpeed?: number): void;
  5637. /**
  5638. * Releases all resources associated with the current skeleton
  5639. */
  5640. dispose(): void;
  5641. /**
  5642. * Serialize the skeleton in a JSON object
  5643. * @returns a JSON object
  5644. */
  5645. serialize(): any;
  5646. /**
  5647. * Creates a new skeleton from serialized data
  5648. * @param parsedSkeleton defines the serialized data
  5649. * @param scene defines the hosting scene
  5650. * @returns a new skeleton
  5651. */
  5652. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5653. /**
  5654. * Compute all node absolute transforms
  5655. * @param forceUpdate defines if computation must be done even if cache is up to date
  5656. */
  5657. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5658. /**
  5659. * Gets the root pose matrix
  5660. * @returns a matrix
  5661. */
  5662. getPoseMatrix(): Nullable<Matrix>;
  5663. /**
  5664. * Sorts bones per internal index
  5665. */
  5666. sortBones(): void;
  5667. private _sortBones;
  5668. }
  5669. }
  5670. declare module BABYLON {
  5671. class ArcRotateCamera extends TargetCamera {
  5672. alpha: number;
  5673. beta: number;
  5674. radius: number;
  5675. protected _target: Vector3;
  5676. protected _targetHost: Nullable<AbstractMesh>;
  5677. target: Vector3;
  5678. inertialAlphaOffset: number;
  5679. inertialBetaOffset: number;
  5680. inertialRadiusOffset: number;
  5681. lowerAlphaLimit: Nullable<number>;
  5682. upperAlphaLimit: Nullable<number>;
  5683. lowerBetaLimit: number;
  5684. upperBetaLimit: number;
  5685. lowerRadiusLimit: Nullable<number>;
  5686. upperRadiusLimit: Nullable<number>;
  5687. inertialPanningX: number;
  5688. inertialPanningY: number;
  5689. pinchToPanMaxDistance: number;
  5690. panningDistanceLimit: Nullable<number>;
  5691. panningOriginTarget: Vector3;
  5692. panningInertia: number;
  5693. angularSensibilityX: number;
  5694. angularSensibilityY: number;
  5695. pinchPrecision: number;
  5696. pinchDeltaPercentage: number;
  5697. panningSensibility: number;
  5698. keysUp: number[];
  5699. keysDown: number[];
  5700. keysLeft: number[];
  5701. keysRight: number[];
  5702. wheelPrecision: number;
  5703. wheelDeltaPercentage: number;
  5704. zoomOnFactor: number;
  5705. targetScreenOffset: Vector2;
  5706. allowUpsideDown: boolean;
  5707. /** @hidden */
  5708. _viewMatrix: Matrix;
  5709. /** @hidden */
  5710. _useCtrlForPanning: boolean;
  5711. /** @hidden */
  5712. _panningMouseButton: number;
  5713. inputs: ArcRotateCameraInputsManager;
  5714. /** @hidden */
  5715. _reset: () => void;
  5716. panningAxis: Vector3;
  5717. protected _localDirection: Vector3;
  5718. protected _transformedDirection: Vector3;
  5719. private _bouncingBehavior;
  5720. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5721. useBouncingBehavior: boolean;
  5722. private _framingBehavior;
  5723. readonly framingBehavior: Nullable<FramingBehavior>;
  5724. useFramingBehavior: boolean;
  5725. private _autoRotationBehavior;
  5726. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5727. useAutoRotationBehavior: boolean;
  5728. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5729. onCollide: (collidedMesh: AbstractMesh) => void;
  5730. checkCollisions: boolean;
  5731. collisionRadius: Vector3;
  5732. protected _collider: Collider;
  5733. protected _previousPosition: Vector3;
  5734. protected _collisionVelocity: Vector3;
  5735. protected _newPosition: Vector3;
  5736. protected _previousAlpha: number;
  5737. protected _previousBeta: number;
  5738. protected _previousRadius: number;
  5739. protected _collisionTriggered: boolean;
  5740. protected _targetBoundingCenter: Nullable<Vector3>;
  5741. private _computationVector;
  5742. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5743. /** @hidden */
  5744. _initCache(): void;
  5745. /** @hidden */
  5746. _updateCache(ignoreParentClass?: boolean): void;
  5747. protected _getTargetPosition(): Vector3;
  5748. /**
  5749. * Store current camera state (fov, position, etc..)
  5750. */
  5751. private _storedAlpha;
  5752. private _storedBeta;
  5753. private _storedRadius;
  5754. private _storedTarget;
  5755. storeState(): Camera;
  5756. /**
  5757. * @hidden
  5758. * Restored camera state. You must call storeState() first
  5759. */
  5760. _restoreStateValues(): boolean;
  5761. /** @hidden */
  5762. _isSynchronizedViewMatrix(): boolean;
  5763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5764. detachControl(element: HTMLElement): void;
  5765. /** @hidden */
  5766. _checkInputs(): void;
  5767. protected _checkLimits(): void;
  5768. rebuildAnglesAndRadius(): void;
  5769. setPosition(position: Vector3): void;
  5770. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5771. /** @hidden */
  5772. _getViewMatrix(): Matrix;
  5773. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5774. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5775. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5776. min: Vector3;
  5777. max: Vector3;
  5778. distance: number;
  5779. }, doNotUpdateMaxZ?: boolean): void;
  5780. /**
  5781. * @override
  5782. * Override Camera.createRigCamera
  5783. */
  5784. createRigCamera(name: string, cameraIndex: number): Camera;
  5785. /**
  5786. * @hidden
  5787. * @override
  5788. * Override Camera._updateRigCameras
  5789. */
  5790. _updateRigCameras(): void;
  5791. dispose(): void;
  5792. getClassName(): string;
  5793. }
  5794. }
  5795. declare module BABYLON {
  5796. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5797. constructor(camera: ArcRotateCamera);
  5798. addMouseWheel(): ArcRotateCameraInputsManager;
  5799. addPointers(): ArcRotateCameraInputsManager;
  5800. addKeyboard(): ArcRotateCameraInputsManager;
  5801. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5802. }
  5803. }
  5804. declare module BABYLON {
  5805. class Camera extends Node {
  5806. inputs: CameraInputsManager<Camera>;
  5807. private static _PERSPECTIVE_CAMERA;
  5808. private static _ORTHOGRAPHIC_CAMERA;
  5809. private static _FOVMODE_VERTICAL_FIXED;
  5810. private static _FOVMODE_HORIZONTAL_FIXED;
  5811. private static _RIG_MODE_NONE;
  5812. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5813. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5814. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5815. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5816. private static _RIG_MODE_VR;
  5817. private static _RIG_MODE_WEBVR;
  5818. static readonly PERSPECTIVE_CAMERA: number;
  5819. static readonly ORTHOGRAPHIC_CAMERA: number;
  5820. /**
  5821. * This is the default FOV mode for perspective cameras.
  5822. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5823. *
  5824. */
  5825. static readonly FOVMODE_VERTICAL_FIXED: number;
  5826. /**
  5827. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5828. *
  5829. */
  5830. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5831. static readonly RIG_MODE_NONE: number;
  5832. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5833. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5834. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5835. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5836. static readonly RIG_MODE_VR: number;
  5837. static readonly RIG_MODE_WEBVR: number;
  5838. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5839. static UseAlternateWebVRRendering: boolean;
  5840. position: Vector3;
  5841. /**
  5842. * The vector the camera should consider as up.
  5843. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5844. */
  5845. upVector: Vector3;
  5846. orthoLeft: Nullable<number>;
  5847. orthoRight: Nullable<number>;
  5848. orthoBottom: Nullable<number>;
  5849. orthoTop: Nullable<number>;
  5850. /**
  5851. * FOV is set in Radians. (default is 0.8)
  5852. */
  5853. fov: number;
  5854. minZ: number;
  5855. maxZ: number;
  5856. inertia: number;
  5857. mode: number;
  5858. isIntermediate: boolean;
  5859. viewport: Viewport;
  5860. /**
  5861. * Restricts the camera to viewing objects with the same layerMask.
  5862. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5863. */
  5864. layerMask: number;
  5865. /**
  5866. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5867. */
  5868. fovMode: number;
  5869. cameraRigMode: number;
  5870. interaxialDistance: number;
  5871. isStereoscopicSideBySide: boolean;
  5872. /** @hidden */
  5873. _cameraRigParams: any;
  5874. /** @hidden */
  5875. _rigCameras: Camera[];
  5876. /** @hidden */
  5877. _rigPostProcess: Nullable<PostProcess>;
  5878. protected _webvrViewMatrix: Matrix;
  5879. /** @hidden */
  5880. _skipRendering: boolean;
  5881. /** @hidden */
  5882. _alternateCamera: Camera;
  5883. customRenderTargets: RenderTargetTexture[];
  5884. onViewMatrixChangedObservable: Observable<Camera>;
  5885. onProjectionMatrixChangedObservable: Observable<Camera>;
  5886. onAfterCheckInputsObservable: Observable<Camera>;
  5887. onRestoreStateObservable: Observable<Camera>;
  5888. private _computedViewMatrix;
  5889. _projectionMatrix: Matrix;
  5890. private _doNotComputeProjectionMatrix;
  5891. private _worldMatrix;
  5892. _postProcesses: Nullable<PostProcess>[];
  5893. private _transformMatrix;
  5894. _activeMeshes: SmartArray<AbstractMesh>;
  5895. protected _globalPosition: Vector3;
  5896. private _frustumPlanes;
  5897. private _refreshFrustumPlanes;
  5898. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5899. private _storedFov;
  5900. private _stateStored;
  5901. /**
  5902. * Store current camera state (fov, position, etc..)
  5903. */
  5904. storeState(): Camera;
  5905. /**
  5906. * Restores the camera state values if it has been stored. You must call storeState() first
  5907. */
  5908. protected _restoreStateValues(): boolean;
  5909. /**
  5910. * Restored camera state. You must call storeState() first
  5911. */
  5912. restoreState(): boolean;
  5913. getClassName(): string;
  5914. /**
  5915. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5916. */
  5917. toString(fullDetails?: boolean): string;
  5918. readonly globalPosition: Vector3;
  5919. getActiveMeshes(): SmartArray<AbstractMesh>;
  5920. isActiveMesh(mesh: Mesh): boolean;
  5921. /**
  5922. * Is this camera ready to be used/rendered
  5923. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5924. * @return true if the camera is ready
  5925. */
  5926. isReady(completeCheck?: boolean): boolean;
  5927. /** @hidden */
  5928. _initCache(): void;
  5929. /** @hidden */
  5930. _updateCache(ignoreParentClass?: boolean): void;
  5931. /** @hidden */
  5932. _isSynchronized(): boolean;
  5933. /** @hidden */
  5934. _isSynchronizedViewMatrix(): boolean;
  5935. /** @hidden */
  5936. _isSynchronizedProjectionMatrix(): boolean;
  5937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5938. detachControl(element: HTMLElement): void;
  5939. update(): void;
  5940. /** @hidden */
  5941. _checkInputs(): void;
  5942. readonly rigCameras: Camera[];
  5943. readonly rigPostProcess: Nullable<PostProcess>;
  5944. /**
  5945. * Internal, gets the first post proces.
  5946. * @returns the first post process to be run on this camera.
  5947. */
  5948. _getFirstPostProcess(): Nullable<PostProcess>;
  5949. private _cascadePostProcessesToRigCams;
  5950. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5951. detachPostProcess(postProcess: PostProcess): void;
  5952. getWorldMatrix(): Matrix;
  5953. /** @hidden */
  5954. _getViewMatrix(): Matrix;
  5955. getViewMatrix(force?: boolean): Matrix;
  5956. freezeProjectionMatrix(projection?: Matrix): void;
  5957. unfreezeProjectionMatrix(): void;
  5958. getProjectionMatrix(force?: boolean): Matrix;
  5959. /**
  5960. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5961. * @returns a Matrix
  5962. */
  5963. getTransformationMatrix(): Matrix;
  5964. private updateFrustumPlanes;
  5965. isInFrustum(target: ICullable): boolean;
  5966. isCompletelyInFrustum(target: ICullable): boolean;
  5967. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5968. /**
  5969. * Releases resources associated with this node.
  5970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5972. */
  5973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5974. readonly leftCamera: Nullable<FreeCamera>;
  5975. readonly rightCamera: Nullable<FreeCamera>;
  5976. getLeftTarget(): Nullable<Vector3>;
  5977. getRightTarget(): Nullable<Vector3>;
  5978. setCameraRigMode(mode: number, rigParams: any): void;
  5979. private _getVRProjectionMatrix;
  5980. protected _updateCameraRotationMatrix(): void;
  5981. protected _updateWebVRCameraRotationMatrix(): void;
  5982. /**
  5983. * This function MUST be overwritten by the different WebVR cameras available.
  5984. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5985. */
  5986. protected _getWebVRProjectionMatrix(): Matrix;
  5987. /**
  5988. * This function MUST be overwritten by the different WebVR cameras available.
  5989. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5990. */
  5991. protected _getWebVRViewMatrix(): Matrix;
  5992. setCameraRigParameter(name: string, value: any): void;
  5993. /**
  5994. * needs to be overridden by children so sub has required properties to be copied
  5995. */
  5996. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5997. /**
  5998. * May need to be overridden by children
  5999. * @hidden
  6000. */
  6001. _updateRigCameras(): void;
  6002. /** @hidden */
  6003. _setupInputs(): void;
  6004. serialize(): any;
  6005. clone(name: string): Camera;
  6006. getDirection(localAxis: Vector3): Vector3;
  6007. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6008. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6009. computeWorldMatrix(): Matrix;
  6010. static Parse(parsedCamera: any, scene: Scene): Camera;
  6011. }
  6012. }
  6013. declare module BABYLON {
  6014. var CameraInputTypes: {};
  6015. interface ICameraInput<TCamera extends Camera> {
  6016. camera: Nullable<TCamera>;
  6017. getClassName(): string;
  6018. getSimpleName(): string;
  6019. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6020. detachControl: (element: Nullable<HTMLElement>) => void;
  6021. checkInputs?: () => void;
  6022. }
  6023. interface CameraInputsMap<TCamera extends Camera> {
  6024. [name: string]: ICameraInput<TCamera>;
  6025. [idx: number]: ICameraInput<TCamera>;
  6026. }
  6027. class CameraInputsManager<TCamera extends Camera> {
  6028. attached: CameraInputsMap<TCamera>;
  6029. attachedElement: Nullable<HTMLElement>;
  6030. noPreventDefault: boolean;
  6031. camera: TCamera;
  6032. checkInputs: () => void;
  6033. constructor(camera: TCamera);
  6034. /**
  6035. * Add an input method to a camera
  6036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6037. * @param input camera input method
  6038. */
  6039. add(input: ICameraInput<TCamera>): void;
  6040. /**
  6041. * Remove a specific input method from a camera
  6042. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6043. * @param inputToRemove camera input method
  6044. */
  6045. remove(inputToRemove: ICameraInput<TCamera>): void;
  6046. removeByType(inputType: string): void;
  6047. private _addCheckInputs;
  6048. attachInput(input: ICameraInput<TCamera>): void;
  6049. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6050. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6051. rebuildInputCheck(): void;
  6052. /**
  6053. * Remove all attached input methods from a camera
  6054. */
  6055. clear(): void;
  6056. serialize(serializedCamera: any): void;
  6057. parse(parsedCamera: any): void;
  6058. }
  6059. }
  6060. declare module BABYLON {
  6061. /**
  6062. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6063. * being tilted forward or back and left or right.
  6064. */
  6065. class DeviceOrientationCamera extends FreeCamera {
  6066. private _initialQuaternion;
  6067. private _quaternionCache;
  6068. /**
  6069. * Creates a new device orientation camera
  6070. * @param name The name of the camera
  6071. * @param position The start position camera
  6072. * @param scene The scene the camera belongs to
  6073. */
  6074. constructor(name: string, position: Vector3, scene: Scene);
  6075. /**
  6076. * Gets the current instance class name ("DeviceOrientationCamera").
  6077. * This helps avoiding instanceof at run time.
  6078. * @returns the class name
  6079. */
  6080. getClassName(): string;
  6081. /**
  6082. * @hidden
  6083. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6084. */
  6085. _checkInputs(): void;
  6086. /**
  6087. * Reset the camera to its default orientation on the specified axis only.
  6088. * @param axis The axis to reset
  6089. */
  6090. resetToCurrentRotation(axis?: Axis): void;
  6091. }
  6092. }
  6093. declare module BABYLON {
  6094. class FollowCamera extends TargetCamera {
  6095. radius: number;
  6096. rotationOffset: number;
  6097. heightOffset: number;
  6098. cameraAcceleration: number;
  6099. maxCameraSpeed: number;
  6100. lockedTarget: Nullable<AbstractMesh>;
  6101. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6102. private getRadians;
  6103. private follow;
  6104. /** @hidden */
  6105. _checkInputs(): void;
  6106. getClassName(): string;
  6107. }
  6108. class ArcFollowCamera extends TargetCamera {
  6109. alpha: number;
  6110. beta: number;
  6111. radius: number;
  6112. target: Nullable<AbstractMesh>;
  6113. private _cartesianCoordinates;
  6114. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6115. private follow;
  6116. /** @hidden */
  6117. _checkInputs(): void;
  6118. getClassName(): string;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. class FreeCamera extends TargetCamera {
  6123. ellipsoid: Vector3;
  6124. ellipsoidOffset: Vector3;
  6125. checkCollisions: boolean;
  6126. applyGravity: boolean;
  6127. inputs: FreeCameraInputsManager;
  6128. /**
  6129. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6130. * Higher values reduce sensitivity.
  6131. */
  6132. /**
  6133. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6134. * Higher values reduce sensitivity.
  6135. */
  6136. angularSensibility: number;
  6137. keysUp: number[];
  6138. keysDown: number[];
  6139. keysLeft: number[];
  6140. keysRight: number[];
  6141. onCollide: (collidedMesh: AbstractMesh) => void;
  6142. private _collider;
  6143. private _needMoveForGravity;
  6144. private _oldPosition;
  6145. private _diffPosition;
  6146. private _newPosition;
  6147. /** @hidden */
  6148. _localDirection: Vector3;
  6149. /** @hidden */
  6150. _transformedDirection: Vector3;
  6151. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6153. detachControl(element: HTMLElement): void;
  6154. private _collisionMask;
  6155. collisionMask: number;
  6156. /** @hidden */
  6157. _collideWithWorld(displacement: Vector3): void;
  6158. private _onCollisionPositionChange;
  6159. /** @hidden */
  6160. _checkInputs(): void;
  6161. /** @hidden */
  6162. _decideIfNeedsToMove(): boolean;
  6163. /** @hidden */
  6164. _updatePosition(): void;
  6165. dispose(): void;
  6166. getClassName(): string;
  6167. }
  6168. }
  6169. declare module BABYLON {
  6170. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6171. constructor(camera: FreeCamera);
  6172. addKeyboard(): FreeCameraInputsManager;
  6173. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6174. addDeviceOrientation(): FreeCameraInputsManager;
  6175. addTouch(): FreeCameraInputsManager;
  6176. addVirtualJoystick(): FreeCameraInputsManager;
  6177. }
  6178. }
  6179. declare module BABYLON {
  6180. class GamepadCamera extends UniversalCamera {
  6181. gamepadAngularSensibility: number;
  6182. gamepadMoveSensibility: number;
  6183. constructor(name: string, position: Vector3, scene: Scene);
  6184. getClassName(): string;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. class TargetCamera extends Camera {
  6189. cameraDirection: Vector3;
  6190. cameraRotation: Vector2;
  6191. rotation: Vector3;
  6192. rotationQuaternion: Quaternion;
  6193. speed: number;
  6194. noRotationConstraint: boolean;
  6195. lockedTarget: any;
  6196. /** @hidden */
  6197. _currentTarget: Vector3;
  6198. /** @hidden */
  6199. _viewMatrix: Matrix;
  6200. /** @hidden */
  6201. _camMatrix: Matrix;
  6202. /** @hidden */
  6203. _cameraTransformMatrix: Matrix;
  6204. /** @hidden */
  6205. _cameraRotationMatrix: Matrix;
  6206. private _rigCamTransformMatrix;
  6207. /** @hidden */
  6208. _referencePoint: Vector3;
  6209. /** @hidden */
  6210. _transformedReferencePoint: Vector3;
  6211. protected _globalCurrentTarget: Vector3;
  6212. protected _globalCurrentUpVector: Vector3;
  6213. /** @hidden */
  6214. _reset: () => void;
  6215. private _defaultUp;
  6216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6217. getFrontPosition(distance: number): Vector3;
  6218. /** @hidden */
  6219. _getLockedTargetPosition(): Nullable<Vector3>;
  6220. /**
  6221. * Store current camera state (fov, position, etc..)
  6222. */
  6223. private _storedPosition;
  6224. private _storedRotation;
  6225. private _storedRotationQuaternion;
  6226. storeState(): Camera;
  6227. /**
  6228. * Restored camera state. You must call storeState() first
  6229. * @returns whether it was successful or not
  6230. * @hidden
  6231. */
  6232. _restoreStateValues(): boolean;
  6233. /** @hidden */
  6234. _initCache(): void;
  6235. /** @hidden */
  6236. _updateCache(ignoreParentClass?: boolean): void;
  6237. /** @hidden */
  6238. _isSynchronizedViewMatrix(): boolean;
  6239. /** @hidden */
  6240. _computeLocalCameraSpeed(): number;
  6241. /** @hidden */
  6242. setTarget(target: Vector3): void;
  6243. /**
  6244. * Return the current target position of the camera. This value is expressed in local space.
  6245. */
  6246. getTarget(): Vector3;
  6247. /** @hidden */
  6248. _decideIfNeedsToMove(): boolean;
  6249. /** @hidden */
  6250. _updatePosition(): void;
  6251. /** @hidden */
  6252. _checkInputs(): void;
  6253. protected _updateCameraRotationMatrix(): void;
  6254. /**
  6255. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  6256. * @returns the current camera
  6257. */
  6258. private _rotateUpVectorWithCameraRotationMatrix;
  6259. private _cachedRotationZ;
  6260. /** @hidden */
  6261. _getViewMatrix(): Matrix;
  6262. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6263. /**
  6264. * @override
  6265. * Override Camera.createRigCamera
  6266. */
  6267. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6268. /**
  6269. * @hidden
  6270. * @override
  6271. * Override Camera._updateRigCameras
  6272. */
  6273. _updateRigCameras(): void;
  6274. private _getRigCamPosition;
  6275. getClassName(): string;
  6276. }
  6277. }
  6278. declare module BABYLON {
  6279. class TouchCamera extends FreeCamera {
  6280. touchAngularSensibility: number;
  6281. touchMoveSensibility: number;
  6282. constructor(name: string, position: Vector3, scene: Scene);
  6283. getClassName(): string;
  6284. /** @hidden */
  6285. _setupInputs(): void;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. class UniversalCamera extends TouchCamera {
  6290. gamepadAngularSensibility: number;
  6291. gamepadMoveSensibility: number;
  6292. constructor(name: string, position: Vector3, scene: Scene);
  6293. getClassName(): string;
  6294. }
  6295. }
  6296. declare module BABYLON {
  6297. class VirtualJoysticksCamera extends FreeCamera {
  6298. constructor(name: string, position: Vector3, scene: Scene);
  6299. getClassName(): string;
  6300. }
  6301. }
  6302. interface VRDisplay extends EventTarget {
  6303. /**
  6304. * Dictionary of capabilities describing the VRDisplay.
  6305. */
  6306. readonly capabilities: VRDisplayCapabilities;
  6307. /**
  6308. * z-depth defining the far plane of the eye view frustum
  6309. * enables mapping of values in the render target depth
  6310. * attachment to scene coordinates. Initially set to 10000.0.
  6311. */
  6312. depthFar: number;
  6313. /**
  6314. * z-depth defining the near plane of the eye view frustum
  6315. * enables mapping of values in the render target depth
  6316. * attachment to scene coordinates. Initially set to 0.01.
  6317. */
  6318. depthNear: number;
  6319. /**
  6320. * An identifier for this distinct VRDisplay. Used as an
  6321. * association point in the Gamepad API.
  6322. */
  6323. readonly displayId: number;
  6324. /**
  6325. * A display name, a user-readable name identifying it.
  6326. */
  6327. readonly displayName: string;
  6328. readonly isConnected: boolean;
  6329. readonly isPresenting: boolean;
  6330. /**
  6331. * If this VRDisplay supports room-scale experiences, the optional
  6332. * stage attribute contains details on the room-scale parameters.
  6333. */
  6334. readonly stageParameters: VRStageParameters | null;
  6335. /**
  6336. * Passing the value returned by `requestAnimationFrame` to
  6337. * `cancelAnimationFrame` will unregister the callback.
  6338. */
  6339. cancelAnimationFrame(handle: number): void;
  6340. /**
  6341. * Stops presenting to the VRDisplay.
  6342. */
  6343. exitPresent(): Promise<void>;
  6344. getEyeParameters(whichEye: string): VREyeParameters;
  6345. /**
  6346. * Populates the passed VRFrameData with the information required to render
  6347. * the current frame.
  6348. */
  6349. getFrameData(frameData: VRFrameData): boolean;
  6350. /**
  6351. * Get the layers currently being presented.
  6352. */
  6353. getLayers(): VRLayer[];
  6354. /**
  6355. * Return a VRPose containing the future predicted pose of the VRDisplay
  6356. * when the current frame will be presented. The value returned will not
  6357. * change until JavaScript has returned control to the browser.
  6358. *
  6359. * The VRPose will contain the position, orientation, velocity,
  6360. * and acceleration of each of these properties.
  6361. */
  6362. getPose(): VRPose;
  6363. /**
  6364. * Return the current instantaneous pose of the VRDisplay, with no
  6365. * prediction applied.
  6366. */
  6367. getImmediatePose(): VRPose;
  6368. /**
  6369. * The callback passed to `requestAnimationFrame` will be called
  6370. * any time a new frame should be rendered. When the VRDisplay is
  6371. * presenting the callback will be called at the native refresh
  6372. * rate of the HMD. When not presenting this function acts
  6373. * identically to how window.requestAnimationFrame acts. Content should
  6374. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6375. * asynchronously from other displays and at differing refresh rates.
  6376. */
  6377. requestAnimationFrame(callback: FrameRequestCallback): number;
  6378. /**
  6379. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6380. * Repeat calls while already presenting will update the VRLayers being displayed.
  6381. */
  6382. requestPresent(layers: VRLayer[]): Promise<void>;
  6383. /**
  6384. * Reset the pose for this display, treating its current position and
  6385. * orientation as the "origin/zero" values. VRPose.position,
  6386. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6387. * updated when calling resetPose(). This should be called in only
  6388. * sitting-space experiences.
  6389. */
  6390. resetPose(): void;
  6391. /**
  6392. * The VRLayer provided to the VRDisplay will be captured and presented
  6393. * in the HMD. Calling this function has the same effect on the source
  6394. * canvas as any other operation that uses its source image, and canvases
  6395. * created without preserveDrawingBuffer set to true will be cleared.
  6396. */
  6397. submitFrame(pose?: VRPose): void;
  6398. }
  6399. declare var VRDisplay: {
  6400. prototype: VRDisplay;
  6401. new (): VRDisplay;
  6402. };
  6403. interface VRLayer {
  6404. leftBounds?: number[] | Float32Array | null;
  6405. rightBounds?: number[] | Float32Array | null;
  6406. source?: HTMLCanvasElement | null;
  6407. }
  6408. interface VRDisplayCapabilities {
  6409. readonly canPresent: boolean;
  6410. readonly hasExternalDisplay: boolean;
  6411. readonly hasOrientation: boolean;
  6412. readonly hasPosition: boolean;
  6413. readonly maxLayers: number;
  6414. }
  6415. interface VREyeParameters {
  6416. /** @deprecated */
  6417. readonly fieldOfView: VRFieldOfView;
  6418. readonly offset: Float32Array;
  6419. readonly renderHeight: number;
  6420. readonly renderWidth: number;
  6421. }
  6422. interface VRFieldOfView {
  6423. readonly downDegrees: number;
  6424. readonly leftDegrees: number;
  6425. readonly rightDegrees: number;
  6426. readonly upDegrees: number;
  6427. }
  6428. interface VRFrameData {
  6429. readonly leftProjectionMatrix: Float32Array;
  6430. readonly leftViewMatrix: Float32Array;
  6431. readonly pose: VRPose;
  6432. readonly rightProjectionMatrix: Float32Array;
  6433. readonly rightViewMatrix: Float32Array;
  6434. readonly timestamp: number;
  6435. }
  6436. interface VRPose {
  6437. readonly angularAcceleration: Float32Array | null;
  6438. readonly angularVelocity: Float32Array | null;
  6439. readonly linearAcceleration: Float32Array | null;
  6440. readonly linearVelocity: Float32Array | null;
  6441. readonly orientation: Float32Array | null;
  6442. readonly position: Float32Array | null;
  6443. readonly timestamp: number;
  6444. }
  6445. interface VRStageParameters {
  6446. sittingToStandingTransform?: Float32Array;
  6447. sizeX?: number;
  6448. sizeY?: number;
  6449. }
  6450. interface Navigator {
  6451. getVRDisplays(): Promise<VRDisplay[]>;
  6452. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6453. }
  6454. interface Window {
  6455. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6456. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6457. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6458. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6459. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6460. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6461. }
  6462. interface Gamepad {
  6463. readonly displayId: number;
  6464. }
  6465. declare module BABYLON {
  6466. class Collider {
  6467. /** Define if a collision was found */
  6468. collisionFound: boolean;
  6469. /**
  6470. * Define last intersection point in local space
  6471. */
  6472. intersectionPoint: Vector3;
  6473. /**
  6474. * Define last collided mesh
  6475. */
  6476. collidedMesh: Nullable<AbstractMesh>;
  6477. private _collisionPoint;
  6478. private _planeIntersectionPoint;
  6479. private _tempVector;
  6480. private _tempVector2;
  6481. private _tempVector3;
  6482. private _tempVector4;
  6483. private _edge;
  6484. private _baseToVertex;
  6485. private _destinationPoint;
  6486. private _slidePlaneNormal;
  6487. private _displacementVector;
  6488. /** @hidden */
  6489. _radius: Vector3;
  6490. /** @hidden */
  6491. _retry: number;
  6492. private _velocity;
  6493. private _basePoint;
  6494. private _epsilon;
  6495. /** @hidden */
  6496. _velocityWorldLength: number;
  6497. /** @hidden */
  6498. _basePointWorld: Vector3;
  6499. private _velocityWorld;
  6500. private _normalizedVelocity;
  6501. /** @hidden */
  6502. _initialVelocity: Vector3;
  6503. /** @hidden */
  6504. _initialPosition: Vector3;
  6505. private _nearestDistance;
  6506. private _collisionMask;
  6507. collisionMask: number;
  6508. /**
  6509. * Gets the plane normal used to compute the sliding response (in local space)
  6510. */
  6511. readonly slidePlaneNormal: Vector3;
  6512. /** @hidden */
  6513. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6514. /** @hidden */
  6515. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6516. /** @hidden */
  6517. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6518. /** @hidden */
  6519. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6520. /** @hidden */
  6521. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6522. /** @hidden */
  6523. _getResponse(pos: Vector3, vel: Vector3): void;
  6524. }
  6525. }
  6526. declare module BABYLON {
  6527. var CollisionWorker: string;
  6528. interface ICollisionCoordinator {
  6529. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6530. init(scene: Scene): void;
  6531. destroy(): void;
  6532. onMeshAdded(mesh: AbstractMesh): void;
  6533. onMeshUpdated(mesh: AbstractMesh): void;
  6534. onMeshRemoved(mesh: AbstractMesh): void;
  6535. onGeometryAdded(geometry: Geometry): void;
  6536. onGeometryUpdated(geometry: Geometry): void;
  6537. onGeometryDeleted(geometry: Geometry): void;
  6538. }
  6539. interface SerializedMesh {
  6540. id: string;
  6541. name: string;
  6542. uniqueId: number;
  6543. geometryId: Nullable<string>;
  6544. sphereCenter: Array<number>;
  6545. sphereRadius: number;
  6546. boxMinimum: Array<number>;
  6547. boxMaximum: Array<number>;
  6548. worldMatrixFromCache: any;
  6549. subMeshes: Array<SerializedSubMesh>;
  6550. checkCollisions: boolean;
  6551. }
  6552. interface SerializedSubMesh {
  6553. position: number;
  6554. verticesStart: number;
  6555. verticesCount: number;
  6556. indexStart: number;
  6557. indexCount: number;
  6558. hasMaterial: boolean;
  6559. sphereCenter: Array<number>;
  6560. sphereRadius: number;
  6561. boxMinimum: Array<number>;
  6562. boxMaximum: Array<number>;
  6563. }
  6564. /**
  6565. * Interface describing the value associated with a geometry
  6566. */
  6567. interface SerializedGeometry {
  6568. /**
  6569. * Defines the unique ID of the geometry
  6570. */
  6571. id: string;
  6572. /**
  6573. * Defines the array containing the positions
  6574. */
  6575. positions: Float32Array;
  6576. /**
  6577. * Defines the array containing the indices
  6578. */
  6579. indices: Uint32Array;
  6580. /**
  6581. * Defines the array containing the normals
  6582. */
  6583. normals: Float32Array;
  6584. }
  6585. interface BabylonMessage {
  6586. taskType: WorkerTaskType;
  6587. payload: InitPayload | CollidePayload | UpdatePayload;
  6588. }
  6589. interface SerializedColliderToWorker {
  6590. position: Array<number>;
  6591. velocity: Array<number>;
  6592. radius: Array<number>;
  6593. }
  6594. /** Defines supported task for worker process */
  6595. enum WorkerTaskType {
  6596. /** Initialization */
  6597. INIT = 0,
  6598. /** Update of geometry */
  6599. UPDATE = 1,
  6600. /** Evaluate collision */
  6601. COLLIDE = 2
  6602. }
  6603. interface WorkerReply {
  6604. error: WorkerReplyType;
  6605. taskType: WorkerTaskType;
  6606. payload?: any;
  6607. }
  6608. interface CollisionReplyPayload {
  6609. newPosition: Array<number>;
  6610. collisionId: number;
  6611. collidedMeshUniqueId: number;
  6612. }
  6613. interface InitPayload {
  6614. }
  6615. interface CollidePayload {
  6616. collisionId: number;
  6617. collider: SerializedColliderToWorker;
  6618. maximumRetry: number;
  6619. excludedMeshUniqueId: Nullable<number>;
  6620. }
  6621. interface UpdatePayload {
  6622. updatedMeshes: {
  6623. [n: number]: SerializedMesh;
  6624. };
  6625. updatedGeometries: {
  6626. [s: string]: SerializedGeometry;
  6627. };
  6628. removedMeshes: Array<number>;
  6629. removedGeometries: Array<string>;
  6630. }
  6631. /** Defines kind of replies returned by worker */
  6632. enum WorkerReplyType {
  6633. /** Success */
  6634. SUCCESS = 0,
  6635. /** Unkown error */
  6636. UNKNOWN_ERROR = 1
  6637. }
  6638. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6639. private _scene;
  6640. private _scaledPosition;
  6641. private _scaledVelocity;
  6642. private _collisionsCallbackArray;
  6643. private _init;
  6644. private _runningUpdated;
  6645. private _worker;
  6646. private _addUpdateMeshesList;
  6647. private _addUpdateGeometriesList;
  6648. private _toRemoveMeshesArray;
  6649. private _toRemoveGeometryArray;
  6650. constructor();
  6651. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6652. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6653. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6654. init(scene: Scene): void;
  6655. destroy(): void;
  6656. onMeshAdded(mesh: AbstractMesh): void;
  6657. onMeshUpdated: (transformNode: TransformNode) => void;
  6658. onMeshRemoved(mesh: AbstractMesh): void;
  6659. onGeometryAdded(geometry: Geometry): void;
  6660. onGeometryUpdated: (geometry: Geometry) => void;
  6661. onGeometryDeleted(geometry: Geometry): void;
  6662. private _afterRender;
  6663. private _onMessageFromWorker;
  6664. }
  6665. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6666. private _scene;
  6667. private _scaledPosition;
  6668. private _scaledVelocity;
  6669. private _finalPosition;
  6670. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6671. init(scene: Scene): void;
  6672. destroy(): void;
  6673. onMeshAdded(mesh: AbstractMesh): void;
  6674. onMeshUpdated(mesh: AbstractMesh): void;
  6675. onMeshRemoved(mesh: AbstractMesh): void;
  6676. onGeometryAdded(geometry: Geometry): void;
  6677. onGeometryUpdated(geometry: Geometry): void;
  6678. onGeometryDeleted(geometry: Geometry): void;
  6679. private _collideWithWorld;
  6680. }
  6681. }
  6682. declare function importScripts(...urls: string[]): void;
  6683. declare const safePostMessage: any;
  6684. declare module BABYLON {
  6685. var WorkerIncluded: boolean;
  6686. class CollisionCache {
  6687. private _meshes;
  6688. private _geometries;
  6689. getMeshes(): {
  6690. [n: number]: SerializedMesh;
  6691. };
  6692. getGeometries(): {
  6693. [s: number]: SerializedGeometry;
  6694. };
  6695. getMesh(id: any): SerializedMesh;
  6696. addMesh(mesh: SerializedMesh): void;
  6697. removeMesh(uniqueId: number): void;
  6698. getGeometry(id: string): SerializedGeometry;
  6699. addGeometry(geometry: SerializedGeometry): void;
  6700. removeGeometry(id: string): void;
  6701. }
  6702. class CollideWorker {
  6703. collider: Collider;
  6704. private _collisionCache;
  6705. private finalPosition;
  6706. private collisionsScalingMatrix;
  6707. private collisionTranformationMatrix;
  6708. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6709. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6710. private checkCollision;
  6711. private processCollisionsForSubMeshes;
  6712. private collideForSubMesh;
  6713. private checkSubmeshCollision;
  6714. }
  6715. interface ICollisionDetector {
  6716. onInit(payload: InitPayload): void;
  6717. onUpdate(payload: UpdatePayload): void;
  6718. onCollision(payload: CollidePayload): void;
  6719. }
  6720. class CollisionDetectorTransferable implements ICollisionDetector {
  6721. private _collisionCache;
  6722. onInit(payload: InitPayload): void;
  6723. onUpdate(payload: UpdatePayload): void;
  6724. onCollision(payload: CollidePayload): void;
  6725. }
  6726. }
  6727. declare module BABYLON {
  6728. class IntersectionInfo {
  6729. bu: Nullable<number>;
  6730. bv: Nullable<number>;
  6731. distance: number;
  6732. faceId: number;
  6733. subMeshId: number;
  6734. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6735. }
  6736. /**
  6737. * Information about the result of picking within a scene
  6738. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6739. */
  6740. class PickingInfo {
  6741. /**
  6742. * If the pick collided with an object
  6743. */
  6744. hit: boolean;
  6745. /**
  6746. * Distance away where the pick collided
  6747. */
  6748. distance: number;
  6749. /**
  6750. * The location of pick collision
  6751. */
  6752. pickedPoint: Nullable<Vector3>;
  6753. /**
  6754. * The mesh corresponding the the pick collision
  6755. */
  6756. pickedMesh: Nullable<AbstractMesh>;
  6757. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6758. bu: number;
  6759. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6760. bv: number;
  6761. /** The id of the face on the mesh that was picked */
  6762. faceId: number;
  6763. /** Id of the the submesh that was picked */
  6764. subMeshId: number;
  6765. /** If a sprite was picked, this will be the sprite the pick collided with */
  6766. pickedSprite: Nullable<Sprite>;
  6767. /**
  6768. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6769. */
  6770. originMesh: Nullable<AbstractMesh>;
  6771. /**
  6772. * The ray that was used to perform the picking.
  6773. */
  6774. ray: Nullable<Ray>;
  6775. /**
  6776. * Gets the normal correspodning to the face the pick collided with
  6777. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6778. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6779. * @returns The normal correspodning to the face the pick collided with
  6780. */
  6781. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6782. /**
  6783. * Gets the texture coordinates of where the pick occured
  6784. * @returns the vector containing the coordnates of the texture
  6785. */
  6786. getTextureCoordinates(): Nullable<Vector2>;
  6787. }
  6788. }
  6789. declare module BABYLON {
  6790. class BoundingBox implements ICullable {
  6791. vectors: Vector3[];
  6792. center: Vector3;
  6793. centerWorld: Vector3;
  6794. extendSize: Vector3;
  6795. extendSizeWorld: Vector3;
  6796. directions: Vector3[];
  6797. vectorsWorld: Vector3[];
  6798. minimumWorld: Vector3;
  6799. maximumWorld: Vector3;
  6800. minimum: Vector3;
  6801. maximum: Vector3;
  6802. private _worldMatrix;
  6803. /**
  6804. * Creates a new bounding box
  6805. * @param min defines the minimum vector (in local space)
  6806. * @param max defines the maximum vector (in local space)
  6807. */
  6808. constructor(min: Vector3, max: Vector3);
  6809. /**
  6810. * Recreates the entire bounding box from scratch
  6811. * @param min defines the new minimum vector (in local space)
  6812. * @param max defines the new maximum vector (in local space)
  6813. */
  6814. reConstruct(min: Vector3, max: Vector3): void;
  6815. /**
  6816. * Scale the current bounding box by applying a scale factor
  6817. * @param factor defines the scale factor to apply
  6818. * @returns the current bounding box
  6819. */
  6820. scale(factor: number): BoundingBox;
  6821. getWorldMatrix(): Matrix;
  6822. setWorldMatrix(matrix: Matrix): BoundingBox;
  6823. /** @hidden */
  6824. _update(world: Matrix): void;
  6825. isInFrustum(frustumPlanes: Plane[]): boolean;
  6826. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6827. intersectsPoint(point: Vector3): boolean;
  6828. intersectsSphere(sphere: BoundingSphere): boolean;
  6829. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6830. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6831. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6832. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6833. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6834. }
  6835. }
  6836. declare module BABYLON {
  6837. interface ICullable {
  6838. isInFrustum(frustumPlanes: Plane[]): boolean;
  6839. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6840. }
  6841. class BoundingInfo implements ICullable {
  6842. minimum: Vector3;
  6843. maximum: Vector3;
  6844. boundingBox: BoundingBox;
  6845. boundingSphere: BoundingSphere;
  6846. private _isLocked;
  6847. constructor(minimum: Vector3, maximum: Vector3);
  6848. isLocked: boolean;
  6849. update(world: Matrix): void;
  6850. /**
  6851. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6852. * @param center New center of the bounding info
  6853. * @param extend New extend of the bounding info
  6854. */
  6855. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6856. /**
  6857. * Scale the current bounding info by applying a scale factor
  6858. * @param factor defines the scale factor to apply
  6859. * @returns the current bounding info
  6860. */
  6861. scale(factor: number): BoundingInfo;
  6862. /**
  6863. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6864. * @param frustumPlanes defines the frustum to test
  6865. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6866. * @returns true if the bounding info is in the frustum planes
  6867. */
  6868. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6869. /**
  6870. * Gets the world distance between the min and max points of the bounding box
  6871. */
  6872. readonly diagonalLength: number;
  6873. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6874. /** @hidden */
  6875. _checkCollision(collider: Collider): boolean;
  6876. intersectsPoint(point: Vector3): boolean;
  6877. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6878. }
  6879. }
  6880. declare module BABYLON {
  6881. class BoundingSphere {
  6882. center: Vector3;
  6883. radius: number;
  6884. centerWorld: Vector3;
  6885. radiusWorld: number;
  6886. minimum: Vector3;
  6887. maximum: Vector3;
  6888. private _tempRadiusVector;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. */
  6894. constructor(min: Vector3, max: Vector3);
  6895. /**
  6896. * Recreates the entire bounding sphere from scratch
  6897. * @param min defines the new minimum vector (in local space)
  6898. * @param max defines the new maximum vector (in local space)
  6899. */
  6900. reConstruct(min: Vector3, max: Vector3): void;
  6901. /**
  6902. * Scale the current bounding sphere by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingSphere;
  6907. /** @hidden */
  6908. _update(world: Matrix): void;
  6909. isInFrustum(frustumPlanes: Plane[]): boolean;
  6910. intersectsPoint(point: Vector3): boolean;
  6911. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6912. }
  6913. }
  6914. declare module BABYLON {
  6915. class Ray {
  6916. origin: Vector3;
  6917. direction: Vector3;
  6918. length: number;
  6919. private _edge1;
  6920. private _edge2;
  6921. private _pvec;
  6922. private _tvec;
  6923. private _qvec;
  6924. private _tmpRay;
  6925. constructor(origin: Vector3, direction: Vector3, length?: number);
  6926. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6927. intersectsBox(box: BoundingBox): boolean;
  6928. intersectsSphere(sphere: BoundingSphere): boolean;
  6929. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6930. intersectsPlane(plane: Plane): Nullable<number>;
  6931. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6932. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6933. private _comparePickingInfo;
  6934. private static smallnum;
  6935. private static rayl;
  6936. /**
  6937. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6938. * @param sega the first point of the segment to test the intersection against
  6939. * @param segb the second point of the segment to test the intersection against
  6940. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6941. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6942. */
  6943. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6944. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6945. static Zero(): Ray;
  6946. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6947. /**
  6948. * 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
  6949. * transformed to the given world matrix.
  6950. * @param origin The origin point
  6951. * @param end The end point
  6952. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6953. */
  6954. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6955. static Transform(ray: Ray, matrix: Matrix): Ray;
  6956. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6957. }
  6958. }
  6959. /**
  6960. * Module Debug contains the (visual) components to debug a scene correctly
  6961. */
  6962. declare module BABYLON.Debug {
  6963. /**
  6964. * The Axes viewer will show 3 axes in a specific point in space
  6965. */
  6966. class AxesViewer {
  6967. private _xline;
  6968. private _yline;
  6969. private _zline;
  6970. private _xmesh;
  6971. private _ymesh;
  6972. private _zmesh;
  6973. /**
  6974. * Gets the hosting scene
  6975. */
  6976. scene: Nullable<Scene>;
  6977. /**
  6978. * Gets or sets a number used to scale line length
  6979. */
  6980. scaleLines: number;
  6981. /**
  6982. * Creates a new AxesViewer
  6983. * @param scene defines the hosting scene
  6984. * @param scaleLines defines a number used to scale line length (1 by default)
  6985. */
  6986. constructor(scene: Scene, scaleLines?: number);
  6987. /**
  6988. * Force the viewer to update
  6989. * @param position defines the position of the viewer
  6990. * @param xaxis defines the x axis of the viewer
  6991. * @param yaxis defines the y axis of the viewer
  6992. * @param zaxis defines the z axis of the viewer
  6993. */
  6994. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6995. /** Releases resources */
  6996. dispose(): void;
  6997. }
  6998. }
  6999. declare module BABYLON.Debug {
  7000. /**
  7001. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  7002. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7003. */
  7004. class BoneAxesViewer extends AxesViewer {
  7005. /**
  7006. * Gets or sets the target mesh where to display the axes viewer
  7007. */
  7008. mesh: Nullable<Mesh>;
  7009. /**
  7010. * Gets or sets the target bone where to display the axes viewer
  7011. */
  7012. bone: Nullable<Bone>;
  7013. /** Gets current position */
  7014. pos: Vector3;
  7015. /** Gets direction of X axis */
  7016. xaxis: Vector3;
  7017. /** Gets direction of Y axis */
  7018. yaxis: Vector3;
  7019. /** Gets direction of Z axis */
  7020. zaxis: Vector3;
  7021. /**
  7022. * Creates a new BoneAxesViewer
  7023. * @param scene defines the hosting scene
  7024. * @param bone defines the target bone
  7025. * @param mesh defines the target mesh
  7026. * @param scaleLines defines a scaling factor for line length (1 by default)
  7027. */
  7028. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7029. /**
  7030. * Force the viewer to update
  7031. */
  7032. update(): void;
  7033. /** Releases resources */
  7034. dispose(): void;
  7035. }
  7036. }
  7037. declare module BABYLON {
  7038. class DebugLayer {
  7039. private _scene;
  7040. static InspectorURL: string;
  7041. private _inspector;
  7042. private BJSINSPECTOR;
  7043. onPropertyChangedObservable: Observable<{
  7044. object: any;
  7045. property: string;
  7046. value: any;
  7047. initialValue: any;
  7048. }>;
  7049. constructor(scene: Scene);
  7050. /** Creates the inspector window. */
  7051. private _createInspector;
  7052. isVisible(): boolean;
  7053. hide(): void;
  7054. /**
  7055. *
  7056. * Launch the debugLayer.
  7057. *
  7058. * initialTab:
  7059. * | Value | Tab Name |
  7060. * | --- | --- |
  7061. * | 0 | Scene |
  7062. * | 1 | Console |
  7063. * | 2 | Stats |
  7064. * | 3 | Textures |
  7065. * | 4 | Mesh |
  7066. * | 5 | Light |
  7067. * | 6 | Material |
  7068. * | 7 | GLTF |
  7069. * | 8 | GUI |
  7070. * | 9 | Physics |
  7071. * | 10 | Camera |
  7072. * | 11 | Audio |
  7073. *
  7074. */
  7075. show(config?: {
  7076. popup?: boolean;
  7077. initialTab?: number;
  7078. parentElement?: HTMLElement;
  7079. newColors?: {
  7080. backgroundColor?: string;
  7081. backgroundColorLighter?: string;
  7082. backgroundColorLighter2?: string;
  7083. backgroundColorLighter3?: string;
  7084. color?: string;
  7085. colorTop?: string;
  7086. colorBot?: string;
  7087. };
  7088. }): void;
  7089. /**
  7090. * Gets the active tab
  7091. * @return the index of the active tab or -1 if the inspector is hidden
  7092. */
  7093. getActiveTab(): number;
  7094. }
  7095. }
  7096. declare module BABYLON.Debug {
  7097. /**
  7098. * Used to show the physics impostor around the specific mesh
  7099. */
  7100. class PhysicsViewer {
  7101. /** @hidden */
  7102. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7103. /** @hidden */
  7104. protected _meshes: Array<Nullable<AbstractMesh>>;
  7105. /** @hidden */
  7106. protected _scene: Nullable<Scene>;
  7107. /** @hidden */
  7108. protected _numMeshes: number;
  7109. /** @hidden */
  7110. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7111. private _renderFunction;
  7112. private _debugBoxMesh;
  7113. private _debugSphereMesh;
  7114. private _debugMaterial;
  7115. /**
  7116. * Creates a new PhysicsViewer
  7117. * @param scene defines the hosting scene
  7118. */
  7119. constructor(scene: Scene);
  7120. /** @hidden */
  7121. protected _updateDebugMeshes(): void;
  7122. /**
  7123. * Renders a specified physic impostor
  7124. * @param impostor defines the impostor to render
  7125. */
  7126. showImpostor(impostor: PhysicsImpostor): void;
  7127. /**
  7128. * Hides a specified physic impostor
  7129. * @param impostor defines the impostor to hide
  7130. */
  7131. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7132. private _getDebugMaterial;
  7133. private _getDebugBoxMesh;
  7134. private _getDebugSphereMesh;
  7135. private _getDebugMesh;
  7136. /** Releases all resources */
  7137. dispose(): void;
  7138. }
  7139. }
  7140. declare module BABYLON {
  7141. class RayHelper {
  7142. ray: Nullable<Ray>;
  7143. private _renderPoints;
  7144. private _renderLine;
  7145. private _renderFunction;
  7146. private _scene;
  7147. private _updateToMeshFunction;
  7148. private _attachedToMesh;
  7149. private _meshSpaceDirection;
  7150. private _meshSpaceOrigin;
  7151. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7152. constructor(ray: Ray);
  7153. show(scene: Scene, color?: Color3): void;
  7154. hide(): void;
  7155. private _render;
  7156. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7157. detachFromMesh(): void;
  7158. private _updateToMesh;
  7159. dispose(): void;
  7160. }
  7161. }
  7162. declare module BABYLON.Debug {
  7163. /**
  7164. * Class used to render a debug view of a given skeleton
  7165. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7166. */
  7167. class SkeletonViewer {
  7168. /** defines the skeleton to render */
  7169. skeleton: Skeleton;
  7170. /** defines the mesh attached to the skeleton */
  7171. mesh: AbstractMesh;
  7172. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7173. autoUpdateBonesMatrices: boolean;
  7174. /** defines the rendering group id to use with the viewer */
  7175. renderingGroupId: number;
  7176. /** Gets or sets the color used to render the skeleton */
  7177. color: Color3;
  7178. private _scene;
  7179. private _debugLines;
  7180. private _debugMesh;
  7181. private _isEnabled;
  7182. private _renderFunction;
  7183. /**
  7184. * Creates a new SkeletonViewer
  7185. * @param skeleton defines the skeleton to render
  7186. * @param mesh defines the mesh attached to the skeleton
  7187. * @param scene defines the hosting scene
  7188. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7189. * @param renderingGroupId defines the rendering group id to use with the viewer
  7190. */
  7191. constructor(
  7192. /** defines the skeleton to render */
  7193. skeleton: Skeleton,
  7194. /** defines the mesh attached to the skeleton */
  7195. mesh: AbstractMesh, scene: Scene,
  7196. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7197. autoUpdateBonesMatrices?: boolean,
  7198. /** defines the rendering group id to use with the viewer */
  7199. renderingGroupId?: number);
  7200. /** Gets or sets a boolean indicating if the viewer is enabled */
  7201. isEnabled: boolean;
  7202. private _getBonePosition;
  7203. private _getLinesForBonesWithLength;
  7204. private _getLinesForBonesNoLength;
  7205. /** Update the viewer to sync with current skeleton state */
  7206. update(): void;
  7207. /** Release associated resources */
  7208. dispose(): void;
  7209. }
  7210. }
  7211. declare module BABYLON {
  7212. /**
  7213. * Interface for attribute information associated with buffer instanciation
  7214. */
  7215. class InstancingAttributeInfo {
  7216. /**
  7217. * Index/offset of the attribute in the vertex shader
  7218. */
  7219. index: number;
  7220. /**
  7221. * size of the attribute, 1, 2, 3 or 4
  7222. */
  7223. attributeSize: number;
  7224. /**
  7225. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7226. * default is FLOAT
  7227. */
  7228. attribyteType: number;
  7229. /**
  7230. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7231. */
  7232. normalized: boolean;
  7233. /**
  7234. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7235. */
  7236. offset: number;
  7237. /**
  7238. * Name of the GLSL attribute, for debugging purpose only
  7239. */
  7240. attributeName: string;
  7241. }
  7242. /**
  7243. * Define options used to create a render target texture
  7244. */
  7245. class RenderTargetCreationOptions {
  7246. /**
  7247. * Specifies is mipmaps must be generated
  7248. */
  7249. generateMipMaps?: boolean;
  7250. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7251. generateDepthBuffer?: boolean;
  7252. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7253. generateStencilBuffer?: boolean;
  7254. /** Defines texture type (int by default) */
  7255. type?: number;
  7256. /** Defines sampling mode (trilinear by default) */
  7257. samplingMode?: number;
  7258. /** Defines format (RGBA by default) */
  7259. format?: number;
  7260. }
  7261. /**
  7262. * Define options used to create a depth texture
  7263. */
  7264. class DepthTextureCreationOptions {
  7265. /** Specifies whether or not a stencil should be allocated in the texture */
  7266. generateStencil?: boolean;
  7267. /** Specifies whether or not bilinear filtering is enable on the texture */
  7268. bilinearFiltering?: boolean;
  7269. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7270. comparisonFunction?: number;
  7271. /** Specifies if the created texture is a cube texture */
  7272. isCube?: boolean;
  7273. }
  7274. /**
  7275. * Class used to describe the capabilities of the engine relatively to the current browser
  7276. */
  7277. class EngineCapabilities {
  7278. /** Maximum textures units per fragment shader */
  7279. maxTexturesImageUnits: number;
  7280. /** Maximum texture units per vertex shader */
  7281. maxVertexTextureImageUnits: number;
  7282. /** Maximum textures units in the entire pipeline */
  7283. maxCombinedTexturesImageUnits: number;
  7284. /** Maximum texture size */
  7285. maxTextureSize: number;
  7286. /** Maximum cube texture size */
  7287. maxCubemapTextureSize: number;
  7288. /** Maximum render texture size */
  7289. maxRenderTextureSize: number;
  7290. /** Maximum number of vertex attributes */
  7291. maxVertexAttribs: number;
  7292. /** Maximum number of varyings */
  7293. maxVaryingVectors: number;
  7294. /** Maximum number of uniforms per vertex shader */
  7295. maxVertexUniformVectors: number;
  7296. /** Maximum number of uniforms per fragment shader */
  7297. maxFragmentUniformVectors: number;
  7298. /** Defines if standard derivates (dx/dy) are supported */
  7299. standardDerivatives: boolean;
  7300. /** Defines if s3tc texture compression is supported */
  7301. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7302. /** Defines if pvrtc texture compression is supported */
  7303. pvrtc: any;
  7304. /** Defines if etc1 texture compression is supported */
  7305. etc1: any;
  7306. /** Defines if etc2 texture compression is supported */
  7307. etc2: any;
  7308. /** Defines if astc texture compression is supported */
  7309. astc: any;
  7310. /** Defines if float textures are supported */
  7311. textureFloat: boolean;
  7312. /** Defines if vertex array objects are supported */
  7313. vertexArrayObject: boolean;
  7314. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7315. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7316. /** Gets the maximum level of anisotropy supported */
  7317. maxAnisotropy: number;
  7318. /** Defines if instancing is supported */
  7319. instancedArrays: boolean;
  7320. /** Defines if 32 bits indices are supported */
  7321. uintIndices: boolean;
  7322. /** Defines if high precision shaders are supported */
  7323. highPrecisionShaderSupported: boolean;
  7324. /** Defines if depth reading in the fragment shader is supported */
  7325. fragmentDepthSupported: boolean;
  7326. /** Defines if float texture linear filtering is supported*/
  7327. textureFloatLinearFiltering: boolean;
  7328. /** Defines if rendering to float textures is supported */
  7329. textureFloatRender: boolean;
  7330. /** Defines if half float textures are supported*/
  7331. textureHalfFloat: boolean;
  7332. /** Defines if half float texture linear filtering is supported*/
  7333. textureHalfFloatLinearFiltering: boolean;
  7334. /** Defines if rendering to half float textures is supported */
  7335. textureHalfFloatRender: boolean;
  7336. /** Defines if textureLOD shader command is supported */
  7337. textureLOD: boolean;
  7338. /** Defines if draw buffers extension is supported */
  7339. drawBuffersExtension: boolean;
  7340. /** Defines if depth textures are supported */
  7341. depthTextureExtension: boolean;
  7342. /** Defines if float color buffer are supported */
  7343. colorBufferFloat: boolean;
  7344. /** Gets disjoint timer query extension (null if not supported) */
  7345. timerQuery: EXT_disjoint_timer_query;
  7346. /** Defines if timestamp can be used with timer query */
  7347. canUseTimestampForTimerQuery: boolean;
  7348. }
  7349. /** Interface defining initialization parameters for Engine class */
  7350. interface EngineOptions extends WebGLContextAttributes {
  7351. /**
  7352. * Defines if the engine should no exceed a specified device ratio
  7353. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7354. */
  7355. limitDeviceRatio?: number;
  7356. /**
  7357. * Defines if webvr should be enabled automatically
  7358. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7359. */
  7360. autoEnableWebVR?: boolean;
  7361. /**
  7362. * Defines if webgl2 should be turned off even if supported
  7363. * @see http://doc.babylonjs.com/features/webgl2
  7364. */
  7365. disableWebGL2Support?: boolean;
  7366. /**
  7367. * Defines if webaudio should be initialized as well
  7368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7369. */
  7370. audioEngine?: boolean;
  7371. /**
  7372. * Defines if animations should run using a deterministic lock step
  7373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7374. */
  7375. deterministicLockstep?: boolean;
  7376. /** Defines the maximum steps to use with deterministic lock step mode */
  7377. lockstepMaxSteps?: number;
  7378. /**
  7379. * Defines that engine should ignore context lost events
  7380. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7381. */
  7382. doNotHandleContextLost?: boolean;
  7383. }
  7384. /**
  7385. * Defines the interface used by display changed events
  7386. */
  7387. interface IDisplayChangedEventArgs {
  7388. /** Gets the vrDisplay object (if any) */
  7389. vrDisplay: Nullable<any>;
  7390. /** Gets a boolean indicating if webVR is supported */
  7391. vrSupported: boolean;
  7392. }
  7393. /**
  7394. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7395. */
  7396. class Engine {
  7397. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7398. static ExceptionList: ({
  7399. key: string;
  7400. capture: string;
  7401. captureConstraint: number;
  7402. targets: string[];
  7403. } | {
  7404. key: string;
  7405. capture: null;
  7406. captureConstraint: null;
  7407. targets: string[];
  7408. })[];
  7409. /** Gets the list of created engines */
  7410. static Instances: Engine[];
  7411. /**
  7412. * Gets the latest created engine
  7413. */
  7414. static readonly LastCreatedEngine: Nullable<Engine>;
  7415. /**
  7416. * Gets the latest created scene
  7417. */
  7418. static readonly LastCreatedScene: Nullable<Scene>;
  7419. /**
  7420. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7421. * @param flag defines which part of the materials must be marked as dirty
  7422. * @param predicate defines a predicate used to filter which materials should be affected
  7423. */
  7424. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7425. /**
  7426. * Hidden
  7427. */
  7428. static _TextureLoaders: IInternalTextureLoader[];
  7429. /** Defines that alpha blending is disabled */
  7430. static readonly ALPHA_DISABLE: number;
  7431. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7432. static readonly ALPHA_ADD: number;
  7433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7434. static readonly ALPHA_COMBINE: number;
  7435. /** Defines that alpha blending to DEST - SRC * DEST */
  7436. static readonly ALPHA_SUBTRACT: number;
  7437. /** Defines that alpha blending to SRC * DEST */
  7438. static readonly ALPHA_MULTIPLY: number;
  7439. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7440. static readonly ALPHA_MAXIMIZED: number;
  7441. /** Defines that alpha blending to SRC + DEST */
  7442. static readonly ALPHA_ONEONE: number;
  7443. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7444. static readonly ALPHA_PREMULTIPLIED: number;
  7445. /**
  7446. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7447. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7448. */
  7449. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7450. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7451. static readonly ALPHA_INTERPOLATE: number;
  7452. /**
  7453. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7454. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7455. */
  7456. static readonly ALPHA_SCREENMODE: number;
  7457. /** Defines that the ressource is not delayed*/
  7458. static readonly DELAYLOADSTATE_NONE: number;
  7459. /** Defines that the ressource was successfully delay loaded */
  7460. static readonly DELAYLOADSTATE_LOADED: number;
  7461. /** Defines that the ressource is currently delay loading */
  7462. static readonly DELAYLOADSTATE_LOADING: number;
  7463. /** Defines that the ressource is delayed and has not started loading */
  7464. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7466. static readonly NEVER: number;
  7467. /** 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 */
  7468. static readonly ALWAYS: number;
  7469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7470. static readonly LESS: number;
  7471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7472. static readonly EQUAL: number;
  7473. /** 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 */
  7474. static readonly LEQUAL: number;
  7475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7476. static readonly GREATER: number;
  7477. /** 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 */
  7478. static readonly GEQUAL: number;
  7479. /** 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 */
  7480. static readonly NOTEQUAL: number;
  7481. /** Passed to stencilOperation to specify that stencil value must be kept */
  7482. static readonly KEEP: number;
  7483. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7484. static readonly REPLACE: number;
  7485. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7486. static readonly INCR: number;
  7487. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7488. static readonly DECR: number;
  7489. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7490. static readonly INVERT: number;
  7491. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7492. static readonly INCR_WRAP: number;
  7493. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7494. static readonly DECR_WRAP: number;
  7495. /** Texture is not repeating outside of 0..1 UVs */
  7496. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7497. /** Texture is repeating outside of 0..1 UVs */
  7498. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7499. /** Texture is repeating and mirrored */
  7500. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7501. /** ALPHA */
  7502. static readonly TEXTUREFORMAT_ALPHA: number;
  7503. /** LUMINANCE */
  7504. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7505. /** LUMINANCE_ALPHA */
  7506. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7507. /** RGB */
  7508. static readonly TEXTUREFORMAT_RGB: number;
  7509. /** RGBA */
  7510. static readonly TEXTUREFORMAT_RGBA: number;
  7511. /** RED */
  7512. static readonly TEXTUREFORMAT_RED: number;
  7513. /** RED (2nd reference) */
  7514. static readonly TEXTUREFORMAT_R: number;
  7515. /** RG */
  7516. static readonly TEXTUREFORMAT_RG: number;
  7517. /** RED_INTEGER */
  7518. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7519. /** RED_INTEGER (2nd reference) */
  7520. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7521. /** RG_INTEGER */
  7522. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7523. /** RGB_INTEGER */
  7524. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7525. /** RGBA_INTEGER */
  7526. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7527. /** UNSIGNED_BYTE */
  7528. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7529. /** UNSIGNED_BYTE (2nd reference) */
  7530. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7531. /** FLOAT */
  7532. static readonly TEXTURETYPE_FLOAT: number;
  7533. /** HALF_FLOAT */
  7534. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7535. /** BYTE */
  7536. static readonly TEXTURETYPE_BYTE: number;
  7537. /** SHORT */
  7538. static readonly TEXTURETYPE_SHORT: number;
  7539. /** UNSIGNED_SHORT */
  7540. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7541. /** INT */
  7542. static readonly TEXTURETYPE_INT: number;
  7543. /** UNSIGNED_INT */
  7544. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7545. /** UNSIGNED_SHORT_4_4_4_4 */
  7546. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7547. /** UNSIGNED_SHORT_5_5_5_1 */
  7548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7549. /** UNSIGNED_SHORT_5_6_5 */
  7550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7551. /** UNSIGNED_INT_2_10_10_10_REV */
  7552. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7553. /** UNSIGNED_INT_24_8 */
  7554. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7555. /** UNSIGNED_INT_10F_11F_11F_REV */
  7556. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7557. /** UNSIGNED_INT_5_9_9_9_REV */
  7558. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7559. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7560. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7561. /** nearest is mag = nearest and min = nearest and mip = linear */
  7562. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7564. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7565. /** Trilinear is mag = linear and min = linear and mip = linear */
  7566. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7567. /** nearest is mag = nearest and min = nearest and mip = linear */
  7568. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7569. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7570. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7571. /** Trilinear is mag = linear and min = linear and mip = linear */
  7572. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7573. /** mag = nearest and min = nearest and mip = nearest */
  7574. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7575. /** mag = nearest and min = linear and mip = nearest */
  7576. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7577. /** mag = nearest and min = linear and mip = linear */
  7578. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7579. /** mag = nearest and min = linear and mip = none */
  7580. static readonly TEXTURE_NEAREST_LINEAR: number;
  7581. /** mag = nearest and min = nearest and mip = none */
  7582. static readonly TEXTURE_NEAREST_NEAREST: number;
  7583. /** mag = linear and min = nearest and mip = nearest */
  7584. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7585. /** mag = linear and min = nearest and mip = linear */
  7586. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7587. /** mag = linear and min = linear and mip = none */
  7588. static readonly TEXTURE_LINEAR_LINEAR: number;
  7589. /** mag = linear and min = nearest and mip = none */
  7590. static readonly TEXTURE_LINEAR_NEAREST: number;
  7591. /** Explicit coordinates mode */
  7592. static readonly TEXTURE_EXPLICIT_MODE: number;
  7593. /** Spherical coordinates mode */
  7594. static readonly TEXTURE_SPHERICAL_MODE: number;
  7595. /** Planar coordinates mode */
  7596. static readonly TEXTURE_PLANAR_MODE: number;
  7597. /** Cubic coordinates mode */
  7598. static readonly TEXTURE_CUBIC_MODE: number;
  7599. /** Projection coordinates mode */
  7600. static readonly TEXTURE_PROJECTION_MODE: number;
  7601. /** Skybox coordinates mode */
  7602. static readonly TEXTURE_SKYBOX_MODE: number;
  7603. /** Inverse Cubic coordinates mode */
  7604. static readonly TEXTURE_INVCUBIC_MODE: number;
  7605. /** Equirectangular coordinates mode */
  7606. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7607. /** Equirectangular Fixed coordinates mode */
  7608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7609. /** Equirectangular Fixed Mirrored coordinates mode */
  7610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7611. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7612. static readonly SCALEMODE_FLOOR: number;
  7613. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7614. static readonly SCALEMODE_NEAREST: number;
  7615. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7616. static readonly SCALEMODE_CEILING: number;
  7617. /**
  7618. * Returns the current version of the framework
  7619. */
  7620. static readonly Version: string;
  7621. /**
  7622. * Gets or sets the epsilon value used by collision engine
  7623. */
  7624. static CollisionsEpsilon: number;
  7625. /**
  7626. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7627. */
  7628. static CodeRepository: string;
  7629. /**
  7630. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7631. */
  7632. static ShadersRepository: string;
  7633. /**
  7634. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7635. */
  7636. forcePOTTextures: boolean;
  7637. /**
  7638. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7639. */
  7640. isFullscreen: boolean;
  7641. /**
  7642. * Gets a boolean indicating if the pointer is currently locked
  7643. */
  7644. isPointerLock: boolean;
  7645. /**
  7646. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7647. */
  7648. cullBackFaces: boolean;
  7649. /**
  7650. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7651. */
  7652. renderEvenInBackground: boolean;
  7653. /**
  7654. * Gets or sets a boolean indicating that cache can be kept between frames
  7655. */
  7656. preventCacheWipeBetweenFrames: boolean;
  7657. /**
  7658. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7659. **/
  7660. enableOfflineSupport: boolean;
  7661. /**
  7662. * 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)
  7663. **/
  7664. disableManifestCheck: boolean;
  7665. /**
  7666. * Gets the list of created scenes
  7667. */
  7668. scenes: Scene[];
  7669. /**
  7670. * Gets the list of created postprocesses
  7671. */
  7672. postProcesses: PostProcess[];
  7673. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7674. validateShaderPrograms: boolean;
  7675. /**
  7676. * Observable event triggered each time the rendering canvas is resized
  7677. */
  7678. onResizeObservable: Observable<Engine>;
  7679. /**
  7680. * Observable event triggered each time the canvas loses focus
  7681. */
  7682. onCanvasBlurObservable: Observable<Engine>;
  7683. /**
  7684. * Observable event triggered each time the canvas gains focus
  7685. */
  7686. onCanvasFocusObservable: Observable<Engine>;
  7687. /**
  7688. * Observable event triggered each time the canvas receives pointerout event
  7689. */
  7690. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7691. /**
  7692. * Observable event triggered before each texture is initialized
  7693. */
  7694. onBeforeTextureInitObservable: Observable<Texture>;
  7695. private _vrDisplay;
  7696. private _vrSupported;
  7697. private _oldSize;
  7698. private _oldHardwareScaleFactor;
  7699. private _vrExclusivePointerMode;
  7700. private _webVRInitPromise;
  7701. /**
  7702. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7703. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7704. */
  7705. readonly isInVRExclusivePointerMode: boolean;
  7706. /**
  7707. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7708. */
  7709. disableUniformBuffers: boolean;
  7710. /** @hidden */
  7711. _uniformBuffers: UniformBuffer[];
  7712. /**
  7713. * Gets a boolean indicating that the engine supports uniform buffers
  7714. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7715. */
  7716. readonly supportsUniformBuffers: boolean;
  7717. /**
  7718. * Observable raised when the engine begins a new frame
  7719. */
  7720. onBeginFrameObservable: Observable<Engine>;
  7721. /**
  7722. * Observable raised when the engine ends the current frame
  7723. */
  7724. onEndFrameObservable: Observable<Engine>;
  7725. /**
  7726. * Observable raised when the engine is about to compile a shader
  7727. */
  7728. onBeforeShaderCompilationObservable: Observable<Engine>;
  7729. /**
  7730. * Observable raised when the engine has jsut compiled a shader
  7731. */
  7732. onAfterShaderCompilationObservable: Observable<Engine>;
  7733. /** @hidden */
  7734. _gl: WebGLRenderingContext;
  7735. private _renderingCanvas;
  7736. private _windowIsBackground;
  7737. private _webGLVersion;
  7738. /**
  7739. * Gets a boolean indicating that only power of 2 textures are supported
  7740. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7741. */
  7742. readonly needPOTTextures: boolean;
  7743. /** @hidden */
  7744. _badOS: boolean;
  7745. /** @hidden */
  7746. _badDesktopOS: boolean;
  7747. /**
  7748. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7749. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7750. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7751. */
  7752. disableTextureBindingOptimization: boolean;
  7753. /**
  7754. * Gets the audio engine
  7755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7756. * @ignorenaming
  7757. */
  7758. static audioEngine: AudioEngine;
  7759. private _onFocus;
  7760. private _onBlur;
  7761. private _onCanvasPointerOut;
  7762. private _onCanvasBlur;
  7763. private _onCanvasFocus;
  7764. private _onFullscreenChange;
  7765. private _onPointerLockChange;
  7766. private _onVRDisplayPointerRestricted;
  7767. private _onVRDisplayPointerUnrestricted;
  7768. private _onVrDisplayConnect;
  7769. private _onVrDisplayDisconnect;
  7770. private _onVrDisplayPresentChange;
  7771. /**
  7772. * Observable signaled when VR display mode changes
  7773. */
  7774. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7775. /**
  7776. * Observable signaled when VR request present is complete
  7777. */
  7778. onVRRequestPresentComplete: Observable<boolean>;
  7779. /**
  7780. * Observable signaled when VR request present starts
  7781. */
  7782. onVRRequestPresentStart: Observable<Engine>;
  7783. private _hardwareScalingLevel;
  7784. /** @hidden */
  7785. protected _caps: EngineCapabilities;
  7786. private _pointerLockRequested;
  7787. private _isStencilEnable;
  7788. private _colorWrite;
  7789. private _loadingScreen;
  7790. /** @hidden */
  7791. _drawCalls: PerfCounter;
  7792. /** @hidden */
  7793. _textureCollisions: PerfCounter;
  7794. private _glVersion;
  7795. private _glRenderer;
  7796. private _glVendor;
  7797. private _videoTextureSupported;
  7798. private _renderingQueueLaunched;
  7799. private _activeRenderLoops;
  7800. private _deterministicLockstep;
  7801. private _lockstepMaxSteps;
  7802. /**
  7803. * Observable signaled when a context lost event is raised
  7804. */
  7805. onContextLostObservable: Observable<Engine>;
  7806. /**
  7807. * Observable signaled when a context restored event is raised
  7808. */
  7809. onContextRestoredObservable: Observable<Engine>;
  7810. private _onContextLost;
  7811. private _onContextRestored;
  7812. private _contextWasLost;
  7813. private _doNotHandleContextLost;
  7814. /**
  7815. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7817. */
  7818. doNotHandleContextLost: boolean;
  7819. private _performanceMonitor;
  7820. private _fps;
  7821. private _deltaTime;
  7822. /**
  7823. * Turn this value on if you want to pause FPS computation when in background
  7824. */
  7825. disablePerformanceMonitorInBackground: boolean;
  7826. /**
  7827. * Gets the performance monitor attached to this engine
  7828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7829. */
  7830. readonly performanceMonitor: PerformanceMonitor;
  7831. /** @hidden */
  7832. protected _depthCullingState: _DepthCullingState;
  7833. /** @hidden */
  7834. protected _stencilState: _StencilState;
  7835. /** @hidden */
  7836. protected _alphaState: _AlphaState;
  7837. /** @hidden */
  7838. protected _alphaMode: number;
  7839. protected _internalTexturesCache: InternalTexture[];
  7840. /** @hidden */
  7841. protected _activeChannel: number;
  7842. private _currentTextureChannel;
  7843. /** @hidden */
  7844. protected _boundTexturesCache: {
  7845. [key: string]: Nullable<InternalTexture>;
  7846. };
  7847. /** @hidden */
  7848. protected _currentEffect: Nullable<Effect>;
  7849. /** @hidden */
  7850. protected _currentProgram: Nullable<WebGLProgram>;
  7851. private _compiledEffects;
  7852. private _vertexAttribArraysEnabled;
  7853. /** @hidden */
  7854. protected _cachedViewport: Nullable<Viewport>;
  7855. private _cachedVertexArrayObject;
  7856. /** @hidden */
  7857. protected _cachedVertexBuffers: any;
  7858. /** @hidden */
  7859. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7860. /** @hidden */
  7861. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7862. /** @hidden */
  7863. protected _currentRenderTarget: Nullable<InternalTexture>;
  7864. private _uintIndicesCurrentlySet;
  7865. private _currentBoundBuffer;
  7866. /** @hidden */
  7867. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7868. private _currentBufferPointers;
  7869. private _currentInstanceLocations;
  7870. private _currentInstanceBuffers;
  7871. private _textureUnits;
  7872. private _firstBoundInternalTextureTracker;
  7873. private _lastBoundInternalTextureTracker;
  7874. private _workingCanvas;
  7875. private _workingContext;
  7876. private _rescalePostProcess;
  7877. private _dummyFramebuffer;
  7878. private _externalData;
  7879. private _bindedRenderFunction;
  7880. private _vaoRecordInProgress;
  7881. private _mustWipeVertexAttributes;
  7882. private _emptyTexture;
  7883. private _emptyCubeTexture;
  7884. private _emptyTexture3D;
  7885. private _frameHandler;
  7886. private _nextFreeTextureSlots;
  7887. private _maxSimultaneousTextures;
  7888. private _activeRequests;
  7889. private _texturesSupported;
  7890. private _textureFormatInUse;
  7891. /**
  7892. * Gets the list of texture formats supported
  7893. */
  7894. readonly texturesSupported: Array<string>;
  7895. /**
  7896. * Gets the list of texture formats in use
  7897. */
  7898. readonly textureFormatInUse: Nullable<string>;
  7899. /**
  7900. * Gets the current viewport
  7901. */
  7902. readonly currentViewport: Nullable<Viewport>;
  7903. /**
  7904. * Gets the default empty texture
  7905. */
  7906. readonly emptyTexture: InternalTexture;
  7907. /**
  7908. * Gets the default empty 3D texture
  7909. */
  7910. readonly emptyTexture3D: InternalTexture;
  7911. /**
  7912. * Gets the default empty cube texture
  7913. */
  7914. readonly emptyCubeTexture: InternalTexture;
  7915. /**
  7916. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7917. */
  7918. readonly premultipliedAlpha: boolean;
  7919. /**
  7920. * Creates a new engine
  7921. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  7922. * @param antialias defines enable antialiasing (default: false)
  7923. * @param options defines further options to be sent to the getContext() function
  7924. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7925. */
  7926. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7927. private _rebuildInternalTextures;
  7928. private _rebuildEffects;
  7929. private _rebuildBuffers;
  7930. private _initGLContext;
  7931. /**
  7932. * Gets version of the current webGL context
  7933. */
  7934. readonly webGLVersion: number;
  7935. /**
  7936. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7937. */
  7938. readonly isStencilEnable: boolean;
  7939. private _prepareWorkingCanvas;
  7940. /**
  7941. * Reset the texture cache to empty state
  7942. */
  7943. resetTextureCache(): void;
  7944. /**
  7945. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7947. * @returns true if engine is in deterministic lock step mode
  7948. */
  7949. isDeterministicLockStep(): boolean;
  7950. /**
  7951. * Gets the max steps when engine is running in deterministic lock step
  7952. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7953. * @returns the max steps
  7954. */
  7955. getLockstepMaxSteps(): number;
  7956. /**
  7957. * Gets an object containing information about the current webGL context
  7958. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7959. */
  7960. getGlInfo(): {
  7961. vendor: string;
  7962. renderer: string;
  7963. version: string;
  7964. };
  7965. /**
  7966. * Gets current aspect ratio
  7967. * @param camera defines the camera to use to get the aspect ratio
  7968. * @param useScreen defines if screen size must be used (or the current render target if any)
  7969. * @returns a number defining the aspect ratio
  7970. */
  7971. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7972. /**
  7973. * Gets current screen aspect ratio
  7974. * @returns a number defining the aspect ratio
  7975. */
  7976. getScreenAspectRatio(): number;
  7977. /**
  7978. * Gets the current render width
  7979. * @param useScreen defines if screen size must be used (or the current render target if any)
  7980. * @returns a number defining the current render width
  7981. */
  7982. getRenderWidth(useScreen?: boolean): number;
  7983. /**
  7984. * Gets the current render height
  7985. * @param useScreen defines if screen size must be used (or the current render target if any)
  7986. * @returns a number defining the current render height
  7987. */
  7988. getRenderHeight(useScreen?: boolean): number;
  7989. /**
  7990. * Gets the HTML canvas attached with the current webGL context
  7991. * @returns a HTML canvas
  7992. */
  7993. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7994. /**
  7995. * Gets the client rect of the HTML canvas attached with the current webGL context
  7996. * @returns a client rectanglee
  7997. */
  7998. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7999. /**
  8000. * Defines the hardware scaling level.
  8001. * By default the hardware scaling level is computed from the window device ratio.
  8002. * 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.
  8003. * @param level defines the level to use
  8004. */
  8005. setHardwareScalingLevel(level: number): void;
  8006. /**
  8007. * Gets the current hardware scaling level.
  8008. * By default the hardware scaling level is computed from the window device ratio.
  8009. * 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.
  8010. * @returns a number indicating the current hardware scaling level
  8011. */
  8012. getHardwareScalingLevel(): number;
  8013. /**
  8014. * Gets the list of loaded textures
  8015. * @returns an array containing all loaded textures
  8016. */
  8017. getLoadedTexturesCache(): InternalTexture[];
  8018. /**
  8019. * Gets the object containing all engine capabilities
  8020. * @returns the EngineCapabilities object
  8021. */
  8022. getCaps(): EngineCapabilities;
  8023. /** @hidden */
  8024. readonly drawCalls: number;
  8025. /** @hidden */
  8026. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  8027. /**
  8028. * Gets the current depth function
  8029. * @returns a number defining the depth function
  8030. */
  8031. getDepthFunction(): Nullable<number>;
  8032. /**
  8033. * Sets the current depth function
  8034. * @param depthFunc defines the function to use
  8035. */
  8036. setDepthFunction(depthFunc: number): void;
  8037. /**
  8038. * Sets the current depth function to GREATER
  8039. */
  8040. setDepthFunctionToGreater(): void;
  8041. /**
  8042. * Sets the current depth function to GEQUAL
  8043. */
  8044. setDepthFunctionToGreaterOrEqual(): void;
  8045. /**
  8046. * Sets the current depth function to LESS
  8047. */
  8048. setDepthFunctionToLess(): void;
  8049. /**
  8050. * Sets the current depth function to LEQUAL
  8051. */
  8052. setDepthFunctionToLessOrEqual(): void;
  8053. /**
  8054. * Gets a boolean indicating if stencil buffer is enabled
  8055. * @returns the current stencil buffer state
  8056. */
  8057. getStencilBuffer(): boolean;
  8058. /**
  8059. * Enable or disable the stencil buffer
  8060. * @param enable defines if the stencil buffer must be enabled or disabled
  8061. */
  8062. setStencilBuffer(enable: boolean): void;
  8063. /**
  8064. * Gets the current stencil mask
  8065. * @returns a number defining the new stencil mask to use
  8066. */
  8067. getStencilMask(): number;
  8068. /**
  8069. * Sets the current stencil mask
  8070. * @param mask defines the new stencil mask to use
  8071. */
  8072. setStencilMask(mask: number): void;
  8073. /**
  8074. * Gets the current stencil function
  8075. * @returns a number defining the stencil function to use
  8076. */
  8077. getStencilFunction(): number;
  8078. /**
  8079. * Gets the current stencil reference value
  8080. * @returns a number defining the stencil reference value to use
  8081. */
  8082. getStencilFunctionReference(): number;
  8083. /**
  8084. * Gets the current stencil mask
  8085. * @returns a number defining the stencil mask to use
  8086. */
  8087. getStencilFunctionMask(): number;
  8088. /**
  8089. * Sets the current stencil function
  8090. * @param stencilFunc defines the new stencil function to use
  8091. */
  8092. setStencilFunction(stencilFunc: number): void;
  8093. /**
  8094. * Sets the current stencil reference
  8095. * @param reference defines the new stencil reference to use
  8096. */
  8097. setStencilFunctionReference(reference: number): void;
  8098. /**
  8099. * Sets the current stencil mask
  8100. * @param mask defines the new stencil mask to use
  8101. */
  8102. setStencilFunctionMask(mask: number): void;
  8103. /**
  8104. * Gets the current stencil operation when stencil fails
  8105. * @returns a number defining stencil operation to use when stencil fails
  8106. */
  8107. getStencilOperationFail(): number;
  8108. /**
  8109. * Gets the current stencil operation when depth fails
  8110. * @returns a number defining stencil operation to use when depth fails
  8111. */
  8112. getStencilOperationDepthFail(): number;
  8113. /**
  8114. * Gets the current stencil operation when stencil passes
  8115. * @returns a number defining stencil operation to use when stencil passes
  8116. */
  8117. getStencilOperationPass(): number;
  8118. /**
  8119. * Sets the stencil operation to use when stencil fails
  8120. * @param operation defines the stencil operation to use when stencil fails
  8121. */
  8122. setStencilOperationFail(operation: number): void;
  8123. /**
  8124. * Sets the stencil operation to use when depth fails
  8125. * @param operation defines the stencil operation to use when depth fails
  8126. */
  8127. setStencilOperationDepthFail(operation: number): void;
  8128. /**
  8129. * Sets the stencil operation to use when stencil passes
  8130. * @param operation defines the stencil operation to use when stencil passes
  8131. */
  8132. setStencilOperationPass(operation: number): void;
  8133. /**
  8134. * Sets a boolean indicating if the dithering state is enabled or disabled
  8135. * @param value defines the dithering state
  8136. */
  8137. setDitheringState(value: boolean): void;
  8138. /**
  8139. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8140. * @param value defines the rasterizer state
  8141. */
  8142. setRasterizerState(value: boolean): void;
  8143. /**
  8144. * stop executing a render loop function and remove it from the execution array
  8145. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8146. */
  8147. stopRenderLoop(renderFunction?: () => void): void;
  8148. /** @hidden */
  8149. _renderLoop(): void;
  8150. /**
  8151. * Register and execute a render loop. The engine can have more than one render function
  8152. * @param renderFunction defines the function to continuously execute
  8153. */
  8154. runRenderLoop(renderFunction: () => void): void;
  8155. /**
  8156. * Toggle full screen mode
  8157. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8158. * @param options defines an option object to be sent to the requestFullscreen function
  8159. */
  8160. switchFullscreen(requestPointerLock: boolean): void;
  8161. /**
  8162. * Clear the current render buffer or the current render target (if any is set up)
  8163. * @param color defines the color to use
  8164. * @param backBuffer defines if the back buffer must be cleared
  8165. * @param depth defines if the depth buffer must be cleared
  8166. * @param stencil defines if the stencil buffer must be cleared
  8167. */
  8168. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8169. /**
  8170. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8171. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8172. * @param y defines the y-coordinate of the corner of the clear rectangle
  8173. * @param width defines the width of the clear rectangle
  8174. * @param height defines the height of the clear rectangle
  8175. * @param clearColor defines the clear color
  8176. */
  8177. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8178. private _viewportCached;
  8179. /** @hidden */
  8180. _viewport(x: number, y: number, width: number, height: number): void;
  8181. /**
  8182. * Set the WebGL's viewport
  8183. * @param viewport defines the viewport element to be used
  8184. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8185. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8186. */
  8187. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8188. /**
  8189. * Directly set the WebGL Viewport
  8190. * @param x defines the x coordinate of the viewport (in screen space)
  8191. * @param y defines the y coordinate of the viewport (in screen space)
  8192. * @param width defines the width of the viewport (in screen space)
  8193. * @param height defines the height of the viewport (in screen space)
  8194. * @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
  8195. */
  8196. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8197. /**
  8198. * Begin a new frame
  8199. */
  8200. beginFrame(): void;
  8201. /**
  8202. * Enf the current frame
  8203. */
  8204. endFrame(): void;
  8205. /**
  8206. * Resize the view according to the canvas' size
  8207. */
  8208. resize(): void;
  8209. /**
  8210. * Force a specific size of the canvas
  8211. * @param width defines the new canvas' width
  8212. * @param height defines the new canvas' height
  8213. */
  8214. setSize(width: number, height: number): void;
  8215. /**
  8216. * Gets a boolean indicating if a webVR device was detected
  8217. * @returns true if a webVR device was detected
  8218. */
  8219. isVRDevicePresent(): boolean;
  8220. /**
  8221. * Gets the current webVR device
  8222. * @returns the current webVR device (or null)
  8223. */
  8224. getVRDevice(): any;
  8225. /**
  8226. * Initializes a webVR display and starts listening to display change events
  8227. * The onVRDisplayChangedObservable will be notified upon these changes
  8228. * @returns The onVRDisplayChangedObservable
  8229. */
  8230. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8231. /**
  8232. * Initializes a webVR display and starts listening to display change events
  8233. * The onVRDisplayChangedObservable will be notified upon these changes
  8234. * @returns A promise containing a VRDisplay and if vr is supported
  8235. */
  8236. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8237. /**
  8238. * Call this function to switch to webVR mode
  8239. * Will do nothing if webVR is not supported or if there is no webVR device
  8240. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8241. */
  8242. enableVR(): void;
  8243. /**
  8244. * Call this function to leave webVR mode
  8245. * Will do nothing if webVR is not supported or if there is no webVR device
  8246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8247. */
  8248. disableVR(): void;
  8249. private _onVRFullScreenTriggered;
  8250. private _getVRDisplaysAsync;
  8251. /**
  8252. * Binds the frame buffer to the specified texture.
  8253. * @param texture The texture to render to or null for the default canvas
  8254. * @param faceIndex The face of the texture to render to in case of cube texture
  8255. * @param requiredWidth The width of the target to render to
  8256. * @param requiredHeight The height of the target to render to
  8257. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8258. * @param depthStencilTexture The depth stencil texture to use to render
  8259. * @param lodLevel defines le lod level to bind to the frame buffer
  8260. */
  8261. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8262. private bindUnboundFramebuffer;
  8263. /**
  8264. * Unbind the current render target texture from the webGL context
  8265. * @param texture defines the render target texture to unbind
  8266. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8267. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8268. */
  8269. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8270. /**
  8271. * Unbind a list of render target textures from the webGL context
  8272. * This is used only when drawBuffer extension or webGL2 are active
  8273. * @param textures defines the render target textures to unbind
  8274. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8275. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8276. */
  8277. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8278. /**
  8279. * Force the mipmap generation for the given render target texture
  8280. * @param texture defines the render target texture to use
  8281. */
  8282. generateMipMapsForCubemap(texture: InternalTexture): void;
  8283. /**
  8284. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8285. */
  8286. flushFramebuffer(): void;
  8287. /**
  8288. * Unbind the current render target and bind the default framebuffer
  8289. */
  8290. restoreDefaultFramebuffer(): void;
  8291. /**
  8292. * Create an uniform buffer
  8293. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8294. * @param elements defines the content of the uniform buffer
  8295. * @returns the webGL uniform buffer
  8296. */
  8297. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8298. /**
  8299. * Create a dynamic uniform buffer
  8300. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8301. * @param elements defines the content of the uniform buffer
  8302. * @returns the webGL uniform buffer
  8303. */
  8304. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8305. /**
  8306. * Update an existing uniform buffer
  8307. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8308. * @param uniformBuffer defines the target uniform buffer
  8309. * @param elements defines the content to update
  8310. * @param offset defines the offset in the uniform buffer where update should start
  8311. * @param count defines the size of the data to update
  8312. */
  8313. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8314. private _resetVertexBufferBinding;
  8315. /**
  8316. * Creates a vertex buffer
  8317. * @param data the data for the vertex buffer
  8318. * @returns the new WebGL static buffer
  8319. */
  8320. createVertexBuffer(data: DataArray): WebGLBuffer;
  8321. /**
  8322. * Creates a dynamic vertex buffer
  8323. * @param data the data for the dynamic vertex buffer
  8324. * @returns the new WebGL dynamic buffer
  8325. */
  8326. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8327. /**
  8328. * Update a dynamic index buffer
  8329. * @param indexBuffer defines the target index buffer
  8330. * @param indices defines the data to update
  8331. * @param offset defines the offset in the target index buffer where update should start
  8332. */
  8333. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8334. /**
  8335. * Updates a dynamic vertex buffer.
  8336. * @param vertexBuffer the vertex buffer to update
  8337. * @param data the data used to update the vertex buffer
  8338. * @param byteOffset the byte offset of the data
  8339. * @param byteLength the byte length of the data
  8340. */
  8341. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8342. private _resetIndexBufferBinding;
  8343. /**
  8344. * Creates a new index buffer
  8345. * @param indices defines the content of the index buffer
  8346. * @param updatable defines if the index buffer must be updatable
  8347. * @returns a new webGL buffer
  8348. */
  8349. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8350. /**
  8351. * Bind a webGL buffer to the webGL context
  8352. * @param buffer defines the buffer to bind
  8353. */
  8354. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8355. /**
  8356. * Bind an uniform buffer to the current webGL context
  8357. * @param buffer defines the buffer to bind
  8358. */
  8359. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8360. /**
  8361. * Bind a buffer to the current webGL context at a given location
  8362. * @param buffer defines the buffer to bind
  8363. * @param location defines the index where to bind the buffer
  8364. */
  8365. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8366. /**
  8367. * Bind a specific block at a given index in a specific shader program
  8368. * @param shaderProgram defines the shader program
  8369. * @param blockName defines the block name
  8370. * @param index defines the index where to bind the block
  8371. */
  8372. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8373. private bindIndexBuffer;
  8374. private bindBuffer;
  8375. /**
  8376. * update the bound buffer with the given data
  8377. * @param data defines the data to update
  8378. */
  8379. updateArrayBuffer(data: Float32Array): void;
  8380. private _vertexAttribPointer;
  8381. private _bindIndexBufferWithCache;
  8382. private _bindVertexBuffersAttributes;
  8383. /**
  8384. * Records a vertex array object
  8385. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8386. * @param vertexBuffers defines the list of vertex buffers to store
  8387. * @param indexBuffer defines the index buffer to store
  8388. * @param effect defines the effect to store
  8389. * @returns the new vertex array object
  8390. */
  8391. recordVertexArrayObject(vertexBuffers: {
  8392. [key: string]: VertexBuffer;
  8393. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8394. /**
  8395. * Bind a specific vertex array object
  8396. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8397. * @param vertexArrayObject defines the vertex array object to bind
  8398. * @param indexBuffer defines the index buffer to bind
  8399. */
  8400. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8401. /**
  8402. * Bind webGl buffers directly to the webGL context
  8403. * @param vertexBuffer defines the vertex buffer to bind
  8404. * @param indexBuffer defines the index buffer to bind
  8405. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8406. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8407. * @param effect defines the effect associated with the vertex buffer
  8408. */
  8409. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8410. private _unbindVertexArrayObject;
  8411. /**
  8412. * Bind a list of vertex buffers to the webGL context
  8413. * @param vertexBuffers defines the list of vertex buffers to bind
  8414. * @param indexBuffer defines the index buffer to bind
  8415. * @param effect defines the effect associated with the vertex buffers
  8416. */
  8417. bindBuffers(vertexBuffers: {
  8418. [key: string]: Nullable<VertexBuffer>;
  8419. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8420. /**
  8421. * Unbind all instance attributes
  8422. */
  8423. unbindInstanceAttributes(): void;
  8424. /**
  8425. * Release and free the memory of a vertex array object
  8426. * @param vao defines the vertex array object to delete
  8427. */
  8428. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8429. /** @hidden */
  8430. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8431. /**
  8432. * Creates a webGL buffer to use with instanciation
  8433. * @param capacity defines the size of the buffer
  8434. * @returns the webGL buffer
  8435. */
  8436. createInstancesBuffer(capacity: number): WebGLBuffer;
  8437. /**
  8438. * Delete a webGL buffer used with instanciation
  8439. * @param buffer defines the webGL buffer to delete
  8440. */
  8441. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8442. /**
  8443. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8444. * @param instancesBuffer defines the webGL buffer to update and bind
  8445. * @param data defines the data to store in the buffer
  8446. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8447. */
  8448. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8449. /**
  8450. * Apply all cached states (depth, culling, stencil and alpha)
  8451. */
  8452. applyStates(): void;
  8453. /**
  8454. * Send a draw order
  8455. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8456. * @param indexStart defines the starting index
  8457. * @param indexCount defines the number of index to draw
  8458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8459. */
  8460. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8461. /**
  8462. * Draw a list of points
  8463. * @param verticesStart defines the index of first vertex to draw
  8464. * @param verticesCount defines the count of vertices to draw
  8465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8466. */
  8467. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8468. /**
  8469. * Draw a list of unindexed primitives
  8470. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8471. * @param verticesStart defines the index of first vertex to draw
  8472. * @param verticesCount defines the count of vertices to draw
  8473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8474. */
  8475. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8476. /**
  8477. * Draw a list of indexed primitives
  8478. * @param fillMode defines the primitive to use
  8479. * @param indexStart defines the starting index
  8480. * @param indexCount defines the number of index to draw
  8481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8482. */
  8483. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8484. /**
  8485. * Draw a list of unindexed primitives
  8486. * @param fillMode defines the primitive to use
  8487. * @param verticesStart defines the index of first vertex to draw
  8488. * @param verticesCount defines the count of vertices to draw
  8489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8490. */
  8491. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8492. private _drawMode;
  8493. /** @hidden */
  8494. _releaseEffect(effect: Effect): void;
  8495. /** @hidden */
  8496. _deleteProgram(program: WebGLProgram): void;
  8497. /**
  8498. * Create a new effect (used to store vertex/fragment shaders)
  8499. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8500. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8501. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8502. * @param samplers defines an array of string used to represent textures
  8503. * @param defines defines the string containing the defines to use to compile the shaders
  8504. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8505. * @param onCompiled defines a function to call when the effect creation is successful
  8506. * @param onError defines a function to call when the effect creation has failed
  8507. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8508. * @returns the new Effect
  8509. */
  8510. 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;
  8511. private _compileShader;
  8512. private _compileRawShader;
  8513. /**
  8514. * Directly creates a webGL program
  8515. * @param vertexCode defines the vertex shader code to use
  8516. * @param fragmentCode defines the fragment shader code to use
  8517. * @param context defines the webGL context to use (if not set, the current one will be used)
  8518. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8519. * @returns the new webGL program
  8520. */
  8521. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8522. /**
  8523. * Creates a webGL program
  8524. * @param vertexCode defines the vertex shader code to use
  8525. * @param fragmentCode defines the fragment shader code to use
  8526. * @param defines defines the string containing the defines to use to compile the shaders
  8527. * @param context defines the webGL context to use (if not set, the current one will be used)
  8528. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8529. * @returns the new webGL program
  8530. */
  8531. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8532. private _createShaderProgram;
  8533. /**
  8534. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8535. * @param shaderProgram defines the webGL program to use
  8536. * @param uniformsNames defines the list of uniform names
  8537. * @returns an array of webGL uniform locations
  8538. */
  8539. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8540. /**
  8541. * Gets the lsit of active attributes for a given webGL program
  8542. * @param shaderProgram defines the webGL program to use
  8543. * @param attributesNames defines the list of attribute names to get
  8544. * @returns an array of indices indicating the offset of each attribute
  8545. */
  8546. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8547. /**
  8548. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8549. * @param effect defines the effect to activate
  8550. */
  8551. enableEffect(effect: Nullable<Effect>): void;
  8552. /**
  8553. * Set the value of an uniform to an array of int32
  8554. * @param uniform defines the webGL uniform location where to store the value
  8555. * @param array defines the array of int32 to store
  8556. */
  8557. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8558. /**
  8559. * Set the value of an uniform to an array of int32 (stored as vec2)
  8560. * @param uniform defines the webGL uniform location where to store the value
  8561. * @param array defines the array of int32 to store
  8562. */
  8563. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8564. /**
  8565. * Set the value of an uniform to an array of int32 (stored as vec3)
  8566. * @param uniform defines the webGL uniform location where to store the value
  8567. * @param array defines the array of int32 to store
  8568. */
  8569. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8570. /**
  8571. * Set the value of an uniform to an array of int32 (stored as vec4)
  8572. * @param uniform defines the webGL uniform location where to store the value
  8573. * @param array defines the array of int32 to store
  8574. */
  8575. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8576. /**
  8577. * Set the value of an uniform to an array of float32
  8578. * @param uniform defines the webGL uniform location where to store the value
  8579. * @param array defines the array of float32 to store
  8580. */
  8581. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8582. /**
  8583. * Set the value of an uniform to an array of float32 (stored as vec2)
  8584. * @param uniform defines the webGL uniform location where to store the value
  8585. * @param array defines the array of float32 to store
  8586. */
  8587. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8588. /**
  8589. * Set the value of an uniform to an array of float32 (stored as vec3)
  8590. * @param uniform defines the webGL uniform location where to store the value
  8591. * @param array defines the array of float32 to store
  8592. */
  8593. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8594. /**
  8595. * Set the value of an uniform to an array of float32 (stored as vec4)
  8596. * @param uniform defines the webGL uniform location where to store the value
  8597. * @param array defines the array of float32 to store
  8598. */
  8599. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8600. /**
  8601. * Set the value of an uniform to an array of number
  8602. * @param uniform defines the webGL uniform location where to store the value
  8603. * @param array defines the array of number to store
  8604. */
  8605. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8606. /**
  8607. * Set the value of an uniform to an array of number (stored as vec2)
  8608. * @param uniform defines the webGL uniform location where to store the value
  8609. * @param array defines the array of number to store
  8610. */
  8611. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8612. /**
  8613. * Set the value of an uniform to an array of number (stored as vec3)
  8614. * @param uniform defines the webGL uniform location where to store the value
  8615. * @param array defines the array of number to store
  8616. */
  8617. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8618. /**
  8619. * Set the value of an uniform to an array of number (stored as vec4)
  8620. * @param uniform defines the webGL uniform location where to store the value
  8621. * @param array defines the array of number to store
  8622. */
  8623. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8624. /**
  8625. * Set the value of an uniform to an array of float32 (stored as matrices)
  8626. * @param uniform defines the webGL uniform location where to store the value
  8627. * @param matrices defines the array of float32 to store
  8628. */
  8629. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8630. /**
  8631. * Set the value of an uniform to a matrix
  8632. * @param uniform defines the webGL uniform location where to store the value
  8633. * @param matrix defines the matrix to store
  8634. */
  8635. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8636. /**
  8637. * Set the value of an uniform to a matrix (3x3)
  8638. * @param uniform defines the webGL uniform location where to store the value
  8639. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8640. */
  8641. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8642. /**
  8643. * Set the value of an uniform to a matrix (2x2)
  8644. * @param uniform defines the webGL uniform location where to store the value
  8645. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8646. */
  8647. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8648. /**
  8649. * Set the value of an uniform to a number (int)
  8650. * @param uniform defines the webGL uniform location where to store the value
  8651. * @param value defines the int number to store
  8652. */
  8653. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8654. /**
  8655. * Set the value of an uniform to a number (float)
  8656. * @param uniform defines the webGL uniform location where to store the value
  8657. * @param value defines the float number to store
  8658. */
  8659. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8660. /**
  8661. * Set the value of an uniform to a vec2
  8662. * @param uniform defines the webGL uniform location where to store the value
  8663. * @param x defines the 1st component of the value
  8664. * @param y defines the 2nd component of the value
  8665. */
  8666. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8667. /**
  8668. * Set the value of an uniform to a vec3
  8669. * @param uniform defines the webGL uniform location where to store the value
  8670. * @param x defines the 1st component of the value
  8671. * @param y defines the 2nd component of the value
  8672. * @param z defines the 3rd component of the value
  8673. */
  8674. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8675. /**
  8676. * Set the value of an uniform to a boolean
  8677. * @param uniform defines the webGL uniform location where to store the value
  8678. * @param bool defines the boolean to store
  8679. */
  8680. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8681. /**
  8682. * Set the value of an uniform to a vec4
  8683. * @param uniform defines the webGL uniform location where to store the value
  8684. * @param x defines the 1st component of the value
  8685. * @param y defines the 2nd component of the value
  8686. * @param z defines the 3rd component of the value
  8687. * @param w defines the 4th component of the value
  8688. */
  8689. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8690. /**
  8691. * Set the value of an uniform to a Color3
  8692. * @param uniform defines the webGL uniform location where to store the value
  8693. * @param color3 defines the color to store
  8694. */
  8695. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8696. /**
  8697. * Set the value of an uniform to a Color3 and an alpha value
  8698. * @param uniform defines the webGL uniform location where to store the value
  8699. * @param color3 defines the color to store
  8700. * @param alpha defines the alpha component to store
  8701. */
  8702. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8703. /**
  8704. * Sets a Color4 on a uniform variable
  8705. * @param uniform defines the uniform location
  8706. * @param color4 defines the value to be set
  8707. */
  8708. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8709. /**
  8710. * Set various states to the webGL context
  8711. * @param culling defines backface culling state
  8712. * @param zOffset defines the value to apply to zOffset (0 by default)
  8713. * @param force defines if states must be applied even if cache is up to date
  8714. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8715. */
  8716. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8717. /**
  8718. * Set the z offset to apply to current rendering
  8719. * @param value defines the offset to apply
  8720. */
  8721. setZOffset(value: number): void;
  8722. /**
  8723. * Gets the current value of the zOffset
  8724. * @returns the current zOffset state
  8725. */
  8726. getZOffset(): number;
  8727. /**
  8728. * Enable or disable depth buffering
  8729. * @param enable defines the state to set
  8730. */
  8731. setDepthBuffer(enable: boolean): void;
  8732. /**
  8733. * Gets a boolean indicating if depth writing is enabled
  8734. * @returns the current depth writing state
  8735. */
  8736. getDepthWrite(): boolean;
  8737. /**
  8738. * Enable or disable depth writing
  8739. * @param enable defines the state to set
  8740. */
  8741. setDepthWrite(enable: boolean): void;
  8742. /**
  8743. * Enable or disable color writing
  8744. * @param enable defines the state to set
  8745. */
  8746. setColorWrite(enable: boolean): void;
  8747. /**
  8748. * Gets a boolean indicating if color writing is enabled
  8749. * @returns the current color writing state
  8750. */
  8751. getColorWrite(): boolean;
  8752. /**
  8753. * Sets alpha constants used by some alpha blending modes
  8754. * @param r defines the red component
  8755. * @param g defines the green component
  8756. * @param b defines the blue component
  8757. * @param a defines the alpha component
  8758. */
  8759. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8760. /**
  8761. * Sets the current alpha mode
  8762. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8763. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8765. */
  8766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8767. /**
  8768. * Gets the current alpha mode
  8769. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8770. * @returns the current alpha mode
  8771. */
  8772. getAlphaMode(): number;
  8773. /**
  8774. * Clears the list of texture accessible through engine.
  8775. * This can help preventing texture load conflict due to name collision.
  8776. */
  8777. clearInternalTexturesCache(): void;
  8778. /**
  8779. * Force the entire cache to be cleared
  8780. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8781. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8782. */
  8783. wipeCaches(bruteForce?: boolean): void;
  8784. /**
  8785. * Set the compressed texture format to use, based on the formats you have, and the formats
  8786. * supported by the hardware / browser.
  8787. *
  8788. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8789. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8790. * to API arguments needed to compressed textures. This puts the burden on the container
  8791. * generator to house the arcane code for determining these for current & future formats.
  8792. *
  8793. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8794. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8795. *
  8796. * Note: The result of this call is not taken into account when a texture is base64.
  8797. *
  8798. * @param formatsAvailable defines the list of those format families you have created
  8799. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8800. *
  8801. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8802. * @returns The extension selected.
  8803. */
  8804. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8805. private _getSamplingParameters;
  8806. private _partialLoadImg;
  8807. private _cascadeLoadImgs;
  8808. /** @hidden */
  8809. _createTexture(): WebGLTexture;
  8810. /**
  8811. * Usually called from BABYLON.Texture.ts.
  8812. * Passed information to create a WebGLTexture
  8813. * @param urlArg defines a value which contains one of the following:
  8814. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8815. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8816. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8818. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8819. * @param scene needed for loading to the correct scene
  8820. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8821. * @param onLoad optional callback to be called upon successful completion
  8822. * @param onError optional callback to be called upon failure
  8823. * @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
  8824. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8825. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8826. * @param forcedExtension defines the extension to use to pick the right loader
  8827. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8828. */
  8829. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  8830. private _rescaleTexture;
  8831. /**
  8832. * Update a raw texture
  8833. * @param texture defines the texture to update
  8834. * @param data defines the data to store in the texture
  8835. * @param format defines the format of the data
  8836. * @param invertY defines if data must be stored with Y axis inverted
  8837. * @param compression defines the compression used (null by default)
  8838. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8839. */
  8840. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8841. /**
  8842. * Creates a raw texture
  8843. * @param data defines the data to store in the texture
  8844. * @param width defines the width of the texture
  8845. * @param height defines the height of the texture
  8846. * @param format defines the format of the data
  8847. * @param generateMipMaps defines if the engine should generate the mip levels
  8848. * @param invertY defines if data must be stored with Y axis inverted
  8849. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8850. * @param compression defines the compression used (null by default)
  8851. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8852. * @returns the raw texture inside an InternalTexture
  8853. */
  8854. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8855. private _unpackFlipYCached;
  8856. /** @hidden */
  8857. _unpackFlipY(value: boolean): void;
  8858. /** @hidden */
  8859. _getUnpackAlignement(): number;
  8860. /**
  8861. * Creates a dynamic texture
  8862. * @param width defines the width of the texture
  8863. * @param height defines the height of the texture
  8864. * @param generateMipMaps defines if the engine should generate the mip levels
  8865. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8866. * @returns the dynamic texture inside an InternalTexture
  8867. */
  8868. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8869. /**
  8870. * Update the sampling mode of a given texture
  8871. * @param samplingMode defines the required sampling mode
  8872. * @param texture defines the texture to update
  8873. */
  8874. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8875. /**
  8876. * Update the content of a dynamic texture
  8877. * @param texture defines the texture to update
  8878. * @param canvas defines the canvas containing the source
  8879. * @param invertY defines if data must be stored with Y axis inverted
  8880. * @param premulAlpha defines if alpha is stored as premultiplied
  8881. * @param format defines the format of the data
  8882. */
  8883. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8884. /**
  8885. * Update a video texture
  8886. * @param texture defines the texture to update
  8887. * @param video defines the video element to use
  8888. * @param invertY defines if data must be stored with Y axis inverted
  8889. */
  8890. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8891. /**
  8892. * Updates a depth texture Comparison Mode and Function.
  8893. * If the comparison Function is equal to 0, the mode will be set to none.
  8894. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8895. * @param texture The texture to set the comparison function for
  8896. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8897. */
  8898. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8899. private _setupDepthStencilTexture;
  8900. /**
  8901. * Creates a depth stencil texture.
  8902. * This is only available in WebGL 2 or with the depth texture extension available.
  8903. * @param size The size of face edge in the texture.
  8904. * @param options The options defining the texture.
  8905. * @returns The texture
  8906. */
  8907. createDepthStencilTexture(size: number | {
  8908. width: number;
  8909. height: number;
  8910. }, options: DepthTextureCreationOptions): InternalTexture;
  8911. /**
  8912. * Creates a depth stencil texture.
  8913. * This is only available in WebGL 2 or with the depth texture extension available.
  8914. * @param size The size of face edge in the texture.
  8915. * @param options The options defining the texture.
  8916. * @returns The texture
  8917. */
  8918. private _createDepthStencilTexture;
  8919. /**
  8920. * Creates a depth stencil cube texture.
  8921. * This is only available in WebGL 2.
  8922. * @param size The size of face edge in the cube texture.
  8923. * @param options The options defining the cube texture.
  8924. * @returns The cube texture
  8925. */
  8926. private _createDepthStencilCubeTexture;
  8927. /**
  8928. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8929. * @param renderTarget The render target to set the frame buffer for
  8930. */
  8931. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8932. /**
  8933. * Creates a new render target texture
  8934. * @param size defines the size of the texture
  8935. * @param options defines the options used to create the texture
  8936. * @returns a new render target texture stored in an InternalTexture
  8937. */
  8938. createRenderTargetTexture(size: number | {
  8939. width: number;
  8940. height: number;
  8941. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8942. /**
  8943. * Create a multi render target texture
  8944. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8945. * @param size defines the size of the texture
  8946. * @param options defines the creation options
  8947. * @returns the cube texture as an InternalTexture
  8948. */
  8949. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8950. private _setupFramebufferDepthAttachments;
  8951. /**
  8952. * Updates the sample count of a render target texture
  8953. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8954. * @param texture defines the texture to update
  8955. * @param samples defines the sample count to set
  8956. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8957. */
  8958. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8959. /**
  8960. * Update the sample count for a given multiple render target texture
  8961. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8962. * @param textures defines the textures to update
  8963. * @param samples defines the sample count to set
  8964. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8965. */
  8966. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8967. /** @hidden */
  8968. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8969. /** @hidden */
  8970. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8971. /** @hidden */
  8972. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8973. /** @hidden */
  8974. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8975. /**
  8976. * Creates a new render target cube texture
  8977. * @param size defines the size of the texture
  8978. * @param options defines the options used to create the texture
  8979. * @returns a new render target cube texture stored in an InternalTexture
  8980. */
  8981. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8982. /**
  8983. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8984. * @param rootUrl defines the url where the file to load is located
  8985. * @param scene defines the current scene
  8986. * @param lodScale defines scale to apply to the mip map selection
  8987. * @param lodOffset defines offset to apply to the mip map selection
  8988. * @param onLoad defines an optional callback raised when the texture is loaded
  8989. * @param onError defines an optional callback raised if there is an issue to load the texture
  8990. * @param format defines the format of the data
  8991. * @param forcedExtension defines the extension to use to pick the right loader
  8992. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8993. * @returns the cube texture as an InternalTexture
  8994. */
  8995. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8996. /**
  8997. * Creates a cube texture
  8998. * @param rootUrl defines the url where the files to load is located
  8999. * @param scene defines the current scene
  9000. * @param files defines the list of files to load (1 per face)
  9001. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  9002. * @param onLoad defines an optional callback raised when the texture is loaded
  9003. * @param onError defines an optional callback raised if there is an issue to load the texture
  9004. * @param format defines the format of the data
  9005. * @param forcedExtension defines the extension to use to pick the right loader
  9006. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  9007. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  9008. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  9009. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  9010. * @returns the cube texture as an InternalTexture
  9011. */
  9012. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  9013. /**
  9014. * @hidden
  9015. */
  9016. _setCubeMapTextureParams(loadMipmap: boolean): void;
  9017. /**
  9018. * Update a raw cube texture
  9019. * @param texture defines the texture to udpdate
  9020. * @param data defines the data to store
  9021. * @param format defines the data format
  9022. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9023. * @param invertY defines if data must be stored with Y axis inverted
  9024. * @param compression defines the compression used (null by default)
  9025. * @param level defines which level of the texture to update
  9026. */
  9027. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  9028. /**
  9029. * Creates a new raw cube texture
  9030. * @param data defines the array of data to use to create each face
  9031. * @param size defines the size of the textures
  9032. * @param format defines the format of the data
  9033. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9034. * @param generateMipMaps defines if the engine should generate the mip levels
  9035. * @param invertY defines if data must be stored with Y axis inverted
  9036. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9037. * @param compression defines the compression used (null by default)
  9038. * @returns the cube texture as an InternalTexture
  9039. */
  9040. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  9041. /**
  9042. * Creates a new raw cube texture from a specified url
  9043. * @param url defines the url where the data is located
  9044. * @param scene defines the current scene
  9045. * @param size defines the size of the textures
  9046. * @param format defines the format of the data
  9047. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9048. * @param noMipmap defines if the engine should avoid generating the mip levels
  9049. * @param callback defines a callback used to extract texture data from loaded data
  9050. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9051. * @param onLoad defines a callback called when texture is loaded
  9052. * @param onError defines a callback called if there is an error
  9053. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9054. * @param invertY defines if data must be stored with Y axis inverted
  9055. * @returns the cube texture as an InternalTexture
  9056. */
  9057. 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;
  9058. /**
  9059. * Update a raw 3D texture
  9060. * @param texture defines the texture to update
  9061. * @param data defines the data to store
  9062. * @param format defines the data format
  9063. * @param invertY defines if data must be stored with Y axis inverted
  9064. * @param compression defines the used compression (can be null)
  9065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9066. */
  9067. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  9068. /**
  9069. * Creates a new raw 3D texture
  9070. * @param data defines the data used to create the texture
  9071. * @param width defines the width of the texture
  9072. * @param height defines the height of the texture
  9073. * @param depth defines the depth of the texture
  9074. * @param format defines the format of the texture
  9075. * @param generateMipMaps defines if the engine must generate mip levels
  9076. * @param invertY defines if data must be stored with Y axis inverted
  9077. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9078. * @param compression defines the compressed used (can be null)
  9079. * @param textureType defines the compressed used (can be null)
  9080. * @returns a new raw 3D texture (stored in an InternalTexture)
  9081. */
  9082. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  9083. private _prepareWebGLTextureContinuation;
  9084. private _prepareWebGLTexture;
  9085. private _convertRGBtoRGBATextureData;
  9086. /** @hidden */
  9087. _releaseFramebufferObjects(texture: InternalTexture): void;
  9088. /** @hidden */
  9089. _releaseTexture(texture: InternalTexture): void;
  9090. private setProgram;
  9091. private _boundUniforms;
  9092. /**
  9093. * Binds an effect to the webGL context
  9094. * @param effect defines the effect to bind
  9095. */
  9096. bindSamplers(effect: Effect): void;
  9097. private _moveBoundTextureOnTop;
  9098. private _getCorrectTextureChannel;
  9099. private _linkTrackers;
  9100. private _removeDesignatedSlot;
  9101. private _activateCurrentTexture;
  9102. /** @hidden */
  9103. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  9104. /** @hidden */
  9105. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9106. /**
  9107. * Sets a texture to the webGL context from a postprocess
  9108. * @param channel defines the channel to use
  9109. * @param postProcess defines the source postprocess
  9110. */
  9111. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9112. /**
  9113. * Binds the output of the passed in post process to the texture channel specified
  9114. * @param channel The channel the texture should be bound to
  9115. * @param postProcess The post process which's output should be bound
  9116. */
  9117. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9118. /**
  9119. * Unbind all textures from the webGL context
  9120. */
  9121. unbindAllTextures(): void;
  9122. /**
  9123. * Sets a texture to the according uniform.
  9124. * @param channel The texture channel
  9125. * @param uniform The uniform to set
  9126. * @param texture The texture to apply
  9127. */
  9128. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9129. /**
  9130. * Sets a depth stencil texture from a render target to the according uniform.
  9131. * @param channel The texture channel
  9132. * @param uniform The uniform to set
  9133. * @param texture The render target texture containing the depth stencil texture to apply
  9134. */
  9135. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9136. private _bindSamplerUniformToChannel;
  9137. private _getTextureWrapMode;
  9138. private _setTexture;
  9139. /**
  9140. * Sets an array of texture to the webGL context
  9141. * @param channel defines the channel where the texture array must be set
  9142. * @param uniform defines the associated uniform location
  9143. * @param textures defines the array of textures to bind
  9144. */
  9145. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9146. /** @hidden */
  9147. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9148. private _setTextureParameterFloat;
  9149. private _setTextureParameterInteger;
  9150. /**
  9151. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9152. * @param x defines the x coordinate of the rectangle where pixels must be read
  9153. * @param y defines the y coordinate of the rectangle where pixels must be read
  9154. * @param width defines the width of the rectangle where pixels must be read
  9155. * @param height defines the height of the rectangle where pixels must be read
  9156. * @returns a Uint8Array containing RGBA colors
  9157. */
  9158. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9159. /**
  9160. * Add an externaly attached data from its key.
  9161. * This method call will fail and return false, if such key already exists.
  9162. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9163. * @param key the unique key that identifies the data
  9164. * @param data the data object to associate to the key for this Engine instance
  9165. * @return true if no such key were already present and the data was added successfully, false otherwise
  9166. */
  9167. addExternalData<T>(key: string, data: T): boolean;
  9168. /**
  9169. * Get an externaly attached data from its key
  9170. * @param key the unique key that identifies the data
  9171. * @return the associated data, if present (can be null), or undefined if not present
  9172. */
  9173. getExternalData<T>(key: string): T;
  9174. /**
  9175. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9176. * @param key the unique key that identifies the data
  9177. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9178. * @return the associated data, can be null if the factory returned null.
  9179. */
  9180. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9181. /**
  9182. * Remove an externaly attached data from the Engine instance
  9183. * @param key the unique key that identifies the data
  9184. * @return true if the data was successfully removed, false if it doesn't exist
  9185. */
  9186. removeExternalData(key: string): boolean;
  9187. /**
  9188. * Unbind all vertex attributes from the webGL context
  9189. */
  9190. unbindAllAttributes(): void;
  9191. /**
  9192. * 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
  9193. */
  9194. releaseEffects(): void;
  9195. /**
  9196. * Dispose and release all associated resources
  9197. */
  9198. dispose(): void;
  9199. /**
  9200. * Display the loading screen
  9201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9202. */
  9203. displayLoadingUI(): void;
  9204. /**
  9205. * Hide the loading screen
  9206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9207. */
  9208. hideLoadingUI(): void;
  9209. /**
  9210. * Gets the current loading screen object
  9211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9212. */
  9213. /**
  9214. * Sets the current loading screen object
  9215. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9216. */
  9217. loadingScreen: ILoadingScreen;
  9218. /**
  9219. * Sets the current loading screen text
  9220. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9221. */
  9222. loadingUIText: string;
  9223. /**
  9224. * Sets the current loading screen background color
  9225. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9226. */
  9227. loadingUIBackgroundColor: string;
  9228. /**
  9229. * Attach a new callback raised when context lost event is fired
  9230. * @param callback defines the callback to call
  9231. */
  9232. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9233. /**
  9234. * Attach a new callback raised when context restored event is fired
  9235. * @param callback defines the callback to call
  9236. */
  9237. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9238. /**
  9239. * Gets the source code of the vertex shader associated with a specific webGL program
  9240. * @param program defines the program to use
  9241. * @returns a string containing the source code of the vertex shader associated with the program
  9242. */
  9243. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9244. /**
  9245. * Gets the source code of the fragment shader associated with a specific webGL program
  9246. * @param program defines the program to use
  9247. * @returns a string containing the source code of the fragment shader associated with the program
  9248. */
  9249. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9250. /**
  9251. * Get the current error code of the webGL context
  9252. * @returns the error code
  9253. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9254. */
  9255. getError(): number;
  9256. /**
  9257. * Gets the current framerate
  9258. * @returns a number representing the framerate
  9259. */
  9260. getFps(): number;
  9261. /**
  9262. * Gets the time spent between current and previous frame
  9263. * @returns a number representing the delta time in ms
  9264. */
  9265. getDeltaTime(): number;
  9266. private _measureFps;
  9267. /** @hidden */
  9268. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9269. private _canRenderToFloatFramebuffer;
  9270. private _canRenderToHalfFloatFramebuffer;
  9271. private _canRenderToFramebuffer;
  9272. /** @hidden */
  9273. _getWebGLTextureType(type: number): number;
  9274. private _getInternalFormat;
  9275. /** @hidden */
  9276. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9277. /** @hidden */
  9278. _getRGBAMultiSampleBufferFormat(type: number): number;
  9279. /** @hidden */
  9280. _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;
  9281. /** @hidden */
  9282. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9283. private _partialLoadFile;
  9284. private _cascadeLoadFiles;
  9285. /**
  9286. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9287. * @returns true if the engine can be created
  9288. * @ignorenaming
  9289. */
  9290. static isSupported(): boolean;
  9291. }
  9292. }
  9293. declare module BABYLON {
  9294. class NullEngineOptions {
  9295. renderWidth: number;
  9296. renderHeight: number;
  9297. textureSize: number;
  9298. deterministicLockstep: boolean;
  9299. lockstepMaxSteps: number;
  9300. }
  9301. /**
  9302. * The null engine class provides support for headless version of babylon.js.
  9303. * This can be used in server side scenario or for testing purposes
  9304. */
  9305. class NullEngine extends Engine {
  9306. private _options;
  9307. isDeterministicLockStep(): boolean;
  9308. getLockstepMaxSteps(): number;
  9309. getHardwareScalingLevel(): number;
  9310. constructor(options?: NullEngineOptions);
  9311. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9312. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9313. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9314. getRenderWidth(useScreen?: boolean): number;
  9315. getRenderHeight(useScreen?: boolean): number;
  9316. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9317. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9318. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9319. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9320. bindSamplers(effect: Effect): void;
  9321. enableEffect(effect: Effect): void;
  9322. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9323. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9324. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9325. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9326. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9327. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9328. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9329. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9330. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9331. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9332. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9333. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9334. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9335. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9336. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9337. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9338. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9339. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9340. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9341. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9342. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9343. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9344. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9345. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9346. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9347. bindBuffers(vertexBuffers: {
  9348. [key: string]: VertexBuffer;
  9349. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9350. wipeCaches(bruteForce?: boolean): void;
  9351. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9352. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9353. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9354. /** @hidden */
  9355. _createTexture(): WebGLTexture;
  9356. /** @hidden */
  9357. _releaseTexture(texture: InternalTexture): void;
  9358. 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;
  9359. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9360. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9361. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9362. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9363. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9364. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9365. /**
  9366. * @hidden
  9367. * Get the current error code of the webGL context
  9368. * @returns the error code
  9369. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9370. */
  9371. getError(): number;
  9372. /** @hidden */
  9373. _getUnpackAlignement(): number;
  9374. /** @hidden */
  9375. _unpackFlipY(value: boolean): void;
  9376. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9377. /**
  9378. * Updates a dynamic vertex buffer.
  9379. * @param vertexBuffer the vertex buffer to update
  9380. * @param data the data used to update the vertex buffer
  9381. * @param byteOffset the byte offset of the data (optional)
  9382. * @param byteLength the byte length of the data (optional)
  9383. */
  9384. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9385. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9386. /** @hidden */
  9387. _bindTexture(channel: number, texture: InternalTexture): void;
  9388. /** @hidden */
  9389. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9390. releaseEffects(): void;
  9391. displayLoadingUI(): void;
  9392. hideLoadingUI(): void;
  9393. /** @hidden */
  9394. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9395. /** @hidden */
  9396. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9397. /** @hidden */
  9398. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9399. /** @hidden */
  9400. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9401. }
  9402. }
  9403. interface WebGLRenderingContext {
  9404. readonly RASTERIZER_DISCARD: number;
  9405. readonly DEPTH_COMPONENT24: number;
  9406. readonly TEXTURE_3D: number;
  9407. readonly TEXTURE_2D_ARRAY: number;
  9408. readonly TEXTURE_COMPARE_FUNC: number;
  9409. readonly TEXTURE_COMPARE_MODE: number;
  9410. readonly COMPARE_REF_TO_TEXTURE: number;
  9411. readonly TEXTURE_WRAP_R: number;
  9412. readonly HALF_FLOAT: number;
  9413. readonly RGB8: number;
  9414. readonly RED_INTEGER: number;
  9415. readonly RG_INTEGER: number;
  9416. readonly RGB_INTEGER: number;
  9417. readonly RGBA_INTEGER: number;
  9418. readonly R8_SNORM: number;
  9419. readonly RG8_SNORM: number;
  9420. readonly RGB8_SNORM: number;
  9421. readonly RGBA8_SNORM: number;
  9422. readonly R8I: number;
  9423. readonly RG8I: number;
  9424. readonly RGB8I: number;
  9425. readonly RGBA8I: number;
  9426. readonly R8UI: number;
  9427. readonly RG8UI: number;
  9428. readonly RGB8UI: number;
  9429. readonly RGBA8UI: number;
  9430. readonly R16I: number;
  9431. readonly RG16I: number;
  9432. readonly RGB16I: number;
  9433. readonly RGBA16I: number;
  9434. readonly R16UI: number;
  9435. readonly RG16UI: number;
  9436. readonly RGB16UI: number;
  9437. readonly RGBA16UI: number;
  9438. readonly R32I: number;
  9439. readonly RG32I: number;
  9440. readonly RGB32I: number;
  9441. readonly RGBA32I: number;
  9442. readonly R32UI: number;
  9443. readonly RG32UI: number;
  9444. readonly RGB32UI: number;
  9445. readonly RGBA32UI: number;
  9446. readonly RGB10_A2UI: number;
  9447. readonly R11F_G11F_B10F: number;
  9448. readonly RGB9_E5: number;
  9449. readonly RGB10_A2: number;
  9450. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9451. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9452. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9453. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9454. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9455. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9456. 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;
  9457. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9458. readonly TRANSFORM_FEEDBACK: number;
  9459. readonly INTERLEAVED_ATTRIBS: number;
  9460. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9461. createTransformFeedback(): WebGLTransformFeedback;
  9462. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9463. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9464. beginTransformFeedback(primitiveMode: number): void;
  9465. endTransformFeedback(): void;
  9466. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9467. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9468. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9469. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9470. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9471. }
  9472. interface ImageBitmap {
  9473. readonly width: number;
  9474. readonly height: number;
  9475. close(): void;
  9476. }
  9477. interface WebGLQuery extends WebGLObject {
  9478. }
  9479. declare var WebGLQuery: {
  9480. prototype: WebGLQuery;
  9481. new (): WebGLQuery;
  9482. };
  9483. interface WebGLSampler extends WebGLObject {
  9484. }
  9485. declare var WebGLSampler: {
  9486. prototype: WebGLSampler;
  9487. new (): WebGLSampler;
  9488. };
  9489. interface WebGLSync extends WebGLObject {
  9490. }
  9491. declare var WebGLSync: {
  9492. prototype: WebGLSync;
  9493. new (): WebGLSync;
  9494. };
  9495. interface WebGLTransformFeedback extends WebGLObject {
  9496. }
  9497. declare var WebGLTransformFeedback: {
  9498. prototype: WebGLTransformFeedback;
  9499. new (): WebGLTransformFeedback;
  9500. };
  9501. interface WebGLVertexArrayObject extends WebGLObject {
  9502. }
  9503. declare var WebGLVertexArrayObject: {
  9504. prototype: WebGLVertexArrayObject;
  9505. new (): WebGLVertexArrayObject;
  9506. };
  9507. declare module BABYLON {
  9508. class KeyboardEventTypes {
  9509. static _KEYDOWN: number;
  9510. static _KEYUP: number;
  9511. static readonly KEYDOWN: number;
  9512. static readonly KEYUP: number;
  9513. }
  9514. class KeyboardInfo {
  9515. type: number;
  9516. event: KeyboardEvent;
  9517. constructor(type: number, event: KeyboardEvent);
  9518. }
  9519. /**
  9520. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9521. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9522. */
  9523. class KeyboardInfoPre extends KeyboardInfo {
  9524. constructor(type: number, event: KeyboardEvent);
  9525. skipOnPointerObservable: boolean;
  9526. }
  9527. }
  9528. declare module BABYLON {
  9529. class PointerEventTypes {
  9530. static _POINTERDOWN: number;
  9531. static _POINTERUP: number;
  9532. static _POINTERMOVE: number;
  9533. static _POINTERWHEEL: number;
  9534. static _POINTERPICK: number;
  9535. static _POINTERTAP: number;
  9536. static _POINTERDOUBLETAP: number;
  9537. static readonly POINTERDOWN: number;
  9538. static readonly POINTERUP: number;
  9539. static readonly POINTERMOVE: number;
  9540. static readonly POINTERWHEEL: number;
  9541. static readonly POINTERPICK: number;
  9542. static readonly POINTERTAP: number;
  9543. static readonly POINTERDOUBLETAP: number;
  9544. }
  9545. class PointerInfoBase {
  9546. type: number;
  9547. event: PointerEvent | MouseWheelEvent;
  9548. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9549. }
  9550. /**
  9551. * This class is used to store pointer related info for the onPrePointerObservable event.
  9552. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9553. */
  9554. class PointerInfoPre extends PointerInfoBase {
  9555. /**
  9556. * Ray from a pointer if availible (eg. 6dof controller)
  9557. */
  9558. ray: Nullable<Ray>;
  9559. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9560. localPosition: Vector2;
  9561. skipOnPointerObservable: boolean;
  9562. }
  9563. /**
  9564. * This type contains all the data related to a pointer event in Babylon.js.
  9565. * 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.
  9566. */
  9567. class PointerInfo extends PointerInfoBase {
  9568. pickInfo: Nullable<PickingInfo>;
  9569. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9570. }
  9571. }
  9572. declare module BABYLON {
  9573. class StickValues {
  9574. x: number;
  9575. y: number;
  9576. constructor(x: number, y: number);
  9577. }
  9578. interface GamepadButtonChanges {
  9579. changed: boolean;
  9580. pressChanged: boolean;
  9581. touchChanged: boolean;
  9582. valueChanged: boolean;
  9583. }
  9584. class Gamepad {
  9585. id: string;
  9586. index: number;
  9587. browserGamepad: any;
  9588. type: number;
  9589. private _leftStick;
  9590. private _rightStick;
  9591. /** @hidden */
  9592. _isConnected: boolean;
  9593. private _leftStickAxisX;
  9594. private _leftStickAxisY;
  9595. private _rightStickAxisX;
  9596. private _rightStickAxisY;
  9597. private _onleftstickchanged;
  9598. private _onrightstickchanged;
  9599. static GAMEPAD: number;
  9600. static GENERIC: number;
  9601. static XBOX: number;
  9602. static POSE_ENABLED: number;
  9603. protected _invertLeftStickY: boolean;
  9604. readonly isConnected: boolean;
  9605. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9606. onleftstickchanged(callback: (values: StickValues) => void): void;
  9607. onrightstickchanged(callback: (values: StickValues) => void): void;
  9608. leftStick: StickValues;
  9609. rightStick: StickValues;
  9610. update(): void;
  9611. dispose(): void;
  9612. }
  9613. class GenericPad extends Gamepad {
  9614. private _buttons;
  9615. private _onbuttondown;
  9616. private _onbuttonup;
  9617. onButtonDownObservable: Observable<number>;
  9618. onButtonUpObservable: Observable<number>;
  9619. onbuttondown(callback: (buttonPressed: number) => void): void;
  9620. onbuttonup(callback: (buttonReleased: number) => void): void;
  9621. constructor(id: string, index: number, browserGamepad: any);
  9622. private _setButtonValue;
  9623. update(): void;
  9624. dispose(): void;
  9625. }
  9626. }
  9627. declare module BABYLON {
  9628. class GamepadManager {
  9629. private _scene?;
  9630. private _babylonGamepads;
  9631. private _oneGamepadConnected;
  9632. /** @hidden */
  9633. _isMonitoring: boolean;
  9634. private _gamepadEventSupported;
  9635. private _gamepadSupport;
  9636. onGamepadConnectedObservable: Observable<Gamepad>;
  9637. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9638. private _onGamepadConnectedEvent;
  9639. private _onGamepadDisconnectedEvent;
  9640. constructor(_scene?: Scene | undefined);
  9641. readonly gamepads: Gamepad[];
  9642. getGamepadByType(type?: number): Nullable<Gamepad>;
  9643. dispose(): void;
  9644. private _addNewGamepad;
  9645. private _startMonitoringGamepads;
  9646. private _stopMonitoringGamepads;
  9647. /** @hidden */
  9648. _checkGamepadsStatus(): void;
  9649. private _updateGamepadObjects;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. interface Scene {
  9654. /** @hidden */
  9655. _gamepadManager: Nullable<GamepadManager>;
  9656. /**
  9657. * Gets the gamepad manager associated with the scene
  9658. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9659. */
  9660. gamepadManager: GamepadManager;
  9661. }
  9662. interface FreeCameraInputsManager {
  9663. addGamepad(): FreeCameraInputsManager;
  9664. }
  9665. interface ArcRotateCameraInputsManager {
  9666. addGamepad(): ArcRotateCameraInputsManager;
  9667. }
  9668. /**
  9669. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9670. */
  9671. class GamepadSystemSceneComponent implements ISceneComponent {
  9672. /**
  9673. * The component name helpfull to identify the component in the list of scene components.
  9674. */
  9675. readonly name: string;
  9676. /**
  9677. * The scene the component belongs to.
  9678. */
  9679. scene: Scene;
  9680. /**
  9681. * Creates a new instance of the component for the given scene
  9682. * @param scene Defines the scene to register the component in
  9683. */
  9684. constructor(scene: Scene);
  9685. /**
  9686. * Registers the component in a given scene
  9687. */
  9688. register(): void;
  9689. /**
  9690. * Rebuilds the elements related to this component in case of
  9691. * context lost for instance.
  9692. */
  9693. rebuild(): void;
  9694. /**
  9695. * Disposes the component and the associated ressources
  9696. */
  9697. dispose(): void;
  9698. private _beforeCameraUpdate;
  9699. }
  9700. }
  9701. declare module BABYLON {
  9702. /**
  9703. * Defines supported buttons for XBox360 compatible gamepads
  9704. */
  9705. enum Xbox360Button {
  9706. /** A */
  9707. A = 0,
  9708. /** B */
  9709. B = 1,
  9710. /** X */
  9711. X = 2,
  9712. /** Y */
  9713. Y = 3,
  9714. /** Start */
  9715. Start = 4,
  9716. /** Back */
  9717. Back = 5,
  9718. /** Left button */
  9719. LB = 6,
  9720. /** Right button */
  9721. RB = 7,
  9722. /** Left stick */
  9723. LeftStick = 8,
  9724. /** Right stick */
  9725. RightStick = 9
  9726. }
  9727. /** Defines values for XBox360 DPad */
  9728. enum Xbox360Dpad {
  9729. /** Up */
  9730. Up = 0,
  9731. /** Down */
  9732. Down = 1,
  9733. /** Left */
  9734. Left = 2,
  9735. /** Right */
  9736. Right = 3
  9737. }
  9738. /**
  9739. * Defines a XBox360 gamepad
  9740. */
  9741. class Xbox360Pad extends Gamepad {
  9742. private _leftTrigger;
  9743. private _rightTrigger;
  9744. private _onlefttriggerchanged;
  9745. private _onrighttriggerchanged;
  9746. private _onbuttondown;
  9747. private _onbuttonup;
  9748. private _ondpaddown;
  9749. private _ondpadup;
  9750. /** Observable raised when a button is pressed */
  9751. onButtonDownObservable: Observable<Xbox360Button>;
  9752. /** Observable raised when a button is released */
  9753. onButtonUpObservable: Observable<Xbox360Button>;
  9754. /** Observable raised when a pad is pressed */
  9755. onPadDownObservable: Observable<Xbox360Dpad>;
  9756. /** Observable raised when a pad is released */
  9757. onPadUpObservable: Observable<Xbox360Dpad>;
  9758. private _buttonA;
  9759. private _buttonB;
  9760. private _buttonX;
  9761. private _buttonY;
  9762. private _buttonBack;
  9763. private _buttonStart;
  9764. private _buttonLB;
  9765. private _buttonRB;
  9766. private _buttonLeftStick;
  9767. private _buttonRightStick;
  9768. private _dPadUp;
  9769. private _dPadDown;
  9770. private _dPadLeft;
  9771. private _dPadRight;
  9772. private _isXboxOnePad;
  9773. /**
  9774. * Creates a new XBox360 gamepad object
  9775. * @param id defines the id of this gamepad
  9776. * @param index defines its index
  9777. * @param gamepad defines the internal HTML gamepad object
  9778. * @param xboxOne defines if it is a XBox One gamepad
  9779. */
  9780. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9781. /**
  9782. * Defines the callback to call when left trigger is pressed
  9783. * @param callback defines the callback to use
  9784. */
  9785. onlefttriggerchanged(callback: (value: number) => void): void;
  9786. /**
  9787. * Defines the callback to call when right trigger is pressed
  9788. * @param callback defines the callback to use
  9789. */
  9790. onrighttriggerchanged(callback: (value: number) => void): void;
  9791. /**
  9792. * Gets or sets left trigger value
  9793. */
  9794. leftTrigger: number;
  9795. /**
  9796. * Gets or sets right trigger value
  9797. */
  9798. rightTrigger: number;
  9799. /**
  9800. * Defines the callback to call when a button is pressed
  9801. * @param callback defines the callback to use
  9802. */
  9803. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9804. /**
  9805. * Defines the callback to call when a button is released
  9806. * @param callback defines the callback to use
  9807. */
  9808. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9809. /**
  9810. * Defines the callback to call when a pad is pressed
  9811. * @param callback defines the callback to use
  9812. */
  9813. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9814. /**
  9815. * Defines the callback to call when a pad is released
  9816. * @param callback defines the callback to use
  9817. */
  9818. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9819. private _setButtonValue;
  9820. private _setDPadValue;
  9821. /** Gets or sets value of A button */
  9822. buttonA: number;
  9823. /** Gets or sets value of B button */
  9824. buttonB: number;
  9825. /** Gets or sets value of X button */
  9826. buttonX: number;
  9827. /** Gets or sets value of Y button */
  9828. buttonY: number;
  9829. /** Gets or sets value of Start button */
  9830. buttonStart: number;
  9831. /** Gets or sets value of Back button */
  9832. buttonBack: number;
  9833. /** Gets or sets value of Left button */
  9834. buttonLB: number;
  9835. /** Gets or sets value of Right button */
  9836. buttonRB: number;
  9837. /** Gets or sets value of left stick */
  9838. buttonLeftStick: number;
  9839. /** Gets or sets value of right stick */
  9840. buttonRightStick: number;
  9841. /** Gets or sets value of DPad up */
  9842. dPadUp: number;
  9843. /** Gets or sets value of DPad down */
  9844. dPadDown: number;
  9845. /** Gets or sets value of DPad left */
  9846. dPadLeft: number;
  9847. /** Gets or sets value of DPad right */
  9848. dPadRight: number;
  9849. /**
  9850. * Force the gamepad to synchronize with device values
  9851. */
  9852. update(): void;
  9853. dispose(): void;
  9854. }
  9855. }
  9856. declare module BABYLON {
  9857. /**
  9858. * Single axis drag gizmo
  9859. */
  9860. class AxisDragGizmo extends Gizmo {
  9861. /**
  9862. * Drag behavior responsible for the gizmos dragging interactions
  9863. */
  9864. dragBehavior: PointerDragBehavior;
  9865. private _pointerObserver;
  9866. /**
  9867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9868. */
  9869. snapDistance: number;
  9870. /**
  9871. * Event that fires each time the gizmo snaps to a new location.
  9872. * * snapDistance is the the change in distance
  9873. */
  9874. onSnapObservable: Observable<{
  9875. snapDistance: number;
  9876. }>;
  9877. /**
  9878. * Creates an AxisDragGizmo
  9879. * @param gizmoLayer The utility layer the gizmo will be added to
  9880. * @param dragAxis The axis which the gizmo will be able to drag on
  9881. * @param color The color of the gizmo
  9882. */
  9883. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9884. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9885. /**
  9886. * Disposes of the gizmo
  9887. */
  9888. dispose(): void;
  9889. }
  9890. }
  9891. declare module BABYLON {
  9892. /**
  9893. * Single axis scale gizmo
  9894. */
  9895. class AxisScaleGizmo extends Gizmo {
  9896. private _coloredMaterial;
  9897. /**
  9898. * Drag behavior responsible for the gizmos dragging interactions
  9899. */
  9900. dragBehavior: PointerDragBehavior;
  9901. private _pointerObserver;
  9902. /**
  9903. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9904. */
  9905. snapDistance: number;
  9906. /**
  9907. * Event that fires each time the gizmo snaps to a new location.
  9908. * * snapDistance is the the change in distance
  9909. */
  9910. onSnapObservable: Observable<{
  9911. snapDistance: number;
  9912. }>;
  9913. /**
  9914. * If the scaling operation should be done on all axis (default: false)
  9915. */
  9916. uniformScaling: boolean;
  9917. /**
  9918. * Creates an AxisScaleGizmo
  9919. * @param gizmoLayer The utility layer the gizmo will be added to
  9920. * @param dragAxis The axis which the gizmo will be able to scale on
  9921. * @param color The color of the gizmo
  9922. */
  9923. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9924. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9925. /**
  9926. * Disposes of the gizmo
  9927. */
  9928. dispose(): void;
  9929. /**
  9930. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9931. * @param mesh The mesh to replace the default mesh of the gizmo
  9932. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9933. */
  9934. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9935. }
  9936. }
  9937. declare module BABYLON {
  9938. /**
  9939. * Bounding box gizmo
  9940. */
  9941. class BoundingBoxGizmo extends Gizmo {
  9942. private _lineBoundingBox;
  9943. private _rotateSpheresParent;
  9944. private _scaleBoxesParent;
  9945. private _boundingDimensions;
  9946. private _renderObserver;
  9947. private _pointerObserver;
  9948. private _scaleDragSpeed;
  9949. private _tmpQuaternion;
  9950. private _tmpVector;
  9951. private _tmpRotationMatrix;
  9952. /**
  9953. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  9954. */
  9955. ignoreChildren: boolean;
  9956. /**
  9957. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9958. */
  9959. rotationSphereSize: number;
  9960. /**
  9961. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9962. */
  9963. scaleBoxSize: number;
  9964. /**
  9965. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  9966. */
  9967. fixedDragMeshScreenSize: boolean;
  9968. /**
  9969. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9970. */
  9971. fixedDragMeshScreenSizeDistanceFactor: number;
  9972. /**
  9973. * Fired when a rotation sphere or scale box is dragged
  9974. */
  9975. onDragStartObservable: Observable<{}>;
  9976. /**
  9977. * Fired when a scale box is dragged
  9978. */
  9979. onScaleBoxDragObservable: Observable<{}>;
  9980. /**
  9981. * Fired when a scale box drag is ended
  9982. */
  9983. onScaleBoxDragEndObservable: Observable<{}>;
  9984. /**
  9985. * Fired when a rotation sphere is dragged
  9986. */
  9987. onRotationSphereDragObservable: Observable<{}>;
  9988. /**
  9989. * Fired when a rotation sphere drag is ended
  9990. */
  9991. onRotationSphereDragEndObservable: Observable<{}>;
  9992. /**
  9993. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  9994. */
  9995. scalePivot: Nullable<Vector3>;
  9996. private _anchorMesh;
  9997. private _existingMeshScale;
  9998. private _oldPivotPoint;
  9999. private _pivotTranslation;
  10000. private removeAndStorePivotPoint;
  10001. private restorePivotPoint;
  10002. /**
  10003. * Creates an BoundingBoxGizmo
  10004. * @param gizmoLayer The utility layer the gizmo will be added to
  10005. * @param color The color of the gizmo
  10006. */
  10007. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10009. private _selectNode;
  10010. private _recurseComputeWorld;
  10011. /**
  10012. * Updates the bounding box information for the Gizmo
  10013. */
  10014. updateBoundingBox(): void;
  10015. /**
  10016. * Enables rotation on the specified axis and disables rotation on the others
  10017. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10018. */
  10019. setEnabledRotationAxis(axis: string): void;
  10020. /**
  10021. * Disposes of the gizmo
  10022. */
  10023. dispose(): void;
  10024. /**
  10025. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  10026. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10027. * @returns the bounding box mesh with the passed in mesh as a child
  10028. */
  10029. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10030. /**
  10031. * CustomMeshes are not supported by this gizmo
  10032. * @param mesh The mesh to replace the default mesh of the gizmo
  10033. */
  10034. setCustomMesh(mesh: Mesh): void;
  10035. }
  10036. }
  10037. declare module BABYLON {
  10038. /**
  10039. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10040. */
  10041. class Gizmo implements IDisposable {
  10042. /** The utility layer the gizmo will be added to */
  10043. gizmoLayer: UtilityLayerRenderer;
  10044. /**
  10045. * The root mesh of the gizmo
  10046. */
  10047. protected _rootMesh: Mesh;
  10048. private _attachedMesh;
  10049. /**
  10050. * Ratio for the scale of the gizmo (Default: 1)
  10051. */
  10052. scaleRatio: number;
  10053. private _tmpMatrix;
  10054. /**
  10055. * If a custom mesh has been set (Default: false)
  10056. */
  10057. protected _customMeshSet: boolean;
  10058. /**
  10059. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10060. * * When set, interactions will be enabled
  10061. */
  10062. attachedMesh: Nullable<AbstractMesh>;
  10063. /**
  10064. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10065. * @param mesh The mesh to replace the default mesh of the gizmo
  10066. */
  10067. setCustomMesh(mesh: Mesh): void;
  10068. /**
  10069. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10070. */
  10071. updateGizmoRotationToMatchAttachedMesh: boolean;
  10072. /**
  10073. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10074. */
  10075. updateGizmoPositionToMatchAttachedMesh: boolean;
  10076. /**
  10077. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10078. */
  10079. protected _updateScale: boolean;
  10080. protected _interactionsEnabled: boolean;
  10081. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10082. private _beforeRenderObserver;
  10083. /**
  10084. * Creates a gizmo
  10085. * @param gizmoLayer The utility layer the gizmo will be added to
  10086. */
  10087. constructor(
  10088. /** The utility layer the gizmo will be added to */
  10089. gizmoLayer?: UtilityLayerRenderer);
  10090. private _tempVector;
  10091. /**
  10092. * @hidden
  10093. * Updates the gizmo to match the attached mesh's position/rotation
  10094. */
  10095. protected _update(): void;
  10096. /**
  10097. * Disposes of the gizmo
  10098. */
  10099. dispose(): void;
  10100. }
  10101. }
  10102. declare module BABYLON {
  10103. /**
  10104. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10105. */
  10106. class GizmoManager implements IDisposable {
  10107. private scene;
  10108. /**
  10109. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10110. */
  10111. gizmos: {
  10112. positionGizmo: Nullable<PositionGizmo>;
  10113. rotationGizmo: Nullable<RotationGizmo>;
  10114. scaleGizmo: Nullable<ScaleGizmo>;
  10115. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10116. };
  10117. private _gizmosEnabled;
  10118. private _pointerObserver;
  10119. private _attachedMesh;
  10120. private _boundingBoxColor;
  10121. private _dragBehavior;
  10122. /**
  10123. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10124. */
  10125. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10126. /**
  10127. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10128. */
  10129. usePointerToAttachGizmos: boolean;
  10130. /**
  10131. * Instatiates a gizmo manager
  10132. * @param scene the scene to overlay the gizmos on top of
  10133. */
  10134. constructor(scene: Scene);
  10135. /**
  10136. * Attaches a set of gizmos to the specified mesh
  10137. * @param mesh The mesh the gizmo's should be attached to
  10138. */
  10139. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10140. /**
  10141. * If the position gizmo is enabled
  10142. */
  10143. positionGizmoEnabled: boolean;
  10144. /**
  10145. * If the rotation gizmo is enabled
  10146. */
  10147. rotationGizmoEnabled: boolean;
  10148. /**
  10149. * If the scale gizmo is enabled
  10150. */
  10151. scaleGizmoEnabled: boolean;
  10152. /**
  10153. * If the boundingBox gizmo is enabled
  10154. */
  10155. boundingBoxGizmoEnabled: boolean;
  10156. /**
  10157. * Disposes of the gizmo manager
  10158. */
  10159. dispose(): void;
  10160. }
  10161. }
  10162. declare module BABYLON {
  10163. /**
  10164. * Single plane rotation gizmo
  10165. */
  10166. class PlaneRotationGizmo extends Gizmo {
  10167. /**
  10168. * Drag behavior responsible for the gizmos dragging interactions
  10169. */
  10170. dragBehavior: PointerDragBehavior;
  10171. private _pointerObserver;
  10172. /**
  10173. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10174. */
  10175. snapDistance: number;
  10176. /**
  10177. * Event that fires each time the gizmo snaps to a new location.
  10178. * * snapDistance is the the change in distance
  10179. */
  10180. onSnapObservable: Observable<{
  10181. snapDistance: number;
  10182. }>;
  10183. /**
  10184. * Creates a PlaneRotationGizmo
  10185. * @param gizmoLayer The utility layer the gizmo will be added to
  10186. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10187. * @param color The color of the gizmo
  10188. */
  10189. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10190. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10191. /**
  10192. * Disposes of the gizmo
  10193. */
  10194. dispose(): void;
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * Gizmo that enables dragging a mesh along 3 axis
  10200. */
  10201. class PositionGizmo extends Gizmo {
  10202. /**
  10203. * Internal gizmo used for interactions on the x axis
  10204. */
  10205. xGizmo: AxisDragGizmo;
  10206. /**
  10207. * Internal gizmo used for interactions on the y axis
  10208. */
  10209. yGizmo: AxisDragGizmo;
  10210. /**
  10211. * Internal gizmo used for interactions on the z axis
  10212. */
  10213. zGizmo: AxisDragGizmo;
  10214. attachedMesh: Nullable<AbstractMesh>;
  10215. /**
  10216. * Creates a PositionGizmo
  10217. * @param gizmoLayer The utility layer the gizmo will be added to
  10218. */
  10219. constructor(gizmoLayer?: UtilityLayerRenderer);
  10220. updateGizmoRotationToMatchAttachedMesh: boolean;
  10221. /**
  10222. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10223. */
  10224. snapDistance: number;
  10225. /**
  10226. * Ratio for the scale of the gizmo (Default: 1)
  10227. */
  10228. scaleRatio: number;
  10229. /**
  10230. * Disposes of the gizmo
  10231. */
  10232. dispose(): void;
  10233. /**
  10234. * CustomMeshes are not supported by this gizmo
  10235. * @param mesh The mesh to replace the default mesh of the gizmo
  10236. */
  10237. setCustomMesh(mesh: Mesh): void;
  10238. }
  10239. }
  10240. declare module BABYLON {
  10241. /**
  10242. * Gizmo that enables rotating a mesh along 3 axis
  10243. */
  10244. class RotationGizmo extends Gizmo {
  10245. /**
  10246. * Internal gizmo used for interactions on the x axis
  10247. */
  10248. xGizmo: PlaneRotationGizmo;
  10249. /**
  10250. * Internal gizmo used for interactions on the y axis
  10251. */
  10252. yGizmo: PlaneRotationGizmo;
  10253. /**
  10254. * Internal gizmo used for interactions on the z axis
  10255. */
  10256. zGizmo: PlaneRotationGizmo;
  10257. attachedMesh: Nullable<AbstractMesh>;
  10258. /**
  10259. * Creates a RotationGizmo
  10260. * @param gizmoLayer The utility layer the gizmo will be added to
  10261. */
  10262. constructor(gizmoLayer?: UtilityLayerRenderer);
  10263. updateGizmoRotationToMatchAttachedMesh: boolean;
  10264. /**
  10265. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10266. */
  10267. snapDistance: number;
  10268. /**
  10269. * Ratio for the scale of the gizmo (Default: 1)
  10270. */
  10271. scaleRatio: number;
  10272. /**
  10273. * Disposes of the gizmo
  10274. */
  10275. dispose(): void;
  10276. /**
  10277. * CustomMeshes are not supported by this gizmo
  10278. * @param mesh The mesh to replace the default mesh of the gizmo
  10279. */
  10280. setCustomMesh(mesh: Mesh): void;
  10281. }
  10282. }
  10283. declare module BABYLON {
  10284. /**
  10285. * Gizmo that enables scaling a mesh along 3 axis
  10286. */
  10287. class ScaleGizmo extends Gizmo {
  10288. /**
  10289. * Internal gizmo used for interactions on the x axis
  10290. */
  10291. xGizmo: AxisScaleGizmo;
  10292. /**
  10293. * Internal gizmo used for interactions on the y axis
  10294. */
  10295. yGizmo: AxisScaleGizmo;
  10296. /**
  10297. * Internal gizmo used for interactions on the z axis
  10298. */
  10299. zGizmo: AxisScaleGizmo;
  10300. /**
  10301. * @hidden
  10302. * Internal gizmo used to scale all axis equally
  10303. */
  10304. private _uniformGizmo;
  10305. attachedMesh: Nullable<AbstractMesh>;
  10306. /**
  10307. * Creates a ScaleGizmo
  10308. * @param gizmoLayer The utility layer the gizmo will be added to
  10309. */
  10310. constructor(gizmoLayer?: UtilityLayerRenderer);
  10311. updateGizmoRotationToMatchAttachedMesh: boolean;
  10312. /**
  10313. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10314. */
  10315. snapDistance: number;
  10316. /**
  10317. * Ratio for the scale of the gizmo (Default: 1)
  10318. */
  10319. scaleRatio: number;
  10320. /**
  10321. * Disposes of the gizmo
  10322. */
  10323. dispose(): void;
  10324. }
  10325. }
  10326. declare module BABYLON {
  10327. /**
  10328. * Represents the different options available during the creation of
  10329. * a Environment helper.
  10330. *
  10331. * This can control the default ground, skybox and image processing setup of your scene.
  10332. */
  10333. interface IEnvironmentHelperOptions {
  10334. /**
  10335. * Specifies wether or not to create a ground.
  10336. * True by default.
  10337. */
  10338. createGround: boolean;
  10339. /**
  10340. * Specifies the ground size.
  10341. * 15 by default.
  10342. */
  10343. groundSize: number;
  10344. /**
  10345. * The texture used on the ground for the main color.
  10346. * Comes from the BabylonJS CDN by default.
  10347. *
  10348. * Remarks: Can be either a texture or a url.
  10349. */
  10350. groundTexture: string | BaseTexture;
  10351. /**
  10352. * The color mixed in the ground texture by default.
  10353. * BabylonJS clearColor by default.
  10354. */
  10355. groundColor: Color3;
  10356. /**
  10357. * Specifies the ground opacity.
  10358. * 1 by default.
  10359. */
  10360. groundOpacity: number;
  10361. /**
  10362. * Enables the ground to receive shadows.
  10363. * True by default.
  10364. */
  10365. enableGroundShadow: boolean;
  10366. /**
  10367. * Helps preventing the shadow to be fully black on the ground.
  10368. * 0.5 by default.
  10369. */
  10370. groundShadowLevel: number;
  10371. /**
  10372. * Creates a mirror texture attach to the ground.
  10373. * false by default.
  10374. */
  10375. enableGroundMirror: boolean;
  10376. /**
  10377. * Specifies the ground mirror size ratio.
  10378. * 0.3 by default as the default kernel is 64.
  10379. */
  10380. groundMirrorSizeRatio: number;
  10381. /**
  10382. * Specifies the ground mirror blur kernel size.
  10383. * 64 by default.
  10384. */
  10385. groundMirrorBlurKernel: number;
  10386. /**
  10387. * Specifies the ground mirror visibility amount.
  10388. * 1 by default
  10389. */
  10390. groundMirrorAmount: number;
  10391. /**
  10392. * Specifies the ground mirror reflectance weight.
  10393. * This uses the standard weight of the background material to setup the fresnel effect
  10394. * of the mirror.
  10395. * 1 by default.
  10396. */
  10397. groundMirrorFresnelWeight: number;
  10398. /**
  10399. * Specifies the ground mirror Falloff distance.
  10400. * This can helps reducing the size of the reflection.
  10401. * 0 by Default.
  10402. */
  10403. groundMirrorFallOffDistance: number;
  10404. /**
  10405. * Specifies the ground mirror texture type.
  10406. * Unsigned Int by Default.
  10407. */
  10408. groundMirrorTextureType: number;
  10409. /**
  10410. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10411. * the shown objects.
  10412. */
  10413. groundYBias: number;
  10414. /**
  10415. * Specifies wether or not to create a skybox.
  10416. * True by default.
  10417. */
  10418. createSkybox: boolean;
  10419. /**
  10420. * Specifies the skybox size.
  10421. * 20 by default.
  10422. */
  10423. skyboxSize: number;
  10424. /**
  10425. * The texture used on the skybox for the main color.
  10426. * Comes from the BabylonJS CDN by default.
  10427. *
  10428. * Remarks: Can be either a texture or a url.
  10429. */
  10430. skyboxTexture: string | BaseTexture;
  10431. /**
  10432. * The color mixed in the skybox texture by default.
  10433. * BabylonJS clearColor by default.
  10434. */
  10435. skyboxColor: Color3;
  10436. /**
  10437. * The background rotation around the Y axis of the scene.
  10438. * This helps aligning the key lights of your scene with the background.
  10439. * 0 by default.
  10440. */
  10441. backgroundYRotation: number;
  10442. /**
  10443. * Compute automatically the size of the elements to best fit with the scene.
  10444. */
  10445. sizeAuto: boolean;
  10446. /**
  10447. * Default position of the rootMesh if autoSize is not true.
  10448. */
  10449. rootPosition: Vector3;
  10450. /**
  10451. * Sets up the image processing in the scene.
  10452. * true by default.
  10453. */
  10454. setupImageProcessing: boolean;
  10455. /**
  10456. * The texture used as your environment texture in the scene.
  10457. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10458. *
  10459. * Remarks: Can be either a texture or a url.
  10460. */
  10461. environmentTexture: string | BaseTexture;
  10462. /**
  10463. * The value of the exposure to apply to the scene.
  10464. * 0.6 by default if setupImageProcessing is true.
  10465. */
  10466. cameraExposure: number;
  10467. /**
  10468. * The value of the contrast to apply to the scene.
  10469. * 1.6 by default if setupImageProcessing is true.
  10470. */
  10471. cameraContrast: number;
  10472. /**
  10473. * Specifies wether or not tonemapping should be enabled in the scene.
  10474. * true by default if setupImageProcessing is true.
  10475. */
  10476. toneMappingEnabled: boolean;
  10477. }
  10478. /**
  10479. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10480. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10481. * It also helps with the default setup of your imageProcessing configuration.
  10482. */
  10483. class EnvironmentHelper {
  10484. /**
  10485. * Default ground texture URL.
  10486. */
  10487. private static _groundTextureCDNUrl;
  10488. /**
  10489. * Default skybox texture URL.
  10490. */
  10491. private static _skyboxTextureCDNUrl;
  10492. /**
  10493. * Default environment texture URL.
  10494. */
  10495. private static _environmentTextureCDNUrl;
  10496. /**
  10497. * Creates the default options for the helper.
  10498. */
  10499. private static _getDefaultOptions;
  10500. private _rootMesh;
  10501. /**
  10502. * Gets the root mesh created by the helper.
  10503. */
  10504. readonly rootMesh: Mesh;
  10505. private _skybox;
  10506. /**
  10507. * Gets the skybox created by the helper.
  10508. */
  10509. readonly skybox: Nullable<Mesh>;
  10510. private _skyboxTexture;
  10511. /**
  10512. * Gets the skybox texture created by the helper.
  10513. */
  10514. readonly skyboxTexture: Nullable<BaseTexture>;
  10515. private _skyboxMaterial;
  10516. /**
  10517. * Gets the skybox material created by the helper.
  10518. */
  10519. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10520. private _ground;
  10521. /**
  10522. * Gets the ground mesh created by the helper.
  10523. */
  10524. readonly ground: Nullable<Mesh>;
  10525. private _groundTexture;
  10526. /**
  10527. * Gets the ground texture created by the helper.
  10528. */
  10529. readonly groundTexture: Nullable<BaseTexture>;
  10530. private _groundMirror;
  10531. /**
  10532. * Gets the ground mirror created by the helper.
  10533. */
  10534. readonly groundMirror: Nullable<MirrorTexture>;
  10535. /**
  10536. * Gets the ground mirror render list to helps pushing the meshes
  10537. * you wish in the ground reflection.
  10538. */
  10539. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10540. private _groundMaterial;
  10541. /**
  10542. * Gets the ground material created by the helper.
  10543. */
  10544. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10545. /**
  10546. * Stores the creation options.
  10547. */
  10548. private readonly _scene;
  10549. private _options;
  10550. /**
  10551. * This observable will be notified with any error during the creation of the environment,
  10552. * mainly texture creation errors.
  10553. */
  10554. onErrorObservable: Observable<{
  10555. message?: string;
  10556. exception?: any;
  10557. }>;
  10558. /**
  10559. * constructor
  10560. * @param options
  10561. * @param scene The scene to add the material to
  10562. */
  10563. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10564. /**
  10565. * Updates the background according to the new options
  10566. * @param options
  10567. */
  10568. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10569. /**
  10570. * Sets the primary color of all the available elements.
  10571. * @param color the main color to affect to the ground and the background
  10572. */
  10573. setMainColor(color: Color3): void;
  10574. /**
  10575. * Setup the image processing according to the specified options.
  10576. */
  10577. private _setupImageProcessing;
  10578. /**
  10579. * Setup the environment texture according to the specified options.
  10580. */
  10581. private _setupEnvironmentTexture;
  10582. /**
  10583. * Setup the background according to the specified options.
  10584. */
  10585. private _setupBackground;
  10586. /**
  10587. * Get the scene sizes according to the setup.
  10588. */
  10589. private _getSceneSize;
  10590. /**
  10591. * Setup the ground according to the specified options.
  10592. */
  10593. private _setupGround;
  10594. /**
  10595. * Setup the ground material according to the specified options.
  10596. */
  10597. private _setupGroundMaterial;
  10598. /**
  10599. * Setup the ground diffuse texture according to the specified options.
  10600. */
  10601. private _setupGroundDiffuseTexture;
  10602. /**
  10603. * Setup the ground mirror texture according to the specified options.
  10604. */
  10605. private _setupGroundMirrorTexture;
  10606. /**
  10607. * Setup the ground to receive the mirror texture.
  10608. */
  10609. private _setupMirrorInGroundMaterial;
  10610. /**
  10611. * Setup the skybox according to the specified options.
  10612. */
  10613. private _setupSkybox;
  10614. /**
  10615. * Setup the skybox material according to the specified options.
  10616. */
  10617. private _setupSkyboxMaterial;
  10618. /**
  10619. * Setup the skybox reflection texture according to the specified options.
  10620. */
  10621. private _setupSkyboxReflectionTexture;
  10622. private _errorHandler;
  10623. /**
  10624. * Dispose all the elements created by the Helper.
  10625. */
  10626. dispose(): void;
  10627. }
  10628. }
  10629. declare module BABYLON {
  10630. /**
  10631. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10632. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10633. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10634. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10635. */
  10636. class PhotoDome extends TransformNode {
  10637. private _useDirectMapping;
  10638. /**
  10639. * The texture being displayed on the sphere
  10640. */
  10641. protected _photoTexture: Texture;
  10642. /**
  10643. * Gets or sets the texture being displayed on the sphere
  10644. */
  10645. photoTexture: Texture;
  10646. /**
  10647. * Observable raised when an error occured while loading the 360 image
  10648. */
  10649. onLoadErrorObservable: Observable<string>;
  10650. /**
  10651. * The skybox material
  10652. */
  10653. protected _material: BackgroundMaterial;
  10654. /**
  10655. * The surface used for the skybox
  10656. */
  10657. protected _mesh: Mesh;
  10658. /**
  10659. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10660. * Also see the options.resolution property.
  10661. */
  10662. fovMultiplier: number;
  10663. /**
  10664. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10665. * @param name Element's name, child elements will append suffixes for their own names.
  10666. * @param urlsOfPhoto defines the url of the photo to display
  10667. * @param options defines an object containing optional or exposed sub element properties
  10668. * @param onError defines a callback called when an error occured while loading the texture
  10669. */
  10670. constructor(name: string, urlOfPhoto: string, options: {
  10671. resolution?: number;
  10672. size?: number;
  10673. useDirectMapping?: boolean;
  10674. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10675. /**
  10676. * Releases resources associated with this node.
  10677. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10678. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10679. */
  10680. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10681. }
  10682. }
  10683. declare module BABYLON {
  10684. /**
  10685. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10686. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10687. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10688. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10689. */
  10690. class VideoDome extends TransformNode {
  10691. private _useDirectMapping;
  10692. /**
  10693. * The video texture being displayed on the sphere
  10694. */
  10695. protected _videoTexture: VideoTexture;
  10696. /**
  10697. * Gets the video texture being displayed on the sphere
  10698. */
  10699. readonly videoTexture: VideoTexture;
  10700. /**
  10701. * The skybox material
  10702. */
  10703. protected _material: BackgroundMaterial;
  10704. /**
  10705. * The surface used for the skybox
  10706. */
  10707. protected _mesh: Mesh;
  10708. /**
  10709. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10710. * Also see the options.resolution property.
  10711. */
  10712. fovMultiplier: number;
  10713. /**
  10714. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10715. * @param name Element's name, child elements will append suffixes for their own names.
  10716. * @param urlsOrVideo defines the url(s) or the video element to use
  10717. * @param options An object containing optional or exposed sub element properties
  10718. */
  10719. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10720. resolution?: number;
  10721. clickToPlay?: boolean;
  10722. autoPlay?: boolean;
  10723. loop?: boolean;
  10724. size?: number;
  10725. poster?: string;
  10726. useDirectMapping?: boolean;
  10727. }, scene: Scene);
  10728. /**
  10729. * Releases resources associated with this node.
  10730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10732. */
  10733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10734. }
  10735. }
  10736. declare module BABYLON {
  10737. /**
  10738. * This class can be used to get instrumentation data from a Babylon engine
  10739. */
  10740. class EngineInstrumentation implements IDisposable {
  10741. engine: Engine;
  10742. private _captureGPUFrameTime;
  10743. private _gpuFrameTimeToken;
  10744. private _gpuFrameTime;
  10745. private _captureShaderCompilationTime;
  10746. private _shaderCompilationTime;
  10747. private _onBeginFrameObserver;
  10748. private _onEndFrameObserver;
  10749. private _onBeforeShaderCompilationObserver;
  10750. private _onAfterShaderCompilationObserver;
  10751. /**
  10752. * Gets the perf counter used for GPU frame time
  10753. */
  10754. readonly gpuFrameTimeCounter: PerfCounter;
  10755. /**
  10756. * Gets the GPU frame time capture status
  10757. */
  10758. /**
  10759. * Enable or disable the GPU frame time capture
  10760. */
  10761. captureGPUFrameTime: boolean;
  10762. /**
  10763. * Gets the perf counter used for shader compilation time
  10764. */
  10765. readonly shaderCompilationTimeCounter: PerfCounter;
  10766. /**
  10767. * Gets the shader compilation time capture status
  10768. */
  10769. /**
  10770. * Enable or disable the shader compilation time capture
  10771. */
  10772. captureShaderCompilationTime: boolean;
  10773. constructor(engine: Engine);
  10774. dispose(): void;
  10775. }
  10776. }
  10777. declare module BABYLON {
  10778. /**
  10779. * This class can be used to get instrumentation data from a Babylon engine
  10780. */
  10781. class SceneInstrumentation implements IDisposable {
  10782. scene: Scene;
  10783. private _captureActiveMeshesEvaluationTime;
  10784. private _activeMeshesEvaluationTime;
  10785. private _captureRenderTargetsRenderTime;
  10786. private _renderTargetsRenderTime;
  10787. private _captureFrameTime;
  10788. private _frameTime;
  10789. private _captureRenderTime;
  10790. private _renderTime;
  10791. private _captureInterFrameTime;
  10792. private _interFrameTime;
  10793. private _captureParticlesRenderTime;
  10794. private _particlesRenderTime;
  10795. private _captureSpritesRenderTime;
  10796. private _spritesRenderTime;
  10797. private _capturePhysicsTime;
  10798. private _physicsTime;
  10799. private _captureAnimationsTime;
  10800. private _animationsTime;
  10801. private _captureCameraRenderTime;
  10802. private _cameraRenderTime;
  10803. private _onBeforeActiveMeshesEvaluationObserver;
  10804. private _onAfterActiveMeshesEvaluationObserver;
  10805. private _onBeforeRenderTargetsRenderObserver;
  10806. private _onAfterRenderTargetsRenderObserver;
  10807. private _onAfterRenderObserver;
  10808. private _onBeforeDrawPhaseObserver;
  10809. private _onAfterDrawPhaseObserver;
  10810. private _onBeforeAnimationsObserver;
  10811. private _onBeforeParticlesRenderingObserver;
  10812. private _onAfterParticlesRenderingObserver;
  10813. private _onBeforeSpritesRenderingObserver;
  10814. private _onAfterSpritesRenderingObserver;
  10815. private _onBeforePhysicsObserver;
  10816. private _onAfterPhysicsObserver;
  10817. private _onAfterAnimationsObserver;
  10818. private _onBeforeCameraRenderObserver;
  10819. private _onAfterCameraRenderObserver;
  10820. /**
  10821. * Gets the perf counter used for active meshes evaluation time
  10822. */
  10823. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10824. /**
  10825. * Gets the active meshes evaluation time capture status
  10826. */
  10827. /**
  10828. * Enable or disable the active meshes evaluation time capture
  10829. */
  10830. captureActiveMeshesEvaluationTime: boolean;
  10831. /**
  10832. * Gets the perf counter used for render targets render time
  10833. */
  10834. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10835. /**
  10836. * Gets the render targets render time capture status
  10837. */
  10838. /**
  10839. * Enable or disable the render targets render time capture
  10840. */
  10841. captureRenderTargetsRenderTime: boolean;
  10842. /**
  10843. * Gets the perf counter used for particles render time
  10844. */
  10845. readonly particlesRenderTimeCounter: PerfCounter;
  10846. /**
  10847. * Gets the particles render time capture status
  10848. */
  10849. /**
  10850. * Enable or disable the particles render time capture
  10851. */
  10852. captureParticlesRenderTime: boolean;
  10853. /**
  10854. * Gets the perf counter used for sprites render time
  10855. */
  10856. readonly spritesRenderTimeCounter: PerfCounter;
  10857. /**
  10858. * Gets the sprites render time capture status
  10859. */
  10860. /**
  10861. * Enable or disable the sprites render time capture
  10862. */
  10863. captureSpritesRenderTime: boolean;
  10864. /**
  10865. * Gets the perf counter used for physics time
  10866. */
  10867. readonly physicsTimeCounter: PerfCounter;
  10868. /**
  10869. * Gets the physics time capture status
  10870. */
  10871. /**
  10872. * Enable or disable the physics time capture
  10873. */
  10874. capturePhysicsTime: boolean;
  10875. /**
  10876. * Gets the perf counter used for animations time
  10877. */
  10878. readonly animationsTimeCounter: PerfCounter;
  10879. /**
  10880. * Gets the animations time capture status
  10881. */
  10882. /**
  10883. * Enable or disable the animations time capture
  10884. */
  10885. captureAnimationsTime: boolean;
  10886. /**
  10887. * Gets the perf counter used for frame time capture
  10888. */
  10889. readonly frameTimeCounter: PerfCounter;
  10890. /**
  10891. * Gets the frame time capture status
  10892. */
  10893. /**
  10894. * Enable or disable the frame time capture
  10895. */
  10896. captureFrameTime: boolean;
  10897. /**
  10898. * Gets the perf counter used for inter-frames time capture
  10899. */
  10900. readonly interFrameTimeCounter: PerfCounter;
  10901. /**
  10902. * Gets the inter-frames time capture status
  10903. */
  10904. /**
  10905. * Enable or disable the inter-frames time capture
  10906. */
  10907. captureInterFrameTime: boolean;
  10908. /**
  10909. * Gets the perf counter used for render time capture
  10910. */
  10911. readonly renderTimeCounter: PerfCounter;
  10912. /**
  10913. * Gets the render time capture status
  10914. */
  10915. /**
  10916. * Enable or disable the render time capture
  10917. */
  10918. captureRenderTime: boolean;
  10919. /**
  10920. * Gets the perf counter used for camera render time capture
  10921. */
  10922. readonly cameraRenderTimeCounter: PerfCounter;
  10923. /**
  10924. * Gets the camera render time capture status
  10925. */
  10926. /**
  10927. * Enable or disable the camera render time capture
  10928. */
  10929. captureCameraRenderTime: boolean;
  10930. /**
  10931. * Gets the perf counter used for draw calls
  10932. */
  10933. readonly drawCallsCounter: PerfCounter;
  10934. /**
  10935. * Gets the perf counter used for texture collisions
  10936. */
  10937. readonly textureCollisionsCounter: PerfCounter;
  10938. constructor(scene: Scene);
  10939. dispose(): void;
  10940. }
  10941. }
  10942. declare module BABYLON {
  10943. /**
  10944. * @hidden
  10945. **/
  10946. class _TimeToken {
  10947. _startTimeQuery: Nullable<WebGLQuery>;
  10948. _endTimeQuery: Nullable<WebGLQuery>;
  10949. _timeElapsedQuery: Nullable<WebGLQuery>;
  10950. _timeElapsedQueryEnded: boolean;
  10951. }
  10952. }
  10953. declare module BABYLON {
  10954. /**
  10955. * Effect layer options. This helps customizing the behaviour
  10956. * of the effect layer.
  10957. */
  10958. interface IEffectLayerOptions {
  10959. /**
  10960. * Multiplication factor apply to the canvas size to compute the render target size
  10961. * used to generated the objects (the smaller the faster).
  10962. */
  10963. mainTextureRatio: number;
  10964. /**
  10965. * Enforces a fixed size texture to ensure effect stability across devices.
  10966. */
  10967. mainTextureFixedSize?: number;
  10968. /**
  10969. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10970. */
  10971. alphaBlendingMode: number;
  10972. /**
  10973. * The camera attached to the layer.
  10974. */
  10975. camera: Nullable<Camera>;
  10976. /**
  10977. * The rendering group to draw the layer in.
  10978. */
  10979. renderingGroupId: number;
  10980. }
  10981. /**
  10982. * The effect layer Helps adding post process effect blended with the main pass.
  10983. *
  10984. * This can be for instance use to generate glow or higlight effects on the scene.
  10985. *
  10986. * The effect layer class can not be used directly and is intented to inherited from to be
  10987. * customized per effects.
  10988. */
  10989. abstract class EffectLayer {
  10990. private _vertexBuffers;
  10991. private _indexBuffer;
  10992. private _cachedDefines;
  10993. private _effectLayerMapGenerationEffect;
  10994. private _effectLayerOptions;
  10995. private _mergeEffect;
  10996. protected _scene: Scene;
  10997. protected _engine: Engine;
  10998. protected _maxSize: number;
  10999. protected _mainTextureDesiredSize: ISize;
  11000. protected _mainTexture: RenderTargetTexture;
  11001. protected _shouldRender: boolean;
  11002. protected _postProcesses: PostProcess[];
  11003. protected _textures: BaseTexture[];
  11004. protected _emissiveTextureAndColor: {
  11005. texture: Nullable<BaseTexture>;
  11006. color: Color4;
  11007. };
  11008. /**
  11009. * The name of the layer
  11010. */
  11011. name: string;
  11012. /**
  11013. * The clear color of the texture used to generate the glow map.
  11014. */
  11015. neutralColor: Color4;
  11016. /**
  11017. * Specifies wether the highlight layer is enabled or not.
  11018. */
  11019. isEnabled: boolean;
  11020. /**
  11021. * Gets the camera attached to the layer.
  11022. */
  11023. readonly camera: Nullable<Camera>;
  11024. /**
  11025. * Gets the rendering group id the layer should render in.
  11026. */
  11027. readonly renderingGroupId: number;
  11028. /**
  11029. * An event triggered when the effect layer has been disposed.
  11030. */
  11031. onDisposeObservable: Observable<EffectLayer>;
  11032. /**
  11033. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11034. */
  11035. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11036. /**
  11037. * An event triggered when the generated texture is being merged in the scene.
  11038. */
  11039. onBeforeComposeObservable: Observable<EffectLayer>;
  11040. /**
  11041. * An event triggered when the generated texture has been merged in the scene.
  11042. */
  11043. onAfterComposeObservable: Observable<EffectLayer>;
  11044. /**
  11045. * An event triggered when the efffect layer changes its size.
  11046. */
  11047. onSizeChangedObservable: Observable<EffectLayer>;
  11048. /**
  11049. * Instantiates a new effect Layer and references it in the scene.
  11050. * @param name The name of the layer
  11051. * @param scene The scene to use the layer in
  11052. */
  11053. constructor(
  11054. /** The Friendly of the effect in the scene */
  11055. name: string, scene: Scene);
  11056. /**
  11057. * Get the effect name of the layer.
  11058. * @return The effect name
  11059. */
  11060. abstract getEffectName(): string;
  11061. /**
  11062. * Checks for the readiness of the element composing the layer.
  11063. * @param subMesh the mesh to check for
  11064. * @param useInstances specify wether or not to use instances to render the mesh
  11065. * @return true if ready otherwise, false
  11066. */
  11067. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11068. /**
  11069. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11070. * @returns true if the effect requires stencil during the main canvas render pass.
  11071. */
  11072. abstract needStencil(): boolean;
  11073. /**
  11074. * Create the merge effect. This is the shader use to blit the information back
  11075. * to the main canvas at the end of the scene rendering.
  11076. * @returns The effect containing the shader used to merge the effect on the main canvas
  11077. */
  11078. protected abstract _createMergeEffect(): Effect;
  11079. /**
  11080. * Creates the render target textures and post processes used in the effect layer.
  11081. */
  11082. protected abstract _createTextureAndPostProcesses(): void;
  11083. /**
  11084. * Implementation specific of rendering the generating effect on the main canvas.
  11085. * @param effect The effect used to render through
  11086. */
  11087. protected abstract _internalRender(effect: Effect): void;
  11088. /**
  11089. * Sets the required values for both the emissive texture and and the main color.
  11090. */
  11091. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11092. /**
  11093. * Free any resources and references associated to a mesh.
  11094. * Internal use
  11095. * @param mesh The mesh to free.
  11096. */
  11097. abstract _disposeMesh(mesh: Mesh): void;
  11098. /**
  11099. * Serializes this layer (Glow or Highlight for example)
  11100. * @returns a serialized layer object
  11101. */
  11102. abstract serialize?(): any;
  11103. /**
  11104. * Initializes the effect layer with the required options.
  11105. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11106. */
  11107. protected _init(options: Partial<IEffectLayerOptions>): void;
  11108. /**
  11109. * Generates the index buffer of the full screen quad blending to the main canvas.
  11110. */
  11111. private _generateIndexBuffer;
  11112. /**
  11113. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11114. */
  11115. private _genrateVertexBuffer;
  11116. /**
  11117. * Sets the main texture desired size which is the closest power of two
  11118. * of the engine canvas size.
  11119. */
  11120. private _setMainTextureSize;
  11121. /**
  11122. * Creates the main texture for the effect layer.
  11123. */
  11124. protected _createMainTexture(): void;
  11125. /**
  11126. * Checks for the readiness of the element composing the layer.
  11127. * @param subMesh the mesh to check for
  11128. * @param useInstances specify wether or not to use instances to render the mesh
  11129. * @param emissiveTexture the associated emissive texture used to generate the glow
  11130. * @return true if ready otherwise, false
  11131. */
  11132. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11133. /**
  11134. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11135. */
  11136. render(): void;
  11137. /**
  11138. * Determine if a given mesh will be used in the current effect.
  11139. * @param mesh mesh to test
  11140. * @returns true if the mesh will be used
  11141. */
  11142. hasMesh(mesh: AbstractMesh): boolean;
  11143. /**
  11144. * Returns true if the layer contains information to display, otherwise false.
  11145. * @returns true if the glow layer should be rendered
  11146. */
  11147. shouldRender(): boolean;
  11148. /**
  11149. * Returns true if the mesh should render, otherwise false.
  11150. * @param mesh The mesh to render
  11151. * @returns true if it should render otherwise false
  11152. */
  11153. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11154. /**
  11155. * Returns true if the mesh should render, otherwise false.
  11156. * @param mesh The mesh to render
  11157. * @returns true if it should render otherwise false
  11158. */
  11159. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11160. /**
  11161. * Renders the submesh passed in parameter to the generation map.
  11162. */
  11163. protected _renderSubMesh(subMesh: SubMesh): void;
  11164. /**
  11165. * Rebuild the required buffers.
  11166. * @hidden Internal use only.
  11167. */
  11168. _rebuild(): void;
  11169. /**
  11170. * Dispose only the render target textures and post process.
  11171. */
  11172. private _disposeTextureAndPostProcesses;
  11173. /**
  11174. * Dispose the highlight layer and free resources.
  11175. */
  11176. dispose(): void;
  11177. /**
  11178. * Gets the class name of the effect layer
  11179. * @returns the string with the class name of the effect layer
  11180. */
  11181. getClassName(): string;
  11182. /**
  11183. * Creates an effect layer from parsed effect layer data
  11184. * @param parsedEffectLayer defines effect layer data
  11185. * @param scene defines the current scene
  11186. * @param rootUrl defines the root URL containing the effect layer information
  11187. * @returns a parsed effect Layer
  11188. */
  11189. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11190. }
  11191. }
  11192. declare module BABYLON {
  11193. interface AbstractScene {
  11194. /**
  11195. * The list of effect layers (highlights/glow) added to the scene
  11196. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11197. * @see http://doc.babylonjs.com/how_to/glow_layer
  11198. */
  11199. effectLayers: Array<EffectLayer>;
  11200. /**
  11201. * Removes the given effect layer from this scene.
  11202. * @param toRemove defines the effect layer to remove
  11203. * @returns the index of the removed effect layer
  11204. */
  11205. removeEffectLayer(toRemove: EffectLayer): number;
  11206. /**
  11207. * Adds the given effect layer to this scene
  11208. * @param newEffectLayer defines the effect layer to add
  11209. */
  11210. addEffectLayer(newEffectLayer: EffectLayer): void;
  11211. }
  11212. /**
  11213. * Defines the layer scene component responsible to manage any effect layers
  11214. * in a given scene.
  11215. */
  11216. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11217. /**
  11218. * The component name helpfull to identify the component in the list of scene components.
  11219. */
  11220. readonly name: string;
  11221. /**
  11222. * The scene the component belongs to.
  11223. */
  11224. scene: Scene;
  11225. private _engine;
  11226. private _renderEffects;
  11227. private _needStencil;
  11228. private _previousStencilState;
  11229. /**
  11230. * Creates a new instance of the component for the given scene
  11231. * @param scene Defines the scene to register the component in
  11232. */
  11233. constructor(scene: Scene);
  11234. /**
  11235. * Registers the component in a given scene
  11236. */
  11237. register(): void;
  11238. /**
  11239. * Rebuilds the elements related to this component in case of
  11240. * context lost for instance.
  11241. */
  11242. rebuild(): void;
  11243. /**
  11244. * Serializes the component data to the specified json object
  11245. * @param serializationObject The object to serialize to
  11246. */
  11247. serialize(serializationObject: any): void;
  11248. /**
  11249. * Adds all the element from the container to the scene
  11250. * @param container the container holding the elements
  11251. */
  11252. addFromContainer(container: AbstractScene): void;
  11253. /**
  11254. * Removes all the elements in the container from the scene
  11255. * @param container contains the elements to remove
  11256. */
  11257. removeFromContainer(container: AbstractScene): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. private _isReadyForMesh;
  11263. private _renderMainTexture;
  11264. private _setStencil;
  11265. private _setStencilBack;
  11266. private _draw;
  11267. private _drawCamera;
  11268. private _drawRenderingGroup;
  11269. }
  11270. }
  11271. declare module BABYLON {
  11272. interface AbstractScene {
  11273. /**
  11274. * Return a the first highlight layer of the scene with a given name.
  11275. * @param name The name of the highlight layer to look for.
  11276. * @return The highlight layer if found otherwise null.
  11277. */
  11278. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11279. }
  11280. /**
  11281. * Glow layer options. This helps customizing the behaviour
  11282. * of the glow layer.
  11283. */
  11284. interface IGlowLayerOptions {
  11285. /**
  11286. * Multiplication factor apply to the canvas size to compute the render target size
  11287. * used to generated the glowing objects (the smaller the faster).
  11288. */
  11289. mainTextureRatio: number;
  11290. /**
  11291. * Enforces a fixed size texture to ensure resize independant blur.
  11292. */
  11293. mainTextureFixedSize?: number;
  11294. /**
  11295. * How big is the kernel of the blur texture.
  11296. */
  11297. blurKernelSize: number;
  11298. /**
  11299. * The camera attached to the layer.
  11300. */
  11301. camera: Nullable<Camera>;
  11302. /**
  11303. * Enable MSAA by chosing the number of samples.
  11304. */
  11305. mainTextureSamples?: number;
  11306. /**
  11307. * The rendering group to draw the layer in.
  11308. */
  11309. renderingGroupId: number;
  11310. }
  11311. /**
  11312. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11313. *
  11314. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11315. * glowy meshes to your scene.
  11316. *
  11317. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11318. */
  11319. class GlowLayer extends EffectLayer {
  11320. /**
  11321. * Effect Name of the layer.
  11322. */
  11323. static readonly EffectName: string;
  11324. /**
  11325. * The default blur kernel size used for the glow.
  11326. */
  11327. static DefaultBlurKernelSize: number;
  11328. /**
  11329. * The default texture size ratio used for the glow.
  11330. */
  11331. static DefaultTextureRatio: number;
  11332. /**
  11333. * Sets the kernel size of the blur.
  11334. */
  11335. /**
  11336. * Gets the kernel size of the blur.
  11337. */
  11338. blurKernelSize: number;
  11339. /**
  11340. * Sets the glow intensity.
  11341. */
  11342. /**
  11343. * Gets the glow intensity.
  11344. */
  11345. intensity: number;
  11346. private _options;
  11347. private _intensity;
  11348. private _horizontalBlurPostprocess1;
  11349. private _verticalBlurPostprocess1;
  11350. private _horizontalBlurPostprocess2;
  11351. private _verticalBlurPostprocess2;
  11352. private _blurTexture1;
  11353. private _blurTexture2;
  11354. private _postProcesses1;
  11355. private _postProcesses2;
  11356. private _includedOnlyMeshes;
  11357. private _excludedMeshes;
  11358. /**
  11359. * Callback used to let the user override the color selection on a per mesh basis
  11360. */
  11361. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11362. /**
  11363. * Callback used to let the user override the texture selection on a per mesh basis
  11364. */
  11365. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11366. /**
  11367. * Instantiates a new glow Layer and references it to the scene.
  11368. * @param name The name of the layer
  11369. * @param scene The scene to use the layer in
  11370. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11371. */
  11372. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11373. /**
  11374. * Get the effect name of the layer.
  11375. * @return The effect name
  11376. */
  11377. getEffectName(): string;
  11378. /**
  11379. * Create the merge effect. This is the shader use to blit the information back
  11380. * to the main canvas at the end of the scene rendering.
  11381. */
  11382. protected _createMergeEffect(): Effect;
  11383. /**
  11384. * Creates the render target textures and post processes used in the glow layer.
  11385. */
  11386. protected _createTextureAndPostProcesses(): void;
  11387. /**
  11388. * Checks for the readiness of the element composing the layer.
  11389. * @param subMesh the mesh to check for
  11390. * @param useInstances specify wether or not to use instances to render the mesh
  11391. * @param emissiveTexture the associated emissive texture used to generate the glow
  11392. * @return true if ready otherwise, false
  11393. */
  11394. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11395. /**
  11396. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11397. */
  11398. needStencil(): boolean;
  11399. /**
  11400. * Implementation specific of rendering the generating effect on the main canvas.
  11401. * @param effect The effect used to render through
  11402. */
  11403. protected _internalRender(effect: Effect): void;
  11404. /**
  11405. * Sets the required values for both the emissive texture and and the main color.
  11406. */
  11407. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11408. /**
  11409. * Returns true if the mesh should render, otherwise false.
  11410. * @param mesh The mesh to render
  11411. * @returns true if it should render otherwise false
  11412. */
  11413. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11414. /**
  11415. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11416. * @param mesh The mesh to exclude from the glow layer
  11417. */
  11418. addExcludedMesh(mesh: Mesh): void;
  11419. /**
  11420. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11421. * @param mesh The mesh to remove
  11422. */
  11423. removeExcludedMesh(mesh: Mesh): void;
  11424. /**
  11425. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11426. * @param mesh The mesh to include in the glow layer
  11427. */
  11428. addIncludedOnlyMesh(mesh: Mesh): void;
  11429. /**
  11430. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11431. * @param mesh The mesh to remove
  11432. */
  11433. removeIncludedOnlyMesh(mesh: Mesh): void;
  11434. /**
  11435. * Determine if a given mesh will be used in the glow layer
  11436. * @param mesh The mesh to test
  11437. * @returns true if the mesh will be highlighted by the current glow layer
  11438. */
  11439. hasMesh(mesh: AbstractMesh): boolean;
  11440. /**
  11441. * Free any resources and references associated to a mesh.
  11442. * Internal use
  11443. * @param mesh The mesh to free.
  11444. * @hidden
  11445. */
  11446. _disposeMesh(mesh: Mesh): void;
  11447. /**
  11448. * Gets the class name of the effect layer
  11449. * @returns the string with the class name of the effect layer
  11450. */
  11451. getClassName(): string;
  11452. /**
  11453. * Serializes this glow layer
  11454. * @returns a serialized glow layer object
  11455. */
  11456. serialize(): any;
  11457. /**
  11458. * Creates a Glow Layer from parsed glow layer data
  11459. * @param parsedGlowLayer defines glow layer data
  11460. * @param scene defines the current scene
  11461. * @param rootUrl defines the root URL containing the glow layer information
  11462. * @returns a parsed Glow Layer
  11463. */
  11464. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. interface AbstractScene {
  11469. /**
  11470. * Return a the first highlight layer of the scene with a given name.
  11471. * @param name The name of the highlight layer to look for.
  11472. * @return The highlight layer if found otherwise null.
  11473. */
  11474. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11475. }
  11476. /**
  11477. * Highlight layer options. This helps customizing the behaviour
  11478. * of the highlight layer.
  11479. */
  11480. interface IHighlightLayerOptions {
  11481. /**
  11482. * Multiplication factor apply to the canvas size to compute the render target size
  11483. * used to generated the glowing objects (the smaller the faster).
  11484. */
  11485. mainTextureRatio: number;
  11486. /**
  11487. * Enforces a fixed size texture to ensure resize independant blur.
  11488. */
  11489. mainTextureFixedSize?: number;
  11490. /**
  11491. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11492. * of the picture to blur (the smaller the faster).
  11493. */
  11494. blurTextureSizeRatio: number;
  11495. /**
  11496. * How big in texel of the blur texture is the vertical blur.
  11497. */
  11498. blurVerticalSize: number;
  11499. /**
  11500. * How big in texel of the blur texture is the horizontal blur.
  11501. */
  11502. blurHorizontalSize: number;
  11503. /**
  11504. * Alpha blending mode used to apply the blur. Default is combine.
  11505. */
  11506. alphaBlendingMode: number;
  11507. /**
  11508. * The camera attached to the layer.
  11509. */
  11510. camera: Nullable<Camera>;
  11511. /**
  11512. * Should we display highlight as a solid stroke?
  11513. */
  11514. isStroke?: boolean;
  11515. /**
  11516. * The rendering group to draw the layer in.
  11517. */
  11518. renderingGroupId: number;
  11519. }
  11520. /**
  11521. * The highlight layer Helps adding a glow effect around a mesh.
  11522. *
  11523. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11524. * glowy meshes to your scene.
  11525. *
  11526. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11527. */
  11528. class HighlightLayer extends EffectLayer {
  11529. name: string;
  11530. /**
  11531. * Effect Name of the highlight layer.
  11532. */
  11533. static readonly EffectName: string;
  11534. /**
  11535. * The neutral color used during the preparation of the glow effect.
  11536. * This is black by default as the blend operation is a blend operation.
  11537. */
  11538. static NeutralColor: Color4;
  11539. /**
  11540. * Stencil value used for glowing meshes.
  11541. */
  11542. static GlowingMeshStencilReference: number;
  11543. /**
  11544. * Stencil value used for the other meshes in the scene.
  11545. */
  11546. static NormalMeshStencilReference: number;
  11547. /**
  11548. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11549. */
  11550. innerGlow: boolean;
  11551. /**
  11552. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11553. */
  11554. outerGlow: boolean;
  11555. /**
  11556. * Specifies the horizontal size of the blur.
  11557. */
  11558. /**
  11559. * Gets the horizontal size of the blur.
  11560. */
  11561. blurHorizontalSize: number;
  11562. /**
  11563. * Specifies the vertical size of the blur.
  11564. */
  11565. /**
  11566. * Gets the vertical size of the blur.
  11567. */
  11568. blurVerticalSize: number;
  11569. /**
  11570. * An event triggered when the highlight layer is being blurred.
  11571. */
  11572. onBeforeBlurObservable: Observable<HighlightLayer>;
  11573. /**
  11574. * An event triggered when the highlight layer has been blurred.
  11575. */
  11576. onAfterBlurObservable: Observable<HighlightLayer>;
  11577. private _instanceGlowingMeshStencilReference;
  11578. private _options;
  11579. private _downSamplePostprocess;
  11580. private _horizontalBlurPostprocess;
  11581. private _verticalBlurPostprocess;
  11582. private _blurTexture;
  11583. private _meshes;
  11584. private _excludedMeshes;
  11585. /**
  11586. * Instantiates a new highlight Layer and references it to the scene..
  11587. * @param name The name of the layer
  11588. * @param scene The scene to use the layer in
  11589. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11590. */
  11591. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11592. /**
  11593. * Get the effect name of the layer.
  11594. * @return The effect name
  11595. */
  11596. getEffectName(): string;
  11597. /**
  11598. * Create the merge effect. This is the shader use to blit the information back
  11599. * to the main canvas at the end of the scene rendering.
  11600. */
  11601. protected _createMergeEffect(): Effect;
  11602. /**
  11603. * Creates the render target textures and post processes used in the highlight layer.
  11604. */
  11605. protected _createTextureAndPostProcesses(): void;
  11606. /**
  11607. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11608. */
  11609. needStencil(): boolean;
  11610. /**
  11611. * Checks for the readiness of the element composing the layer.
  11612. * @param subMesh the mesh to check for
  11613. * @param useInstances specify wether or not to use instances to render the mesh
  11614. * @param emissiveTexture the associated emissive texture used to generate the glow
  11615. * @return true if ready otherwise, false
  11616. */
  11617. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11618. /**
  11619. * Implementation specific of rendering the generating effect on the main canvas.
  11620. * @param effect The effect used to render through
  11621. */
  11622. protected _internalRender(effect: Effect): void;
  11623. /**
  11624. * Returns true if the layer contains information to display, otherwise false.
  11625. */
  11626. shouldRender(): boolean;
  11627. /**
  11628. * Returns true if the mesh should render, otherwise false.
  11629. * @param mesh The mesh to render
  11630. * @returns true if it should render otherwise false
  11631. */
  11632. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11633. /**
  11634. * Sets the required values for both the emissive texture and and the main color.
  11635. */
  11636. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11637. /**
  11638. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11639. * @param mesh The mesh to exclude from the highlight layer
  11640. */
  11641. addExcludedMesh(mesh: Mesh): void;
  11642. /**
  11643. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11644. * @param mesh The mesh to highlight
  11645. */
  11646. removeExcludedMesh(mesh: Mesh): void;
  11647. /**
  11648. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11649. * @param mesh mesh to test
  11650. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11651. */
  11652. hasMesh(mesh: AbstractMesh): boolean;
  11653. /**
  11654. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11655. * @param mesh The mesh to highlight
  11656. * @param color The color of the highlight
  11657. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11658. */
  11659. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11660. /**
  11661. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11662. * @param mesh The mesh to highlight
  11663. */
  11664. removeMesh(mesh: Mesh): void;
  11665. /**
  11666. * Force the stencil to the normal expected value for none glowing parts
  11667. */
  11668. private _defaultStencilReference;
  11669. /**
  11670. * Free any resources and references associated to a mesh.
  11671. * Internal use
  11672. * @param mesh The mesh to free.
  11673. * @hidden
  11674. */
  11675. _disposeMesh(mesh: Mesh): void;
  11676. /**
  11677. * Dispose the highlight layer and free resources.
  11678. */
  11679. dispose(): void;
  11680. /**
  11681. * Gets the class name of the effect layer
  11682. * @returns the string with the class name of the effect layer
  11683. */
  11684. getClassName(): string;
  11685. /**
  11686. * Serializes this Highlight layer
  11687. * @returns a serialized Highlight layer object
  11688. */
  11689. serialize(): any;
  11690. /**
  11691. * Creates a Highlight layer from parsed Highlight layer data
  11692. * @param parsedHightlightLayer defines the Highlight layer data
  11693. * @param scene defines the current scene
  11694. * @param rootUrl defines the root URL containing the Highlight layer information
  11695. * @returns a parsed Highlight layer
  11696. */
  11697. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11698. }
  11699. }
  11700. declare module BABYLON {
  11701. class Layer {
  11702. name: string;
  11703. texture: Nullable<Texture>;
  11704. isBackground: boolean;
  11705. color: Color4;
  11706. scale: Vector2;
  11707. offset: Vector2;
  11708. alphaBlendingMode: number;
  11709. alphaTest: boolean;
  11710. layerMask: number;
  11711. private _scene;
  11712. private _vertexBuffers;
  11713. private _indexBuffer;
  11714. private _effect;
  11715. private _alphaTestEffect;
  11716. /**
  11717. * An event triggered when the layer is disposed.
  11718. */
  11719. onDisposeObservable: Observable<Layer>;
  11720. private _onDisposeObserver;
  11721. onDispose: () => void;
  11722. /**
  11723. * An event triggered before rendering the scene
  11724. */
  11725. onBeforeRenderObservable: Observable<Layer>;
  11726. private _onBeforeRenderObserver;
  11727. onBeforeRender: () => void;
  11728. /**
  11729. * An event triggered after rendering the scene
  11730. */
  11731. onAfterRenderObservable: Observable<Layer>;
  11732. private _onAfterRenderObserver;
  11733. onAfterRender: () => void;
  11734. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11735. private _createIndexBuffer;
  11736. /** @hidden */
  11737. _rebuild(): void;
  11738. render(): void;
  11739. dispose(): void;
  11740. }
  11741. }
  11742. declare module BABYLON {
  11743. interface AbstractScene {
  11744. /**
  11745. * The list of layers (background and foreground) of the scene
  11746. */
  11747. layers: Array<Layer>;
  11748. }
  11749. /**
  11750. * Defines the layer scene component responsible to manage any layers
  11751. * in a given scene.
  11752. */
  11753. class LayerSceneComponent implements ISceneComponent {
  11754. /**
  11755. * The component name helpfull to identify the component in the list of scene components.
  11756. */
  11757. readonly name: string;
  11758. /**
  11759. * The scene the component belongs to.
  11760. */
  11761. scene: Scene;
  11762. private _engine;
  11763. /**
  11764. * Creates a new instance of the component for the given scene
  11765. * @param scene Defines the scene to register the component in
  11766. */
  11767. constructor(scene: Scene);
  11768. /**
  11769. * Registers the component in a given scene
  11770. */
  11771. register(): void;
  11772. /**
  11773. * Rebuilds the elements related to this component in case of
  11774. * context lost for instance.
  11775. */
  11776. rebuild(): void;
  11777. /**
  11778. * Disposes the component and the associated ressources.
  11779. */
  11780. dispose(): void;
  11781. private _draw;
  11782. private _drawBackground;
  11783. private _drawForeground;
  11784. }
  11785. }
  11786. declare module BABYLON {
  11787. class LensFlare {
  11788. size: number;
  11789. position: number;
  11790. color: Color3;
  11791. texture: Nullable<Texture>;
  11792. alphaMode: number;
  11793. private _system;
  11794. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11795. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11796. dispose(): void;
  11797. }
  11798. }
  11799. declare module BABYLON {
  11800. class LensFlareSystem {
  11801. name: string;
  11802. lensFlares: LensFlare[];
  11803. borderLimit: number;
  11804. viewportBorder: number;
  11805. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11806. layerMask: number;
  11807. id: string;
  11808. private _scene;
  11809. private _emitter;
  11810. private _vertexBuffers;
  11811. private _indexBuffer;
  11812. private _effect;
  11813. private _positionX;
  11814. private _positionY;
  11815. private _isEnabled;
  11816. constructor(name: string, emitter: any, scene: Scene);
  11817. isEnabled: boolean;
  11818. getScene(): Scene;
  11819. getEmitter(): any;
  11820. setEmitter(newEmitter: any): void;
  11821. getEmitterPosition(): Vector3;
  11822. computeEffectivePosition(globalViewport: Viewport): boolean;
  11823. /** @hidden */
  11824. _isVisible(): boolean;
  11825. render(): boolean;
  11826. dispose(): void;
  11827. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11828. serialize(): any;
  11829. }
  11830. }
  11831. declare module BABYLON {
  11832. interface AbstractScene {
  11833. /**
  11834. * The list of lens flare system added to the scene
  11835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11836. */
  11837. lensFlareSystems: Array<LensFlareSystem>;
  11838. /**
  11839. * Removes the given lens flare system from this scene.
  11840. * @param toRemove The lens flare system to remove
  11841. * @returns The index of the removed lens flare system
  11842. */
  11843. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11844. /**
  11845. * Adds the given lens flare system to this scene
  11846. * @param newLensFlareSystem The lens flare system to add
  11847. */
  11848. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11849. /**
  11850. * Gets a lens flare system using its name
  11851. * @param name defines the name to look for
  11852. * @returns the lens flare system or null if not found
  11853. */
  11854. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11855. /**
  11856. * Gets a lens flare system using its id
  11857. * @param id defines the id to look for
  11858. * @returns the lens flare system or null if not found
  11859. */
  11860. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11861. }
  11862. /**
  11863. * Defines the lens flare scene component responsible to manage any lens flares
  11864. * in a given scene.
  11865. */
  11866. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11867. /**
  11868. * The component name helpfull to identify the component in the list of scene components.
  11869. */
  11870. readonly name: string;
  11871. /**
  11872. * The scene the component belongs to.
  11873. */
  11874. scene: Scene;
  11875. /**
  11876. * Creates a new instance of the component for the given scene
  11877. * @param scene Defines the scene to register the component in
  11878. */
  11879. constructor(scene: Scene);
  11880. /**
  11881. * Registers the component in a given scene
  11882. */
  11883. register(): void;
  11884. /**
  11885. * Rebuilds the elements related to this component in case of
  11886. * context lost for instance.
  11887. */
  11888. rebuild(): void;
  11889. /**
  11890. * Adds all the element from the container to the scene
  11891. * @param container the container holding the elements
  11892. */
  11893. addFromContainer(container: AbstractScene): void;
  11894. /**
  11895. * Removes all the elements in the container from the scene
  11896. * @param container contains the elements to remove
  11897. */
  11898. removeFromContainer(container: AbstractScene): void;
  11899. /**
  11900. * Serializes the component data to the specified json object
  11901. * @param serializationObject The object to serialize to
  11902. */
  11903. serialize(serializationObject: any): void;
  11904. /**
  11905. * Disposes the component and the associated ressources.
  11906. */
  11907. dispose(): void;
  11908. private _draw;
  11909. }
  11910. }
  11911. declare module BABYLON {
  11912. /**
  11913. * A directional light is defined by a direction (what a surprise!).
  11914. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11915. * 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.
  11916. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11917. */
  11918. class DirectionalLight extends ShadowLight {
  11919. private _shadowFrustumSize;
  11920. /**
  11921. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11922. */
  11923. /**
  11924. * Specifies a fix frustum size for the shadow generation.
  11925. */
  11926. shadowFrustumSize: number;
  11927. private _shadowOrthoScale;
  11928. /**
  11929. * Gets the shadow projection scale against the optimal computed one.
  11930. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11931. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11932. */
  11933. /**
  11934. * Sets the shadow projection scale against the optimal computed one.
  11935. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11936. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11937. */
  11938. shadowOrthoScale: number;
  11939. /**
  11940. * Automatically compute the projection matrix to best fit (including all the casters)
  11941. * on each frame.
  11942. */
  11943. autoUpdateExtends: boolean;
  11944. private _orthoLeft;
  11945. private _orthoRight;
  11946. private _orthoTop;
  11947. private _orthoBottom;
  11948. /**
  11949. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11950. * The directional light is emitted from everywhere in the given direction.
  11951. * It can cast shawdows.
  11952. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11953. * @param name The friendly name of the light
  11954. * @param direction The direction of the light
  11955. * @param scene The scene the light belongs to
  11956. */
  11957. constructor(name: string, direction: Vector3, scene: Scene);
  11958. /**
  11959. * Returns the string "DirectionalLight".
  11960. * @return The class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Returns the integer 1.
  11965. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11966. */
  11967. getTypeID(): number;
  11968. /**
  11969. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11970. * Returns the DirectionalLight Shadow projection matrix.
  11971. */
  11972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11973. /**
  11974. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11975. * Returns the DirectionalLight Shadow projection matrix.
  11976. */
  11977. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11978. /**
  11979. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11980. * Returns the DirectionalLight Shadow projection matrix.
  11981. */
  11982. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11983. protected _buildUniformLayout(): void;
  11984. /**
  11985. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11986. * @param effect The effect to update
  11987. * @param lightIndex The index of the light in the effect to update
  11988. * @returns The directional light
  11989. */
  11990. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11991. /**
  11992. * Gets the minZ used for shadow according to both the scene and the light.
  11993. *
  11994. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11995. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11996. * @param activeCamera The camera we are returning the min for
  11997. * @returns the depth min z
  11998. */
  11999. getDepthMinZ(activeCamera: Camera): number;
  12000. /**
  12001. * Gets the maxZ used for shadow according to both the scene and the light.
  12002. *
  12003. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12004. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12005. * @param activeCamera The camera we are returning the max for
  12006. * @returns the depth max z
  12007. */
  12008. getDepthMaxZ(activeCamera: Camera): number;
  12009. /**
  12010. * Prepares the list of defines specific to the light type.
  12011. * @param defines the list of defines
  12012. * @param lightIndex defines the index of the light for the effect
  12013. */
  12014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12015. }
  12016. }
  12017. declare module BABYLON {
  12018. /**
  12019. * The HemisphericLight simulates the ambient environment light,
  12020. * so the passed direction is the light reflection direction, not the incoming direction.
  12021. */
  12022. class HemisphericLight extends Light {
  12023. /**
  12024. * The groundColor is the light in the opposite direction to the one specified during creation.
  12025. * 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.
  12026. */
  12027. groundColor: Color3;
  12028. /**
  12029. * The light reflection direction, not the incoming direction.
  12030. */
  12031. direction: Vector3;
  12032. private _worldMatrix;
  12033. /**
  12034. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12035. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12036. * The HemisphericLight can't cast shadows.
  12037. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12038. * @param name The friendly name of the light
  12039. * @param direction The direction of the light reflection
  12040. * @param scene The scene the light belongs to
  12041. */
  12042. constructor(name: string, direction: Vector3, scene: Scene);
  12043. protected _buildUniformLayout(): void;
  12044. /**
  12045. * Returns the string "HemisphericLight".
  12046. * @return The class name
  12047. */
  12048. getClassName(): string;
  12049. /**
  12050. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12051. * Returns the updated direction.
  12052. * @param target The target the direction should point to
  12053. * @return The computed direction
  12054. */
  12055. setDirectionToTarget(target: Vector3): Vector3;
  12056. /**
  12057. * Returns the shadow generator associated to the light.
  12058. * @returns Always null for hemispheric lights because it does not support shadows.
  12059. */
  12060. getShadowGenerator(): Nullable<ShadowGenerator>;
  12061. /**
  12062. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12063. * @param effect The effect to update
  12064. * @param lightIndex The index of the light in the effect to update
  12065. * @returns The hemispheric light
  12066. */
  12067. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12068. /**
  12069. * @hidden internal use only.
  12070. */
  12071. _getWorldMatrix(): Matrix;
  12072. /**
  12073. * Returns the integer 3.
  12074. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12075. */
  12076. getTypeID(): number;
  12077. /**
  12078. * Prepares the list of defines specific to the light type.
  12079. * @param defines the list of defines
  12080. * @param lightIndex defines the index of the light for the effect
  12081. */
  12082. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12083. }
  12084. }
  12085. declare module BABYLON {
  12086. /**
  12087. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12088. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12089. * 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.
  12090. */
  12091. abstract class Light extends Node {
  12092. /**
  12093. * Falloff Default: light is falling off following the material specification:
  12094. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12095. */
  12096. static readonly FALLOFF_DEFAULT: number;
  12097. /**
  12098. * Falloff Physical: light is falling off following the inverse squared distance law.
  12099. */
  12100. static readonly FALLOFF_PHYSICAL: number;
  12101. /**
  12102. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12103. * to enhance interoperability with other engines.
  12104. */
  12105. static readonly FALLOFF_GLTF: number;
  12106. /**
  12107. * Falloff Standard: light is falling off like in the standard material
  12108. * to enhance interoperability with other materials.
  12109. */
  12110. static readonly FALLOFF_STANDARD: number;
  12111. /**
  12112. * If every light affecting the material is in this lightmapMode,
  12113. * material.lightmapTexture adds or multiplies
  12114. * (depends on material.useLightmapAsShadowmap)
  12115. * after every other light calculations.
  12116. */
  12117. static readonly LIGHTMAP_DEFAULT: number;
  12118. /**
  12119. * material.lightmapTexture as only diffuse lighting from this light
  12120. * adds only specular lighting from this light
  12121. * adds dynamic shadows
  12122. */
  12123. static readonly LIGHTMAP_SPECULAR: number;
  12124. /**
  12125. * material.lightmapTexture as only lighting
  12126. * no light calculation from this light
  12127. * only adds dynamic shadows from this light
  12128. */
  12129. static readonly LIGHTMAP_SHADOWSONLY: number;
  12130. /**
  12131. * Each light type uses the default quantity according to its type:
  12132. * point/spot lights use luminous intensity
  12133. * directional lights use illuminance
  12134. */
  12135. static readonly INTENSITYMODE_AUTOMATIC: number;
  12136. /**
  12137. * lumen (lm)
  12138. */
  12139. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12140. /**
  12141. * candela (lm/sr)
  12142. */
  12143. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12144. /**
  12145. * lux (lm/m^2)
  12146. */
  12147. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12148. /**
  12149. * nit (cd/m^2)
  12150. */
  12151. static readonly INTENSITYMODE_LUMINANCE: number;
  12152. /**
  12153. * Light type const id of the point light.
  12154. */
  12155. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12156. /**
  12157. * Light type const id of the directional light.
  12158. */
  12159. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12160. /**
  12161. * Light type const id of the spot light.
  12162. */
  12163. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12164. /**
  12165. * Light type const id of the hemispheric light.
  12166. */
  12167. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12168. /**
  12169. * Diffuse gives the basic color to an object.
  12170. */
  12171. diffuse: Color3;
  12172. /**
  12173. * Specular produces a highlight color on an object.
  12174. * Note: This is note affecting PBR materials.
  12175. */
  12176. specular: Color3;
  12177. /**
  12178. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12179. * falling off base on range or angle.
  12180. * This can be set to any values in Light.FALLOFF_x.
  12181. *
  12182. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12183. * other types of materials.
  12184. */
  12185. falloffType: number;
  12186. /**
  12187. * Strength of the light.
  12188. * Note: By default it is define in the framework own unit.
  12189. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12190. */
  12191. intensity: number;
  12192. private _range;
  12193. protected _inverseSquaredRange: number;
  12194. /**
  12195. * Defines how far from the source the light is impacting in scene units.
  12196. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12197. */
  12198. /**
  12199. * Defines how far from the source the light is impacting in scene units.
  12200. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12201. */
  12202. range: number;
  12203. /**
  12204. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12205. * of light.
  12206. */
  12207. private _photometricScale;
  12208. private _intensityMode;
  12209. /**
  12210. * Gets the photometric scale used to interpret the intensity.
  12211. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12212. */
  12213. /**
  12214. * Sets the photometric scale used to interpret the intensity.
  12215. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12216. */
  12217. intensityMode: number;
  12218. private _radius;
  12219. /**
  12220. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12221. */
  12222. /**
  12223. * sets the light radius used by PBR Materials to simulate soft area lights.
  12224. */
  12225. radius: number;
  12226. private _renderPriority;
  12227. /**
  12228. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12229. * exceeding the number allowed of the materials.
  12230. */
  12231. renderPriority: number;
  12232. private _shadowEnabled;
  12233. /**
  12234. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12235. * the current shadow generator.
  12236. */
  12237. /**
  12238. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12239. * the current shadow generator.
  12240. */
  12241. shadowEnabled: boolean;
  12242. private _includedOnlyMeshes;
  12243. /**
  12244. * Gets the only meshes impacted by this light.
  12245. */
  12246. /**
  12247. * Sets the only meshes impacted by this light.
  12248. */
  12249. includedOnlyMeshes: AbstractMesh[];
  12250. private _excludedMeshes;
  12251. /**
  12252. * Gets the meshes not impacted by this light.
  12253. */
  12254. /**
  12255. * Sets the meshes not impacted by this light.
  12256. */
  12257. excludedMeshes: AbstractMesh[];
  12258. private _excludeWithLayerMask;
  12259. /**
  12260. * Gets the layer id use to find what meshes are not impacted by the light.
  12261. * Inactive if 0
  12262. */
  12263. /**
  12264. * Sets the layer id use to find what meshes are not impacted by the light.
  12265. * Inactive if 0
  12266. */
  12267. excludeWithLayerMask: number;
  12268. private _includeOnlyWithLayerMask;
  12269. /**
  12270. * Gets the layer id use to find what meshes are impacted by the light.
  12271. * Inactive if 0
  12272. */
  12273. /**
  12274. * Sets the layer id use to find what meshes are impacted by the light.
  12275. * Inactive if 0
  12276. */
  12277. includeOnlyWithLayerMask: number;
  12278. private _lightmapMode;
  12279. /**
  12280. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12281. */
  12282. /**
  12283. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12284. */
  12285. lightmapMode: number;
  12286. private _parentedWorldMatrix;
  12287. /**
  12288. * Shadow generator associted to the light.
  12289. * @hidden Internal use only.
  12290. */
  12291. _shadowGenerator: Nullable<IShadowGenerator>;
  12292. /**
  12293. * @hidden Internal use only.
  12294. */
  12295. _excludedMeshesIds: string[];
  12296. /**
  12297. * @hidden Internal use only.
  12298. */
  12299. _includedOnlyMeshesIds: string[];
  12300. /**
  12301. * The current light unifom buffer.
  12302. * @hidden Internal use only.
  12303. */
  12304. _uniformBuffer: UniformBuffer;
  12305. /**
  12306. * Creates a Light object in the scene.
  12307. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12308. * @param name The firendly name of the light
  12309. * @param scene The scene the light belongs too
  12310. */
  12311. constructor(name: string, scene: Scene);
  12312. protected abstract _buildUniformLayout(): void;
  12313. /**
  12314. * Sets the passed Effect "effect" with the Light information.
  12315. * @param effect The effect to update
  12316. * @param lightIndex The index of the light in the effect to update
  12317. * @returns The light
  12318. */
  12319. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12320. /**
  12321. * @hidden internal use only.
  12322. */
  12323. abstract _getWorldMatrix(): Matrix;
  12324. /**
  12325. * Returns the string "Light".
  12326. * @returns the class name
  12327. */
  12328. getClassName(): string;
  12329. /**
  12330. * Converts the light information to a readable string for debug purpose.
  12331. * @param fullDetails Supports for multiple levels of logging within scene loading
  12332. * @returns the human readable light info
  12333. */
  12334. toString(fullDetails?: boolean): string;
  12335. /**
  12336. * Set the enabled state of this node.
  12337. * @param value - the new enabled state
  12338. */
  12339. setEnabled(value: boolean): void;
  12340. /**
  12341. * Returns the Light associated shadow generator if any.
  12342. * @return the associated shadow generator.
  12343. */
  12344. getShadowGenerator(): Nullable<IShadowGenerator>;
  12345. /**
  12346. * Returns a Vector3, the absolute light position in the World.
  12347. * @returns the world space position of the light
  12348. */
  12349. getAbsolutePosition(): Vector3;
  12350. /**
  12351. * Specifies if the light will affect the passed mesh.
  12352. * @param mesh The mesh to test against the light
  12353. * @return true the mesh is affected otherwise, false.
  12354. */
  12355. canAffectMesh(mesh: AbstractMesh): boolean;
  12356. /**
  12357. * Computes and Returns the light World matrix.
  12358. * @returns the world matrix
  12359. */
  12360. getWorldMatrix(): Matrix;
  12361. /**
  12362. * Sort function to order lights for rendering.
  12363. * @param a First Light object to compare to second.
  12364. * @param b Second Light object to compare first.
  12365. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12366. */
  12367. static CompareLightsPriority(a: Light, b: Light): number;
  12368. /**
  12369. * Releases resources associated with this node.
  12370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12372. */
  12373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12374. /**
  12375. * Returns the light type ID (integer).
  12376. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12377. */
  12378. getTypeID(): number;
  12379. /**
  12380. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12381. * @returns the scaled intensity in intensity mode unit
  12382. */
  12383. getScaledIntensity(): number;
  12384. /**
  12385. * Returns a new Light object, named "name", from the current one.
  12386. * @param name The name of the cloned light
  12387. * @returns the new created light
  12388. */
  12389. clone(name: string): Nullable<Light>;
  12390. /**
  12391. * Serializes the current light into a Serialization object.
  12392. * @returns the serialized object.
  12393. */
  12394. serialize(): any;
  12395. /**
  12396. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12397. * This new light is named "name" and added to the passed scene.
  12398. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12399. * @param name The friendly name of the light
  12400. * @param scene The scene the new light will belong to
  12401. * @returns the constructor function
  12402. */
  12403. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12404. /**
  12405. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12406. * @param parsedLight The JSON representation of the light
  12407. * @param scene The scene to create the parsed light in
  12408. * @returns the created light after parsing
  12409. */
  12410. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12411. private _hookArrayForExcluded;
  12412. private _hookArrayForIncludedOnly;
  12413. private _resyncMeshes;
  12414. /**
  12415. * Forces the meshes to update their light related information in their rendering used effects
  12416. * @hidden Internal Use Only
  12417. */
  12418. _markMeshesAsLightDirty(): void;
  12419. /**
  12420. * Recomputes the cached photometric scale if needed.
  12421. */
  12422. private _computePhotometricScale;
  12423. /**
  12424. * Returns the Photometric Scale according to the light type and intensity mode.
  12425. */
  12426. private _getPhotometricScale;
  12427. /**
  12428. * Reorder the light in the scene according to their defined priority.
  12429. * @hidden Internal Use Only
  12430. */
  12431. _reorderLightsInScene(): void;
  12432. /**
  12433. * Prepares the list of defines specific to the light type.
  12434. * @param defines the list of defines
  12435. * @param lightIndex defines the index of the light for the effect
  12436. */
  12437. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12438. }
  12439. }
  12440. declare module BABYLON {
  12441. /**
  12442. * A point light is a light defined by an unique point in world space.
  12443. * The light is emitted in every direction from this point.
  12444. * A good example of a point light is a standard light bulb.
  12445. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12446. */
  12447. class PointLight extends ShadowLight {
  12448. private _shadowAngle;
  12449. /**
  12450. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12451. * This specifies what angle the shadow will use to be created.
  12452. *
  12453. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12454. */
  12455. /**
  12456. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12457. * This specifies what angle the shadow will use to be created.
  12458. *
  12459. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12460. */
  12461. shadowAngle: number;
  12462. /**
  12463. * Gets the direction if it has been set.
  12464. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12465. */
  12466. /**
  12467. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12468. */
  12469. direction: Vector3;
  12470. /**
  12471. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12472. * A PointLight emits the light in every direction.
  12473. * It can cast shadows.
  12474. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12475. * ```javascript
  12476. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12477. * ```
  12478. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12479. * @param name The light friendly name
  12480. * @param position The position of the point light in the scene
  12481. * @param scene The scene the lights belongs to
  12482. */
  12483. constructor(name: string, position: Vector3, scene: Scene);
  12484. /**
  12485. * Returns the string "PointLight"
  12486. * @returns the class name
  12487. */
  12488. getClassName(): string;
  12489. /**
  12490. * Returns the integer 0.
  12491. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12492. */
  12493. getTypeID(): number;
  12494. /**
  12495. * Specifies wether or not the shadowmap should be a cube texture.
  12496. * @returns true if the shadowmap needs to be a cube texture.
  12497. */
  12498. needCube(): boolean;
  12499. /**
  12500. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12501. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12502. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12503. */
  12504. getShadowDirection(faceIndex?: number): Vector3;
  12505. /**
  12506. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12507. * - fov = PI / 2
  12508. * - aspect ratio : 1.0
  12509. * - z-near and far equal to the active camera minZ and maxZ.
  12510. * Returns the PointLight.
  12511. */
  12512. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12513. protected _buildUniformLayout(): void;
  12514. /**
  12515. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12516. * @param effect The effect to update
  12517. * @param lightIndex The index of the light in the effect to update
  12518. * @returns The point light
  12519. */
  12520. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12521. /**
  12522. * Prepares the list of defines specific to the light type.
  12523. * @param defines the list of defines
  12524. * @param lightIndex defines the index of the light for the effect
  12525. */
  12526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /**
  12531. * Interface describing all the common properties and methods a shadow light needs to implement.
  12532. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12533. * as well as binding the different shadow properties to the effects.
  12534. */
  12535. interface IShadowLight extends Light {
  12536. /**
  12537. * The light id in the scene (used in scene.findLighById for instance)
  12538. */
  12539. id: string;
  12540. /**
  12541. * The position the shdow will be casted from.
  12542. */
  12543. position: Vector3;
  12544. /**
  12545. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12546. */
  12547. direction: Vector3;
  12548. /**
  12549. * The transformed position. Position of the light in world space taking parenting in account.
  12550. */
  12551. transformedPosition: Vector3;
  12552. /**
  12553. * The transformed direction. Direction of the light in world space taking parenting in account.
  12554. */
  12555. transformedDirection: Vector3;
  12556. /**
  12557. * The friendly name of the light in the scene.
  12558. */
  12559. name: string;
  12560. /**
  12561. * Defines the shadow projection clipping minimum z value.
  12562. */
  12563. shadowMinZ: number;
  12564. /**
  12565. * Defines the shadow projection clipping maximum z value.
  12566. */
  12567. shadowMaxZ: number;
  12568. /**
  12569. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12570. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12571. */
  12572. computeTransformedInformation(): boolean;
  12573. /**
  12574. * Gets the scene the light belongs to.
  12575. * @returns The scene
  12576. */
  12577. getScene(): Scene;
  12578. /**
  12579. * Callback defining a custom Projection Matrix Builder.
  12580. * This can be used to override the default projection matrix computation.
  12581. */
  12582. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12583. /**
  12584. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12585. * @param matrix The materix to updated with the projection information
  12586. * @param viewMatrix The transform matrix of the light
  12587. * @param renderList The list of mesh to render in the map
  12588. * @returns The current light
  12589. */
  12590. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12591. /**
  12592. * Gets the current depth scale used in ESM.
  12593. * @returns The scale
  12594. */
  12595. getDepthScale(): number;
  12596. /**
  12597. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12598. * @returns true if a cube texture needs to be use
  12599. */
  12600. needCube(): boolean;
  12601. /**
  12602. * Detects if the projection matrix requires to be recomputed this frame.
  12603. * @returns true if it requires to be recomputed otherwise, false.
  12604. */
  12605. needProjectionMatrixCompute(): boolean;
  12606. /**
  12607. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12608. */
  12609. forceProjectionMatrixCompute(): void;
  12610. /**
  12611. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12612. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12613. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12614. */
  12615. getShadowDirection(faceIndex?: number): Vector3;
  12616. /**
  12617. * Gets the minZ used for shadow according to both the scene and the light.
  12618. * @param activeCamera The camera we are returning the min for
  12619. * @returns the depth min z
  12620. */
  12621. getDepthMinZ(activeCamera: Camera): number;
  12622. /**
  12623. * Gets the maxZ used for shadow according to both the scene and the light.
  12624. * @param activeCamera The camera we are returning the max for
  12625. * @returns the depth max z
  12626. */
  12627. getDepthMaxZ(activeCamera: Camera): number;
  12628. }
  12629. /**
  12630. * Base implementation IShadowLight
  12631. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12632. */
  12633. abstract class ShadowLight extends Light implements IShadowLight {
  12634. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12635. protected _position: Vector3;
  12636. protected _setPosition(value: Vector3): void;
  12637. /**
  12638. * Sets the position the shadow will be casted from. Also use as the light position for both
  12639. * point and spot lights.
  12640. */
  12641. /**
  12642. * Sets the position the shadow will be casted from. Also use as the light position for both
  12643. * point and spot lights.
  12644. */
  12645. position: Vector3;
  12646. protected _direction: Vector3;
  12647. protected _setDirection(value: Vector3): void;
  12648. /**
  12649. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12650. * Also use as the light direction on spot and directional lights.
  12651. */
  12652. /**
  12653. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12654. * Also use as the light direction on spot and directional lights.
  12655. */
  12656. direction: Vector3;
  12657. private _shadowMinZ;
  12658. /**
  12659. * Gets the shadow projection clipping minimum z value.
  12660. */
  12661. /**
  12662. * Sets the shadow projection clipping minimum z value.
  12663. */
  12664. shadowMinZ: number;
  12665. private _shadowMaxZ;
  12666. /**
  12667. * Sets the shadow projection clipping maximum z value.
  12668. */
  12669. /**
  12670. * Gets the shadow projection clipping maximum z value.
  12671. */
  12672. shadowMaxZ: number;
  12673. /**
  12674. * Callback defining a custom Projection Matrix Builder.
  12675. * This can be used to override the default projection matrix computation.
  12676. */
  12677. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12678. /**
  12679. * The transformed position. Position of the light in world space taking parenting in account.
  12680. */
  12681. transformedPosition: Vector3;
  12682. /**
  12683. * The transformed direction. Direction of the light in world space taking parenting in account.
  12684. */
  12685. transformedDirection: Vector3;
  12686. private _worldMatrix;
  12687. private _needProjectionMatrixCompute;
  12688. /**
  12689. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12690. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12691. */
  12692. computeTransformedInformation(): boolean;
  12693. /**
  12694. * Return the depth scale used for the shadow map.
  12695. * @returns the depth scale.
  12696. */
  12697. getDepthScale(): number;
  12698. /**
  12699. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12700. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12701. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12702. */
  12703. getShadowDirection(faceIndex?: number): Vector3;
  12704. /**
  12705. * Returns the ShadowLight absolute position in the World.
  12706. * @returns the position vector in world space
  12707. */
  12708. getAbsolutePosition(): Vector3;
  12709. /**
  12710. * Sets the ShadowLight direction toward the passed target.
  12711. * @param target The point tot target in local space
  12712. * @returns the updated ShadowLight direction
  12713. */
  12714. setDirectionToTarget(target: Vector3): Vector3;
  12715. /**
  12716. * Returns the light rotation in euler definition.
  12717. * @returns the x y z rotation in local space.
  12718. */
  12719. getRotation(): Vector3;
  12720. /**
  12721. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12722. * @returns true if a cube texture needs to be use
  12723. */
  12724. needCube(): boolean;
  12725. /**
  12726. * Detects if the projection matrix requires to be recomputed this frame.
  12727. * @returns true if it requires to be recomputed otherwise, false.
  12728. */
  12729. needProjectionMatrixCompute(): boolean;
  12730. /**
  12731. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12732. */
  12733. forceProjectionMatrixCompute(): void;
  12734. /**
  12735. * Get the world matrix of the sahdow lights.
  12736. * @hidden Internal Use Only
  12737. */
  12738. _getWorldMatrix(): Matrix;
  12739. /**
  12740. * Gets the minZ used for shadow according to both the scene and the light.
  12741. * @param activeCamera The camera we are returning the min for
  12742. * @returns the depth min z
  12743. */
  12744. getDepthMinZ(activeCamera: Camera): number;
  12745. /**
  12746. * Gets the maxZ used for shadow according to both the scene and the light.
  12747. * @param activeCamera The camera we are returning the max for
  12748. * @returns the depth max z
  12749. */
  12750. getDepthMaxZ(activeCamera: Camera): number;
  12751. /**
  12752. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12753. * @param matrix The materix to updated with the projection information
  12754. * @param viewMatrix The transform matrix of the light
  12755. * @param renderList The list of mesh to render in the map
  12756. * @returns The current light
  12757. */
  12758. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12759. }
  12760. }
  12761. declare module BABYLON {
  12762. /**
  12763. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12764. * These values define a cone of light starting from the position, emitting toward the direction.
  12765. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12766. * and the exponent defines the speed of the decay of the light with distance (reach).
  12767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12768. */
  12769. class SpotLight extends ShadowLight {
  12770. private _angle;
  12771. private _innerAngle;
  12772. private _cosHalfAngle;
  12773. private _lightAngleScale;
  12774. private _lightAngleOffset;
  12775. /**
  12776. * Gets the cone angle of the spot light in Radians.
  12777. */
  12778. /**
  12779. * Sets the cone angle of the spot light in Radians.
  12780. */
  12781. angle: number;
  12782. /**
  12783. * Only used in gltf falloff mode, this defines the angle where
  12784. * the directional falloff will start before cutting at angle which could be seen
  12785. * as outer angle.
  12786. */
  12787. /**
  12788. * Only used in gltf falloff mode, this defines the angle where
  12789. * the directional falloff will start before cutting at angle which could be seen
  12790. * as outer angle.
  12791. */
  12792. innerAngle: number;
  12793. private _shadowAngleScale;
  12794. /**
  12795. * Allows scaling the angle of the light for shadow generation only.
  12796. */
  12797. /**
  12798. * Allows scaling the angle of the light for shadow generation only.
  12799. */
  12800. shadowAngleScale: number;
  12801. /**
  12802. * The light decay speed with the distance from the emission spot.
  12803. */
  12804. exponent: number;
  12805. private _projectionTextureMatrix;
  12806. /**
  12807. * Allows reading the projecton texture
  12808. */
  12809. readonly projectionTextureMatrix: Matrix;
  12810. protected _projectionTextureLightNear: number;
  12811. /**
  12812. * Gets the near clip of the Spotlight for texture projection.
  12813. */
  12814. /**
  12815. * Sets the near clip of the Spotlight for texture projection.
  12816. */
  12817. projectionTextureLightNear: number;
  12818. protected _projectionTextureLightFar: number;
  12819. /**
  12820. * Gets the far clip of the Spotlight for texture projection.
  12821. */
  12822. /**
  12823. * Sets the far clip of the Spotlight for texture projection.
  12824. */
  12825. projectionTextureLightFar: number;
  12826. protected _projectionTextureUpDirection: Vector3;
  12827. /**
  12828. * Gets the Up vector of the Spotlight for texture projection.
  12829. */
  12830. /**
  12831. * Sets the Up vector of the Spotlight for texture projection.
  12832. */
  12833. projectionTextureUpDirection: Vector3;
  12834. private _projectionTexture;
  12835. /**
  12836. * Gets the projection texture of the light.
  12837. */
  12838. /**
  12839. * Sets the projection texture of the light.
  12840. */
  12841. projectionTexture: Nullable<BaseTexture>;
  12842. private _projectionTextureViewLightDirty;
  12843. private _projectionTextureProjectionLightDirty;
  12844. private _projectionTextureDirty;
  12845. private _projectionTextureViewTargetVector;
  12846. private _projectionTextureViewLightMatrix;
  12847. private _projectionTextureProjectionLightMatrix;
  12848. private _projectionTextureScalingMatrix;
  12849. /**
  12850. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12851. * It can cast shadows.
  12852. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12853. * @param name The light friendly name
  12854. * @param position The position of the spot light in the scene
  12855. * @param direction The direction of the light in the scene
  12856. * @param angle The cone angle of the light in Radians
  12857. * @param exponent The light decay speed with the distance from the emission spot
  12858. * @param scene The scene the lights belongs to
  12859. */
  12860. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12861. /**
  12862. * Returns the string "SpotLight".
  12863. * @returns the class name
  12864. */
  12865. getClassName(): string;
  12866. /**
  12867. * Returns the integer 2.
  12868. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12869. */
  12870. getTypeID(): number;
  12871. /**
  12872. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12873. */
  12874. protected _setDirection(value: Vector3): void;
  12875. /**
  12876. * Overrides the position setter to recompute the projection texture view light Matrix.
  12877. */
  12878. protected _setPosition(value: Vector3): void;
  12879. /**
  12880. * 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.
  12881. * Returns the SpotLight.
  12882. */
  12883. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12884. protected _computeProjectionTextureViewLightMatrix(): void;
  12885. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12886. /**
  12887. * Main function for light texture projection matrix computing.
  12888. */
  12889. protected _computeProjectionTextureMatrix(): void;
  12890. protected _buildUniformLayout(): void;
  12891. private _computeAngleValues;
  12892. /**
  12893. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12894. * @param effect The effect to update
  12895. * @param lightIndex The index of the light in the effect to update
  12896. * @returns The spot light
  12897. */
  12898. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12899. /**
  12900. * Disposes the light and the associated resources.
  12901. */
  12902. dispose(): void;
  12903. /**
  12904. * Prepares the list of defines specific to the light type.
  12905. * @param defines the list of defines
  12906. * @param lightIndex defines the index of the light for the effect
  12907. */
  12908. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12909. }
  12910. }
  12911. declare module BABYLON {
  12912. interface ILoadingScreen {
  12913. displayLoadingUI: () => void;
  12914. hideLoadingUI: () => void;
  12915. loadingUIBackgroundColor: string;
  12916. loadingUIText: string;
  12917. }
  12918. class DefaultLoadingScreen implements ILoadingScreen {
  12919. private _renderingCanvas;
  12920. private _loadingText;
  12921. private _loadingDivBackgroundColor;
  12922. private _loadingDiv;
  12923. private _loadingTextDiv;
  12924. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12925. displayLoadingUI(): void;
  12926. hideLoadingUI(): void;
  12927. loadingUIText: string;
  12928. loadingUIBackgroundColor: string;
  12929. private _resizeLoadingUI;
  12930. }
  12931. }
  12932. declare module BABYLON {
  12933. class SceneLoaderProgressEvent {
  12934. readonly lengthComputable: boolean;
  12935. readonly loaded: number;
  12936. readonly total: number;
  12937. constructor(lengthComputable: boolean, loaded: number, total: number);
  12938. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12939. }
  12940. interface ISceneLoaderPluginExtensions {
  12941. [extension: string]: {
  12942. isBinary: boolean;
  12943. };
  12944. }
  12945. interface ISceneLoaderPluginFactory {
  12946. name: string;
  12947. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12948. canDirectLoad?: (data: string) => boolean;
  12949. }
  12950. interface ISceneLoaderPlugin {
  12951. /**
  12952. * The friendly name of this plugin.
  12953. */
  12954. name: string;
  12955. /**
  12956. * The file extensions supported by this plugin.
  12957. */
  12958. extensions: string | ISceneLoaderPluginExtensions;
  12959. /**
  12960. * Import meshes into a scene.
  12961. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12962. * @param scene The scene to import into
  12963. * @param data The data to import
  12964. * @param rootUrl The root url for scene and resources
  12965. * @param meshes The meshes array to import into
  12966. * @param particleSystems The particle systems array to import into
  12967. * @param skeletons The skeletons array to import into
  12968. * @param onError The callback when import fails
  12969. * @returns True if successful or false otherwise
  12970. */
  12971. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12972. /**
  12973. * Load into a scene.
  12974. * @param scene The scene to load into
  12975. * @param data The data to import
  12976. * @param rootUrl The root url for scene and resources
  12977. * @param onError The callback when import fails
  12978. * @returns true if successful or false otherwise
  12979. */
  12980. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12981. /**
  12982. * The callback that returns true if the data can be directly loaded.
  12983. */
  12984. canDirectLoad?: (data: string) => boolean;
  12985. /**
  12986. * The callback that allows custom handling of the root url based on the response url.
  12987. */
  12988. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12989. /**
  12990. * Load into an asset container.
  12991. * @param scene The scene to load into
  12992. * @param data The data to import
  12993. * @param rootUrl The root url for scene and resources
  12994. * @param onError The callback when import fails
  12995. * @returns The loaded asset container
  12996. */
  12997. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12998. }
  12999. interface ISceneLoaderPluginAsync {
  13000. /**
  13001. * The friendly name of this plugin.
  13002. */
  13003. name: string;
  13004. /**
  13005. * The file extensions supported by this plugin.
  13006. */
  13007. extensions: string | ISceneLoaderPluginExtensions;
  13008. /**
  13009. * Import meshes into a scene.
  13010. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13011. * @param scene The scene to import into
  13012. * @param data The data to import
  13013. * @param rootUrl The root url for scene and resources
  13014. * @param onProgress The callback when the load progresses
  13015. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13016. */
  13017. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  13018. meshes: AbstractMesh[];
  13019. particleSystems: IParticleSystem[];
  13020. skeletons: Skeleton[];
  13021. animationGroups: AnimationGroup[];
  13022. }>;
  13023. /**
  13024. * Load into a scene.
  13025. * @param scene The scene to load into
  13026. * @param data The data to import
  13027. * @param rootUrl The root url for scene and resources
  13028. * @param onProgress The callback when the load progresses
  13029. * @returns Nothing
  13030. */
  13031. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  13032. /**
  13033. * The callback that returns true if the data can be directly loaded.
  13034. */
  13035. canDirectLoad?: (data: string) => boolean;
  13036. /**
  13037. * The callback that allows custom handling of the root url based on the response url.
  13038. */
  13039. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13040. /**
  13041. * Load into an asset container.
  13042. * @param scene The scene to load into
  13043. * @param data The data to import
  13044. * @param rootUrl The root url for scene and resources
  13045. * @param onProgress The callback when the load progresses
  13046. * @returns The loaded asset container
  13047. */
  13048. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  13049. }
  13050. class SceneLoader {
  13051. private static _ForceFullSceneLoadingForIncremental;
  13052. private static _ShowLoadingScreen;
  13053. private static _CleanBoneMatrixWeights;
  13054. static readonly NO_LOGGING: number;
  13055. static readonly MINIMAL_LOGGING: number;
  13056. static readonly SUMMARY_LOGGING: number;
  13057. static readonly DETAILED_LOGGING: number;
  13058. private static _loggingLevel;
  13059. static ForceFullSceneLoadingForIncremental: boolean;
  13060. static ShowLoadingScreen: boolean;
  13061. static loggingLevel: number;
  13062. static CleanBoneMatrixWeights: boolean;
  13063. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13064. private static _registeredPlugins;
  13065. private static _getDefaultPlugin;
  13066. private static _getPluginForExtension;
  13067. private static _getPluginForDirectLoad;
  13068. private static _getPluginForFilename;
  13069. private static _getDirectLoad;
  13070. private static _loadData;
  13071. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13072. static IsPluginForExtensionAvailable(extension: string): boolean;
  13073. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  13074. /**
  13075. * Import meshes into a scene
  13076. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13077. * @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)
  13078. * @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)
  13079. * @param scene the instance of BABYLON.Scene to append to
  13080. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13081. * @param onProgress a callback with a progress event for each file being loaded
  13082. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13083. * @param pluginExtension the extension used to determine the plugin
  13084. * @returns The loaded plugin
  13085. */
  13086. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13087. /**
  13088. * Import meshes into a scene
  13089. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13090. * @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)
  13091. * @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)
  13092. * @param scene the instance of BABYLON.Scene to append to
  13093. * @param onProgress a callback with a progress event for each file being loaded
  13094. * @param pluginExtension the extension used to determine the plugin
  13095. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13096. */
  13097. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13098. meshes: AbstractMesh[];
  13099. particleSystems: IParticleSystem[];
  13100. skeletons: Skeleton[];
  13101. animationGroups: AnimationGroup[];
  13102. }>;
  13103. /**
  13104. * Load a scene
  13105. * @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)
  13106. * @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)
  13107. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13108. * @param onSuccess a callback with the scene when import succeeds
  13109. * @param onProgress a callback with a progress event for each file being loaded
  13110. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13111. * @param pluginExtension the extension used to determine the plugin
  13112. * @returns The loaded plugin
  13113. */
  13114. 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>;
  13115. /**
  13116. * Load a scene
  13117. * @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)
  13118. * @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)
  13119. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13120. * @param onProgress a callback with a progress event for each file being loaded
  13121. * @param pluginExtension the extension used to determine the plugin
  13122. * @returns The loaded scene
  13123. */
  13124. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13125. /**
  13126. * Append a scene
  13127. * @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)
  13128. * @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)
  13129. * @param scene is the instance of BABYLON.Scene to append to
  13130. * @param onSuccess a callback with the scene when import succeeds
  13131. * @param onProgress a callback with a progress event for each file being loaded
  13132. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13133. * @param pluginExtension the extension used to determine the plugin
  13134. * @returns The loaded plugin
  13135. */
  13136. 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>;
  13137. /**
  13138. * Append a scene
  13139. * @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)
  13140. * @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)
  13141. * @param scene is the instance of BABYLON.Scene to append to
  13142. * @param onProgress a callback with a progress event for each file being loaded
  13143. * @param pluginExtension the extension used to determine the plugin
  13144. * @returns The given scene
  13145. */
  13146. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13147. /**
  13148. * Load a scene into an asset container
  13149. * @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)
  13150. * @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)
  13151. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13152. * @param onSuccess a callback with the scene when import succeeds
  13153. * @param onProgress a callback with a progress event for each file being loaded
  13154. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13155. * @param pluginExtension the extension used to determine the plugin
  13156. * @returns The loaded plugin
  13157. */
  13158. 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>;
  13159. /**
  13160. * Load a scene into an asset container
  13161. * @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)
  13162. * @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)
  13163. * @param scene is the instance of BABYLON.Scene to append to
  13164. * @param onProgress a callback with a progress event for each file being loaded
  13165. * @param pluginExtension the extension used to determine the plugin
  13166. * @returns The loaded asset container
  13167. */
  13168. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13169. }
  13170. }
  13171. declare module BABYLON {
  13172. /**
  13173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13175. * 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;
  13176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13177. */
  13178. class ColorCurves {
  13179. private _dirty;
  13180. private _tempColor;
  13181. private _globalCurve;
  13182. private _highlightsCurve;
  13183. private _midtonesCurve;
  13184. private _shadowsCurve;
  13185. private _positiveCurve;
  13186. private _negativeCurve;
  13187. private _globalHue;
  13188. private _globalDensity;
  13189. private _globalSaturation;
  13190. private _globalExposure;
  13191. /**
  13192. * Gets the global Hue value.
  13193. * 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).
  13194. */
  13195. /**
  13196. * Sets the global Hue value.
  13197. * 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).
  13198. */
  13199. globalHue: number;
  13200. /**
  13201. * Gets the global Density value.
  13202. * 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.
  13203. * Values less than zero provide a filter of opposite hue.
  13204. */
  13205. /**
  13206. * Sets the global Density value.
  13207. * 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.
  13208. * Values less than zero provide a filter of opposite hue.
  13209. */
  13210. globalDensity: number;
  13211. /**
  13212. * Gets the global Saturation value.
  13213. * 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.
  13214. */
  13215. /**
  13216. * Sets the global Saturation value.
  13217. * 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.
  13218. */
  13219. globalSaturation: number;
  13220. /**
  13221. * Gets the global Exposure value.
  13222. * 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.
  13223. */
  13224. /**
  13225. * Sets the global Exposure value.
  13226. * 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.
  13227. */
  13228. globalExposure: number;
  13229. private _highlightsHue;
  13230. private _highlightsDensity;
  13231. private _highlightsSaturation;
  13232. private _highlightsExposure;
  13233. /**
  13234. * Gets the highlights Hue value.
  13235. * 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).
  13236. */
  13237. /**
  13238. * Sets the highlights Hue value.
  13239. * 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).
  13240. */
  13241. highlightsHue: number;
  13242. /**
  13243. * Gets the highlights Density value.
  13244. * 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.
  13245. * Values less than zero provide a filter of opposite hue.
  13246. */
  13247. /**
  13248. * Sets the highlights Density value.
  13249. * 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.
  13250. * Values less than zero provide a filter of opposite hue.
  13251. */
  13252. highlightsDensity: number;
  13253. /**
  13254. * Gets the highlights Saturation value.
  13255. * 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.
  13256. */
  13257. /**
  13258. * Sets the highlights Saturation value.
  13259. * 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.
  13260. */
  13261. highlightsSaturation: number;
  13262. /**
  13263. * Gets the highlights Exposure value.
  13264. * 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.
  13265. */
  13266. /**
  13267. * Sets the highlights Exposure value.
  13268. * 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.
  13269. */
  13270. highlightsExposure: number;
  13271. private _midtonesHue;
  13272. private _midtonesDensity;
  13273. private _midtonesSaturation;
  13274. private _midtonesExposure;
  13275. /**
  13276. * Gets the midtones Hue value.
  13277. * 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).
  13278. */
  13279. /**
  13280. * Sets the midtones Hue value.
  13281. * 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).
  13282. */
  13283. midtonesHue: number;
  13284. /**
  13285. * Gets the midtones Density value.
  13286. * 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.
  13287. * Values less than zero provide a filter of opposite hue.
  13288. */
  13289. /**
  13290. * Sets the midtones Density value.
  13291. * 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.
  13292. * Values less than zero provide a filter of opposite hue.
  13293. */
  13294. midtonesDensity: number;
  13295. /**
  13296. * Gets the midtones Saturation value.
  13297. * 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.
  13298. */
  13299. /**
  13300. * Sets the midtones Saturation value.
  13301. * 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.
  13302. */
  13303. midtonesSaturation: number;
  13304. /**
  13305. * Gets the midtones Exposure value.
  13306. * 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.
  13307. */
  13308. /**
  13309. * Sets the midtones Exposure value.
  13310. * 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.
  13311. */
  13312. midtonesExposure: number;
  13313. private _shadowsHue;
  13314. private _shadowsDensity;
  13315. private _shadowsSaturation;
  13316. private _shadowsExposure;
  13317. /**
  13318. * Gets the shadows Hue value.
  13319. * 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).
  13320. */
  13321. /**
  13322. * Sets the shadows Hue value.
  13323. * 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).
  13324. */
  13325. shadowsHue: number;
  13326. /**
  13327. * Gets the shadows Density value.
  13328. * 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.
  13329. * Values less than zero provide a filter of opposite hue.
  13330. */
  13331. /**
  13332. * Sets the shadows Density value.
  13333. * 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.
  13334. * Values less than zero provide a filter of opposite hue.
  13335. */
  13336. shadowsDensity: number;
  13337. /**
  13338. * Gets the shadows Saturation value.
  13339. * 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.
  13340. */
  13341. /**
  13342. * Sets the shadows Saturation value.
  13343. * 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.
  13344. */
  13345. shadowsSaturation: number;
  13346. /**
  13347. * Gets the shadows Exposure value.
  13348. * 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.
  13349. */
  13350. /**
  13351. * Sets the shadows Exposure value.
  13352. * 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.
  13353. */
  13354. shadowsExposure: number;
  13355. getClassName(): string;
  13356. /**
  13357. * Binds the color curves to the shader.
  13358. * @param colorCurves The color curve to bind
  13359. * @param effect The effect to bind to
  13360. */
  13361. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13362. /**
  13363. * Prepare the list of uniforms associated with the ColorCurves effects.
  13364. * @param uniformsList The list of uniforms used in the effect
  13365. */
  13366. static PrepareUniforms(uniformsList: string[]): void;
  13367. /**
  13368. * Returns color grading data based on a hue, density, saturation and exposure value.
  13369. * @param filterHue The hue of the color filter.
  13370. * @param filterDensity The density of the color filter.
  13371. * @param saturation The saturation.
  13372. * @param exposure The exposure.
  13373. * @param result The result data container.
  13374. */
  13375. private getColorGradingDataToRef;
  13376. /**
  13377. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13378. * @param value The input slider value in range [-100,100].
  13379. * @returns Adjusted value.
  13380. */
  13381. private static applyColorGradingSliderNonlinear;
  13382. /**
  13383. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13384. * @param hue The hue (H) input.
  13385. * @param saturation The saturation (S) input.
  13386. * @param brightness The brightness (B) input.
  13387. * @result An RGBA color represented as Vector4.
  13388. */
  13389. private static fromHSBToRef;
  13390. /**
  13391. * Returns a value clamped between min and max
  13392. * @param value The value to clamp
  13393. * @param min The minimum of value
  13394. * @param max The maximum of value
  13395. * @returns The clamped value.
  13396. */
  13397. private static clamp;
  13398. /**
  13399. * Clones the current color curve instance.
  13400. * @return The cloned curves
  13401. */
  13402. clone(): ColorCurves;
  13403. /**
  13404. * Serializes the current color curve instance to a json representation.
  13405. * @return a JSON representation
  13406. */
  13407. serialize(): any;
  13408. /**
  13409. * Parses the color curve from a json representation.
  13410. * @param source the JSON source to parse
  13411. * @return The parsed curves
  13412. */
  13413. static Parse(source: any): ColorCurves;
  13414. }
  13415. }
  13416. declare module BABYLON {
  13417. /**
  13418. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13419. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13420. */
  13421. class EffectFallbacks {
  13422. private _defines;
  13423. private _currentRank;
  13424. private _maxRank;
  13425. private _mesh;
  13426. /**
  13427. * Removes the fallback from the bound mesh.
  13428. */
  13429. unBindMesh(): void;
  13430. /**
  13431. * Adds a fallback on the specified property.
  13432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13433. * @param define The name of the define in the shader
  13434. */
  13435. addFallback(rank: number, define: string): void;
  13436. /**
  13437. * Sets the mesh to use CPU skinning when needing to fallback.
  13438. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13439. * @param mesh The mesh to use the fallbacks.
  13440. */
  13441. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13442. /**
  13443. * Checks to see if more fallbacks are still availible.
  13444. */
  13445. readonly isMoreFallbacks: boolean;
  13446. /**
  13447. * Removes the defines that shoould be removed when falling back.
  13448. * @param currentDefines defines the current define statements for the shader.
  13449. * @param effect defines the current effect we try to compile
  13450. * @returns The resulting defines with defines of the current rank removed.
  13451. */
  13452. reduce(currentDefines: string, effect: Effect): string;
  13453. }
  13454. /**
  13455. * Options to be used when creating an effect.
  13456. */
  13457. class EffectCreationOptions {
  13458. /**
  13459. * Atrributes that will be used in the shader.
  13460. */
  13461. attributes: string[];
  13462. /**
  13463. * Uniform varible names that will be set in the shader.
  13464. */
  13465. uniformsNames: string[];
  13466. /**
  13467. * Uniform buffer varible names that will be set in the shader.
  13468. */
  13469. uniformBuffersNames: string[];
  13470. /**
  13471. * Sampler texture variable names that will be set in the shader.
  13472. */
  13473. samplers: string[];
  13474. /**
  13475. * Define statements that will be set in the shader.
  13476. */
  13477. defines: any;
  13478. /**
  13479. * Possible fallbacks for this effect to improve performance when needed.
  13480. */
  13481. fallbacks: Nullable<EffectFallbacks>;
  13482. /**
  13483. * Callback that will be called when the shader is compiled.
  13484. */
  13485. onCompiled: Nullable<(effect: Effect) => void>;
  13486. /**
  13487. * Callback that will be called if an error occurs during shader compilation.
  13488. */
  13489. onError: Nullable<(effect: Effect, errors: string) => void>;
  13490. /**
  13491. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13492. */
  13493. indexParameters: any;
  13494. /**
  13495. * Max number of lights that can be used in the shader.
  13496. */
  13497. maxSimultaneousLights: number;
  13498. /**
  13499. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13500. */
  13501. transformFeedbackVaryings: Nullable<string[]>;
  13502. }
  13503. /**
  13504. * Effect containing vertex and fragment shader that can be executed on an object.
  13505. */
  13506. class Effect {
  13507. /**
  13508. * Name of the effect.
  13509. */
  13510. name: any;
  13511. /**
  13512. * String container all the define statements that should be set on the shader.
  13513. */
  13514. defines: string;
  13515. /**
  13516. * Callback that will be called when the shader is compiled.
  13517. */
  13518. onCompiled: Nullable<(effect: Effect) => void>;
  13519. /**
  13520. * Callback that will be called if an error occurs during shader compilation.
  13521. */
  13522. onError: Nullable<(effect: Effect, errors: string) => void>;
  13523. /**
  13524. * Callback that will be called when effect is bound.
  13525. */
  13526. onBind: Nullable<(effect: Effect) => void>;
  13527. /**
  13528. * Unique ID of the effect.
  13529. */
  13530. uniqueId: number;
  13531. /**
  13532. * Observable that will be called when the shader is compiled.
  13533. */
  13534. onCompileObservable: Observable<Effect>;
  13535. /**
  13536. * Observable that will be called if an error occurs during shader compilation.
  13537. */
  13538. onErrorObservable: Observable<Effect>;
  13539. /** @hidden */
  13540. _onBindObservable: Nullable<Observable<Effect>>;
  13541. /**
  13542. * Observable that will be called when effect is bound.
  13543. */
  13544. readonly onBindObservable: Observable<Effect>;
  13545. /** @hidden */
  13546. _bonesComputationForcedToCPU: boolean;
  13547. private static _uniqueIdSeed;
  13548. private _engine;
  13549. private _uniformBuffersNames;
  13550. private _uniformsNames;
  13551. private _samplers;
  13552. private _isReady;
  13553. private _compilationError;
  13554. private _attributesNames;
  13555. private _attributes;
  13556. private _uniforms;
  13557. /**
  13558. * Key for the effect.
  13559. * @hidden
  13560. */
  13561. _key: string;
  13562. private _indexParameters;
  13563. private _fallbacks;
  13564. private _vertexSourceCode;
  13565. private _fragmentSourceCode;
  13566. private _vertexSourceCodeOverride;
  13567. private _fragmentSourceCodeOverride;
  13568. private _transformFeedbackVaryings;
  13569. /**
  13570. * Compiled shader to webGL program.
  13571. * @hidden
  13572. */
  13573. _program: WebGLProgram;
  13574. private _valueCache;
  13575. private static _baseCache;
  13576. /**
  13577. * Instantiates an effect.
  13578. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13579. * @param baseName Name of the effect.
  13580. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13581. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13582. * @param samplers List of sampler variables that will be passed to the shader.
  13583. * @param engine Engine to be used to render the effect
  13584. * @param defines Define statements to be added to the shader.
  13585. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13586. * @param onCompiled Callback that will be called when the shader is compiled.
  13587. * @param onError Callback that will be called if an error occurs during shader compilation.
  13588. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13589. */
  13590. 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);
  13591. /**
  13592. * Unique key for this effect
  13593. */
  13594. readonly key: string;
  13595. /**
  13596. * If the effect has been compiled and prepared.
  13597. * @returns if the effect is compiled and prepared.
  13598. */
  13599. isReady(): boolean;
  13600. /**
  13601. * The engine the effect was initialized with.
  13602. * @returns the engine.
  13603. */
  13604. getEngine(): Engine;
  13605. /**
  13606. * The compiled webGL program for the effect
  13607. * @returns the webGL program.
  13608. */
  13609. getProgram(): WebGLProgram;
  13610. /**
  13611. * The set of names of attribute variables for the shader.
  13612. * @returns An array of attribute names.
  13613. */
  13614. getAttributesNames(): string[];
  13615. /**
  13616. * Returns the attribute at the given index.
  13617. * @param index The index of the attribute.
  13618. * @returns The location of the attribute.
  13619. */
  13620. getAttributeLocation(index: number): number;
  13621. /**
  13622. * Returns the attribute based on the name of the variable.
  13623. * @param name of the attribute to look up.
  13624. * @returns the attribute location.
  13625. */
  13626. getAttributeLocationByName(name: string): number;
  13627. /**
  13628. * The number of attributes.
  13629. * @returns the numnber of attributes.
  13630. */
  13631. getAttributesCount(): number;
  13632. /**
  13633. * Gets the index of a uniform variable.
  13634. * @param uniformName of the uniform to look up.
  13635. * @returns the index.
  13636. */
  13637. getUniformIndex(uniformName: string): number;
  13638. /**
  13639. * Returns the attribute based on the name of the variable.
  13640. * @param uniformName of the uniform to look up.
  13641. * @returns the location of the uniform.
  13642. */
  13643. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13644. /**
  13645. * Returns an array of sampler variable names
  13646. * @returns The array of sampler variable neames.
  13647. */
  13648. getSamplers(): string[];
  13649. /**
  13650. * The error from the last compilation.
  13651. * @returns the error string.
  13652. */
  13653. getCompilationError(): string;
  13654. /**
  13655. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13656. * @param func The callback to be used.
  13657. */
  13658. executeWhenCompiled(func: (effect: Effect) => void): void;
  13659. /** @hidden */
  13660. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13661. /** @hidden */
  13662. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13663. /** @hidden */
  13664. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13665. private _processShaderConversion;
  13666. private _processIncludes;
  13667. private _processPrecision;
  13668. /**
  13669. * Recompiles the webGL program
  13670. * @param vertexSourceCode The source code for the vertex shader.
  13671. * @param fragmentSourceCode The source code for the fragment shader.
  13672. * @param onCompiled Callback called when completed.
  13673. * @param onError Callback called on error.
  13674. * @hidden
  13675. */
  13676. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13677. /**
  13678. * Gets the uniform locations of the the specified variable names
  13679. * @param names THe names of the variables to lookup.
  13680. * @returns Array of locations in the same order as variable names.
  13681. */
  13682. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13683. /**
  13684. * Prepares the effect
  13685. * @hidden
  13686. */
  13687. _prepareEffect(): void;
  13688. /**
  13689. * Checks if the effect is supported. (Must be called after compilation)
  13690. */
  13691. readonly isSupported: boolean;
  13692. /**
  13693. * Binds a texture to the engine to be used as output of the shader.
  13694. * @param channel Name of the output variable.
  13695. * @param texture Texture to bind.
  13696. * @hidden
  13697. */
  13698. _bindTexture(channel: string, texture: InternalTexture): void;
  13699. /**
  13700. * Sets a texture on the engine to be used in the shader.
  13701. * @param channel Name of the sampler variable.
  13702. * @param texture Texture to set.
  13703. */
  13704. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13705. /**
  13706. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13707. * @param channel Name of the sampler variable.
  13708. * @param texture Texture to set.
  13709. */
  13710. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13711. /**
  13712. * Sets an array of textures on the engine to be used in the shader.
  13713. * @param channel Name of the variable.
  13714. * @param textures Textures to set.
  13715. */
  13716. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13717. /**
  13718. * 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)
  13719. * @param channel Name of the sampler variable.
  13720. * @param postProcess Post process to get the input texture from.
  13721. */
  13722. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13723. /**
  13724. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13725. * 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)
  13726. * @param channel Name of the sampler variable.
  13727. * @param postProcess Post process to get the output texture from.
  13728. */
  13729. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13730. /** @hidden */
  13731. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13732. /** @hidden */
  13733. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13734. /** @hidden */
  13735. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13736. /** @hidden */
  13737. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13738. /**
  13739. * Binds a buffer to a uniform.
  13740. * @param buffer Buffer to bind.
  13741. * @param name Name of the uniform variable to bind to.
  13742. */
  13743. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13744. /**
  13745. * Binds block to a uniform.
  13746. * @param blockName Name of the block to bind.
  13747. * @param index Index to bind.
  13748. */
  13749. bindUniformBlock(blockName: string, index: number): void;
  13750. /**
  13751. * Sets an interger value on a uniform variable.
  13752. * @param uniformName Name of the variable.
  13753. * @param value Value to be set.
  13754. * @returns this effect.
  13755. */
  13756. setInt(uniformName: string, value: number): Effect;
  13757. /**
  13758. * Sets an int array on a uniform variable.
  13759. * @param uniformName Name of the variable.
  13760. * @param array array to be set.
  13761. * @returns this effect.
  13762. */
  13763. setIntArray(uniformName: string, array: Int32Array): Effect;
  13764. /**
  13765. * 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)
  13766. * @param uniformName Name of the variable.
  13767. * @param array array to be set.
  13768. * @returns this effect.
  13769. */
  13770. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13771. /**
  13772. * 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)
  13773. * @param uniformName Name of the variable.
  13774. * @param array array to be set.
  13775. * @returns this effect.
  13776. */
  13777. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13778. /**
  13779. * 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)
  13780. * @param uniformName Name of the variable.
  13781. * @param array array to be set.
  13782. * @returns this effect.
  13783. */
  13784. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13785. /**
  13786. * Sets an float array on a uniform variable.
  13787. * @param uniformName Name of the variable.
  13788. * @param array array to be set.
  13789. * @returns this effect.
  13790. */
  13791. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13792. /**
  13793. * 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)
  13794. * @param uniformName Name of the variable.
  13795. * @param array array to be set.
  13796. * @returns this effect.
  13797. */
  13798. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13799. /**
  13800. * 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)
  13801. * @param uniformName Name of the variable.
  13802. * @param array array to be set.
  13803. * @returns this effect.
  13804. */
  13805. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13806. /**
  13807. * 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)
  13808. * @param uniformName Name of the variable.
  13809. * @param array array to be set.
  13810. * @returns this effect.
  13811. */
  13812. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13813. /**
  13814. * Sets an array on a uniform variable.
  13815. * @param uniformName Name of the variable.
  13816. * @param array array to be set.
  13817. * @returns this effect.
  13818. */
  13819. setArray(uniformName: string, array: number[]): Effect;
  13820. /**
  13821. * 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)
  13822. * @param uniformName Name of the variable.
  13823. * @param array array to be set.
  13824. * @returns this effect.
  13825. */
  13826. setArray2(uniformName: string, array: number[]): Effect;
  13827. /**
  13828. * 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)
  13829. * @param uniformName Name of the variable.
  13830. * @param array array to be set.
  13831. * @returns this effect.
  13832. */
  13833. setArray3(uniformName: string, array: number[]): Effect;
  13834. /**
  13835. * 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)
  13836. * @param uniformName Name of the variable.
  13837. * @param array array to be set.
  13838. * @returns this effect.
  13839. */
  13840. setArray4(uniformName: string, array: number[]): Effect;
  13841. /**
  13842. * Sets matrices on a uniform variable.
  13843. * @param uniformName Name of the variable.
  13844. * @param matrices matrices to be set.
  13845. * @returns this effect.
  13846. */
  13847. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13848. /**
  13849. * Sets matrix on a uniform variable.
  13850. * @param uniformName Name of the variable.
  13851. * @param matrix matrix to be set.
  13852. * @returns this effect.
  13853. */
  13854. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13855. /**
  13856. * 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)
  13857. * @param uniformName Name of the variable.
  13858. * @param matrix matrix to be set.
  13859. * @returns this effect.
  13860. */
  13861. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13862. /**
  13863. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13864. * @param uniformName Name of the variable.
  13865. * @param matrix matrix to be set.
  13866. * @returns this effect.
  13867. */
  13868. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13869. /**
  13870. * Sets a float on a uniform variable.
  13871. * @param uniformName Name of the variable.
  13872. * @param value value to be set.
  13873. * @returns this effect.
  13874. */
  13875. setFloat(uniformName: string, value: number): Effect;
  13876. /**
  13877. * Sets a boolean on a uniform variable.
  13878. * @param uniformName Name of the variable.
  13879. * @param bool value to be set.
  13880. * @returns this effect.
  13881. */
  13882. setBool(uniformName: string, bool: boolean): Effect;
  13883. /**
  13884. * Sets a Vector2 on a uniform variable.
  13885. * @param uniformName Name of the variable.
  13886. * @param vector2 vector2 to be set.
  13887. * @returns this effect.
  13888. */
  13889. setVector2(uniformName: string, vector2: Vector2): Effect;
  13890. /**
  13891. * Sets a float2 on a uniform variable.
  13892. * @param uniformName Name of the variable.
  13893. * @param x First float in float2.
  13894. * @param y Second float in float2.
  13895. * @returns this effect.
  13896. */
  13897. setFloat2(uniformName: string, x: number, y: number): Effect;
  13898. /**
  13899. * Sets a Vector3 on a uniform variable.
  13900. * @param uniformName Name of the variable.
  13901. * @param vector3 Value to be set.
  13902. * @returns this effect.
  13903. */
  13904. setVector3(uniformName: string, vector3: Vector3): Effect;
  13905. /**
  13906. * Sets a float3 on a uniform variable.
  13907. * @param uniformName Name of the variable.
  13908. * @param x First float in float3.
  13909. * @param y Second float in float3.
  13910. * @param z Third float in float3.
  13911. * @returns this effect.
  13912. */
  13913. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13914. /**
  13915. * Sets a Vector4 on a uniform variable.
  13916. * @param uniformName Name of the variable.
  13917. * @param vector4 Value to be set.
  13918. * @returns this effect.
  13919. */
  13920. setVector4(uniformName: string, vector4: Vector4): Effect;
  13921. /**
  13922. * Sets a float4 on a uniform variable.
  13923. * @param uniformName Name of the variable.
  13924. * @param x First float in float4.
  13925. * @param y Second float in float4.
  13926. * @param z Third float in float4.
  13927. * @param w Fourth float in float4.
  13928. * @returns this effect.
  13929. */
  13930. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13931. /**
  13932. * Sets a Color3 on a uniform variable.
  13933. * @param uniformName Name of the variable.
  13934. * @param color3 Value to be set.
  13935. * @returns this effect.
  13936. */
  13937. setColor3(uniformName: string, color3: Color3): Effect;
  13938. /**
  13939. * Sets a Color4 on a uniform variable.
  13940. * @param uniformName Name of the variable.
  13941. * @param color3 Value to be set.
  13942. * @param alpha Alpha value to be set.
  13943. * @returns this effect.
  13944. */
  13945. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13946. /**
  13947. * Sets a Color4 on a uniform variable
  13948. * @param uniformName defines the name of the variable
  13949. * @param color4 defines the value to be set
  13950. * @returns this effect.
  13951. */
  13952. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13953. /**
  13954. * This function will add a new shader to the shader store
  13955. * @param name the name of the shader
  13956. * @param pixelShader optional pixel shader content
  13957. * @param vertexShader optional vertex shader content
  13958. */
  13959. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13960. /**
  13961. * Store of each shader (The can be looked up using effect.key)
  13962. */
  13963. static ShadersStore: {
  13964. [key: string]: string;
  13965. };
  13966. /**
  13967. * Store of each included file for a shader (The can be looked up using effect.key)
  13968. */
  13969. static IncludesShadersStore: {
  13970. [key: string]: string;
  13971. };
  13972. /**
  13973. * Resets the cache of effects.
  13974. */
  13975. static ResetCache(): void;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. class FresnelParameters {
  13980. private _isEnabled;
  13981. isEnabled: boolean;
  13982. leftColor: Color3;
  13983. rightColor: Color3;
  13984. bias: number;
  13985. power: number;
  13986. clone(): FresnelParameters;
  13987. serialize(): any;
  13988. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13989. }
  13990. }
  13991. declare module BABYLON {
  13992. /**
  13993. * Interface to follow in your material defines to integrate easily the
  13994. * Image proccessing functions.
  13995. * @hidden
  13996. */
  13997. interface IImageProcessingConfigurationDefines {
  13998. IMAGEPROCESSING: boolean;
  13999. VIGNETTE: boolean;
  14000. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14001. VIGNETTEBLENDMODEOPAQUE: boolean;
  14002. TONEMAPPING: boolean;
  14003. TONEMAPPING_ACES: boolean;
  14004. CONTRAST: boolean;
  14005. EXPOSURE: boolean;
  14006. COLORCURVES: boolean;
  14007. COLORGRADING: boolean;
  14008. COLORGRADING3D: boolean;
  14009. SAMPLER3DGREENDEPTH: boolean;
  14010. SAMPLER3DBGRMAP: boolean;
  14011. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14012. }
  14013. /**
  14014. * @hidden
  14015. */
  14016. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14017. IMAGEPROCESSING: boolean;
  14018. VIGNETTE: boolean;
  14019. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14020. VIGNETTEBLENDMODEOPAQUE: boolean;
  14021. TONEMAPPING: boolean;
  14022. TONEMAPPING_ACES: boolean;
  14023. CONTRAST: boolean;
  14024. COLORCURVES: boolean;
  14025. COLORGRADING: boolean;
  14026. COLORGRADING3D: boolean;
  14027. SAMPLER3DGREENDEPTH: boolean;
  14028. SAMPLER3DBGRMAP: boolean;
  14029. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14030. EXPOSURE: boolean;
  14031. constructor();
  14032. }
  14033. /**
  14034. * This groups together the common properties used for image processing either in direct forward pass
  14035. * or through post processing effect depending on the use of the image processing pipeline in your scene
  14036. * or not.
  14037. */
  14038. class ImageProcessingConfiguration {
  14039. /**
  14040. * Default tone mapping applied in BabylonJS.
  14041. */
  14042. static readonly TONEMAPPING_STANDARD: number;
  14043. /**
  14044. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  14045. * to other engines rendering to increase portability.
  14046. */
  14047. static readonly TONEMAPPING_ACES: number;
  14048. /**
  14049. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  14050. */
  14051. colorCurves: Nullable<ColorCurves>;
  14052. private _colorCurvesEnabled;
  14053. /**
  14054. * Gets wether the color curves effect is enabled.
  14055. */
  14056. /**
  14057. * Sets wether the color curves effect is enabled.
  14058. */
  14059. colorCurvesEnabled: boolean;
  14060. /**
  14061. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14062. */
  14063. colorGradingTexture: Nullable<BaseTexture>;
  14064. private _colorGradingEnabled;
  14065. /**
  14066. * Gets wether the color grading effect is enabled.
  14067. */
  14068. /**
  14069. * Sets wether the color grading effect is enabled.
  14070. */
  14071. colorGradingEnabled: boolean;
  14072. private _colorGradingWithGreenDepth;
  14073. /**
  14074. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  14075. */
  14076. /**
  14077. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  14078. */
  14079. colorGradingWithGreenDepth: boolean;
  14080. private _colorGradingBGR;
  14081. /**
  14082. * Gets wether the color grading texture contains BGR values.
  14083. */
  14084. /**
  14085. * Sets wether the color grading texture contains BGR values.
  14086. */
  14087. colorGradingBGR: boolean;
  14088. /** @hidden */
  14089. _exposure: number;
  14090. /**
  14091. * Gets the Exposure used in the effect.
  14092. */
  14093. /**
  14094. * Sets the Exposure used in the effect.
  14095. */
  14096. exposure: number;
  14097. private _toneMappingEnabled;
  14098. /**
  14099. * Gets wether the tone mapping effect is enabled.
  14100. */
  14101. /**
  14102. * Sets wether the tone mapping effect is enabled.
  14103. */
  14104. toneMappingEnabled: boolean;
  14105. private _toneMappingType;
  14106. /**
  14107. * Gets the type of tone mapping effect.
  14108. */
  14109. /**
  14110. * Sets the type of tone mapping effect used in BabylonJS.
  14111. */
  14112. toneMappingType: number;
  14113. protected _contrast: number;
  14114. /**
  14115. * Gets the contrast used in the effect.
  14116. */
  14117. /**
  14118. * Sets the contrast used in the effect.
  14119. */
  14120. contrast: number;
  14121. /**
  14122. * Vignette stretch size.
  14123. */
  14124. vignetteStretch: number;
  14125. /**
  14126. * Vignette centre X Offset.
  14127. */
  14128. vignetteCentreX: number;
  14129. /**
  14130. * Vignette centre Y Offset.
  14131. */
  14132. vignetteCentreY: number;
  14133. /**
  14134. * Vignette weight or intensity of the vignette effect.
  14135. */
  14136. vignetteWeight: number;
  14137. /**
  14138. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14139. * if vignetteEnabled is set to true.
  14140. */
  14141. vignetteColor: Color4;
  14142. /**
  14143. * Camera field of view used by the Vignette effect.
  14144. */
  14145. vignetteCameraFov: number;
  14146. private _vignetteBlendMode;
  14147. /**
  14148. * Gets the vignette blend mode allowing different kind of effect.
  14149. */
  14150. /**
  14151. * Sets the vignette blend mode allowing different kind of effect.
  14152. */
  14153. vignetteBlendMode: number;
  14154. private _vignetteEnabled;
  14155. /**
  14156. * Gets wether the vignette effect is enabled.
  14157. */
  14158. /**
  14159. * Sets wether the vignette effect is enabled.
  14160. */
  14161. vignetteEnabled: boolean;
  14162. private _applyByPostProcess;
  14163. /**
  14164. * Gets wether the image processing is applied through a post process or not.
  14165. */
  14166. /**
  14167. * Sets wether the image processing is applied through a post process or not.
  14168. */
  14169. applyByPostProcess: boolean;
  14170. private _isEnabled;
  14171. /**
  14172. * Gets wether the image processing is enabled or not.
  14173. */
  14174. /**
  14175. * Sets wether the image processing is enabled or not.
  14176. */
  14177. isEnabled: boolean;
  14178. /**
  14179. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14180. */
  14181. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14182. /**
  14183. * Method called each time the image processing information changes requires to recompile the effect.
  14184. */
  14185. protected _updateParameters(): void;
  14186. getClassName(): string;
  14187. /**
  14188. * Prepare the list of uniforms associated with the Image Processing effects.
  14189. * @param uniformsList The list of uniforms used in the effect
  14190. * @param defines the list of defines currently in use
  14191. */
  14192. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14193. /**
  14194. * Prepare the list of samplers associated with the Image Processing effects.
  14195. * @param uniformsList The list of uniforms used in the effect
  14196. * @param defines the list of defines currently in use
  14197. */
  14198. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14199. /**
  14200. * Prepare the list of defines associated to the shader.
  14201. * @param defines the list of defines to complete
  14202. */
  14203. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14204. /**
  14205. * Returns true if all the image processing information are ready.
  14206. */
  14207. isReady(): boolean;
  14208. /**
  14209. * Binds the image processing to the shader.
  14210. * @param effect The effect to bind to
  14211. */
  14212. bind(effect: Effect, aspectRatio?: number): void;
  14213. /**
  14214. * Clones the current image processing instance.
  14215. * @return The cloned image processing
  14216. */
  14217. clone(): ImageProcessingConfiguration;
  14218. /**
  14219. * Serializes the current image processing instance to a json representation.
  14220. * @return a JSON representation
  14221. */
  14222. serialize(): any;
  14223. /**
  14224. * Parses the image processing from a json representation.
  14225. * @param source the JSON source to parse
  14226. * @return The parsed image processing
  14227. */
  14228. static Parse(source: any): ImageProcessingConfiguration;
  14229. private static _VIGNETTEMODE_MULTIPLY;
  14230. private static _VIGNETTEMODE_OPAQUE;
  14231. /**
  14232. * Used to apply the vignette as a mix with the pixel color.
  14233. */
  14234. static readonly VIGNETTEMODE_MULTIPLY: number;
  14235. /**
  14236. * Used to apply the vignette as a replacement of the pixel color.
  14237. */
  14238. static readonly VIGNETTEMODE_OPAQUE: number;
  14239. }
  14240. }
  14241. declare module BABYLON {
  14242. /**
  14243. * Manages the defines for the Material
  14244. */
  14245. class MaterialDefines {
  14246. private _keys;
  14247. private _isDirty;
  14248. /** @hidden */
  14249. _renderId: number;
  14250. /** @hidden */
  14251. _areLightsDirty: boolean;
  14252. /** @hidden */
  14253. _areAttributesDirty: boolean;
  14254. /** @hidden */
  14255. _areTexturesDirty: boolean;
  14256. /** @hidden */
  14257. _areFresnelDirty: boolean;
  14258. /** @hidden */
  14259. _areMiscDirty: boolean;
  14260. /** @hidden */
  14261. _areImageProcessingDirty: boolean;
  14262. /** @hidden */
  14263. _normals: boolean;
  14264. /** @hidden */
  14265. _uvs: boolean;
  14266. /** @hidden */
  14267. _needNormals: boolean;
  14268. /** @hidden */
  14269. _needUVs: boolean;
  14270. /**
  14271. * Specifies if the material needs to be re-calculated
  14272. */
  14273. readonly isDirty: boolean;
  14274. /**
  14275. * Marks the material to indicate that it has been re-calculated
  14276. */
  14277. markAsProcessed(): void;
  14278. /**
  14279. * Marks the material to indicate that it needs to be re-calculated
  14280. */
  14281. markAsUnprocessed(): void;
  14282. /**
  14283. * Marks the material to indicate all of its defines need to be re-calculated
  14284. */
  14285. markAllAsDirty(): void;
  14286. /**
  14287. * Marks the material to indicate that image processing needs to be re-calculated
  14288. */
  14289. markAsImageProcessingDirty(): void;
  14290. /**
  14291. * Marks the material to indicate the lights need to be re-calculated
  14292. */
  14293. markAsLightDirty(): void;
  14294. /**
  14295. * Marks the attribute state as changed
  14296. */
  14297. markAsAttributesDirty(): void;
  14298. /**
  14299. * Marks the texture state as changed
  14300. */
  14301. markAsTexturesDirty(): void;
  14302. /**
  14303. * Marks the fresnel state as changed
  14304. */
  14305. markAsFresnelDirty(): void;
  14306. /**
  14307. * Marks the misc state as changed
  14308. */
  14309. markAsMiscDirty(): void;
  14310. /**
  14311. * Rebuilds the material defines
  14312. */
  14313. rebuild(): void;
  14314. /**
  14315. * Specifies if two material defines are equal
  14316. * @param other - A material define instance to compare to
  14317. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14318. */
  14319. isEqual(other: MaterialDefines): boolean;
  14320. /**
  14321. * Clones this instance's defines to another instance
  14322. * @param other - material defines to clone values to
  14323. */
  14324. cloneTo(other: MaterialDefines): void;
  14325. /**
  14326. * Resets the material define values
  14327. */
  14328. reset(): void;
  14329. /**
  14330. * Converts the material define values to a string
  14331. * @returns - String of material define information
  14332. */
  14333. toString(): string;
  14334. }
  14335. /**
  14336. * Base class for the main features of a material in Babylon.js
  14337. */
  14338. class Material implements IAnimatable {
  14339. private static _TriangleFillMode;
  14340. private static _WireFrameFillMode;
  14341. private static _PointFillMode;
  14342. private static _PointListDrawMode;
  14343. private static _LineListDrawMode;
  14344. private static _LineLoopDrawMode;
  14345. private static _LineStripDrawMode;
  14346. private static _TriangleStripDrawMode;
  14347. private static _TriangleFanDrawMode;
  14348. /**
  14349. * Returns the triangle fill mode
  14350. */
  14351. static readonly TriangleFillMode: number;
  14352. /**
  14353. * Returns the wireframe mode
  14354. */
  14355. static readonly WireFrameFillMode: number;
  14356. /**
  14357. * Returns the point fill mode
  14358. */
  14359. static readonly PointFillMode: number;
  14360. /**
  14361. * Returns the point list draw mode
  14362. */
  14363. static readonly PointListDrawMode: number;
  14364. /**
  14365. * Returns the line list draw mode
  14366. */
  14367. static readonly LineListDrawMode: number;
  14368. /**
  14369. * Returns the line loop draw mode
  14370. */
  14371. static readonly LineLoopDrawMode: number;
  14372. /**
  14373. * Returns the line strip draw mode
  14374. */
  14375. static readonly LineStripDrawMode: number;
  14376. /**
  14377. * Returns the triangle strip draw mode
  14378. */
  14379. static readonly TriangleStripDrawMode: number;
  14380. /**
  14381. * Returns the triangle fan draw mode
  14382. */
  14383. static readonly TriangleFanDrawMode: number;
  14384. /**
  14385. * Stores the clock-wise side orientation
  14386. */
  14387. private static _ClockWiseSideOrientation;
  14388. /**
  14389. * Stores the counter clock-wise side orientation
  14390. */
  14391. private static _CounterClockWiseSideOrientation;
  14392. /**
  14393. * Returns the clock-wise side orientation
  14394. */
  14395. static readonly ClockWiseSideOrientation: number;
  14396. /**
  14397. * Returns the counter clock-wise side orientation
  14398. */
  14399. static readonly CounterClockWiseSideOrientation: number;
  14400. /**
  14401. * The dirty texture flag value
  14402. */
  14403. private static _TextureDirtyFlag;
  14404. /**
  14405. * The dirty light flag value
  14406. */
  14407. private static _LightDirtyFlag;
  14408. /**
  14409. * The dirty fresnel flag value
  14410. */
  14411. private static _FresnelDirtyFlag;
  14412. /**
  14413. * The dirty attribute flag value
  14414. */
  14415. private static _AttributesDirtyFlag;
  14416. /**
  14417. * The dirty misc flag value
  14418. */
  14419. private static _MiscDirtyFlag;
  14420. /**
  14421. * Returns the dirty texture flag value
  14422. */
  14423. static readonly TextureDirtyFlag: number;
  14424. /**
  14425. * Returns the dirty light flag value
  14426. */
  14427. static readonly LightDirtyFlag: number;
  14428. /**
  14429. * Returns the dirty fresnel flag value
  14430. */
  14431. static readonly FresnelDirtyFlag: number;
  14432. /**
  14433. * Returns the dirty attributes flag value
  14434. */
  14435. static readonly AttributesDirtyFlag: number;
  14436. /**
  14437. * Returns the dirty misc flag value
  14438. */
  14439. static readonly MiscDirtyFlag: number;
  14440. /**
  14441. * The ID of the material
  14442. */
  14443. id: string;
  14444. /**
  14445. * Gets or sets the unique id of the material
  14446. */
  14447. uniqueId: number;
  14448. /**
  14449. * The name of the material
  14450. */
  14451. name: string;
  14452. /**
  14453. * Specifies if the ready state should be checked on each call
  14454. */
  14455. checkReadyOnEveryCall: boolean;
  14456. /**
  14457. * Specifies if the ready state should be checked once
  14458. */
  14459. checkReadyOnlyOnce: boolean;
  14460. /**
  14461. * The state of the material
  14462. */
  14463. state: string;
  14464. /**
  14465. * The alpha value of the material
  14466. */
  14467. protected _alpha: number;
  14468. /**
  14469. * Sets the alpha value of the material
  14470. */
  14471. /**
  14472. * Gets the alpha value of the material
  14473. */
  14474. alpha: number;
  14475. /**
  14476. * Specifies if back face culling is enabled
  14477. */
  14478. protected _backFaceCulling: boolean;
  14479. /**
  14480. * Sets the back-face culling state
  14481. */
  14482. /**
  14483. * Gets the back-face culling state
  14484. */
  14485. backFaceCulling: boolean;
  14486. /**
  14487. * Stores the value for side orientation
  14488. */
  14489. sideOrientation: number;
  14490. /**
  14491. * Callback triggered when the material is compiled
  14492. */
  14493. onCompiled: (effect: Effect) => void;
  14494. /**
  14495. * Callback triggered when an error occurs
  14496. */
  14497. onError: (effect: Effect, errors: string) => void;
  14498. /**
  14499. * Callback triggered to get the render target textures
  14500. */
  14501. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14502. /**
  14503. * Specifies if the material should be serialized
  14504. */
  14505. doNotSerialize: boolean;
  14506. /**
  14507. * Specifies if the effect should be stored on sub meshes
  14508. */
  14509. storeEffectOnSubMeshes: boolean;
  14510. /**
  14511. * Stores the animations for the material
  14512. */
  14513. animations: Array<Animation>;
  14514. /**
  14515. * An event triggered when the material is disposed
  14516. */
  14517. onDisposeObservable: Observable<Material>;
  14518. /**
  14519. * An observer which watches for dispose events
  14520. */
  14521. private _onDisposeObserver;
  14522. private _onUnBindObservable;
  14523. /**
  14524. * Called during a dispose event
  14525. */
  14526. onDispose: () => void;
  14527. private _onBindObservable;
  14528. /**
  14529. * An event triggered when the material is bound
  14530. */
  14531. readonly onBindObservable: Observable<AbstractMesh>;
  14532. /**
  14533. * An observer which watches for bind events
  14534. */
  14535. private _onBindObserver;
  14536. /**
  14537. * Called during a bind event
  14538. */
  14539. onBind: (Mesh: AbstractMesh) => void;
  14540. /**
  14541. * An event triggered when the material is unbound
  14542. */
  14543. readonly onUnBindObservable: Observable<Material>;
  14544. /**
  14545. * Stores the value of the alpha mode
  14546. */
  14547. private _alphaMode;
  14548. /**
  14549. * Sets the value of the alpha mode.
  14550. *
  14551. * | Value | Type | Description |
  14552. * | --- | --- | --- |
  14553. * | 0 | ALPHA_DISABLE | |
  14554. * | 1 | ALPHA_ADD | |
  14555. * | 2 | ALPHA_COMBINE | |
  14556. * | 3 | ALPHA_SUBTRACT | |
  14557. * | 4 | ALPHA_MULTIPLY | |
  14558. * | 5 | ALPHA_MAXIMIZED | |
  14559. * | 6 | ALPHA_ONEONE | |
  14560. * | 7 | ALPHA_PREMULTIPLIED | |
  14561. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14562. * | 9 | ALPHA_INTERPOLATE | |
  14563. * | 10 | ALPHA_SCREENMODE | |
  14564. *
  14565. */
  14566. /**
  14567. * Gets the value of the alpha mode
  14568. */
  14569. alphaMode: number;
  14570. /**
  14571. * Stores the state of the need depth pre-pass value
  14572. */
  14573. private _needDepthPrePass;
  14574. /**
  14575. * Sets the need depth pre-pass value
  14576. */
  14577. /**
  14578. * Gets the depth pre-pass value
  14579. */
  14580. needDepthPrePass: boolean;
  14581. /**
  14582. * Specifies if depth writing should be disabled
  14583. */
  14584. disableDepthWrite: boolean;
  14585. /**
  14586. * Specifies if depth writing should be forced
  14587. */
  14588. forceDepthWrite: boolean;
  14589. /**
  14590. * Specifies if there should be a separate pass for culling
  14591. */
  14592. separateCullingPass: boolean;
  14593. /**
  14594. * Stores the state specifing if fog should be enabled
  14595. */
  14596. private _fogEnabled;
  14597. /**
  14598. * Sets the state for enabling fog
  14599. */
  14600. /**
  14601. * Gets the value of the fog enabled state
  14602. */
  14603. fogEnabled: boolean;
  14604. /**
  14605. * Stores the size of points
  14606. */
  14607. pointSize: number;
  14608. /**
  14609. * Stores the z offset value
  14610. */
  14611. zOffset: number;
  14612. /**
  14613. * Gets a value specifying if wireframe mode is enabled
  14614. */
  14615. /**
  14616. * Sets the state of wireframe mode
  14617. */
  14618. wireframe: boolean;
  14619. /**
  14620. * Gets the value specifying if point clouds are enabled
  14621. */
  14622. /**
  14623. * Sets the state of point cloud mode
  14624. */
  14625. pointsCloud: boolean;
  14626. /**
  14627. * Gets the material fill mode
  14628. */
  14629. /**
  14630. * Sets the material fill mode
  14631. */
  14632. fillMode: number;
  14633. /**
  14634. * @hidden
  14635. * Stores the effects for the material
  14636. */
  14637. _effect: Nullable<Effect>;
  14638. /**
  14639. * @hidden
  14640. * Specifies if the material was previously ready
  14641. */
  14642. _wasPreviouslyReady: boolean;
  14643. /**
  14644. * Specifies if uniform buffers should be used
  14645. */
  14646. private _useUBO;
  14647. /**
  14648. * Stores a reference to the scene
  14649. */
  14650. private _scene;
  14651. /**
  14652. * Stores the fill mode state
  14653. */
  14654. private _fillMode;
  14655. /**
  14656. * Specifies if the depth write state should be cached
  14657. */
  14658. private _cachedDepthWriteState;
  14659. /**
  14660. * Stores the uniform buffer
  14661. */
  14662. protected _uniformBuffer: UniformBuffer;
  14663. /**
  14664. * Creates a material instance
  14665. * @param name defines the name of the material
  14666. * @param scene defines the scene to reference
  14667. * @param doNotAdd specifies if the material should be added to the scene
  14668. */
  14669. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14670. /**
  14671. * Returns a string representation of the current material
  14672. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14673. * @returns a string with material information
  14674. */
  14675. toString(fullDetails?: boolean): string;
  14676. /**
  14677. * Gets the class name of the material
  14678. * @returns a string with the class name of the material
  14679. */
  14680. getClassName(): string;
  14681. /**
  14682. * Specifies if updates for the material been locked
  14683. */
  14684. readonly isFrozen: boolean;
  14685. /**
  14686. * Locks updates for the material
  14687. */
  14688. freeze(): void;
  14689. /**
  14690. * Unlocks updates for the material
  14691. */
  14692. unfreeze(): void;
  14693. /**
  14694. * Specifies if the material is ready to be used
  14695. * @param mesh defines the mesh to check
  14696. * @param useInstances specifies if instances should be used
  14697. * @returns a boolean indicating if the material is ready to be used
  14698. */
  14699. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14700. /**
  14701. * Specifies that the submesh is ready to be used
  14702. * @param mesh defines the mesh to check
  14703. * @param subMesh defines which submesh to check
  14704. * @param useInstances specifies that instances should be used
  14705. * @returns a boolean indicating that the submesh is ready or not
  14706. */
  14707. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14708. /**
  14709. * Returns the material effect
  14710. * @returns the effect associated with the material
  14711. */
  14712. getEffect(): Nullable<Effect>;
  14713. /**
  14714. * Returns the current scene
  14715. * @returns a Scene
  14716. */
  14717. getScene(): Scene;
  14718. /**
  14719. * Specifies if the material will require alpha blending
  14720. * @returns a boolean specifying if alpha blending is needed
  14721. */
  14722. needAlphaBlending(): boolean;
  14723. /**
  14724. * Specifies if the mesh will require alpha blending
  14725. * @param mesh defines the mesh to check
  14726. * @returns a boolean specifying if alpha blending is needed for the mesh
  14727. */
  14728. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14729. /**
  14730. * Specifies if this material should be rendered in alpha test mode
  14731. * @returns a boolean specifying if an alpha test is needed.
  14732. */
  14733. needAlphaTesting(): boolean;
  14734. /**
  14735. * Gets the texture used for the alpha test
  14736. * @returns the texture to use for alpha testing
  14737. */
  14738. getAlphaTestTexture(): Nullable<BaseTexture>;
  14739. /**
  14740. * Marks the material to indicate that it needs to be re-calculated
  14741. */
  14742. markDirty(): void;
  14743. /** @hidden */
  14744. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14745. /**
  14746. * Binds the material to the mesh
  14747. * @param world defines the world transformation matrix
  14748. * @param mesh defines the mesh to bind the material to
  14749. */
  14750. bind(world: Matrix, mesh?: Mesh): void;
  14751. /**
  14752. * Binds the submesh to the material
  14753. * @param world defines the world transformation matrix
  14754. * @param mesh defines the mesh containing the submesh
  14755. * @param subMesh defines the submesh to bind the material to
  14756. */
  14757. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14758. /**
  14759. * Binds the world matrix to the material
  14760. * @param world defines the world transformation matrix
  14761. */
  14762. bindOnlyWorldMatrix(world: Matrix): void;
  14763. /**
  14764. * Binds the scene's uniform buffer to the effect.
  14765. * @param effect defines the effect to bind to the scene uniform buffer
  14766. * @param sceneUbo defines the uniform buffer storing scene data
  14767. */
  14768. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14769. /**
  14770. * Binds the view matrix to the effect
  14771. * @param effect defines the effect to bind the view matrix to
  14772. */
  14773. bindView(effect: Effect): void;
  14774. /**
  14775. * Binds the view projection matrix to the effect
  14776. * @param effect defines the effect to bind the view projection matrix to
  14777. */
  14778. bindViewProjection(effect: Effect): void;
  14779. /**
  14780. * Specifies if material alpha testing should be turned on for the mesh
  14781. * @param mesh defines the mesh to check
  14782. */
  14783. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14784. /**
  14785. * Processes to execute after binding the material to a mesh
  14786. * @param mesh defines the rendered mesh
  14787. */
  14788. protected _afterBind(mesh?: Mesh): void;
  14789. /**
  14790. * Unbinds the material from the mesh
  14791. */
  14792. unbind(): void;
  14793. /**
  14794. * Gets the active textures from the material
  14795. * @returns an array of textures
  14796. */
  14797. getActiveTextures(): BaseTexture[];
  14798. /**
  14799. * Specifies if the material uses a texture
  14800. * @param texture defines the texture to check against the material
  14801. * @returns a boolean specifying if the material uses the texture
  14802. */
  14803. hasTexture(texture: BaseTexture): boolean;
  14804. /**
  14805. * Makes a duplicate of the material, and gives it a new name
  14806. * @param name defines the new name for the duplicated material
  14807. * @returns the cloned material
  14808. */
  14809. clone(name: string): Nullable<Material>;
  14810. /**
  14811. * Gets the meshes bound to the material
  14812. * @returns an array of meshes bound to the material
  14813. */
  14814. getBindedMeshes(): AbstractMesh[];
  14815. /**
  14816. * Force shader compilation
  14817. * @param mesh defines the mesh associated with this material
  14818. * @param onCompiled defines a function to execute once the material is compiled
  14819. * @param options defines the options to configure the compilation
  14820. */
  14821. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14822. clipPlane: boolean;
  14823. }>): void;
  14824. /**
  14825. * Force shader compilation
  14826. * @param mesh defines the mesh that will use this material
  14827. * @param options defines additional options for compiling the shaders
  14828. * @returns a promise that resolves when the compilation completes
  14829. */
  14830. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14831. clipPlane: boolean;
  14832. }>): Promise<void>;
  14833. /**
  14834. * Marks a define in the material to indicate that it needs to be re-computed
  14835. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14836. */
  14837. markAsDirty(flag: number): void;
  14838. /**
  14839. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14840. * @param func defines a function which checks material defines against the submeshes
  14841. */
  14842. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14843. /**
  14844. * Indicates that image processing needs to be re-calculated for all submeshes
  14845. */
  14846. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14847. /**
  14848. * Indicates that textures need to be re-calculated for all submeshes
  14849. */
  14850. protected _markAllSubMeshesAsTexturesDirty(): void;
  14851. /**
  14852. * Indicates that fresnel needs to be re-calculated for all submeshes
  14853. */
  14854. protected _markAllSubMeshesAsFresnelDirty(): void;
  14855. /**
  14856. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14857. */
  14858. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14859. /**
  14860. * Indicates that lights need to be re-calculated for all submeshes
  14861. */
  14862. protected _markAllSubMeshesAsLightsDirty(): void;
  14863. /**
  14864. * Indicates that attributes need to be re-calculated for all submeshes
  14865. */
  14866. protected _markAllSubMeshesAsAttributesDirty(): void;
  14867. /**
  14868. * Indicates that misc needs to be re-calculated for all submeshes
  14869. */
  14870. protected _markAllSubMeshesAsMiscDirty(): void;
  14871. /**
  14872. * Indicates that textures and misc need to be re-calculated for all submeshes
  14873. */
  14874. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14875. /**
  14876. * Disposes the material
  14877. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14878. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14879. */
  14880. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14881. /**
  14882. * Serializes this material
  14883. * @returns the serialized material object
  14884. */
  14885. serialize(): any;
  14886. /**
  14887. * Creates a MultiMaterial from parsed MultiMaterial data.
  14888. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14889. * @param scene defines the hosting scene
  14890. * @returns a new MultiMaterial
  14891. */
  14892. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14893. /**
  14894. * Creates a material from parsed material data
  14895. * @param parsedMaterial defines parsed material data
  14896. * @param scene defines the hosting scene
  14897. * @param rootUrl defines the root URL to use to load textures
  14898. * @returns a new material
  14899. */
  14900. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14901. }
  14902. }
  14903. declare module BABYLON {
  14904. /**
  14905. * "Static Class" containing the most commonly used helper while dealing with material for
  14906. * rendering purpose.
  14907. *
  14908. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14909. *
  14910. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14911. */
  14912. class MaterialHelper {
  14913. /**
  14914. * Bind the current view position to an effect.
  14915. * @param effect The effect to be bound
  14916. * @param scene The scene the eyes position is used from
  14917. */
  14918. static BindEyePosition(effect: Effect, scene: Scene): void;
  14919. /**
  14920. * Helps preparing the defines values about the UVs in used in the effect.
  14921. * UVs are shared as much as we can accross chanels in the shaders.
  14922. * @param texture The texture we are preparing the UVs for
  14923. * @param defines The defines to update
  14924. * @param key The chanel key "diffuse", "specular"... used in the shader
  14925. */
  14926. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14927. /**
  14928. * Binds a texture matrix value to its corrsponding uniform
  14929. * @param texture The texture to bind the matrix for
  14930. * @param uniformBuffer The uniform buffer receivin the data
  14931. * @param key The chanel key "diffuse", "specular"... used in the shader
  14932. */
  14933. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14934. /**
  14935. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14936. * @param mesh defines the current mesh
  14937. * @param scene defines the current scene
  14938. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14939. * @param pointsCloud defines if point cloud rendering has to be turned on
  14940. * @param fogEnabled defines if fog has to be turned on
  14941. * @param alphaTest defines if alpha testing has to be turned on
  14942. * @param defines defines the current list of defines
  14943. */
  14944. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14945. /**
  14946. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14947. * @param scene defines the current scene
  14948. * @param engine defines the current engine
  14949. * @param defines specifies the list of active defines
  14950. * @param useInstances defines if instances have to be turned on
  14951. * @param useClipPlane defines if clip plane have to be turned on
  14952. */
  14953. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14954. /**
  14955. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14956. * @param mesh The mesh containing the geometry data we will draw
  14957. * @param defines The defines to update
  14958. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14959. * @param useBones Precise whether bones should be used or not (override mesh info)
  14960. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14961. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14962. * @returns false if defines are considered not dirty and have not been checked
  14963. */
  14964. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14965. /**
  14966. * Prepares the defines related to the light information passed in parameter
  14967. * @param scene The scene we are intending to draw
  14968. * @param mesh The mesh the effect is compiling for
  14969. * @param defines The defines to update
  14970. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14971. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14972. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14973. * @returns true if normals will be required for the rest of the effect
  14974. */
  14975. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14976. /**
  14977. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14978. * that won t be acctive due to defines being turned off.
  14979. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14980. * @param samplersList The samplers list
  14981. * @param defines The defines helping in the list generation
  14982. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14983. */
  14984. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14985. /**
  14986. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14987. * @param defines The defines to update while falling back
  14988. * @param fallbacks The authorized effect fallbacks
  14989. * @param maxSimultaneousLights The maximum number of lights allowed
  14990. * @param rank the current rank of the Effect
  14991. * @returns The newly affected rank
  14992. */
  14993. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14994. /**
  14995. * Prepares the list of attributes required for morph targets according to the effect defines.
  14996. * @param attribs The current list of supported attribs
  14997. * @param mesh The mesh to prepare the morph targets attributes for
  14998. * @param defines The current Defines of the effect
  14999. */
  15000. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  15001. /**
  15002. * Prepares the list of attributes required for bones according to the effect defines.
  15003. * @param attribs The current list of supported attribs
  15004. * @param mesh The mesh to prepare the bones attributes for
  15005. * @param defines The current Defines of the effect
  15006. * @param fallbacks The current efffect fallback strategy
  15007. */
  15008. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  15009. /**
  15010. * Prepares the list of attributes required for instances according to the effect defines.
  15011. * @param attribs The current list of supported attribs
  15012. * @param defines The current Defines of the effect
  15013. */
  15014. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  15015. /**
  15016. * Binds the light shadow information to the effect for the given mesh.
  15017. * @param light The light containing the generator
  15018. * @param scene The scene the lights belongs to
  15019. * @param mesh The mesh we are binding the information to render
  15020. * @param lightIndex The light index in the effect used to render the mesh
  15021. * @param effect The effect we are binding the data to
  15022. */
  15023. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  15024. /**
  15025. * Binds the light information to the effect.
  15026. * @param light The light containing the generator
  15027. * @param effect The effect we are binding the data to
  15028. * @param lightIndex The light index in the effect used to render
  15029. */
  15030. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  15031. /**
  15032. * Binds the lights information from the scene to the effect for the given mesh.
  15033. * @param scene The scene the lights belongs to
  15034. * @param mesh The mesh we are binding the information to render
  15035. * @param effect The effect we are binding the data to
  15036. * @param defines The generated defines for the effect
  15037. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  15038. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  15039. */
  15040. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  15041. /**
  15042. * Binds the fog information from the scene to the effect for the given mesh.
  15043. * @param scene The scene the lights belongs to
  15044. * @param mesh The mesh we are binding the information to render
  15045. * @param effect The effect we are binding the data to
  15046. */
  15047. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  15048. /**
  15049. * Binds the bones information from the mesh to the effect.
  15050. * @param mesh The mesh we are binding the information to render
  15051. * @param effect The effect we are binding the data to
  15052. */
  15053. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  15054. /**
  15055. * Binds the morph targets information from the mesh to the effect.
  15056. * @param abstractMesh The mesh we are binding the information to render
  15057. * @param effect The effect we are binding the data to
  15058. */
  15059. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  15060. /**
  15061. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  15062. * @param defines The generated defines used in the effect
  15063. * @param effect The effect we are binding the data to
  15064. * @param scene The scene we are willing to render with logarithmic scale for
  15065. */
  15066. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  15067. /**
  15068. * Binds the clip plane information from the scene to the effect.
  15069. * @param scene The scene the clip plane information are extracted from
  15070. * @param effect The effect we are binding the data to
  15071. */
  15072. static BindClipPlane(effect: Effect, scene: Scene): void;
  15073. }
  15074. }
  15075. declare module BABYLON {
  15076. class MultiMaterial extends Material {
  15077. private _subMaterials;
  15078. subMaterials: Nullable<Material>[];
  15079. constructor(name: string, scene: Scene);
  15080. private _hookArray;
  15081. getSubMaterial(index: number): Nullable<Material>;
  15082. getActiveTextures(): BaseTexture[];
  15083. getClassName(): string;
  15084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15085. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  15086. serialize(): any;
  15087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15088. }
  15089. }
  15090. declare module BABYLON {
  15091. class PushMaterial extends Material {
  15092. protected _activeEffect: Effect;
  15093. protected _normalMatrix: Matrix;
  15094. constructor(name: string, scene: Scene);
  15095. getEffect(): Effect;
  15096. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15097. /**
  15098. * Binds the given world matrix to the active effect
  15099. *
  15100. * @param world the matrix to bind
  15101. */
  15102. bindOnlyWorldMatrix(world: Matrix): void;
  15103. /**
  15104. * Binds the given normal matrix to the active effect
  15105. *
  15106. * @param normalMatrix the matrix to bind
  15107. */
  15108. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  15109. bind(world: Matrix, mesh?: Mesh): void;
  15110. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  15111. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  15112. }
  15113. }
  15114. declare module BABYLON {
  15115. class ShaderMaterial extends Material {
  15116. private _shaderPath;
  15117. private _options;
  15118. private _textures;
  15119. private _textureArrays;
  15120. private _floats;
  15121. private _ints;
  15122. private _floatsArrays;
  15123. private _colors3;
  15124. private _colors3Arrays;
  15125. private _colors4;
  15126. private _vectors2;
  15127. private _vectors3;
  15128. private _vectors4;
  15129. private _matrices;
  15130. private _matrices3x3;
  15131. private _matrices2x2;
  15132. private _vectors2Arrays;
  15133. private _vectors3Arrays;
  15134. private _cachedWorldViewMatrix;
  15135. private _renderId;
  15136. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  15137. getClassName(): string;
  15138. needAlphaBlending(): boolean;
  15139. needAlphaTesting(): boolean;
  15140. private _checkUniform;
  15141. setTexture(name: string, texture: Texture): ShaderMaterial;
  15142. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15143. setFloat(name: string, value: number): ShaderMaterial;
  15144. setInt(name: string, value: number): ShaderMaterial;
  15145. setFloats(name: string, value: number[]): ShaderMaterial;
  15146. setColor3(name: string, value: Color3): ShaderMaterial;
  15147. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15148. setColor4(name: string, value: Color4): ShaderMaterial;
  15149. setVector2(name: string, value: Vector2): ShaderMaterial;
  15150. setVector3(name: string, value: Vector3): ShaderMaterial;
  15151. setVector4(name: string, value: Vector4): ShaderMaterial;
  15152. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15153. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15154. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15155. setArray2(name: string, value: number[]): ShaderMaterial;
  15156. setArray3(name: string, value: number[]): ShaderMaterial;
  15157. private _checkCache;
  15158. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15159. bindOnlyWorldMatrix(world: Matrix): void;
  15160. bind(world: Matrix, mesh?: Mesh): void;
  15161. getActiveTextures(): BaseTexture[];
  15162. hasTexture(texture: BaseTexture): boolean;
  15163. clone(name: string): ShaderMaterial;
  15164. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15165. serialize(): any;
  15166. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15167. }
  15168. }
  15169. declare module BABYLON {
  15170. /** @hidden */
  15171. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  15172. MAINUV1: boolean;
  15173. MAINUV2: boolean;
  15174. DIFFUSE: boolean;
  15175. DIFFUSEDIRECTUV: number;
  15176. AMBIENT: boolean;
  15177. AMBIENTDIRECTUV: number;
  15178. OPACITY: boolean;
  15179. OPACITYDIRECTUV: number;
  15180. OPACITYRGB: boolean;
  15181. REFLECTION: boolean;
  15182. EMISSIVE: boolean;
  15183. EMISSIVEDIRECTUV: number;
  15184. SPECULAR: boolean;
  15185. SPECULARDIRECTUV: number;
  15186. BUMP: boolean;
  15187. BUMPDIRECTUV: number;
  15188. PARALLAX: boolean;
  15189. PARALLAXOCCLUSION: boolean;
  15190. SPECULAROVERALPHA: boolean;
  15191. CLIPPLANE: boolean;
  15192. CLIPPLANE2: boolean;
  15193. CLIPPLANE3: boolean;
  15194. CLIPPLANE4: boolean;
  15195. ALPHATEST: boolean;
  15196. DEPTHPREPASS: boolean;
  15197. ALPHAFROMDIFFUSE: boolean;
  15198. POINTSIZE: boolean;
  15199. FOG: boolean;
  15200. SPECULARTERM: boolean;
  15201. DIFFUSEFRESNEL: boolean;
  15202. OPACITYFRESNEL: boolean;
  15203. REFLECTIONFRESNEL: boolean;
  15204. REFRACTIONFRESNEL: boolean;
  15205. EMISSIVEFRESNEL: boolean;
  15206. FRESNEL: boolean;
  15207. NORMAL: boolean;
  15208. UV1: boolean;
  15209. UV2: boolean;
  15210. VERTEXCOLOR: boolean;
  15211. VERTEXALPHA: boolean;
  15212. NUM_BONE_INFLUENCERS: number;
  15213. BonesPerMesh: number;
  15214. INSTANCES: boolean;
  15215. GLOSSINESS: boolean;
  15216. ROUGHNESS: boolean;
  15217. EMISSIVEASILLUMINATION: boolean;
  15218. LINKEMISSIVEWITHDIFFUSE: boolean;
  15219. REFLECTIONFRESNELFROMSPECULAR: boolean;
  15220. LIGHTMAP: boolean;
  15221. LIGHTMAPDIRECTUV: number;
  15222. OBJECTSPACE_NORMALMAP: boolean;
  15223. USELIGHTMAPASSHADOWMAP: boolean;
  15224. REFLECTIONMAP_3D: boolean;
  15225. REFLECTIONMAP_SPHERICAL: boolean;
  15226. REFLECTIONMAP_PLANAR: boolean;
  15227. REFLECTIONMAP_CUBIC: boolean;
  15228. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  15229. REFLECTIONMAP_PROJECTION: boolean;
  15230. REFLECTIONMAP_SKYBOX: boolean;
  15231. REFLECTIONMAP_EXPLICIT: boolean;
  15232. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  15233. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15234. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15235. INVERTCUBICMAP: boolean;
  15236. LOGARITHMICDEPTH: boolean;
  15237. REFRACTION: boolean;
  15238. REFRACTIONMAP_3D: boolean;
  15239. REFLECTIONOVERALPHA: boolean;
  15240. TWOSIDEDLIGHTING: boolean;
  15241. SHADOWFLOAT: boolean;
  15242. MORPHTARGETS: boolean;
  15243. MORPHTARGETS_NORMAL: boolean;
  15244. MORPHTARGETS_TANGENT: boolean;
  15245. NUM_MORPH_INFLUENCERS: number;
  15246. NONUNIFORMSCALING: boolean;
  15247. PREMULTIPLYALPHA: boolean;
  15248. IMAGEPROCESSING: boolean;
  15249. VIGNETTE: boolean;
  15250. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15251. VIGNETTEBLENDMODEOPAQUE: boolean;
  15252. TONEMAPPING: boolean;
  15253. TONEMAPPING_ACES: boolean;
  15254. CONTRAST: boolean;
  15255. COLORCURVES: boolean;
  15256. COLORGRADING: boolean;
  15257. COLORGRADING3D: boolean;
  15258. SAMPLER3DGREENDEPTH: boolean;
  15259. SAMPLER3DBGRMAP: boolean;
  15260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15261. /**
  15262. * If the reflection texture on this material is in linear color space
  15263. * @hidden
  15264. */
  15265. IS_REFLECTION_LINEAR: boolean;
  15266. /**
  15267. * If the refraction texture on this material is in linear color space
  15268. * @hidden
  15269. */
  15270. IS_REFRACTION_LINEAR: boolean;
  15271. EXPOSURE: boolean;
  15272. constructor();
  15273. setReflectionMode(modeToEnable: string): void;
  15274. }
  15275. class StandardMaterial extends PushMaterial {
  15276. private _diffuseTexture;
  15277. diffuseTexture: Nullable<BaseTexture>;
  15278. private _ambientTexture;
  15279. ambientTexture: Nullable<BaseTexture>;
  15280. private _opacityTexture;
  15281. opacityTexture: Nullable<BaseTexture>;
  15282. private _reflectionTexture;
  15283. reflectionTexture: Nullable<BaseTexture>;
  15284. private _emissiveTexture;
  15285. emissiveTexture: Nullable<BaseTexture>;
  15286. private _specularTexture;
  15287. specularTexture: Nullable<BaseTexture>;
  15288. private _bumpTexture;
  15289. bumpTexture: Nullable<BaseTexture>;
  15290. private _lightmapTexture;
  15291. lightmapTexture: Nullable<BaseTexture>;
  15292. private _refractionTexture;
  15293. refractionTexture: Nullable<BaseTexture>;
  15294. ambientColor: Color3;
  15295. diffuseColor: Color3;
  15296. specularColor: Color3;
  15297. emissiveColor: Color3;
  15298. specularPower: number;
  15299. private _useAlphaFromDiffuseTexture;
  15300. useAlphaFromDiffuseTexture: boolean;
  15301. private _useEmissiveAsIllumination;
  15302. useEmissiveAsIllumination: boolean;
  15303. private _linkEmissiveWithDiffuse;
  15304. linkEmissiveWithDiffuse: boolean;
  15305. private _useSpecularOverAlpha;
  15306. useSpecularOverAlpha: boolean;
  15307. private _useReflectionOverAlpha;
  15308. useReflectionOverAlpha: boolean;
  15309. private _disableLighting;
  15310. disableLighting: boolean;
  15311. private _useObjectSpaceNormalMap;
  15312. /**
  15313. * Allows using an object space normal map (instead of tangent space).
  15314. */
  15315. useObjectSpaceNormalMap: boolean;
  15316. private _useParallax;
  15317. useParallax: boolean;
  15318. private _useParallaxOcclusion;
  15319. useParallaxOcclusion: boolean;
  15320. parallaxScaleBias: number;
  15321. private _roughness;
  15322. roughness: number;
  15323. indexOfRefraction: number;
  15324. invertRefractionY: boolean;
  15325. /**
  15326. * Defines the alpha limits in alpha test mode
  15327. */
  15328. alphaCutOff: number;
  15329. private _useLightmapAsShadowmap;
  15330. useLightmapAsShadowmap: boolean;
  15331. private _diffuseFresnelParameters;
  15332. diffuseFresnelParameters: FresnelParameters;
  15333. private _opacityFresnelParameters;
  15334. opacityFresnelParameters: FresnelParameters;
  15335. private _reflectionFresnelParameters;
  15336. reflectionFresnelParameters: FresnelParameters;
  15337. private _refractionFresnelParameters;
  15338. refractionFresnelParameters: FresnelParameters;
  15339. private _emissiveFresnelParameters;
  15340. emissiveFresnelParameters: FresnelParameters;
  15341. private _useReflectionFresnelFromSpecular;
  15342. useReflectionFresnelFromSpecular: boolean;
  15343. private _useGlossinessFromSpecularMapAlpha;
  15344. useGlossinessFromSpecularMapAlpha: boolean;
  15345. private _maxSimultaneousLights;
  15346. maxSimultaneousLights: number;
  15347. /**
  15348. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15349. */
  15350. private _invertNormalMapX;
  15351. invertNormalMapX: boolean;
  15352. /**
  15353. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15354. */
  15355. private _invertNormalMapY;
  15356. invertNormalMapY: boolean;
  15357. /**
  15358. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15359. */
  15360. private _twoSidedLighting;
  15361. twoSidedLighting: boolean;
  15362. /**
  15363. * Default configuration related to image processing available in the standard Material.
  15364. */
  15365. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15366. /**
  15367. * Gets the image processing configuration used either in this material.
  15368. */
  15369. /**
  15370. * Sets the Default image processing configuration used either in the this material.
  15371. *
  15372. * If sets to null, the scene one is in use.
  15373. */
  15374. imageProcessingConfiguration: ImageProcessingConfiguration;
  15375. /**
  15376. * Keep track of the image processing observer to allow dispose and replace.
  15377. */
  15378. private _imageProcessingObserver;
  15379. /**
  15380. * Attaches a new image processing configuration to the Standard Material.
  15381. * @param configuration
  15382. */
  15383. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15384. /**
  15385. * Gets wether the color curves effect is enabled.
  15386. */
  15387. /**
  15388. * Sets wether the color curves effect is enabled.
  15389. */
  15390. cameraColorCurvesEnabled: boolean;
  15391. /**
  15392. * Gets wether the color grading effect is enabled.
  15393. */
  15394. /**
  15395. * Gets wether the color grading effect is enabled.
  15396. */
  15397. cameraColorGradingEnabled: boolean;
  15398. /**
  15399. * Gets wether tonemapping is enabled or not.
  15400. */
  15401. /**
  15402. * Sets wether tonemapping is enabled or not
  15403. */
  15404. cameraToneMappingEnabled: boolean;
  15405. /**
  15406. * The camera exposure used on this material.
  15407. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15408. * This corresponds to a photographic exposure.
  15409. */
  15410. /**
  15411. * The camera exposure used on this material.
  15412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15413. * This corresponds to a photographic exposure.
  15414. */
  15415. cameraExposure: number;
  15416. /**
  15417. * Gets The camera contrast used on this material.
  15418. */
  15419. /**
  15420. * Sets The camera contrast used on this material.
  15421. */
  15422. cameraContrast: number;
  15423. /**
  15424. * Gets the Color Grading 2D Lookup Texture.
  15425. */
  15426. /**
  15427. * Sets the Color Grading 2D Lookup Texture.
  15428. */
  15429. cameraColorGradingTexture: Nullable<BaseTexture>;
  15430. /**
  15431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15433. * 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;
  15434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15435. */
  15436. /**
  15437. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15438. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15439. * 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;
  15440. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15441. */
  15442. cameraColorCurves: Nullable<ColorCurves>;
  15443. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15444. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15445. protected _worldViewProjectionMatrix: Matrix;
  15446. protected _globalAmbientColor: Color3;
  15447. protected _useLogarithmicDepth: boolean;
  15448. constructor(name: string, scene: Scene);
  15449. getClassName(): string;
  15450. useLogarithmicDepth: boolean;
  15451. needAlphaBlending(): boolean;
  15452. needAlphaTesting(): boolean;
  15453. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15454. getAlphaTestTexture(): Nullable<BaseTexture>;
  15455. /**
  15456. * Child classes can use it to update shaders
  15457. */
  15458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15459. buildUniformLayout(): void;
  15460. unbind(): void;
  15461. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15462. getAnimatables(): IAnimatable[];
  15463. getActiveTextures(): BaseTexture[];
  15464. hasTexture(texture: BaseTexture): boolean;
  15465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15466. clone(name: string): StandardMaterial;
  15467. serialize(): any;
  15468. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15469. static _DiffuseTextureEnabled: boolean;
  15470. static DiffuseTextureEnabled: boolean;
  15471. static _AmbientTextureEnabled: boolean;
  15472. static AmbientTextureEnabled: boolean;
  15473. static _OpacityTextureEnabled: boolean;
  15474. static OpacityTextureEnabled: boolean;
  15475. static _ReflectionTextureEnabled: boolean;
  15476. static ReflectionTextureEnabled: boolean;
  15477. static _EmissiveTextureEnabled: boolean;
  15478. static EmissiveTextureEnabled: boolean;
  15479. static _SpecularTextureEnabled: boolean;
  15480. static SpecularTextureEnabled: boolean;
  15481. static _BumpTextureEnabled: boolean;
  15482. static BumpTextureEnabled: boolean;
  15483. static _LightmapTextureEnabled: boolean;
  15484. static LightmapTextureEnabled: boolean;
  15485. static _RefractionTextureEnabled: boolean;
  15486. static RefractionTextureEnabled: boolean;
  15487. static _ColorGradingTextureEnabled: boolean;
  15488. static ColorGradingTextureEnabled: boolean;
  15489. static _FresnelEnabled: boolean;
  15490. static FresnelEnabled: boolean;
  15491. }
  15492. }
  15493. declare module BABYLON {
  15494. class UniformBuffer {
  15495. private _engine;
  15496. private _buffer;
  15497. private _data;
  15498. private _bufferData;
  15499. private _dynamic?;
  15500. private _uniformLocations;
  15501. private _uniformSizes;
  15502. private _uniformLocationPointer;
  15503. private _needSync;
  15504. private _noUBO;
  15505. private _currentEffect;
  15506. private static _MAX_UNIFORM_SIZE;
  15507. private static _tempBuffer;
  15508. /**
  15509. * Wrapper for updateUniform.
  15510. * @method updateMatrix3x3
  15511. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15512. * @param {Float32Array} matrix
  15513. */
  15514. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15515. /**
  15516. * Wrapper for updateUniform.
  15517. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15518. * @param {Float32Array} matrix
  15519. */
  15520. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15521. /**
  15522. * Wrapper for updateUniform.
  15523. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15524. * @param {number} x
  15525. */
  15526. updateFloat: (name: string, x: number) => void;
  15527. /**
  15528. * Wrapper for updateUniform.
  15529. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15530. * @param {number} x
  15531. * @param {number} y
  15532. * @param {string} [suffix] Suffix to add to the uniform name.
  15533. */
  15534. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15535. /**
  15536. * Wrapper for updateUniform.
  15537. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15538. * @param {number} x
  15539. * @param {number} y
  15540. * @param {number} z
  15541. * @param {string} [suffix] Suffix to add to the uniform name.
  15542. */
  15543. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15544. /**
  15545. * Wrapper for updateUniform.
  15546. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15547. * @param {number} x
  15548. * @param {number} y
  15549. * @param {number} z
  15550. * @param {number} w
  15551. * @param {string} [suffix] Suffix to add to the uniform name.
  15552. */
  15553. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15554. /**
  15555. * Wrapper for updateUniform.
  15556. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15557. * @param {Matrix} A 4x4 matrix.
  15558. */
  15559. updateMatrix: (name: string, mat: Matrix) => void;
  15560. /**
  15561. * Wrapper for updateUniform.
  15562. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15563. * @param {Vector3} vector
  15564. */
  15565. updateVector3: (name: string, vector: Vector3) => void;
  15566. /**
  15567. * Wrapper for updateUniform.
  15568. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15569. * @param {Vector4} vector
  15570. */
  15571. updateVector4: (name: string, vector: Vector4) => void;
  15572. /**
  15573. * Wrapper for updateUniform.
  15574. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15575. * @param {Color3} color
  15576. * @param {string} [suffix] Suffix to add to the uniform name.
  15577. */
  15578. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15579. /**
  15580. * Wrapper for updateUniform.
  15581. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15582. * @param {Color3} color
  15583. * @param {number} alpha
  15584. * @param {string} [suffix] Suffix to add to the uniform name.
  15585. */
  15586. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15587. /**
  15588. * Uniform buffer objects.
  15589. *
  15590. * Handles blocks of uniform on the GPU.
  15591. *
  15592. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15593. *
  15594. * For more information, please refer to :
  15595. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15596. */
  15597. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15598. /**
  15599. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15600. * or just falling back on setUniformXXX calls.
  15601. */
  15602. readonly useUbo: boolean;
  15603. /**
  15604. * Indicates if the WebGL underlying uniform buffer is in sync
  15605. * with the javascript cache data.
  15606. */
  15607. readonly isSync: boolean;
  15608. /**
  15609. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15610. * Also, a dynamic UniformBuffer will disable cache verification and always
  15611. * update the underlying WebGL uniform buffer to the GPU.
  15612. */
  15613. isDynamic(): boolean;
  15614. /**
  15615. * The data cache on JS side.
  15616. */
  15617. getData(): Float32Array;
  15618. /**
  15619. * The underlying WebGL Uniform buffer.
  15620. */
  15621. getBuffer(): Nullable<WebGLBuffer>;
  15622. /**
  15623. * std140 layout specifies how to align data within an UBO structure.
  15624. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15625. * for specs.
  15626. */
  15627. private _fillAlignment;
  15628. /**
  15629. * Adds an uniform in the buffer.
  15630. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15631. * for the layout to be correct !
  15632. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15633. * @param {number|number[]} size Data size, or data directly.
  15634. */
  15635. addUniform(name: string, size: number | number[]): void;
  15636. /**
  15637. * Wrapper for addUniform.
  15638. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15639. * @param {Matrix} mat A 4x4 matrix.
  15640. */
  15641. addMatrix(name: string, mat: Matrix): void;
  15642. /**
  15643. * Wrapper for addUniform.
  15644. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15645. * @param {number} x
  15646. * @param {number} y
  15647. */
  15648. addFloat2(name: string, x: number, y: number): void;
  15649. /**
  15650. * Wrapper for addUniform.
  15651. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15652. * @param {number} x
  15653. * @param {number} y
  15654. * @param {number} z
  15655. */
  15656. addFloat3(name: string, x: number, y: number, z: number): void;
  15657. /**
  15658. * Wrapper for addUniform.
  15659. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15660. * @param {Color3} color
  15661. */
  15662. addColor3(name: string, color: Color3): void;
  15663. /**
  15664. * Wrapper for addUniform.
  15665. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15666. * @param {Color3} color
  15667. * @param {number} alpha
  15668. */
  15669. addColor4(name: string, color: Color3, alpha: number): void;
  15670. /**
  15671. * Wrapper for addUniform.
  15672. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15673. * @param {Vector3} vector
  15674. */
  15675. addVector3(name: string, vector: Vector3): void;
  15676. /**
  15677. * Wrapper for addUniform.
  15678. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15679. */
  15680. addMatrix3x3(name: string): void;
  15681. /**
  15682. * Wrapper for addUniform.
  15683. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15684. */
  15685. addMatrix2x2(name: string): void;
  15686. /**
  15687. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15688. */
  15689. create(): void;
  15690. /** @hidden */
  15691. _rebuild(): void;
  15692. /**
  15693. * Updates the WebGL Uniform Buffer on the GPU.
  15694. * If the `dynamic` flag is set to true, no cache comparison is done.
  15695. * Otherwise, the buffer will be updated only if the cache differs.
  15696. */
  15697. update(): void;
  15698. /**
  15699. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15700. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15701. * @param {number[]|Float32Array} data Flattened data
  15702. * @param {number} size Size of the data.
  15703. */
  15704. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15705. private _updateMatrix3x3ForUniform;
  15706. private _updateMatrix3x3ForEffect;
  15707. private _updateMatrix2x2ForEffect;
  15708. private _updateMatrix2x2ForUniform;
  15709. private _updateFloatForEffect;
  15710. private _updateFloatForUniform;
  15711. private _updateFloat2ForEffect;
  15712. private _updateFloat2ForUniform;
  15713. private _updateFloat3ForEffect;
  15714. private _updateFloat3ForUniform;
  15715. private _updateFloat4ForEffect;
  15716. private _updateFloat4ForUniform;
  15717. private _updateMatrixForEffect;
  15718. private _updateMatrixForUniform;
  15719. private _updateVector3ForEffect;
  15720. private _updateVector3ForUniform;
  15721. private _updateVector4ForEffect;
  15722. private _updateVector4ForUniform;
  15723. private _updateColor3ForEffect;
  15724. private _updateColor3ForUniform;
  15725. private _updateColor4ForEffect;
  15726. private _updateColor4ForUniform;
  15727. /**
  15728. * Sets a sampler uniform on the effect.
  15729. * @param {string} name Name of the sampler.
  15730. * @param {Texture} texture
  15731. */
  15732. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15733. /**
  15734. * Directly updates the value of the uniform in the cache AND on the GPU.
  15735. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15736. * @param {number[]|Float32Array} data Flattened data
  15737. */
  15738. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15739. /**
  15740. * Binds this uniform buffer to an effect.
  15741. * @param {Effect} effect
  15742. * @param {string} name Name of the uniform block in the shader.
  15743. */
  15744. bindToEffect(effect: Effect, name: string): void;
  15745. /**
  15746. * Disposes the uniform buffer.
  15747. */
  15748. dispose(): void;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. class Scalar {
  15753. /**
  15754. * Two pi constants convenient for computation.
  15755. */
  15756. static TwoPi: number;
  15757. /**
  15758. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15759. */
  15760. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15761. /**
  15762. * Returns a string : the upper case translation of the number i to hexadecimal.
  15763. */
  15764. static ToHex(i: number): string;
  15765. /**
  15766. * Returns -1 if value is negative and +1 is value is positive.
  15767. * Returns the value itself if it's equal to zero.
  15768. */
  15769. static Sign(value: number): number;
  15770. /**
  15771. * Returns the value itself if it's between min and max.
  15772. * Returns min if the value is lower than min.
  15773. * Returns max if the value is greater than max.
  15774. */
  15775. static Clamp(value: number, min?: number, max?: number): number;
  15776. /**
  15777. * Returns the log2 of value.
  15778. */
  15779. static Log2(value: number): number;
  15780. /**
  15781. * Loops the value, so that it is never larger than length and never smaller than 0.
  15782. *
  15783. * This is similar to the modulo operator but it works with floating point numbers.
  15784. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15785. * With t = 5 and length = 2.5, the result would be 0.0.
  15786. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15787. */
  15788. static Repeat(value: number, length: number): number;
  15789. /**
  15790. * Normalize the value between 0.0 and 1.0 using min and max values
  15791. */
  15792. static Normalize(value: number, min: number, max: number): number;
  15793. /**
  15794. * Denormalize the value from 0.0 and 1.0 using min and max values
  15795. */
  15796. static Denormalize(normalized: number, min: number, max: number): number;
  15797. /**
  15798. * Calculates the shortest difference between two given angles given in degrees.
  15799. */
  15800. static DeltaAngle(current: number, target: number): number;
  15801. /**
  15802. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15803. *
  15804. * The returned value will move back and forth between 0 and length
  15805. */
  15806. static PingPong(tx: number, length: number): number;
  15807. /**
  15808. * Interpolates between min and max with smoothing at the limits.
  15809. *
  15810. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15811. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15812. */
  15813. static SmoothStep(from: number, to: number, tx: number): number;
  15814. /**
  15815. * Moves a value current towards target.
  15816. *
  15817. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15818. * Negative values of maxDelta pushes the value away from target.
  15819. */
  15820. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15821. /**
  15822. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15823. *
  15824. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15825. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15826. */
  15827. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15828. /**
  15829. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15830. */
  15831. static Lerp(start: number, end: number, amount: number): number;
  15832. /**
  15833. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15834. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15835. */
  15836. static LerpAngle(start: number, end: number, amount: number): number;
  15837. /**
  15838. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15839. */
  15840. static InverseLerp(a: number, b: number, value: number): number;
  15841. /**
  15842. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15843. */
  15844. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15845. /**
  15846. * Returns a random float number between and min and max values
  15847. */
  15848. static RandomRange(min: number, max: number): number;
  15849. /**
  15850. * This function returns percentage of a number in a given range.
  15851. *
  15852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15854. */
  15855. static RangeToPercent(number: number, min: number, max: number): number;
  15856. /**
  15857. * This function returns number that corresponds to the percentage in a given range.
  15858. *
  15859. * PercentToRange(0.34,0,100) will return 34.
  15860. */
  15861. static PercentToRange(percent: number, min: number, max: number): number;
  15862. /**
  15863. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15864. * @param angle The angle to normalize in radian.
  15865. * @return The converted angle.
  15866. */
  15867. static NormalizeRadians(angle: number): number;
  15868. }
  15869. }
  15870. declare module BABYLON {
  15871. const ToGammaSpace: number;
  15872. const ToLinearSpace = 2.2;
  15873. const Epsilon = 0.001;
  15874. /**
  15875. * Class used to hold a RBG color
  15876. */
  15877. class Color3 {
  15878. /**
  15879. * Defines the red component (between 0 and 1, default is 0)
  15880. */
  15881. r: number;
  15882. /**
  15883. * Defines the green component (between 0 and 1, default is 0)
  15884. */
  15885. g: number;
  15886. /**
  15887. * Defines the blue component (between 0 and 1, default is 0)
  15888. */
  15889. b: number;
  15890. /**
  15891. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15892. * @param r defines the red component (between 0 and 1, default is 0)
  15893. * @param g defines the green component (between 0 and 1, default is 0)
  15894. * @param b defines the blue component (between 0 and 1, default is 0)
  15895. */
  15896. constructor(
  15897. /**
  15898. * Defines the red component (between 0 and 1, default is 0)
  15899. */
  15900. r?: number,
  15901. /**
  15902. * Defines the green component (between 0 and 1, default is 0)
  15903. */
  15904. g?: number,
  15905. /**
  15906. * Defines the blue component (between 0 and 1, default is 0)
  15907. */
  15908. b?: number);
  15909. /**
  15910. * Creates a string with the Color3 current values
  15911. * @returns the string representation of the Color3 object
  15912. */
  15913. toString(): string;
  15914. /**
  15915. * Returns the string "Color3"
  15916. * @returns "Color3"
  15917. */
  15918. getClassName(): string;
  15919. /**
  15920. * Compute the Color3 hash code
  15921. * @returns an unique number that can be used to hash Color3 objects
  15922. */
  15923. getHashCode(): number;
  15924. /**
  15925. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15926. * @param array defines the array where to store the r,g,b components
  15927. * @param index defines an optional index in the target array to define where to start storing values
  15928. * @returns the current Color3 object
  15929. */
  15930. toArray(array: FloatArray, index?: number): Color3;
  15931. /**
  15932. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15933. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15934. * @returns a new {BABYLON.Color4} object
  15935. */
  15936. toColor4(alpha?: number): Color4;
  15937. /**
  15938. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15939. * @returns the new array
  15940. */
  15941. asArray(): number[];
  15942. /**
  15943. * Returns the luminance value
  15944. * @returns a float value
  15945. */
  15946. toLuminance(): number;
  15947. /**
  15948. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15949. * @param otherColor defines the second operand
  15950. * @returns the new Color3 object
  15951. */
  15952. multiply(otherColor: Color3): Color3;
  15953. /**
  15954. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15955. * @param otherColor defines the second operand
  15956. * @param result defines the Color3 object where to store the result
  15957. * @returns the current Color3
  15958. */
  15959. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15960. /**
  15961. * Determines equality between Color3 objects
  15962. * @param otherColor defines the second operand
  15963. * @returns true if the rgb values are equal to the given ones
  15964. */
  15965. equals(otherColor: Color3): boolean;
  15966. /**
  15967. * Determines equality between the current Color3 object and a set of r,b,g values
  15968. * @param r defines the red component to check
  15969. * @param g defines the green component to check
  15970. * @param b defines the blue component to check
  15971. * @returns true if the rgb values are equal to the given ones
  15972. */
  15973. equalsFloats(r: number, g: number, b: number): boolean;
  15974. /**
  15975. * Multiplies in place each rgb value by scale
  15976. * @param scale defines the scaling factor
  15977. * @returns the updated Color3
  15978. */
  15979. scale(scale: number): Color3;
  15980. /**
  15981. * Multiplies the rgb values by scale and stores the result into "result"
  15982. * @param scale defines the scaling factor
  15983. * @param result defines the Color3 object where to store the result
  15984. * @returns the unmodified current Color3
  15985. */
  15986. scaleToRef(scale: number, result: Color3): Color3;
  15987. /**
  15988. * Scale the current Color3 values by a factor and add the result to a given Color3
  15989. * @param scale defines the scale factor
  15990. * @param result defines color to store the result into
  15991. * @returns the unmodified current Color3
  15992. */
  15993. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15994. /**
  15995. * Clamps the rgb values by the min and max values and stores the result into "result"
  15996. * @param min defines minimum clamping value (default is 0)
  15997. * @param max defines maximum clamping value (default is 1)
  15998. * @param result defines color to store the result into
  15999. * @returns the original Color3
  16000. */
  16001. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  16002. /**
  16003. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  16004. * @param otherColor defines the second operand
  16005. * @returns the new Color3
  16006. */
  16007. add(otherColor: Color3): Color3;
  16008. /**
  16009. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  16010. * @param otherColor defines the second operand
  16011. * @param result defines Color3 object to store the result into
  16012. * @returns the unmodified current Color3
  16013. */
  16014. addToRef(otherColor: Color3, result: Color3): Color3;
  16015. /**
  16016. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  16017. * @param otherColor defines the second operand
  16018. * @returns the new Color3
  16019. */
  16020. subtract(otherColor: Color3): Color3;
  16021. /**
  16022. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  16023. * @param otherColor defines the second operand
  16024. * @param result defines Color3 object to store the result into
  16025. * @returns the unmodified current Color3
  16026. */
  16027. subtractToRef(otherColor: Color3, result: Color3): Color3;
  16028. /**
  16029. * Copy the current object
  16030. * @returns a new Color3 copied the current one
  16031. */
  16032. clone(): Color3;
  16033. /**
  16034. * Copies the rgb values from the source in the current Color3
  16035. * @param source defines the source Color3 object
  16036. * @returns the updated Color3 object
  16037. */
  16038. copyFrom(source: Color3): Color3;
  16039. /**
  16040. * Updates the Color3 rgb values from the given floats
  16041. * @param r defines the red component to read from
  16042. * @param g defines the green component to read from
  16043. * @param b defines the blue component to read from
  16044. * @returns the current Color3 object
  16045. */
  16046. copyFromFloats(r: number, g: number, b: number): Color3;
  16047. /**
  16048. * Updates the Color3 rgb values from the given floats
  16049. * @param r defines the red component to read from
  16050. * @param g defines the green component to read from
  16051. * @param b defines the blue component to read from
  16052. * @returns the current Color3 object
  16053. */
  16054. set(r: number, g: number, b: number): Color3;
  16055. /**
  16056. * Compute the Color3 hexadecimal code as a string
  16057. * @returns a string containing the hexadecimal representation of the Color3 object
  16058. */
  16059. toHexString(): string;
  16060. /**
  16061. * Computes a new Color3 converted from the current one to linear space
  16062. * @returns a new Color3 object
  16063. */
  16064. toLinearSpace(): Color3;
  16065. /**
  16066. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  16067. * @param convertedColor defines the Color3 object where to store the linear space version
  16068. * @returns the unmodified Color3
  16069. */
  16070. toLinearSpaceToRef(convertedColor: Color3): Color3;
  16071. /**
  16072. * Computes a new Color3 converted from the current one to gamma space
  16073. * @returns a new Color3 object
  16074. */
  16075. toGammaSpace(): Color3;
  16076. /**
  16077. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  16078. * @param convertedColor defines the Color3 object where to store the gamma space version
  16079. * @returns the unmodified Color3
  16080. */
  16081. toGammaSpaceToRef(convertedColor: Color3): Color3;
  16082. /**
  16083. * Creates a new Color3 from the string containing valid hexadecimal values
  16084. * @param hex defines a string containing valid hexadecimal values
  16085. * @returns a new Color3 object
  16086. */
  16087. static FromHexString(hex: string): Color3;
  16088. /**
  16089. * Creates a new Vector3 from the starting index of the given array
  16090. * @param array defines the source array
  16091. * @param offset defines an offset in the source array
  16092. * @returns a new Color3 object
  16093. */
  16094. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  16095. /**
  16096. * Creates a new Color3 from integer values (< 256)
  16097. * @param r defines the red component to read from (value between 0 and 255)
  16098. * @param g defines the green component to read from (value between 0 and 255)
  16099. * @param b defines the blue component to read from (value between 0 and 255)
  16100. * @returns a new Color3 object
  16101. */
  16102. static FromInts(r: number, g: number, b: number): Color3;
  16103. /**
  16104. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  16105. * @param start defines the start Color3 value
  16106. * @param end defines the end Color3 value
  16107. * @param amount defines the gradient value between start and end
  16108. * @returns a new Color3 object
  16109. */
  16110. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  16111. /**
  16112. * Returns a Color3 value containing a red color
  16113. * @returns a new Color3 object
  16114. */
  16115. static Red(): Color3;
  16116. /**
  16117. * Returns a Color3 value containing a green color
  16118. * @returns a new Color3 object
  16119. */
  16120. static Green(): Color3;
  16121. /**
  16122. * Returns a Color3 value containing a blue color
  16123. * @returns a new Color3 object
  16124. */
  16125. static Blue(): Color3;
  16126. /**
  16127. * Returns a Color3 value containing a black color
  16128. * @returns a new Color3 object
  16129. */
  16130. static Black(): Color3;
  16131. /**
  16132. * Returns a Color3 value containing a white color
  16133. * @returns a new Color3 object
  16134. */
  16135. static White(): Color3;
  16136. /**
  16137. * Returns a Color3 value containing a purple color
  16138. * @returns a new Color3 object
  16139. */
  16140. static Purple(): Color3;
  16141. /**
  16142. * Returns a Color3 value containing a magenta color
  16143. * @returns a new Color3 object
  16144. */
  16145. static Magenta(): Color3;
  16146. /**
  16147. * Returns a Color3 value containing a yellow color
  16148. * @returns a new Color3 object
  16149. */
  16150. static Yellow(): Color3;
  16151. /**
  16152. * Returns a Color3 value containing a gray color
  16153. * @returns a new Color3 object
  16154. */
  16155. static Gray(): Color3;
  16156. /**
  16157. * Returns a Color3 value containing a teal color
  16158. * @returns a new Color3 object
  16159. */
  16160. static Teal(): Color3;
  16161. /**
  16162. * Returns a Color3 value containing a random color
  16163. * @returns a new Color3 object
  16164. */
  16165. static Random(): Color3;
  16166. }
  16167. /**
  16168. * Class used to hold a RBGA color
  16169. */
  16170. class Color4 {
  16171. /**
  16172. * Defines the red component (between 0 and 1, default is 0)
  16173. */
  16174. r: number;
  16175. /**
  16176. * Defines the green component (between 0 and 1, default is 0)
  16177. */
  16178. g: number;
  16179. /**
  16180. * Defines the blue component (between 0 and 1, default is 0)
  16181. */
  16182. b: number;
  16183. /**
  16184. * Defines the alpha component (between 0 and 1, default is 1)
  16185. */
  16186. a: number;
  16187. /**
  16188. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  16189. * @param r defines the red component (between 0 and 1, default is 0)
  16190. * @param g defines the green component (between 0 and 1, default is 0)
  16191. * @param b defines the blue component (between 0 and 1, default is 0)
  16192. * @param a defines the alpha component (between 0 and 1, default is 1)
  16193. */
  16194. constructor(
  16195. /**
  16196. * Defines the red component (between 0 and 1, default is 0)
  16197. */
  16198. r?: number,
  16199. /**
  16200. * Defines the green component (between 0 and 1, default is 0)
  16201. */
  16202. g?: number,
  16203. /**
  16204. * Defines the blue component (between 0 and 1, default is 0)
  16205. */
  16206. b?: number,
  16207. /**
  16208. * Defines the alpha component (between 0 and 1, default is 1)
  16209. */
  16210. a?: number);
  16211. /**
  16212. * Adds in place the given Color4 values to the current Color4 object
  16213. * @param right defines the second operand
  16214. * @returns the current updated Color4 object
  16215. */
  16216. addInPlace(right: Color4): Color4;
  16217. /**
  16218. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  16219. * @returns the new array
  16220. */
  16221. asArray(): number[];
  16222. /**
  16223. * Stores from the starting index in the given array the Color4 successive values
  16224. * @param array defines the array where to store the r,g,b components
  16225. * @param index defines an optional index in the target array to define where to start storing values
  16226. * @returns the current Color4 object
  16227. */
  16228. toArray(array: number[], index?: number): Color4;
  16229. /**
  16230. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  16231. * @param right defines the second operand
  16232. * @returns a new Color4 object
  16233. */
  16234. add(right: Color4): Color4;
  16235. /**
  16236. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  16237. * @param right defines the second operand
  16238. * @returns a new Color4 object
  16239. */
  16240. subtract(right: Color4): Color4;
  16241. /**
  16242. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16243. * @param right defines the second operand
  16244. * @param result defines the Color4 object where to store the result
  16245. * @returns the current Color4 object
  16246. */
  16247. subtractToRef(right: Color4, result: Color4): Color4;
  16248. /**
  16249. * Creates a new Color4 with the current Color4 values multiplied by scale
  16250. * @param scale defines the scaling factor to apply
  16251. * @returns a new Color4 object
  16252. */
  16253. scale(scale: number): Color4;
  16254. /**
  16255. * Multiplies the current Color4 values by scale and stores the result in "result"
  16256. * @param scale defines the scaling factor to apply
  16257. * @param result defines the Color4 object where to store the result
  16258. * @returns the current unmodified Color4
  16259. */
  16260. scaleToRef(scale: number, result: Color4): Color4;
  16261. /**
  16262. * Scale the current Color4 values by a factor and add the result to a given Color4
  16263. * @param scale defines the scale factor
  16264. * @param result defines the Color4 object where to store the result
  16265. * @returns the unmodified current Color4
  16266. */
  16267. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16268. /**
  16269. * Clamps the rgb values by the min and max values and stores the result into "result"
  16270. * @param min defines minimum clamping value (default is 0)
  16271. * @param max defines maximum clamping value (default is 1)
  16272. * @param result defines color to store the result into.
  16273. * @returns the cuurent Color4
  16274. */
  16275. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16276. /**
  16277. * Multipy an Color4 value by another and return a new Color4 object
  16278. * @param color defines the Color4 value to multiply by
  16279. * @returns a new Color4 object
  16280. */
  16281. multiply(color: Color4): Color4;
  16282. /**
  16283. * Multipy a Color4 value by another and push the result in a reference value
  16284. * @param color defines the Color4 value to multiply by
  16285. * @param result defines the Color4 to fill the result in
  16286. * @returns the result Color4
  16287. */
  16288. multiplyToRef(color: Color4, result: Color4): Color4;
  16289. /**
  16290. * Creates a string with the Color4 current values
  16291. * @returns the string representation of the Color4 object
  16292. */
  16293. toString(): string;
  16294. /**
  16295. * Returns the string "Color4"
  16296. * @returns "Color4"
  16297. */
  16298. getClassName(): string;
  16299. /**
  16300. * Compute the Color4 hash code
  16301. * @returns an unique number that can be used to hash Color4 objects
  16302. */
  16303. getHashCode(): number;
  16304. /**
  16305. * Creates a new Color4 copied from the current one
  16306. * @returns a new Color4 object
  16307. */
  16308. clone(): Color4;
  16309. /**
  16310. * Copies the given Color4 values into the current one
  16311. * @param source defines the source Color4 object
  16312. * @returns the current updated Color4 object
  16313. */
  16314. copyFrom(source: Color4): Color4;
  16315. /**
  16316. * Copies the given float values into the current one
  16317. * @param r defines the red component to read from
  16318. * @param g defines the green component to read from
  16319. * @param b defines the blue component to read from
  16320. * @param a defines the alpha component to read from
  16321. * @returns the current updated Color4 object
  16322. */
  16323. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16324. /**
  16325. * Copies the given float values into the current one
  16326. * @param r defines the red component to read from
  16327. * @param g defines the green component to read from
  16328. * @param b defines the blue component to read from
  16329. * @param a defines the alpha component to read from
  16330. * @returns the current updated Color4 object
  16331. */
  16332. set(r: number, g: number, b: number, a: number): Color4;
  16333. /**
  16334. * Compute the Color4 hexadecimal code as a string
  16335. * @returns a string containing the hexadecimal representation of the Color4 object
  16336. */
  16337. toHexString(): string;
  16338. /**
  16339. * Computes a new Color4 converted from the current one to linear space
  16340. * @returns a new Color4 object
  16341. */
  16342. toLinearSpace(): Color4;
  16343. /**
  16344. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16345. * @param convertedColor defines the Color4 object where to store the linear space version
  16346. * @returns the unmodified Color4
  16347. */
  16348. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16349. /**
  16350. * Computes a new Color4 converted from the current one to gamma space
  16351. * @returns a new Color4 object
  16352. */
  16353. toGammaSpace(): Color4;
  16354. /**
  16355. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16356. * @param convertedColor defines the Color4 object where to store the gamma space version
  16357. * @returns the unmodified Color4
  16358. */
  16359. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16360. /**
  16361. * Creates a new Color4 from the string containing valid hexadecimal values
  16362. * @param hex defines a string containing valid hexadecimal values
  16363. * @returns a new Color4 object
  16364. */
  16365. static FromHexString(hex: string): Color4;
  16366. /**
  16367. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16368. * @param left defines the start value
  16369. * @param right defines the end value
  16370. * @param amount defines the gradient factor
  16371. * @returns a new Color4 object
  16372. */
  16373. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16374. /**
  16375. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16376. * @param left defines the start value
  16377. * @param right defines the end value
  16378. * @param amount defines the gradient factor
  16379. * @param result defines the Color4 object where to store data
  16380. */
  16381. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16382. /**
  16383. * Creates a new Color4 from the starting index element of the given array
  16384. * @param array defines the source array to read from
  16385. * @param offset defines the offset in the source array
  16386. * @returns a new Color4 object
  16387. */
  16388. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16389. /**
  16390. * Creates a new Color3 from integer values (< 256)
  16391. * @param r defines the red component to read from (value between 0 and 255)
  16392. * @param g defines the green component to read from (value between 0 and 255)
  16393. * @param b defines the blue component to read from (value between 0 and 255)
  16394. * @param a defines the alpha component to read from (value between 0 and 255)
  16395. * @returns a new Color3 object
  16396. */
  16397. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16398. /**
  16399. * Check the content of a given array and convert it to an array containing RGBA data
  16400. * If the original array was already containing count * 4 values then it is returned directly
  16401. * @param colors defines the array to check
  16402. * @param count defines the number of RGBA data to expect
  16403. * @returns an array containing count * 4 values (RGBA)
  16404. */
  16405. static CheckColors4(colors: number[], count: number): number[];
  16406. }
  16407. /**
  16408. * Class representing a vector containing 2 coordinates
  16409. */
  16410. class Vector2 {
  16411. /** defines the first coordinate */
  16412. x: number;
  16413. /** defines the second coordinate */
  16414. y: number;
  16415. /**
  16416. * Creates a new Vector2 from the given x and y coordinates
  16417. * @param x defines the first coordinate
  16418. * @param y defines the second coordinate
  16419. */
  16420. constructor(
  16421. /** defines the first coordinate */
  16422. x?: number,
  16423. /** defines the second coordinate */
  16424. y?: number);
  16425. /**
  16426. * Gets a string with the Vector2 coordinates
  16427. * @returns a string with the Vector2 coordinates
  16428. */
  16429. toString(): string;
  16430. /**
  16431. * Gets class name
  16432. * @returns the string "Vector2"
  16433. */
  16434. getClassName(): string;
  16435. /**
  16436. * Gets current vector hash code
  16437. * @returns the Vector2 hash code as a number
  16438. */
  16439. getHashCode(): number;
  16440. /**
  16441. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16442. * @param array defines the source array
  16443. * @param index defines the offset in source array
  16444. * @returns the current Vector2
  16445. */
  16446. toArray(array: FloatArray, index?: number): Vector2;
  16447. /**
  16448. * Copy the current vector to an array
  16449. * @returns a new array with 2 elements: the Vector2 coordinates.
  16450. */
  16451. asArray(): number[];
  16452. /**
  16453. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16454. * @param source defines the source Vector2
  16455. * @returns the current updated Vector2
  16456. */
  16457. copyFrom(source: Vector2): Vector2;
  16458. /**
  16459. * Sets the Vector2 coordinates with the given floats
  16460. * @param x defines the first coordinate
  16461. * @param y defines the second coordinate
  16462. * @returns the current updated Vector2
  16463. */
  16464. copyFromFloats(x: number, y: number): Vector2;
  16465. /**
  16466. * Sets the Vector2 coordinates with the given floats
  16467. * @param x defines the first coordinate
  16468. * @param y defines the second coordinate
  16469. * @returns the current updated Vector2
  16470. */
  16471. set(x: number, y: number): Vector2;
  16472. /**
  16473. * Add another vector with the current one
  16474. * @param otherVector defines the other vector
  16475. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16476. */
  16477. add(otherVector: Vector2): Vector2;
  16478. /**
  16479. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16480. * @param otherVector defines the other vector
  16481. * @param result defines the target vector
  16482. * @returns the unmodified current Vector2
  16483. */
  16484. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16485. /**
  16486. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16487. * @param otherVector defines the other vector
  16488. * @returns the current updated Vector2
  16489. */
  16490. addInPlace(otherVector: Vector2): Vector2;
  16491. /**
  16492. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16493. * @param otherVector defines the other vector
  16494. * @returns a new Vector2
  16495. */
  16496. addVector3(otherVector: Vector3): Vector2;
  16497. /**
  16498. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16499. * @param otherVector defines the other vector
  16500. * @returns a new Vector2
  16501. */
  16502. subtract(otherVector: Vector2): Vector2;
  16503. /**
  16504. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16505. * @param otherVector defines the other vector
  16506. * @param result defines the target vector
  16507. * @returns the unmodified current Vector2
  16508. */
  16509. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16510. /**
  16511. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16512. * @param otherVector defines the other vector
  16513. * @returns the current updated Vector2
  16514. */
  16515. subtractInPlace(otherVector: Vector2): Vector2;
  16516. /**
  16517. * Multiplies in place the current Vector2 coordinates by the given ones
  16518. * @param otherVector defines the other vector
  16519. * @returns the current updated Vector2
  16520. */
  16521. multiplyInPlace(otherVector: Vector2): Vector2;
  16522. /**
  16523. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16524. * @param otherVector defines the other vector
  16525. * @returns a new Vector2
  16526. */
  16527. multiply(otherVector: Vector2): Vector2;
  16528. /**
  16529. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16530. * @param otherVector defines the other vector
  16531. * @param result defines the target vector
  16532. * @returns the unmodified current Vector2
  16533. */
  16534. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16535. /**
  16536. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16537. * @param x defines the first coordinate
  16538. * @param y defines the second coordinate
  16539. * @returns a new Vector2
  16540. */
  16541. multiplyByFloats(x: number, y: number): Vector2;
  16542. /**
  16543. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16544. * @param otherVector defines the other vector
  16545. * @returns a new Vector2
  16546. */
  16547. divide(otherVector: Vector2): Vector2;
  16548. /**
  16549. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16550. * @param otherVector defines the other vector
  16551. * @param result defines the target vector
  16552. * @returns the unmodified current Vector2
  16553. */
  16554. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16555. /**
  16556. * Divides the current Vector2 coordinates by the given ones
  16557. * @param otherVector defines the other vector
  16558. * @returns the current updated Vector2
  16559. */
  16560. divideInPlace(otherVector: Vector2): Vector2;
  16561. /**
  16562. * Gets a new Vector2 with current Vector2 negated coordinates
  16563. * @returns a new Vector2
  16564. */
  16565. negate(): Vector2;
  16566. /**
  16567. * Multiply the Vector2 coordinates by scale
  16568. * @param scale defines the scaling factor
  16569. * @returns the current updated Vector2
  16570. */
  16571. scaleInPlace(scale: number): Vector2;
  16572. /**
  16573. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16574. * @param scale defines the scaling factor
  16575. * @returns a new Vector2
  16576. */
  16577. scale(scale: number): Vector2;
  16578. /**
  16579. * Scale the current Vector2 values by a factor to a given Vector2
  16580. * @param scale defines the scale factor
  16581. * @param result defines the Vector2 object where to store the result
  16582. * @returns the unmodified current Vector2
  16583. */
  16584. scaleToRef(scale: number, result: Vector2): Vector2;
  16585. /**
  16586. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16587. * @param scale defines the scale factor
  16588. * @param result defines the Vector2 object where to store the result
  16589. * @returns the unmodified current Vector2
  16590. */
  16591. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16592. /**
  16593. * Gets a boolean if two vectors are equals
  16594. * @param otherVector defines the other vector
  16595. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16596. */
  16597. equals(otherVector: Vector2): boolean;
  16598. /**
  16599. * Gets a boolean if two vectors are equals (using an epsilon value)
  16600. * @param otherVector defines the other vector
  16601. * @param epsilon defines the minimal distance to consider equality
  16602. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16603. */
  16604. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16605. /**
  16606. * Gets a new Vector2 from current Vector2 floored values
  16607. * @returns a new Vector2
  16608. */
  16609. floor(): Vector2;
  16610. /**
  16611. * Gets a new Vector2 from current Vector2 floored values
  16612. * @returns a new Vector2
  16613. */
  16614. fract(): Vector2;
  16615. /**
  16616. * Gets the length of the vector
  16617. * @returns the vector length (float)
  16618. */
  16619. length(): number;
  16620. /**
  16621. * Gets the vector squared length
  16622. * @returns the vector squared length (float)
  16623. */
  16624. lengthSquared(): number;
  16625. /**
  16626. * Normalize the vector
  16627. * @returns the current updated Vector2
  16628. */
  16629. normalize(): Vector2;
  16630. /**
  16631. * Gets a new Vector2 copied from the Vector2
  16632. * @returns a new Vector2
  16633. */
  16634. clone(): Vector2;
  16635. /**
  16636. * Gets a new Vector2(0, 0)
  16637. * @returns a new Vector2
  16638. */
  16639. static Zero(): Vector2;
  16640. /**
  16641. * Gets a new Vector2(1, 1)
  16642. * @returns a new Vector2
  16643. */
  16644. static One(): Vector2;
  16645. /**
  16646. * Gets a new Vector2 set from the given index element of the given array
  16647. * @param array defines the data source
  16648. * @param offset defines the offset in the data source
  16649. * @returns a new Vector2
  16650. */
  16651. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16652. /**
  16653. * Sets "result" from the given index element of the given array
  16654. * @param array defines the data source
  16655. * @param offset defines the offset in the data source
  16656. * @param result defines the target vector
  16657. */
  16658. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16659. /**
  16660. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16661. * @param value1 defines 1st point of control
  16662. * @param value2 defines 2nd point of control
  16663. * @param value3 defines 3rd point of control
  16664. * @param value4 defines 4th point of control
  16665. * @param amount defines the interpolation factor
  16666. * @returns a new Vector2
  16667. */
  16668. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16669. /**
  16670. * 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".
  16671. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16672. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16673. * @param value defines the value to clamp
  16674. * @param min defines the lower limit
  16675. * @param max defines the upper limit
  16676. * @returns a new Vector2
  16677. */
  16678. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16679. /**
  16680. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16681. * @param value1 defines the 1st control point
  16682. * @param tangent1 defines the outgoing tangent
  16683. * @param value2 defines the 2nd control point
  16684. * @param tangent2 defines the incoming tangent
  16685. * @param amount defines the interpolation factor
  16686. * @returns a new Vector2
  16687. */
  16688. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16689. /**
  16690. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16691. * @param start defines the start vector
  16692. * @param end defines the end vector
  16693. * @param amount defines the interpolation factor
  16694. * @returns a new Vector2
  16695. */
  16696. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16697. /**
  16698. * Gets the dot product of the vector "left" and the vector "right"
  16699. * @param left defines first vector
  16700. * @param right defines second vector
  16701. * @returns the dot product (float)
  16702. */
  16703. static Dot(left: Vector2, right: Vector2): number;
  16704. /**
  16705. * Returns a new Vector2 equal to the normalized given vector
  16706. * @param vector defines the vector to normalize
  16707. * @returns a new Vector2
  16708. */
  16709. static Normalize(vector: Vector2): Vector2;
  16710. /**
  16711. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16712. * @param left defines 1st vector
  16713. * @param right defines 2nd vector
  16714. * @returns a new Vector2
  16715. */
  16716. static Minimize(left: Vector2, right: Vector2): Vector2;
  16717. /**
  16718. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16719. * @param left defines 1st vector
  16720. * @param right defines 2nd vector
  16721. * @returns a new Vector2
  16722. */
  16723. static Maximize(left: Vector2, right: Vector2): Vector2;
  16724. /**
  16725. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16726. * @param vector defines the vector to transform
  16727. * @param transformation defines the matrix to apply
  16728. * @returns a new Vector2
  16729. */
  16730. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16731. /**
  16732. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16733. * @param vector defines the vector to transform
  16734. * @param transformation defines the matrix to apply
  16735. * @param result defines the target vector
  16736. */
  16737. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16738. /**
  16739. * Determines if a given vector is included in a triangle
  16740. * @param p defines the vector to test
  16741. * @param p0 defines 1st triangle point
  16742. * @param p1 defines 2nd triangle point
  16743. * @param p2 defines 3rd triangle point
  16744. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16745. */
  16746. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16747. /**
  16748. * Gets the distance between the vectors "value1" and "value2"
  16749. * @param value1 defines first vector
  16750. * @param value2 defines second vector
  16751. * @returns the distance between vectors
  16752. */
  16753. static Distance(value1: Vector2, value2: Vector2): number;
  16754. /**
  16755. * Returns the squared distance between the vectors "value1" and "value2"
  16756. * @param value1 defines first vector
  16757. * @param value2 defines second vector
  16758. * @returns the squared distance between vectors
  16759. */
  16760. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16761. /**
  16762. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16763. * @param value1 defines first vector
  16764. * @param value2 defines second vector
  16765. * @returns a new Vector2
  16766. */
  16767. static Center(value1: Vector2, value2: Vector2): Vector2;
  16768. /**
  16769. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16770. * @param p defines the middle point
  16771. * @param segA defines one point of the segment
  16772. * @param segB defines the other point of the segment
  16773. * @returns the shortest distance
  16774. */
  16775. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16776. }
  16777. /**
  16778. * Classed used to store (x,y,z) vector representation
  16779. * A Vector3 is the main object used in 3D geometry
  16780. * It can represent etiher the coordinates of a point the space, either a direction
  16781. * Reminder: Babylon.js uses a left handed forward facing system
  16782. */
  16783. class Vector3 {
  16784. /**
  16785. * Defines the first coordinates (on X axis)
  16786. */
  16787. x: number;
  16788. /**
  16789. * Defines the second coordinates (on Y axis)
  16790. */
  16791. y: number;
  16792. /**
  16793. * Defines the third coordinates (on Z axis)
  16794. */
  16795. z: number;
  16796. /**
  16797. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16798. * @param x defines the first coordinates (on X axis)
  16799. * @param y defines the second coordinates (on Y axis)
  16800. * @param z defines the third coordinates (on Z axis)
  16801. */
  16802. constructor(
  16803. /**
  16804. * Defines the first coordinates (on X axis)
  16805. */
  16806. x?: number,
  16807. /**
  16808. * Defines the second coordinates (on Y axis)
  16809. */
  16810. y?: number,
  16811. /**
  16812. * Defines the third coordinates (on Z axis)
  16813. */
  16814. z?: number);
  16815. /**
  16816. * Creates a string representation of the Vector3
  16817. * @returns a string with the Vector3 coordinates.
  16818. */
  16819. toString(): string;
  16820. /**
  16821. * Gets the class name
  16822. * @returns the string "Vector3"
  16823. */
  16824. getClassName(): string;
  16825. /**
  16826. * Creates the Vector3 hash code
  16827. * @returns a number which tends to be unique between Vector3 instances
  16828. */
  16829. getHashCode(): number;
  16830. /**
  16831. * Creates an array containing three elements : the coordinates of the Vector3
  16832. * @returns a new array of numbers
  16833. */
  16834. asArray(): number[];
  16835. /**
  16836. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16837. * @param array defines the destination array
  16838. * @param index defines the offset in the destination array
  16839. * @returns the current Vector3
  16840. */
  16841. toArray(array: FloatArray, index?: number): Vector3;
  16842. /**
  16843. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16844. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16845. */
  16846. toQuaternion(): Quaternion;
  16847. /**
  16848. * Adds the given vector to the current Vector3
  16849. * @param otherVector defines the second operand
  16850. * @returns the current updated Vector3
  16851. */
  16852. addInPlace(otherVector: Vector3): Vector3;
  16853. /**
  16854. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16855. * @param otherVector defines the second operand
  16856. * @returns the resulting Vector3
  16857. */
  16858. add(otherVector: Vector3): Vector3;
  16859. /**
  16860. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16861. * @param otherVector defines the second operand
  16862. * @param result defines the Vector3 object where to store the result
  16863. * @returns the current Vector3
  16864. */
  16865. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16866. /**
  16867. * Subtract the given vector from the current Vector3
  16868. * @param otherVector defines the second operand
  16869. * @returns the current updated Vector3
  16870. */
  16871. subtractInPlace(otherVector: Vector3): Vector3;
  16872. /**
  16873. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16874. * @param otherVector defines the second operand
  16875. * @returns the resulting Vector3
  16876. */
  16877. subtract(otherVector: Vector3): Vector3;
  16878. /**
  16879. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16880. * @param otherVector defines the second operand
  16881. * @param result defines the Vector3 object where to store the result
  16882. * @returns the current Vector3
  16883. */
  16884. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16885. /**
  16886. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16887. * @param x defines the x coordinate of the operand
  16888. * @param y defines the y coordinate of the operand
  16889. * @param z defines the z coordinate of the operand
  16890. * @returns the resulting Vector3
  16891. */
  16892. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16893. /**
  16894. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16895. * @param x defines the x coordinate of the operand
  16896. * @param y defines the y coordinate of the operand
  16897. * @param z defines the z coordinate of the operand
  16898. * @param result defines the Vector3 object where to store the result
  16899. * @returns the current Vector3
  16900. */
  16901. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16902. /**
  16903. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16904. * @returns a new Vector3
  16905. */
  16906. negate(): Vector3;
  16907. /**
  16908. * Multiplies the Vector3 coordinates by the float "scale"
  16909. * @param scale defines the multiplier factor
  16910. * @returns the current updated Vector3
  16911. */
  16912. scaleInPlace(scale: number): Vector3;
  16913. /**
  16914. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16915. * @param scale defines the multiplier factor
  16916. * @returns a new Vector3
  16917. */
  16918. scale(scale: number): Vector3;
  16919. /**
  16920. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16921. * @param scale defines the multiplier factor
  16922. * @param result defines the Vector3 object where to store the result
  16923. * @returns the current Vector3
  16924. */
  16925. scaleToRef(scale: number, result: Vector3): Vector3;
  16926. /**
  16927. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16928. * @param scale defines the scale factor
  16929. * @param result defines the Vector3 object where to store the result
  16930. * @returns the unmodified current Vector3
  16931. */
  16932. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16933. /**
  16934. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16935. * @param otherVector defines the second operand
  16936. * @returns true if both vectors are equals
  16937. */
  16938. equals(otherVector: Vector3): boolean;
  16939. /**
  16940. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16941. * @param otherVector defines the second operand
  16942. * @param epsilon defines the minimal distance to define values as equals
  16943. * @returns true if both vectors are distant less than epsilon
  16944. */
  16945. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16946. /**
  16947. * Returns true if the current Vector3 coordinates equals the given floats
  16948. * @param x defines the x coordinate of the operand
  16949. * @param y defines the y coordinate of the operand
  16950. * @param z defines the z coordinate of the operand
  16951. * @returns true if both vectors are equals
  16952. */
  16953. equalsToFloats(x: number, y: number, z: number): boolean;
  16954. /**
  16955. * Multiplies the current Vector3 coordinates by the given ones
  16956. * @param otherVector defines the second operand
  16957. * @returns the current updated Vector3
  16958. */
  16959. multiplyInPlace(otherVector: Vector3): Vector3;
  16960. /**
  16961. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16962. * @param otherVector defines the second operand
  16963. * @returns the new Vector3
  16964. */
  16965. multiply(otherVector: Vector3): Vector3;
  16966. /**
  16967. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16968. * @param otherVector defines the second operand
  16969. * @param result defines the Vector3 object where to store the result
  16970. * @returns the current Vector3
  16971. */
  16972. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16973. /**
  16974. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16975. * @param x defines the x coordinate of the operand
  16976. * @param y defines the y coordinate of the operand
  16977. * @param z defines the z coordinate of the operand
  16978. * @returns the new Vector3
  16979. */
  16980. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16981. /**
  16982. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16983. * @param otherVector defines the second operand
  16984. * @returns the new Vector3
  16985. */
  16986. divide(otherVector: Vector3): Vector3;
  16987. /**
  16988. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16989. * @param otherVector defines the second operand
  16990. * @param result defines the Vector3 object where to store the result
  16991. * @returns the current Vector3
  16992. */
  16993. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16994. /**
  16995. * Divides the current Vector3 coordinates by the given ones.
  16996. * @param otherVector defines the second operand
  16997. * @returns the current updated Vector3
  16998. */
  16999. divideInPlace(otherVector: Vector3): Vector3;
  17000. /**
  17001. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  17002. * @param other defines the second operand
  17003. * @returns the current updated Vector3
  17004. */
  17005. minimizeInPlace(other: Vector3): Vector3;
  17006. /**
  17007. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  17008. * @param other defines the second operand
  17009. * @returns the current updated Vector3
  17010. */
  17011. maximizeInPlace(other: Vector3): Vector3;
  17012. /**
  17013. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  17014. */
  17015. readonly isNonUniform: boolean;
  17016. /**
  17017. * Gets a new Vector3 from current Vector3 floored values
  17018. * @returns a new Vector3
  17019. */
  17020. floor(): Vector3;
  17021. /**
  17022. * Gets a new Vector3 from current Vector3 floored values
  17023. * @returns a new Vector3
  17024. */
  17025. fract(): Vector3;
  17026. /**
  17027. * Gets the length of the Vector3
  17028. * @returns the length of the Vecto3
  17029. */
  17030. length(): number;
  17031. /**
  17032. * Gets the squared length of the Vector3
  17033. * @returns squared length of the Vector3
  17034. */
  17035. lengthSquared(): number;
  17036. /**
  17037. * Normalize the current Vector3.
  17038. * Please note that this is an in place operation.
  17039. * @returns the current updated Vector3
  17040. */
  17041. normalize(): Vector3;
  17042. /**
  17043. * Normalize the current Vector3 to a new vector
  17044. * @returns the new Vector3
  17045. */
  17046. normalizeToNew(): Vector3;
  17047. /**
  17048. * Normalize the current Vector3 to the reference
  17049. * @param reference define the Vector3 to update
  17050. * @returns the updated Vector3
  17051. */
  17052. normalizeToRef(reference: Vector3): Vector3;
  17053. /**
  17054. * Creates a new Vector3 copied from the current Vector3
  17055. * @returns the new Vector3
  17056. */
  17057. clone(): Vector3;
  17058. /**
  17059. * Copies the given vector coordinates to the current Vector3 ones
  17060. * @param source defines the source Vector3
  17061. * @returns the current updated Vector3
  17062. */
  17063. copyFrom(source: Vector3): Vector3;
  17064. /**
  17065. * Copies the given floats to the current Vector3 coordinates
  17066. * @param x defines the x coordinate of the operand
  17067. * @param y defines the y coordinate of the operand
  17068. * @param z defines the z coordinate of the operand
  17069. * @returns the current updated Vector3
  17070. */
  17071. copyFromFloats(x: number, y: number, z: number): Vector3;
  17072. /**
  17073. * Copies the given floats to the current Vector3 coordinates
  17074. * @param x defines the x coordinate of the operand
  17075. * @param y defines the y coordinate of the operand
  17076. * @param z defines the z coordinate of the operand
  17077. * @returns the current updated Vector3
  17078. */
  17079. set(x: number, y: number, z: number): Vector3;
  17080. /**
  17081. * Get the clip factor between two vectors
  17082. * @param vector0 defines the first operand
  17083. * @param vector1 defines the second operand
  17084. * @param axis defines the axis to use
  17085. * @param size defines the size along the axis
  17086. * @returns the clip factor
  17087. */
  17088. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  17089. /**
  17090. * Get angle between two vectors
  17091. * @param vector0 angle between vector0 and vector1
  17092. * @param vector1 angle between vector0 and vector1
  17093. * @param normal direction of the normal
  17094. * @return the angle between vector0 and vector1
  17095. */
  17096. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  17097. /**
  17098. * Returns a new Vector3 set from the index "offset" of the given array
  17099. * @param array defines the source array
  17100. * @param offset defines the offset in the source array
  17101. * @returns the new Vector3
  17102. */
  17103. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  17104. /**
  17105. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  17106. * This function is deprecated. Use FromArray instead
  17107. * @param array defines the source array
  17108. * @param offset defines the offset in the source array
  17109. * @returns the new Vector3
  17110. */
  17111. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  17112. /**
  17113. * Sets the given vector "result" with the element values from the index "offset" of the given array
  17114. * @param array defines the source array
  17115. * @param offset defines the offset in the source array
  17116. * @param result defines the Vector3 where to store the result
  17117. */
  17118. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  17119. /**
  17120. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  17121. * This function is deprecated. Use FromArrayToRef instead.
  17122. * @param array defines the source array
  17123. * @param offset defines the offset in the source array
  17124. * @param result defines the Vector3 where to store the result
  17125. */
  17126. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  17127. /**
  17128. * Sets the given vector "result" with the given floats.
  17129. * @param x defines the x coordinate of the source
  17130. * @param y defines the y coordinate of the source
  17131. * @param z defines the z coordinate of the source
  17132. * @param result defines the Vector3 where to store the result
  17133. */
  17134. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  17135. /**
  17136. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  17137. * @returns a new empty Vector3
  17138. */
  17139. static Zero(): Vector3;
  17140. /**
  17141. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  17142. * @returns a new unit Vector3
  17143. */
  17144. static One(): Vector3;
  17145. /**
  17146. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  17147. * @returns a new up Vector3
  17148. */
  17149. static Up(): Vector3;
  17150. /**
  17151. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  17152. * @returns a new down Vector3
  17153. */
  17154. static Down(): Vector3;
  17155. /**
  17156. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  17157. * @returns a new forward Vector3
  17158. */
  17159. static Forward(): Vector3;
  17160. /**
  17161. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  17162. * @returns a new right Vector3
  17163. */
  17164. static Right(): Vector3;
  17165. /**
  17166. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  17167. * @returns a new left Vector3
  17168. */
  17169. static Left(): Vector3;
  17170. /**
  17171. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  17172. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17173. * @param vector defines the Vector3 to transform
  17174. * @param transformation defines the transformation matrix
  17175. * @returns the transformed Vector3
  17176. */
  17177. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  17178. /**
  17179. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  17180. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17181. * @param vector defines the Vector3 to transform
  17182. * @param transformation defines the transformation matrix
  17183. * @param result defines the Vector3 where to store the result
  17184. */
  17185. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17186. /**
  17187. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  17188. * This method computes tranformed coordinates only, not transformed direction vectors
  17189. * @param x define the x coordinate of the source vector
  17190. * @param y define the y coordinate of the source vector
  17191. * @param z define the z coordinate of the source vector
  17192. * @param transformation defines the transformation matrix
  17193. * @param result defines the Vector3 where to store the result
  17194. */
  17195. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17196. /**
  17197. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  17198. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17199. * @param vector defines the Vector3 to transform
  17200. * @param transformation defines the transformation matrix
  17201. * @returns the new Vector3
  17202. */
  17203. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  17204. /**
  17205. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  17206. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17207. * @param vector defines the Vector3 to transform
  17208. * @param transformation defines the transformation matrix
  17209. * @param result defines the Vector3 where to store the result
  17210. */
  17211. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17212. /**
  17213. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  17214. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17215. * @param x define the x coordinate of the source vector
  17216. * @param y define the y coordinate of the source vector
  17217. * @param z define the z coordinate of the source vector
  17218. * @param transformation defines the transformation matrix
  17219. * @param result defines the Vector3 where to store the result
  17220. */
  17221. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17222. /**
  17223. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  17224. * @param value1 defines the first control point
  17225. * @param value2 defines the second control point
  17226. * @param value3 defines the third control point
  17227. * @param value4 defines the fourth control point
  17228. * @param amount defines the amount on the spline to use
  17229. * @returns the new Vector3
  17230. */
  17231. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  17232. /**
  17233. * 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"
  17234. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  17235. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  17236. * @param value defines the current value
  17237. * @param min defines the lower range value
  17238. * @param max defines the upper range value
  17239. * @returns the new Vector3
  17240. */
  17241. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17242. /**
  17243. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17244. * @param value1 defines the first control point
  17245. * @param tangent1 defines the first tangent vector
  17246. * @param value2 defines the second control point
  17247. * @param tangent2 defines the second tangent vector
  17248. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17249. * @returns the new Vector3
  17250. */
  17251. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17252. /**
  17253. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17254. * @param start defines the start value
  17255. * @param end defines the end value
  17256. * @param amount max defines amount between both (between 0 and 1)
  17257. * @returns the new Vector3
  17258. */
  17259. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17260. /**
  17261. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17262. * @param start defines the start value
  17263. * @param end defines the end value
  17264. * @param amount max defines amount between both (between 0 and 1)
  17265. * @param result defines the Vector3 where to store the result
  17266. */
  17267. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17268. /**
  17269. * Returns the dot product (float) between the vectors "left" and "right"
  17270. * @param left defines the left operand
  17271. * @param right defines the right operand
  17272. * @returns the dot product
  17273. */
  17274. static Dot(left: Vector3, right: Vector3): number;
  17275. /**
  17276. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17277. * The cross product is then orthogonal to both "left" and "right"
  17278. * @param left defines the left operand
  17279. * @param right defines the right operand
  17280. * @returns the cross product
  17281. */
  17282. static Cross(left: Vector3, right: Vector3): Vector3;
  17283. /**
  17284. * Sets the given vector "result" with the cross product of "left" and "right"
  17285. * The cross product is then orthogonal to both "left" and "right"
  17286. * @param left defines the left operand
  17287. * @param right defines the right operand
  17288. * @param result defines the Vector3 where to store the result
  17289. */
  17290. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17291. /**
  17292. * Returns a new Vector3 as the normalization of the given vector
  17293. * @param vector defines the Vector3 to normalize
  17294. * @returns the new Vector3
  17295. */
  17296. static Normalize(vector: Vector3): Vector3;
  17297. /**
  17298. * Sets the given vector "result" with the normalization of the given first vector
  17299. * @param vector defines the Vector3 to normalize
  17300. * @param result defines the Vector3 where to store the result
  17301. */
  17302. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17303. private static _viewportMatrixCache;
  17304. /**
  17305. * Project a Vector3 onto screen space
  17306. * @param vector defines the Vector3 to project
  17307. * @param world defines the world matrix to use
  17308. * @param transform defines the transform (view x projection) matrix to use
  17309. * @param viewport defines the screen viewport to use
  17310. * @returns the new Vector3
  17311. */
  17312. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17313. /**
  17314. * Unproject from screen space to object space
  17315. * @param source defines the screen space Vector3 to use
  17316. * @param viewportWidth defines the current width of the viewport
  17317. * @param viewportHeight defines the current height of the viewport
  17318. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17319. * @param transform defines the transform (view x projection) matrix to use
  17320. * @returns the new Vector3
  17321. */
  17322. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17323. /**
  17324. * Unproject from screen space to object space
  17325. * @param source defines the screen space Vector3 to use
  17326. * @param viewportWidth defines the current width of the viewport
  17327. * @param viewportHeight defines the current height of the viewport
  17328. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17329. * @param view defines the view matrix to use
  17330. * @param projection defines the projection matrix to use
  17331. * @returns the new Vector3
  17332. */
  17333. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17334. /**
  17335. * Unproject from screen space to object space
  17336. * @param source defines the screen space Vector3 to use
  17337. * @param viewportWidth defines the current width of the viewport
  17338. * @param viewportHeight defines the current height of the viewport
  17339. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17340. * @param view defines the view matrix to use
  17341. * @param projection defines the projection matrix to use
  17342. * @param result defines the Vector3 where to store the result
  17343. */
  17344. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17345. /**
  17346. * Unproject from screen space to object space
  17347. * @param sourceX defines the screen space x coordinate to use
  17348. * @param sourceY defines the screen space y coordinate to use
  17349. * @param sourceZ defines the screen space z coordinate to use
  17350. * @param viewportWidth defines the current width of the viewport
  17351. * @param viewportHeight defines the current height of the viewport
  17352. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17353. * @param view defines the view matrix to use
  17354. * @param projection defines the projection matrix to use
  17355. * @param result defines the Vector3 where to store the result
  17356. */
  17357. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17358. /**
  17359. * Gets the minimal coordinate values between two Vector3
  17360. * @param left defines the first operand
  17361. * @param right defines the second operand
  17362. * @returns the new Vector3
  17363. */
  17364. static Minimize(left: Vector3, right: Vector3): Vector3;
  17365. /**
  17366. * Gets the maximal coordinate values between two Vector3
  17367. * @param left defines the first operand
  17368. * @param right defines the second operand
  17369. * @returns the new Vector3
  17370. */
  17371. static Maximize(left: Vector3, right: Vector3): Vector3;
  17372. /**
  17373. * Returns the distance between the vectors "value1" and "value2"
  17374. * @param value1 defines the first operand
  17375. * @param value2 defines the second operand
  17376. * @returns the distance
  17377. */
  17378. static Distance(value1: Vector3, value2: Vector3): number;
  17379. /**
  17380. * Returns the squared distance between the vectors "value1" and "value2"
  17381. * @param value1 defines the first operand
  17382. * @param value2 defines the second operand
  17383. * @returns the squared distance
  17384. */
  17385. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17386. /**
  17387. * Returns a new Vector3 located at the center between "value1" and "value2"
  17388. * @param value1 defines the first operand
  17389. * @param value2 defines the second operand
  17390. * @returns the new Vector3
  17391. */
  17392. static Center(value1: Vector3, value2: Vector3): Vector3;
  17393. /**
  17394. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17395. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17396. * to something in order to rotate it from its local system to the given target system
  17397. * Note: axis1, axis2 and axis3 are normalized during this operation
  17398. * @param axis1 defines the first axis
  17399. * @param axis2 defines the second axis
  17400. * @param axis3 defines the third axis
  17401. * @returns a new Vector3
  17402. */
  17403. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17404. /**
  17405. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17406. * @param axis1 defines the first axis
  17407. * @param axis2 defines the second axis
  17408. * @param axis3 defines the third axis
  17409. * @param ref defines the Vector3 where to store the result
  17410. */
  17411. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17412. }
  17413. class Vector4 {
  17414. x: number;
  17415. y: number;
  17416. z: number;
  17417. w: number;
  17418. /**
  17419. * Creates a Vector4 object from the given floats.
  17420. */
  17421. constructor(x: number, y: number, z: number, w: number);
  17422. /**
  17423. * Returns the string with the Vector4 coordinates.
  17424. */
  17425. toString(): string;
  17426. /**
  17427. * Returns the string "Vector4".
  17428. */
  17429. getClassName(): string;
  17430. /**
  17431. * Returns the Vector4 hash code.
  17432. */
  17433. getHashCode(): number;
  17434. /**
  17435. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17436. */
  17437. asArray(): number[];
  17438. /**
  17439. * Populates the given array from the given index with the Vector4 coordinates.
  17440. * Returns the Vector4.
  17441. */
  17442. toArray(array: FloatArray, index?: number): Vector4;
  17443. /**
  17444. * Adds the given vector to the current Vector4.
  17445. * Returns the updated Vector4.
  17446. */
  17447. addInPlace(otherVector: Vector4): Vector4;
  17448. /**
  17449. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17450. */
  17451. add(otherVector: Vector4): Vector4;
  17452. /**
  17453. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17454. * Returns the current Vector4.
  17455. */
  17456. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17457. /**
  17458. * Subtract in place the given vector from the current Vector4.
  17459. * Returns the updated Vector4.
  17460. */
  17461. subtractInPlace(otherVector: Vector4): Vector4;
  17462. /**
  17463. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17464. */
  17465. subtract(otherVector: Vector4): Vector4;
  17466. /**
  17467. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17468. * Returns the current Vector4.
  17469. */
  17470. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17471. /**
  17472. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17473. */
  17474. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17475. /**
  17476. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17477. * Returns the current Vector4.
  17478. */
  17479. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17480. /**
  17481. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17482. */
  17483. negate(): Vector4;
  17484. /**
  17485. * Multiplies the current Vector4 coordinates by scale (float).
  17486. * Returns the updated Vector4.
  17487. */
  17488. scaleInPlace(scale: number): Vector4;
  17489. /**
  17490. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17491. */
  17492. scale(scale: number): Vector4;
  17493. /**
  17494. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17495. * Returns the current Vector4.
  17496. */
  17497. scaleToRef(scale: number, result: Vector4): Vector4;
  17498. /**
  17499. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17500. * @param scale defines the scale factor
  17501. * @param result defines the Vector4 object where to store the result
  17502. * @returns the unmodified current Vector4
  17503. */
  17504. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17505. /**
  17506. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17507. */
  17508. equals(otherVector: Vector4): boolean;
  17509. /**
  17510. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17511. */
  17512. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17513. /**
  17514. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17515. */
  17516. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17517. /**
  17518. * Multiplies in place the current Vector4 by the given one.
  17519. * Returns the updated Vector4.
  17520. */
  17521. multiplyInPlace(otherVector: Vector4): Vector4;
  17522. /**
  17523. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17524. */
  17525. multiply(otherVector: Vector4): Vector4;
  17526. /**
  17527. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17528. * Returns the current Vector4.
  17529. */
  17530. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17531. /**
  17532. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17533. */
  17534. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17535. /**
  17536. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17537. */
  17538. divide(otherVector: Vector4): Vector4;
  17539. /**
  17540. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17541. * Returns the current Vector4.
  17542. */
  17543. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17544. /**
  17545. * Divides the current Vector3 coordinates by the given ones.
  17546. * @returns the updated Vector3.
  17547. */
  17548. divideInPlace(otherVector: Vector4): Vector4;
  17549. /**
  17550. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17551. * @param other defines the second operand
  17552. * @returns the current updated Vector4
  17553. */
  17554. minimizeInPlace(other: Vector4): Vector4;
  17555. /**
  17556. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17557. * @param other defines the second operand
  17558. * @returns the current updated Vector4
  17559. */
  17560. maximizeInPlace(other: Vector4): Vector4;
  17561. /**
  17562. * Gets a new Vector4 from current Vector4 floored values
  17563. * @returns a new Vector4
  17564. */
  17565. floor(): Vector4;
  17566. /**
  17567. * Gets a new Vector4 from current Vector3 floored values
  17568. * @returns a new Vector4
  17569. */
  17570. fract(): Vector4;
  17571. /**
  17572. * Returns the Vector4 length (float).
  17573. */
  17574. length(): number;
  17575. /**
  17576. * Returns the Vector4 squared length (float).
  17577. */
  17578. lengthSquared(): number;
  17579. /**
  17580. * Normalizes in place the Vector4.
  17581. * Returns the updated Vector4.
  17582. */
  17583. normalize(): Vector4;
  17584. /**
  17585. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17586. */
  17587. toVector3(): Vector3;
  17588. /**
  17589. * Returns a new Vector4 copied from the current one.
  17590. */
  17591. clone(): Vector4;
  17592. /**
  17593. * Updates the current Vector4 with the given one coordinates.
  17594. * Returns the updated Vector4.
  17595. */
  17596. copyFrom(source: Vector4): Vector4;
  17597. /**
  17598. * Updates the current Vector4 coordinates with the given floats.
  17599. * Returns the updated Vector4.
  17600. */
  17601. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17602. /**
  17603. * Updates the current Vector4 coordinates with the given floats.
  17604. * Returns the updated Vector4.
  17605. */
  17606. set(x: number, y: number, z: number, w: number): Vector4;
  17607. /**
  17608. * Returns a new Vector4 set from the starting index of the given array.
  17609. */
  17610. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17611. /**
  17612. * Updates the given vector "result" from the starting index of the given array.
  17613. */
  17614. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17615. /**
  17616. * Updates the given vector "result" from the starting index of the given Float32Array.
  17617. */
  17618. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17619. /**
  17620. * Updates the given vector "result" coordinates from the given floats.
  17621. */
  17622. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17623. /**
  17624. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17625. */
  17626. static Zero(): Vector4;
  17627. /**
  17628. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17629. */
  17630. static One(): Vector4;
  17631. /**
  17632. * Returns a new normalized Vector4 from the given one.
  17633. */
  17634. static Normalize(vector: Vector4): Vector4;
  17635. /**
  17636. * Updates the given vector "result" from the normalization of the given one.
  17637. */
  17638. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17639. static Minimize(left: Vector4, right: Vector4): Vector4;
  17640. static Maximize(left: Vector4, right: Vector4): Vector4;
  17641. /**
  17642. * Returns the distance (float) between the vectors "value1" and "value2".
  17643. */
  17644. static Distance(value1: Vector4, value2: Vector4): number;
  17645. /**
  17646. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17647. */
  17648. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17649. /**
  17650. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17651. */
  17652. static Center(value1: Vector4, value2: Vector4): Vector4;
  17653. /**
  17654. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17655. * This methods computes transformed normalized direction vectors only.
  17656. */
  17657. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17658. /**
  17659. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17660. * This methods computes transformed normalized direction vectors only.
  17661. */
  17662. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17663. /**
  17664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17665. * This methods computes transformed normalized direction vectors only.
  17666. */
  17667. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17668. }
  17669. interface ISize {
  17670. width: number;
  17671. height: number;
  17672. }
  17673. class Size implements ISize {
  17674. width: number;
  17675. height: number;
  17676. /**
  17677. * Creates a Size object from the given width and height (floats).
  17678. */
  17679. constructor(width: number, height: number);
  17680. toString(): string;
  17681. /**
  17682. * Returns the string "Size"
  17683. */
  17684. getClassName(): string;
  17685. /**
  17686. * Returns the Size hash code.
  17687. */
  17688. getHashCode(): number;
  17689. /**
  17690. * Updates the current size from the given one.
  17691. * Returns the updated Size.
  17692. */
  17693. copyFrom(src: Size): void;
  17694. /**
  17695. * Updates in place the current Size from the given floats.
  17696. * Returns the updated Size.
  17697. */
  17698. copyFromFloats(width: number, height: number): Size;
  17699. /**
  17700. * Updates in place the current Size from the given floats.
  17701. * Returns the updated Size.
  17702. */
  17703. set(width: number, height: number): Size;
  17704. /**
  17705. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17706. */
  17707. multiplyByFloats(w: number, h: number): Size;
  17708. /**
  17709. * Returns a new Size copied from the given one.
  17710. */
  17711. clone(): Size;
  17712. /**
  17713. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17714. */
  17715. equals(other: Size): boolean;
  17716. /**
  17717. * Returns the surface of the Size : width * height (float).
  17718. */
  17719. readonly surface: number;
  17720. /**
  17721. * Returns a new Size set to (0.0, 0.0)
  17722. */
  17723. static Zero(): Size;
  17724. /**
  17725. * Returns a new Size set as the addition result of the current Size and the given one.
  17726. */
  17727. add(otherSize: Size): Size;
  17728. /**
  17729. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17730. */
  17731. subtract(otherSize: Size): Size;
  17732. /**
  17733. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17734. */
  17735. static Lerp(start: Size, end: Size, amount: number): Size;
  17736. }
  17737. /**
  17738. * Class used to store quaternion data
  17739. * @see https://en.wikipedia.org/wiki/Quaternion
  17740. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17741. */
  17742. class Quaternion {
  17743. /** defines the first component (0 by default) */
  17744. x: number;
  17745. /** defines the second component (0 by default) */
  17746. y: number;
  17747. /** defines the third component (0 by default) */
  17748. z: number;
  17749. /** defines the fourth component (1.0 by default) */
  17750. w: number;
  17751. /**
  17752. * Creates a new Quaternion from the given floats
  17753. * @param x defines the first component (0 by default)
  17754. * @param y defines the second component (0 by default)
  17755. * @param z defines the third component (0 by default)
  17756. * @param w defines the fourth component (1.0 by default)
  17757. */
  17758. constructor(
  17759. /** defines the first component (0 by default) */
  17760. x?: number,
  17761. /** defines the second component (0 by default) */
  17762. y?: number,
  17763. /** defines the third component (0 by default) */
  17764. z?: number,
  17765. /** defines the fourth component (1.0 by default) */
  17766. w?: number);
  17767. /**
  17768. * Gets a string representation for the current quaternion
  17769. * @returns a string with the Quaternion coordinates
  17770. */
  17771. toString(): string;
  17772. /**
  17773. * Gets the class name of the quaternion
  17774. * @returns the string "Quaternion"
  17775. */
  17776. getClassName(): string;
  17777. /**
  17778. * Gets a hash code for this quaternion
  17779. * @returns the quaternion hash code
  17780. */
  17781. getHashCode(): number;
  17782. /**
  17783. * Copy the quaternion to an array
  17784. * @returns a new array populated with 4 elements from the quaternion coordinates
  17785. */
  17786. asArray(): number[];
  17787. /**
  17788. * Check if two quaternions are equals
  17789. * @param otherQuaternion defines the second operand
  17790. * @return true if the current quaternion and the given one coordinates are strictly equals
  17791. */
  17792. equals(otherQuaternion: Quaternion): boolean;
  17793. /**
  17794. * Clone the current quaternion
  17795. * @returns a new quaternion copied from the current one
  17796. */
  17797. clone(): Quaternion;
  17798. /**
  17799. * Copy a quaternion to the current one
  17800. * @param other defines the other quaternion
  17801. * @returns the updated current quaternion
  17802. */
  17803. copyFrom(other: Quaternion): Quaternion;
  17804. /**
  17805. * Updates the current quaternion with the given float coordinates
  17806. * @param x defines the x coordinate
  17807. * @param y defines the y coordinate
  17808. * @param z defines the z coordinate
  17809. * @param w defines the w coordinate
  17810. * @returns the updated current quaternion
  17811. */
  17812. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17813. /**
  17814. * Updates the current quaternion from the given float coordinates
  17815. * @param x defines the x coordinate
  17816. * @param y defines the y coordinate
  17817. * @param z defines the z coordinate
  17818. * @param w defines the w coordinate
  17819. * @returns the updated current quaternion
  17820. */
  17821. set(x: number, y: number, z: number, w: number): Quaternion;
  17822. /**
  17823. * Adds two quaternions
  17824. * @param other defines the second operand
  17825. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17826. */
  17827. add(other: Quaternion): Quaternion;
  17828. /**
  17829. * Add a quaternion to the current one
  17830. * @param other defines the quaternion to add
  17831. * @returns the current quaternion
  17832. */
  17833. addInPlace(other: Quaternion): Quaternion;
  17834. /**
  17835. * Subtract two quaternions
  17836. * @param other defines the second operand
  17837. * @returns a new quaternion as the subtraction result of the given one from the current one
  17838. */
  17839. subtract(other: Quaternion): Quaternion;
  17840. /**
  17841. * Multiplies the current quaternion by a scale factor
  17842. * @param value defines the scale factor
  17843. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17844. */
  17845. scale(value: number): Quaternion;
  17846. /**
  17847. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17848. * @param scale defines the scale factor
  17849. * @param result defines the Quaternion object where to store the result
  17850. * @returns the unmodified current quaternion
  17851. */
  17852. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17853. /**
  17854. * Multiplies in place the current quaternion by a scale factor
  17855. * @param value defines the scale factor
  17856. * @returns the current modified quaternion
  17857. */
  17858. scaleInPlace(value: number): Quaternion;
  17859. /**
  17860. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17861. * @param scale defines the scale factor
  17862. * @param result defines the Quaternion object where to store the result
  17863. * @returns the unmodified current quaternion
  17864. */
  17865. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17866. /**
  17867. * Multiplies two quaternions
  17868. * @param q1 defines the second operand
  17869. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17870. */
  17871. multiply(q1: Quaternion): Quaternion;
  17872. /**
  17873. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17874. * @param q1 defines the second operand
  17875. * @param result defines the target quaternion
  17876. * @returns the current quaternion
  17877. */
  17878. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17879. /**
  17880. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17881. * @param q1 defines the second operand
  17882. * @returns the currentupdated quaternion
  17883. */
  17884. multiplyInPlace(q1: Quaternion): Quaternion;
  17885. /**
  17886. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17887. * @param ref defines the target quaternion
  17888. * @returns the current quaternion
  17889. */
  17890. conjugateToRef(ref: Quaternion): Quaternion;
  17891. /**
  17892. * Conjugates in place (1-q) the current quaternion
  17893. * @returns the current updated quaternion
  17894. */
  17895. conjugateInPlace(): Quaternion;
  17896. /**
  17897. * Conjugates in place (1-q) the current quaternion
  17898. * @returns a new quaternion
  17899. */
  17900. conjugate(): Quaternion;
  17901. /**
  17902. * Gets length of current quaternion
  17903. * @returns the quaternion length (float)
  17904. */
  17905. length(): number;
  17906. /**
  17907. * Normalize in place the current quaternion
  17908. * @returns the current updated quaternion
  17909. */
  17910. normalize(): Quaternion;
  17911. /**
  17912. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17913. * @param order is a reserved parameter and is ignore for now
  17914. * @returns a new Vector3 containing the Euler angles
  17915. */
  17916. toEulerAngles(order?: string): Vector3;
  17917. /**
  17918. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17919. * @param result defines the vector which will be filled with the Euler angles
  17920. * @param order is a reserved parameter and is ignore for now
  17921. * @returns the current unchanged quaternion
  17922. */
  17923. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17924. /**
  17925. * Updates the given rotation matrix with the current quaternion values
  17926. * @param result defines the target matrix
  17927. * @returns the current unchanged quaternion
  17928. */
  17929. toRotationMatrix(result: Matrix): Quaternion;
  17930. /**
  17931. * Updates the current quaternion from the given rotation matrix values
  17932. * @param matrix defines the source matrix
  17933. * @returns the current updated quaternion
  17934. */
  17935. fromRotationMatrix(matrix: Matrix): Quaternion;
  17936. /**
  17937. * Creates a new quaternion from a rotation matrix
  17938. * @param matrix defines the source matrix
  17939. * @returns a new quaternion created from the given rotation matrix values
  17940. */
  17941. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17942. /**
  17943. * Updates the given quaternion with the given rotation matrix values
  17944. * @param matrix defines the source matrix
  17945. * @param result defines the target quaternion
  17946. */
  17947. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17948. /**
  17949. * Returns the dot product (float) between the quaternions "left" and "right"
  17950. * @param left defines the left operand
  17951. * @param right defines the right operand
  17952. * @returns the dot product
  17953. */
  17954. static Dot(left: Quaternion, right: Quaternion): number;
  17955. /**
  17956. * Checks if the two quaternions are close to each other
  17957. * @param quat0 defines the first quaternion to check
  17958. * @param quat1 defines the second quaternion to check
  17959. * @returns true if the two quaternions are close to each other
  17960. */
  17961. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17962. /**
  17963. * Creates an empty quaternion
  17964. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17965. */
  17966. static Zero(): Quaternion;
  17967. /**
  17968. * Inverse a given quaternion
  17969. * @param q defines the source quaternion
  17970. * @returns a new quaternion as the inverted current quaternion
  17971. */
  17972. static Inverse(q: Quaternion): Quaternion;
  17973. /**
  17974. * Creates an identity quaternion
  17975. * @returns the identity quaternion
  17976. */
  17977. static Identity(): Quaternion;
  17978. /**
  17979. * Gets a boolean indicating if the given quaternion is identity
  17980. * @param quaternion defines the quaternion to check
  17981. * @returns true if the quaternion is identity
  17982. */
  17983. static IsIdentity(quaternion: Quaternion): boolean;
  17984. /**
  17985. * Creates a quaternion from a rotation around an axis
  17986. * @param axis defines the axis to use
  17987. * @param angle defines the angle to use
  17988. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17989. */
  17990. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17991. /**
  17992. * Creates a rotation around an axis and stores it into the given quaternion
  17993. * @param axis defines the axis to use
  17994. * @param angle defines the angle to use
  17995. * @param result defines the target quaternion
  17996. * @returns the target quaternion
  17997. */
  17998. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17999. /**
  18000. * Creates a new quaternion from data stored into an array
  18001. * @param array defines the data source
  18002. * @param offset defines the offset in the source array where the data starts
  18003. * @returns a new quaternion
  18004. */
  18005. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  18006. /**
  18007. * Creates a new quaternion from the given Euler float angles (y, x, z)
  18008. * @param yaw defines the rotation around Y axis
  18009. * @param pitch defines the rotation around X axis
  18010. * @param roll defines the rotation around Z axis
  18011. * @returns the new quaternion
  18012. */
  18013. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  18014. /**
  18015. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  18016. * @param yaw defines the rotation around Y axis
  18017. * @param pitch defines the rotation around X axis
  18018. * @param roll defines the rotation around Z axis
  18019. * @param result defines the target quaternion
  18020. */
  18021. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  18022. /**
  18023. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  18024. * @param alpha defines the rotation around first axis
  18025. * @param beta defines the rotation around second axis
  18026. * @param gamma defines the rotation around third axis
  18027. * @returns the new quaternion
  18028. */
  18029. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  18030. /**
  18031. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  18032. * @param alpha defines the rotation around first axis
  18033. * @param beta defines the rotation around second axis
  18034. * @param gamma defines the rotation around third axis
  18035. * @param result defines the target quaternion
  18036. */
  18037. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  18038. /**
  18039. * 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)
  18040. * @param axis1 defines the first axis
  18041. * @param axis2 defines the second axis
  18042. * @param axis3 defines the third axis
  18043. * @returns the new quaternion
  18044. */
  18045. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  18046. /**
  18047. * 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
  18048. * @param axis1 defines the first axis
  18049. * @param axis2 defines the second axis
  18050. * @param axis3 defines the third axis
  18051. * @param ref defines the target quaternion
  18052. */
  18053. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  18054. /**
  18055. * Interpolates between two quaternions
  18056. * @param left defines first quaternion
  18057. * @param right defines second quaternion
  18058. * @param amount defines the gradient to use
  18059. * @returns the new interpolated quaternion
  18060. */
  18061. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  18062. /**
  18063. * Interpolates between two quaternions and stores it into a target quaternion
  18064. * @param left defines first quaternion
  18065. * @param right defines second quaternion
  18066. * @param amount defines the gradient to use
  18067. * @param result defines the target quaternion
  18068. */
  18069. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  18070. /**
  18071. * Interpolate between two quaternions using Hermite interpolation
  18072. * @param value1 defines first quaternion
  18073. * @param tangent1 defines the incoming tangent
  18074. * @param value2 defines second quaternion
  18075. * @param tangent2 defines the outgoing tangent
  18076. * @param amount defines the target quaternion
  18077. * @returns the new interpolated quaternion
  18078. */
  18079. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  18080. }
  18081. /**
  18082. * Class used to store matrix data (4x4)
  18083. */
  18084. class Matrix {
  18085. private static _tempQuaternion;
  18086. private static _xAxis;
  18087. private static _yAxis;
  18088. private static _zAxis;
  18089. private static _updateFlagSeed;
  18090. private static _identityReadOnly;
  18091. private _isIdentity;
  18092. private _isIdentityDirty;
  18093. /**
  18094. * Gets the update flag of the matrix which is an unique number for the matrix.
  18095. * It will be incremented every time the matrix data change.
  18096. * You can use it to speed the comparison between two versions of the same matrix.
  18097. */
  18098. updateFlag: number;
  18099. /**
  18100. * Gets or sets the internal data of the matrix
  18101. */
  18102. m: Float32Array;
  18103. /** @hidden */
  18104. _markAsUpdated(): void;
  18105. /**
  18106. * Creates an empty matrix (filled with zeros)
  18107. */
  18108. constructor();
  18109. /**
  18110. * Check if the current matrix is indentity
  18111. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  18112. * @returns true is the matrix is the identity matrix
  18113. */
  18114. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  18115. /**
  18116. * Gets the determinant of the matrix
  18117. * @returns the matrix determinant
  18118. */
  18119. determinant(): number;
  18120. /**
  18121. * Returns the matrix as a Float32Array
  18122. * @returns the matrix underlying array
  18123. */
  18124. toArray(): Float32Array;
  18125. /**
  18126. * Returns the matrix as a Float32Array
  18127. * @returns the matrix underlying array.
  18128. */
  18129. asArray(): Float32Array;
  18130. /**
  18131. * Inverts the current matrix in place
  18132. * @returns the current inverted matrix
  18133. */
  18134. invert(): Matrix;
  18135. /**
  18136. * Sets all the matrix elements to zero
  18137. * @returns the current matrix
  18138. */
  18139. reset(): Matrix;
  18140. /**
  18141. * Adds the current matrix with a second one
  18142. * @param other defines the matrix to add
  18143. * @returns a new matrix as the addition of the current matrix and the given one
  18144. */
  18145. add(other: Matrix): Matrix;
  18146. /**
  18147. * Sets the given matrix "result" to the addition of the current matrix and the given one
  18148. * @param other defines the matrix to add
  18149. * @param result defines the target matrix
  18150. * @returns the current matrix
  18151. */
  18152. addToRef(other: Matrix, result: Matrix): Matrix;
  18153. /**
  18154. * Adds in place the given matrix to the current matrix
  18155. * @param other defines the second operand
  18156. * @returns the current updated matrix
  18157. */
  18158. addToSelf(other: Matrix): Matrix;
  18159. /**
  18160. * Sets the given matrix to the current inverted Matrix
  18161. * @param other defines the target matrix
  18162. * @returns the unmodified current matrix
  18163. */
  18164. invertToRef(other: Matrix): Matrix;
  18165. /**
  18166. * Inserts the translation vector (using 3 floats) in the current matrix
  18167. * @param x defines the 1st component of the translation
  18168. * @param y defines the 2nd component of the translation
  18169. * @param z defines the 3rd component of the translation
  18170. * @returns the current updated matrix
  18171. */
  18172. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  18173. /**
  18174. * Inserts the translation vector in the current matrix
  18175. * @param vector3 defines the translation to insert
  18176. * @returns the current updated matrix
  18177. */
  18178. setTranslation(vector3: Vector3): Matrix;
  18179. /**
  18180. * Gets the translation value of the current matrix
  18181. * @returns a new Vector3 as the extracted translation from the matrix
  18182. */
  18183. getTranslation(): Vector3;
  18184. /**
  18185. * Fill a Vector3 with the extracted translation from the matrix
  18186. * @param result defines the Vector3 where to store the translation
  18187. * @returns the current matrix
  18188. */
  18189. getTranslationToRef(result: Vector3): Matrix;
  18190. /**
  18191. * Remove rotation and scaling part from the matrix
  18192. * @returns the updated matrix
  18193. */
  18194. removeRotationAndScaling(): Matrix;
  18195. /**
  18196. * Multiply two matrices
  18197. * @param other defines the second operand
  18198. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  18199. */
  18200. multiply(other: Matrix): Matrix;
  18201. /**
  18202. * Copy the current matrix from the given one
  18203. * @param other defines the source matrix
  18204. * @returns the current updated matrix
  18205. */
  18206. copyFrom(other: Matrix): Matrix;
  18207. /**
  18208. * Populates the given array from the starting index with the current matrix values
  18209. * @param array defines the target array
  18210. * @param offset defines the offset in the target array where to start storing values
  18211. * @returns the current matrix
  18212. */
  18213. copyToArray(array: Float32Array, offset?: number): Matrix;
  18214. /**
  18215. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  18216. * @param other defines the second operand
  18217. * @param result defines the matrix where to store the multiplication
  18218. * @returns the current matrix
  18219. */
  18220. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  18221. /**
  18222. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  18223. * @param other defines the second operand
  18224. * @param result defines the array where to store the multiplication
  18225. * @param offset defines the offset in the target array where to start storing values
  18226. * @returns the current matrix
  18227. */
  18228. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  18229. /**
  18230. * Check equality between this matrix and a second one
  18231. * @param value defines the second matrix to compare
  18232. * @returns true is the current matrix and the given one values are strictly equal
  18233. */
  18234. equals(value: Matrix): boolean;
  18235. /**
  18236. * Clone the current matrix
  18237. * @returns a new matrix from the current matrix
  18238. */
  18239. clone(): Matrix;
  18240. /**
  18241. * Returns the name of the current matrix class
  18242. * @returns the string "Matrix"
  18243. */
  18244. getClassName(): string;
  18245. /**
  18246. * Gets the hash code of the current matrix
  18247. * @returns the hash code
  18248. */
  18249. getHashCode(): number;
  18250. /**
  18251. * Decomposes the current Matrix into a translation, rotation and scaling components
  18252. * @param scale defines the scale vector3 given as a reference to update
  18253. * @param rotation defines the rotation quaternion given as a reference to update
  18254. * @param translation defines the translation vector3 given as a reference to update
  18255. * @returns true if operation was successful
  18256. */
  18257. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18258. /**
  18259. * Gets specific row of the matrix
  18260. * @param index defines the number of the row to get
  18261. * @returns the index-th row of the current matrix as a new Vector4
  18262. */
  18263. getRow(index: number): Nullable<Vector4>;
  18264. /**
  18265. * Sets the index-th row of the current matrix to the vector4 values
  18266. * @param index defines the number of the row to set
  18267. * @param row defines the target vector4
  18268. * @returns the updated current matrix
  18269. */
  18270. setRow(index: number, row: Vector4): Matrix;
  18271. /**
  18272. * Compute the transpose of the matrix
  18273. * @returns the new transposed matrix
  18274. */
  18275. transpose(): Matrix;
  18276. /**
  18277. * Compute the transpose of the matrix and store it in a given matrix
  18278. * @param result defines the target matrix
  18279. * @returns the current matrix
  18280. */
  18281. transposeToRef(result: Matrix): Matrix;
  18282. /**
  18283. * Sets the index-th row of the current matrix with the given 4 x float values
  18284. * @param index defines the row index
  18285. * @param x defines the x component to set
  18286. * @param y defines the y component to set
  18287. * @param z defines the z component to set
  18288. * @param w defines the w component to set
  18289. * @returns the updated current matrix
  18290. */
  18291. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18292. /**
  18293. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18294. * @param scale defines the scale factor
  18295. * @returns a new matrix
  18296. */
  18297. scale(scale: number): Matrix;
  18298. /**
  18299. * Scale the current matrix values by a factor to a given result matrix
  18300. * @param scale defines the scale factor
  18301. * @param result defines the matrix to store the result
  18302. * @returns the current matrix
  18303. */
  18304. scaleToRef(scale: number, result: Matrix): Matrix;
  18305. /**
  18306. * Scale the current matrix values by a factor and add the result to a given matrix
  18307. * @param scale defines the scale factor
  18308. * @param result defines the Matrix to store the result
  18309. * @returns the current matrix
  18310. */
  18311. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18312. /**
  18313. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18314. * @param ref matrix to store the result
  18315. */
  18316. toNormalMatrix(ref: Matrix): void;
  18317. /**
  18318. * Gets only rotation part of the current matrix
  18319. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18320. */
  18321. getRotationMatrix(): Matrix;
  18322. /**
  18323. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18324. * @param result defines the target matrix to store data to
  18325. * @returns the current matrix
  18326. */
  18327. getRotationMatrixToRef(result: Matrix): Matrix;
  18328. /**
  18329. * Creates a matrix from an array
  18330. * @param array defines the source array
  18331. * @param offset defines an offset in the source array
  18332. * @returns a new Matrix set from the starting index of the given array
  18333. */
  18334. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18335. /**
  18336. * Copy the content of an array into a given matrix
  18337. * @param array defines the source array
  18338. * @param offset defines an offset in the source array
  18339. * @param result defines the target matrix
  18340. */
  18341. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18342. /**
  18343. * Stores an array into a matrix after having multiplied each component by a given factor
  18344. * @param array defines the source array
  18345. * @param offset defines the offset in the source array
  18346. * @param scale defines the scaling factor
  18347. * @param result defines the target matrix
  18348. */
  18349. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18350. /**
  18351. * Stores a list of values (16) inside a given matrix
  18352. * @param initialM11 defines 1st value of 1st row
  18353. * @param initialM12 defines 2nd value of 1st row
  18354. * @param initialM13 defines 3rd value of 1st row
  18355. * @param initialM14 defines 4th value of 1st row
  18356. * @param initialM21 defines 1st value of 2nd row
  18357. * @param initialM22 defines 2nd value of 2nd row
  18358. * @param initialM23 defines 3rd value of 2nd row
  18359. * @param initialM24 defines 4th value of 2nd row
  18360. * @param initialM31 defines 1st value of 3rd row
  18361. * @param initialM32 defines 2nd value of 3rd row
  18362. * @param initialM33 defines 3rd value of 3rd row
  18363. * @param initialM34 defines 4th value of 3rd row
  18364. * @param initialM41 defines 1st value of 4th row
  18365. * @param initialM42 defines 2nd value of 4th row
  18366. * @param initialM43 defines 3rd value of 4th row
  18367. * @param initialM44 defines 4th value of 4th row
  18368. * @param result defines the target matrix
  18369. */
  18370. 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;
  18371. /**
  18372. * Gets an identity matrix that must not be updated
  18373. */
  18374. static readonly IdentityReadOnly: Matrix;
  18375. /**
  18376. * Creates new matrix from a list of values (16)
  18377. * @param initialM11 defines 1st value of 1st row
  18378. * @param initialM12 defines 2nd value of 1st row
  18379. * @param initialM13 defines 3rd value of 1st row
  18380. * @param initialM14 defines 4th value of 1st row
  18381. * @param initialM21 defines 1st value of 2nd row
  18382. * @param initialM22 defines 2nd value of 2nd row
  18383. * @param initialM23 defines 3rd value of 2nd row
  18384. * @param initialM24 defines 4th value of 2nd row
  18385. * @param initialM31 defines 1st value of 3rd row
  18386. * @param initialM32 defines 2nd value of 3rd row
  18387. * @param initialM33 defines 3rd value of 3rd row
  18388. * @param initialM34 defines 4th value of 3rd row
  18389. * @param initialM41 defines 1st value of 4th row
  18390. * @param initialM42 defines 2nd value of 4th row
  18391. * @param initialM43 defines 3rd value of 4th row
  18392. * @param initialM44 defines 4th value of 4th row
  18393. * @returns the new matrix
  18394. */
  18395. 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;
  18396. /**
  18397. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18398. * @param scale defines the scale vector3
  18399. * @param rotation defines the rotation quaternion
  18400. * @param translation defines the translation vector3
  18401. * @returns a new matrix
  18402. */
  18403. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18404. /**
  18405. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18406. * @param scale defines the scale vector3
  18407. * @param rotation defines the rotation quaternion
  18408. * @param translation defines the translation vector3
  18409. * @param result defines the target matrix
  18410. */
  18411. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18412. /**
  18413. * Creates a new identity matrix
  18414. * @returns a new identity matrix
  18415. */
  18416. static Identity(): Matrix;
  18417. /**
  18418. * Creates a new identity matrix and stores the result in a given matrix
  18419. * @param result defines the target matrix
  18420. */
  18421. static IdentityToRef(result: Matrix): void;
  18422. /**
  18423. * Creates a new zero matrix
  18424. * @returns a new zero matrix
  18425. */
  18426. static Zero(): Matrix;
  18427. /**
  18428. * Creates a new rotation matrix for "angle" radians around the X axis
  18429. * @param angle defines the angle (in radians) to use
  18430. * @return the new matrix
  18431. */
  18432. static RotationX(angle: number): Matrix;
  18433. /**
  18434. * Creates a new matrix as the invert of a given matrix
  18435. * @param source defines the source matrix
  18436. * @returns the new matrix
  18437. */
  18438. static Invert(source: Matrix): Matrix;
  18439. /**
  18440. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18441. * @param angle defines the angle (in radians) to use
  18442. * @param result defines the target matrix
  18443. */
  18444. static RotationXToRef(angle: number, result: Matrix): void;
  18445. /**
  18446. * Creates a new rotation matrix for "angle" radians around the Y axis
  18447. * @param angle defines the angle (in radians) to use
  18448. * @return the new matrix
  18449. */
  18450. static RotationY(angle: number): Matrix;
  18451. /**
  18452. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18453. * @param angle defines the angle (in radians) to use
  18454. * @param result defines the target matrix
  18455. */
  18456. static RotationYToRef(angle: number, result: Matrix): void;
  18457. /**
  18458. * Creates a new rotation matrix for "angle" radians around the Z axis
  18459. * @param angle defines the angle (in radians) to use
  18460. * @return the new matrix
  18461. */
  18462. static RotationZ(angle: number): Matrix;
  18463. /**
  18464. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18465. * @param angle defines the angle (in radians) to use
  18466. * @param result defines the target matrix
  18467. */
  18468. static RotationZToRef(angle: number, result: Matrix): void;
  18469. /**
  18470. * Creates a new rotation matrix for "angle" radians around the given axis
  18471. * @param axis defines the axis to use
  18472. * @param angle defines the angle (in radians) to use
  18473. * @return the new matrix
  18474. */
  18475. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18476. /**
  18477. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18478. * @param axis defines the axis to use
  18479. * @param angle defines the angle (in radians) to use
  18480. * @param result defines the target matrix
  18481. */
  18482. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18483. /**
  18484. * Creates a rotation matrix
  18485. * @param yaw defines the yaw angle in radians (Y axis)
  18486. * @param pitch defines the pitch angle in radians (X axis)
  18487. * @param roll defines the roll angle in radians (X axis)
  18488. * @returns the new rotation matrix
  18489. */
  18490. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18491. /**
  18492. * Creates a rotation matrix and stores it in a given matrix
  18493. * @param yaw defines the yaw angle in radians (Y axis)
  18494. * @param pitch defines the pitch angle in radians (X axis)
  18495. * @param roll defines the roll angle in radians (X axis)
  18496. * @param result defines the target matrix
  18497. */
  18498. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18499. /**
  18500. * Creates a scaling matrix
  18501. * @param x defines the scale factor on X axis
  18502. * @param y defines the scale factor on Y axis
  18503. * @param z defines the scale factor on Z axis
  18504. * @returns the new matrix
  18505. */
  18506. static Scaling(x: number, y: number, z: number): Matrix;
  18507. /**
  18508. * Creates a scaling matrix and stores it in a given matrix
  18509. * @param x defines the scale factor on X axis
  18510. * @param y defines the scale factor on Y axis
  18511. * @param z defines the scale factor on Z axis
  18512. * @param result defines the target matrix
  18513. */
  18514. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18515. /**
  18516. * Creates a translation matrix
  18517. * @param x defines the translation on X axis
  18518. * @param y defines the translation on Y axis
  18519. * @param z defines the translationon Z axis
  18520. * @returns the new matrix
  18521. */
  18522. static Translation(x: number, y: number, z: number): Matrix;
  18523. /**
  18524. * Creates a translation matrix and stores it in a given matrix
  18525. * @param x defines the translation on X axis
  18526. * @param y defines the translation on Y axis
  18527. * @param z defines the translationon Z axis
  18528. * @param result defines the target matrix
  18529. */
  18530. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18531. /**
  18532. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18533. * @param startValue defines the start value
  18534. * @param endValue defines the end value
  18535. * @param gradient defines the gradient factor
  18536. * @returns the new matrix
  18537. */
  18538. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18539. /**
  18540. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18541. * @param startValue defines the start value
  18542. * @param endValue defines the end value
  18543. * @param gradient defines the gradient factor
  18544. * @param result defines the Matrix object where to store data
  18545. */
  18546. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18547. /**
  18548. * Builds a new matrix whose values are computed by:
  18549. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18550. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18551. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18552. * @param startValue defines the first matrix
  18553. * @param endValue defines the second matrix
  18554. * @param gradient defines the gradient between the two matrices
  18555. * @returns the new matrix
  18556. */
  18557. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18558. /**
  18559. * Update a matrix to values which are computed by:
  18560. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18561. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18562. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18563. * @param startValue defines the first matrix
  18564. * @param endValue defines the second matrix
  18565. * @param gradient defines the gradient between the two matrices
  18566. * @param result defines the target matrix
  18567. */
  18568. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18569. /**
  18570. * 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"
  18571. * This function works in left handed mode
  18572. * @param eye defines the final position of the entity
  18573. * @param target defines where the entity should look at
  18574. * @param up defines the up vector for the entity
  18575. * @returns the new matrix
  18576. */
  18577. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18578. /**
  18579. * 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".
  18580. * This function works in left handed mode
  18581. * @param eye defines the final position of the entity
  18582. * @param target defines where the entity should look at
  18583. * @param up defines the up vector for the entity
  18584. * @param result defines the target matrix
  18585. */
  18586. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18587. /**
  18588. * 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"
  18589. * This function works in right handed mode
  18590. * @param eye defines the final position of the entity
  18591. * @param target defines where the entity should look at
  18592. * @param up defines the up vector for the entity
  18593. * @returns the new matrix
  18594. */
  18595. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18596. /**
  18597. * 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".
  18598. * This function works in right handed mode
  18599. * @param eye defines the final position of the entity
  18600. * @param target defines where the entity should look at
  18601. * @param up defines the up vector for the entity
  18602. * @param result defines the target matrix
  18603. */
  18604. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18605. /**
  18606. * Create a left-handed orthographic projection matrix
  18607. * @param width defines the viewport width
  18608. * @param height defines the viewport height
  18609. * @param znear defines the near clip plane
  18610. * @param zfar defines the far clip plane
  18611. * @returns a new matrix as a left-handed orthographic projection matrix
  18612. */
  18613. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18614. /**
  18615. * Store a left-handed orthographic projection to a given matrix
  18616. * @param width defines the viewport width
  18617. * @param height defines the viewport height
  18618. * @param znear defines the near clip plane
  18619. * @param zfar defines the far clip plane
  18620. * @param result defines the target matrix
  18621. */
  18622. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18623. /**
  18624. * Create a left-handed orthographic projection matrix
  18625. * @param left defines the viewport left coordinate
  18626. * @param right defines the viewport right coordinate
  18627. * @param bottom defines the viewport bottom coordinate
  18628. * @param top defines the viewport top coordinate
  18629. * @param znear defines the near clip plane
  18630. * @param zfar defines the far clip plane
  18631. * @returns a new matrix as a left-handed orthographic projection matrix
  18632. */
  18633. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18634. /**
  18635. * Stores a left-handed orthographic projection into a given matrix
  18636. * @param left defines the viewport left coordinate
  18637. * @param right defines the viewport right coordinate
  18638. * @param bottom defines the viewport bottom coordinate
  18639. * @param top defines the viewport top coordinate
  18640. * @param znear defines the near clip plane
  18641. * @param zfar defines the far clip plane
  18642. * @param result defines the target matrix
  18643. */
  18644. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18645. /**
  18646. * Creates a right-handed orthographic projection matrix
  18647. * @param left defines the viewport left coordinate
  18648. * @param right defines the viewport right coordinate
  18649. * @param bottom defines the viewport bottom coordinate
  18650. * @param top defines the viewport top coordinate
  18651. * @param znear defines the near clip plane
  18652. * @param zfar defines the far clip plane
  18653. * @returns a new matrix as a right-handed orthographic projection matrix
  18654. */
  18655. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18656. /**
  18657. * Stores a right-handed orthographic projection into a given matrix
  18658. * @param left defines the viewport left coordinate
  18659. * @param right defines the viewport right coordinate
  18660. * @param bottom defines the viewport bottom coordinate
  18661. * @param top defines the viewport top coordinate
  18662. * @param znear defines the near clip plane
  18663. * @param zfar defines the far clip plane
  18664. * @param result defines the target matrix
  18665. */
  18666. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18667. /**
  18668. * Creates a left-handed perspective projection matrix
  18669. * @param width defines the viewport width
  18670. * @param height defines the viewport height
  18671. * @param znear defines the near clip plane
  18672. * @param zfar defines the far clip plane
  18673. * @returns a new matrix as a left-handed perspective projection matrix
  18674. */
  18675. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18676. /**
  18677. * Creates a left-handed perspective projection matrix
  18678. * @param fov defines the horizontal field of view
  18679. * @param aspect defines the aspect ratio
  18680. * @param znear defines the near clip plane
  18681. * @param zfar defines the far clip plane
  18682. * @returns a new matrix as a left-handed perspective projection matrix
  18683. */
  18684. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18685. /**
  18686. * Stores a left-handed perspective projection into a given matrix
  18687. * @param fov defines the horizontal field of view
  18688. * @param aspect defines the aspect ratio
  18689. * @param znear defines the near clip plane
  18690. * @param zfar defines the far clip plane
  18691. * @param result defines the target matrix
  18692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18693. */
  18694. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18695. /**
  18696. * Creates a right-handed perspective projection matrix
  18697. * @param fov defines the horizontal field of view
  18698. * @param aspect defines the aspect ratio
  18699. * @param znear defines the near clip plane
  18700. * @param zfar defines the far clip plane
  18701. * @returns a new matrix as a right-handed perspective projection matrix
  18702. */
  18703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18704. /**
  18705. * Stores a right-handed perspective projection into a given matrix
  18706. * @param fov defines the horizontal field of view
  18707. * @param aspect defines the aspect ratio
  18708. * @param znear defines the near clip plane
  18709. * @param zfar defines the far clip plane
  18710. * @param result defines the target matrix
  18711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18712. */
  18713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18714. /**
  18715. * Stores a perspective projection for WebVR info a given matrix
  18716. * @param fov defines the field of view
  18717. * @param znear defines the near clip plane
  18718. * @param zfar defines the far clip plane
  18719. * @param result defines the target matrix
  18720. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18721. */
  18722. static PerspectiveFovWebVRToRef(fov: {
  18723. upDegrees: number;
  18724. downDegrees: number;
  18725. leftDegrees: number;
  18726. rightDegrees: number;
  18727. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18728. /**
  18729. * Computes a complete transformation matrix
  18730. * @param viewport defines the viewport to use
  18731. * @param world defines the world matrix
  18732. * @param view defines the view matrix
  18733. * @param projection defines the projection matrix
  18734. * @param zmin defines the near clip plane
  18735. * @param zmax defines the far clip plane
  18736. * @returns the transformation matrix
  18737. */
  18738. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18739. /**
  18740. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18741. * @param matrix defines the matrix to use
  18742. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18743. */
  18744. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18745. /**
  18746. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18747. * @param matrix defines the matrix to use
  18748. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18749. */
  18750. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18751. /**
  18752. * Compute the transpose of a given matrix
  18753. * @param matrix defines the matrix to transpose
  18754. * @returns the new matrix
  18755. */
  18756. static Transpose(matrix: Matrix): Matrix;
  18757. /**
  18758. * Compute the transpose of a matrix and store it in a target matrix
  18759. * @param matrix defines the matrix to transpose
  18760. * @param result defines the target matrix
  18761. */
  18762. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18763. /**
  18764. * Computes a reflection matrix from a plane
  18765. * @param plane defines the reflection plane
  18766. * @returns a new matrix
  18767. */
  18768. static Reflection(plane: Plane): Matrix;
  18769. /**
  18770. * Computes a reflection matrix from a plane
  18771. * @param plane defines the reflection plane
  18772. * @param result defines the target matrix
  18773. */
  18774. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18775. /**
  18776. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18777. * @param xaxis defines the value of the 1st axis
  18778. * @param yaxis defines the value of the 2nd axis
  18779. * @param zaxis defines the value of the 3rd axis
  18780. * @param result defines the target matrix
  18781. */
  18782. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18783. /**
  18784. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18785. * @param quat defines the quaternion to use
  18786. * @param result defines the target matrix
  18787. */
  18788. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18789. }
  18790. class Plane {
  18791. normal: Vector3;
  18792. d: number;
  18793. /**
  18794. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18795. */
  18796. constructor(a: number, b: number, c: number, d: number);
  18797. /**
  18798. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18799. */
  18800. asArray(): number[];
  18801. /**
  18802. * Returns a new plane copied from the current Plane.
  18803. */
  18804. clone(): Plane;
  18805. /**
  18806. * Returns the string "Plane".
  18807. */
  18808. getClassName(): string;
  18809. /**
  18810. * Returns the Plane hash code.
  18811. */
  18812. getHashCode(): number;
  18813. /**
  18814. * Normalize the current Plane in place.
  18815. * Returns the updated Plane.
  18816. */
  18817. normalize(): Plane;
  18818. /**
  18819. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18820. */
  18821. transform(transformation: Matrix): Plane;
  18822. /**
  18823. * Returns the dot product (float) of the point coordinates and the plane normal.
  18824. */
  18825. dotCoordinate(point: Vector3): number;
  18826. /**
  18827. * Updates the current Plane from the plane defined by the three given points.
  18828. * Returns the updated Plane.
  18829. */
  18830. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18831. /**
  18832. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18833. */
  18834. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18835. /**
  18836. * Returns the signed distance (float) from the given point to the Plane.
  18837. */
  18838. signedDistanceTo(point: Vector3): number;
  18839. /**
  18840. * Returns a new Plane from the given array.
  18841. */
  18842. static FromArray(array: ArrayLike<number>): Plane;
  18843. /**
  18844. * Returns a new Plane defined by the three given points.
  18845. */
  18846. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18847. /**
  18848. * Returns a new Plane the normal vector to this plane at the given origin point.
  18849. * Note : the vector "normal" is updated because normalized.
  18850. */
  18851. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18852. /**
  18853. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18854. */
  18855. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18856. }
  18857. class Viewport {
  18858. x: number;
  18859. y: number;
  18860. width: number;
  18861. height: number;
  18862. /**
  18863. * Creates a Viewport object located at (x, y) and sized (width, height).
  18864. */
  18865. constructor(x: number, y: number, width: number, height: number);
  18866. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18867. /**
  18868. * Returns a new Viewport copied from the current one.
  18869. */
  18870. clone(): Viewport;
  18871. }
  18872. class Frustum {
  18873. /**
  18874. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18875. */
  18876. static GetPlanes(transform: Matrix): Plane[];
  18877. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18878. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18879. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18880. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18881. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18882. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18883. /**
  18884. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18885. */
  18886. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18887. }
  18888. /** Defines supported spaces */
  18889. enum Space {
  18890. /** Local (object) space */
  18891. LOCAL = 0,
  18892. /** World space */
  18893. WORLD = 1,
  18894. /** Bone space */
  18895. BONE = 2
  18896. }
  18897. /** Defines the 3 main axes */
  18898. class Axis {
  18899. /** X axis */
  18900. static X: Vector3;
  18901. /** Y axis */
  18902. static Y: Vector3;
  18903. /** Z axis */
  18904. static Z: Vector3;
  18905. }
  18906. class BezierCurve {
  18907. /**
  18908. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18909. */
  18910. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18911. }
  18912. /**
  18913. * Defines potential orientation for back face culling
  18914. */
  18915. enum Orientation {
  18916. /**
  18917. * Clockwise
  18918. */
  18919. CW = 0,
  18920. /** Counter clockwise */
  18921. CCW = 1
  18922. }
  18923. /**
  18924. * Defines angle representation
  18925. */
  18926. class Angle {
  18927. private _radians;
  18928. /**
  18929. * Creates an Angle object of "radians" radians (float).
  18930. */
  18931. constructor(radians: number);
  18932. /**
  18933. * Get value in degrees
  18934. * @returns the Angle value in degrees (float)
  18935. */
  18936. degrees(): number;
  18937. /**
  18938. * Get value in radians
  18939. * @returns the Angle value in radians (float)
  18940. */
  18941. radians(): number;
  18942. /**
  18943. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18944. * @param a defines first vector
  18945. * @param b defines second vector
  18946. * @returns a new Angle
  18947. */
  18948. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18949. /**
  18950. * Gets a new Angle object from the given float in radians
  18951. * @param radians defines the angle value in radians
  18952. * @returns a new Angle
  18953. */
  18954. static FromRadians(radians: number): Angle;
  18955. /**
  18956. * Gets a new Angle object from the given float in degrees
  18957. * @param degrees defines the angle value in degrees
  18958. * @returns a new Angle
  18959. */
  18960. static FromDegrees(degrees: number): Angle;
  18961. }
  18962. class Arc2 {
  18963. startPoint: Vector2;
  18964. midPoint: Vector2;
  18965. endPoint: Vector2;
  18966. centerPoint: Vector2;
  18967. radius: number;
  18968. angle: Angle;
  18969. startAngle: Angle;
  18970. orientation: Orientation;
  18971. /**
  18972. * Creates an Arc object from the three given points : start, middle and end.
  18973. */
  18974. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18975. }
  18976. class Path2 {
  18977. private _points;
  18978. private _length;
  18979. closed: boolean;
  18980. /**
  18981. * Creates a Path2 object from the starting 2D coordinates x and y.
  18982. */
  18983. constructor(x: number, y: number);
  18984. /**
  18985. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18986. * Returns the updated Path2.
  18987. */
  18988. addLineTo(x: number, y: number): Path2;
  18989. /**
  18990. * 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.
  18991. * Returns the updated Path2.
  18992. */
  18993. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18994. /**
  18995. * Closes the Path2.
  18996. * Returns the Path2.
  18997. */
  18998. close(): Path2;
  18999. /**
  19000. * Returns the Path2 total length (float).
  19001. */
  19002. length(): number;
  19003. /**
  19004. * Returns the Path2 internal array of points.
  19005. */
  19006. getPoints(): Vector2[];
  19007. /**
  19008. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  19009. */
  19010. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  19011. /**
  19012. * Returns a new Path2 starting at the coordinates (x, y).
  19013. */
  19014. static StartingAt(x: number, y: number): Path2;
  19015. }
  19016. class Path3D {
  19017. path: Vector3[];
  19018. private _curve;
  19019. private _distances;
  19020. private _tangents;
  19021. private _normals;
  19022. private _binormals;
  19023. private _raw;
  19024. /**
  19025. * new Path3D(path, normal, raw)
  19026. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  19027. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  19028. * path : an array of Vector3, the curve axis of the Path3D
  19029. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  19030. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  19031. */
  19032. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  19033. /**
  19034. * Returns the Path3D array of successive Vector3 designing its curve.
  19035. */
  19036. getCurve(): Vector3[];
  19037. /**
  19038. * Returns an array populated with tangent vectors on each Path3D curve point.
  19039. */
  19040. getTangents(): Vector3[];
  19041. /**
  19042. * Returns an array populated with normal vectors on each Path3D curve point.
  19043. */
  19044. getNormals(): Vector3[];
  19045. /**
  19046. * Returns an array populated with binormal vectors on each Path3D curve point.
  19047. */
  19048. getBinormals(): Vector3[];
  19049. /**
  19050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  19051. */
  19052. getDistances(): number[];
  19053. /**
  19054. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  19055. * Returns the same object updated.
  19056. */
  19057. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  19058. private _compute;
  19059. private _getFirstNonNullVector;
  19060. private _getLastNonNullVector;
  19061. private _normalVector;
  19062. }
  19063. class Curve3 {
  19064. private _points;
  19065. private _length;
  19066. /**
  19067. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  19068. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  19069. * @param v1 (Vector3) the control point
  19070. * @param v2 (Vector3) the end point of the Quadratic Bezier
  19071. * @param nbPoints (integer) the wanted number of points in the curve
  19072. */
  19073. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  19074. /**
  19075. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  19076. * @param v0 (Vector3) the origin point of the Cubic Bezier
  19077. * @param v1 (Vector3) the first control point
  19078. * @param v2 (Vector3) the second control point
  19079. * @param v3 (Vector3) the end point of the Cubic Bezier
  19080. * @param nbPoints (integer) the wanted number of points in the curve
  19081. */
  19082. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  19083. /**
  19084. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  19085. * @param p1 (Vector3) the origin point of the Hermite Spline
  19086. * @param t1 (Vector3) the tangent vector at the origin point
  19087. * @param p2 (Vector3) the end point of the Hermite Spline
  19088. * @param t2 (Vector3) the tangent vector at the end point
  19089. * @param nbPoints (integer) the wanted number of points in the curve
  19090. */
  19091. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  19092. /**
  19093. * Returns a Curve3 object along a CatmullRom Spline curve :
  19094. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  19095. * @param nbPoints (integer) the wanted number of points between each curve control points
  19096. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  19097. */
  19098. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  19099. /**
  19100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  19101. * A Curve3 is designed from a series of successive Vector3.
  19102. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  19103. */
  19104. constructor(points: Vector3[]);
  19105. /**
  19106. * Returns the Curve3 stored array of successive Vector3
  19107. */
  19108. getPoints(): Vector3[];
  19109. /**
  19110. * Returns the computed length (float) of the curve.
  19111. */
  19112. length(): number;
  19113. /**
  19114. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  19115. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  19116. * curveA and curveB keep unchanged.
  19117. */
  19118. continue(curve: Curve3): Curve3;
  19119. private _computeLength;
  19120. }
  19121. class PositionNormalVertex {
  19122. position: Vector3;
  19123. normal: Vector3;
  19124. constructor(position?: Vector3, normal?: Vector3);
  19125. clone(): PositionNormalVertex;
  19126. }
  19127. class PositionNormalTextureVertex {
  19128. position: Vector3;
  19129. normal: Vector3;
  19130. uv: Vector2;
  19131. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  19132. clone(): PositionNormalTextureVertex;
  19133. }
  19134. class Tmp {
  19135. static Color3: Color3[];
  19136. static Color4: Color4[];
  19137. static Vector2: Vector2[];
  19138. static Vector3: Vector3[];
  19139. static Vector4: Vector4[];
  19140. static Quaternion: Quaternion[];
  19141. static Matrix: Matrix[];
  19142. }
  19143. }
  19144. declare module BABYLON {
  19145. /**
  19146. * Class representing spherical polynomial coefficients to the 3rd degree
  19147. */
  19148. class SphericalPolynomial {
  19149. /**
  19150. * The x coefficients of the spherical polynomial
  19151. */
  19152. x: Vector3;
  19153. /**
  19154. * The y coefficients of the spherical polynomial
  19155. */
  19156. y: Vector3;
  19157. /**
  19158. * The z coefficients of the spherical polynomial
  19159. */
  19160. z: Vector3;
  19161. /**
  19162. * The xx coefficients of the spherical polynomial
  19163. */
  19164. xx: Vector3;
  19165. /**
  19166. * The yy coefficients of the spherical polynomial
  19167. */
  19168. yy: Vector3;
  19169. /**
  19170. * The zz coefficients of the spherical polynomial
  19171. */
  19172. zz: Vector3;
  19173. /**
  19174. * The xy coefficients of the spherical polynomial
  19175. */
  19176. xy: Vector3;
  19177. /**
  19178. * The yz coefficients of the spherical polynomial
  19179. */
  19180. yz: Vector3;
  19181. /**
  19182. * The zx coefficients of the spherical polynomial
  19183. */
  19184. zx: Vector3;
  19185. /**
  19186. * Adds an ambient color to the spherical polynomial
  19187. * @param color the color to add
  19188. */
  19189. addAmbient(color: Color3): void;
  19190. /**
  19191. * Scales the spherical polynomial by the given amount
  19192. * @param scale the amount to scale
  19193. */
  19194. scale(scale: number): void;
  19195. /**
  19196. * Gets the spherical polynomial from harmonics
  19197. * @param harmonics the spherical harmonics
  19198. * @returns the spherical polynomial
  19199. */
  19200. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  19201. /**
  19202. * Constructs a spherical polynomial from an array.
  19203. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  19204. * @returns the spherical polynomial
  19205. */
  19206. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  19207. }
  19208. /**
  19209. * Class representing spherical harmonics coefficients to the 3rd degree
  19210. */
  19211. class SphericalHarmonics {
  19212. /**
  19213. * The l0,0 coefficients of the spherical harmonics
  19214. */
  19215. l00: Vector3;
  19216. /**
  19217. * The l1,-1 coefficients of the spherical harmonics
  19218. */
  19219. l1_1: Vector3;
  19220. /**
  19221. * The l1,0 coefficients of the spherical harmonics
  19222. */
  19223. l10: Vector3;
  19224. /**
  19225. * The l1,1 coefficients of the spherical harmonics
  19226. */
  19227. l11: Vector3;
  19228. /**
  19229. * The l2,-2 coefficients of the spherical harmonics
  19230. */
  19231. l2_2: Vector3;
  19232. /**
  19233. * The l2,-1 coefficients of the spherical harmonics
  19234. */
  19235. l2_1: Vector3;
  19236. /**
  19237. * The l2,0 coefficients of the spherical harmonics
  19238. */
  19239. l20: Vector3;
  19240. /**
  19241. * The l2,1 coefficients of the spherical harmonics
  19242. */
  19243. l21: Vector3;
  19244. /**
  19245. * The l2,2 coefficients of the spherical harmonics
  19246. */
  19247. lL22: Vector3;
  19248. /**
  19249. * Adds a light to the spherical harmonics
  19250. * @param direction the direction of the light
  19251. * @param color the color of the light
  19252. * @param deltaSolidAngle the delta solid angle of the light
  19253. */
  19254. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19255. /**
  19256. * Scales the spherical harmonics by the given amount
  19257. * @param scale the amount to scale
  19258. */
  19259. scale(scale: number): void;
  19260. /**
  19261. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19262. *
  19263. * ```
  19264. * E_lm = A_l * L_lm
  19265. * ```
  19266. *
  19267. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19268. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19269. * the scaling factors are given in equation 9.
  19270. */
  19271. convertIncidentRadianceToIrradiance(): void;
  19272. /**
  19273. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19274. *
  19275. * ```
  19276. * L = (1/pi) * E * rho
  19277. * ```
  19278. *
  19279. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19280. */
  19281. convertIrradianceToLambertianRadiance(): void;
  19282. /**
  19283. * Gets the spherical harmonics from polynomial
  19284. * @param polynomial the spherical polynomial
  19285. * @returns the spherical harmonics
  19286. */
  19287. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19288. /**
  19289. * Constructs a spherical harmonics from an array.
  19290. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19291. * @returns the spherical harmonics
  19292. */
  19293. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19294. }
  19295. }
  19296. declare module BABYLON {
  19297. /**
  19298. * Defines a target to use with MorphTargetManager
  19299. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19300. */
  19301. class MorphTarget implements IAnimatable {
  19302. /** defines the name of the target */
  19303. name: string;
  19304. /**
  19305. * Gets or sets the list of animations
  19306. */
  19307. animations: Animation[];
  19308. private _scene;
  19309. private _positions;
  19310. private _normals;
  19311. private _tangents;
  19312. private _influence;
  19313. /**
  19314. * Observable raised when the influence changes
  19315. */
  19316. onInfluenceChanged: Observable<boolean>;
  19317. /**
  19318. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19319. */
  19320. influence: number;
  19321. private _animationPropertiesOverride;
  19322. /**
  19323. * Gets or sets the animation properties override
  19324. */
  19325. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19326. /**
  19327. * Creates a new MorphTarget
  19328. * @param name defines the name of the target
  19329. * @param influence defines the influence to use
  19330. */
  19331. constructor(
  19332. /** defines the name of the target */
  19333. name: string, influence?: number, scene?: Nullable<Scene>);
  19334. /**
  19335. * Gets a boolean defining if the target contains position data
  19336. */
  19337. readonly hasPositions: boolean;
  19338. /**
  19339. * Gets a boolean defining if the target contains normal data
  19340. */
  19341. readonly hasNormals: boolean;
  19342. /**
  19343. * Gets a boolean defining if the target contains tangent data
  19344. */
  19345. readonly hasTangents: boolean;
  19346. /**
  19347. * Affects position data to this target
  19348. * @param data defines the position data to use
  19349. */
  19350. setPositions(data: Nullable<FloatArray>): void;
  19351. /**
  19352. * Gets the position data stored in this target
  19353. * @returns a FloatArray containing the position data (or null if not present)
  19354. */
  19355. getPositions(): Nullable<FloatArray>;
  19356. /**
  19357. * Affects normal data to this target
  19358. * @param data defines the normal data to use
  19359. */
  19360. setNormals(data: Nullable<FloatArray>): void;
  19361. /**
  19362. * Gets the normal data stored in this target
  19363. * @returns a FloatArray containing the normal data (or null if not present)
  19364. */
  19365. getNormals(): Nullable<FloatArray>;
  19366. /**
  19367. * Affects tangent data to this target
  19368. * @param data defines the tangent data to use
  19369. */
  19370. setTangents(data: Nullable<FloatArray>): void;
  19371. /**
  19372. * Gets the tangent data stored in this target
  19373. * @returns a FloatArray containing the tangent data (or null if not present)
  19374. */
  19375. getTangents(): Nullable<FloatArray>;
  19376. /**
  19377. * Serializes the current target into a Serialization object
  19378. * @returns the serialized object
  19379. */
  19380. serialize(): any;
  19381. /**
  19382. * Creates a new target from serialized data
  19383. * @param serializationObject defines the serialized data to use
  19384. * @returns a new MorphTarget
  19385. */
  19386. static Parse(serializationObject: any): MorphTarget;
  19387. /**
  19388. * Creates a MorphTarget from mesh data
  19389. * @param mesh defines the source mesh
  19390. * @param name defines the name to use for the new target
  19391. * @param influence defines the influence to attach to the target
  19392. * @returns a new MorphTarget
  19393. */
  19394. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19395. }
  19396. }
  19397. declare module BABYLON {
  19398. /**
  19399. * This class is used to deform meshes using morphing between different targets
  19400. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19401. */
  19402. class MorphTargetManager {
  19403. private _targets;
  19404. private _targetObservable;
  19405. private _activeTargets;
  19406. private _scene;
  19407. private _influences;
  19408. private _supportsNormals;
  19409. private _supportsTangents;
  19410. private _vertexCount;
  19411. private _uniqueId;
  19412. private _tempInfluences;
  19413. /**
  19414. * Creates a new MorphTargetManager
  19415. * @param scene defines the current scene
  19416. */
  19417. constructor(scene?: Nullable<Scene>);
  19418. /**
  19419. * Gets the unique ID of this manager
  19420. */
  19421. readonly uniqueId: number;
  19422. /**
  19423. * Gets the number of vertices handled by this manager
  19424. */
  19425. readonly vertexCount: number;
  19426. /**
  19427. * Gets a boolean indicating if this manager supports morphing of normals
  19428. */
  19429. readonly supportsNormals: boolean;
  19430. /**
  19431. * Gets a boolean indicating if this manager supports morphing of tangents
  19432. */
  19433. readonly supportsTangents: boolean;
  19434. /**
  19435. * Gets the number of targets stored in this manager
  19436. */
  19437. readonly numTargets: number;
  19438. /**
  19439. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19440. */
  19441. readonly numInfluencers: number;
  19442. /**
  19443. * Gets the list of influences (one per target)
  19444. */
  19445. readonly influences: Float32Array;
  19446. /**
  19447. * Gets the active target at specified index. An active target is a target with an influence > 0
  19448. * @param index defines the index to check
  19449. * @returns the requested target
  19450. */
  19451. getActiveTarget(index: number): MorphTarget;
  19452. /**
  19453. * Gets the target at specified index
  19454. * @param index defines the index to check
  19455. * @returns the requested target
  19456. */
  19457. getTarget(index: number): MorphTarget;
  19458. /**
  19459. * Add a new target to this manager
  19460. * @param target defines the target to add
  19461. */
  19462. addTarget(target: MorphTarget): void;
  19463. /**
  19464. * Removes a target from the manager
  19465. * @param target defines the target to remove
  19466. */
  19467. removeTarget(target: MorphTarget): void;
  19468. /**
  19469. * Serializes the current manager into a Serialization object
  19470. * @returns the serialized object
  19471. */
  19472. serialize(): any;
  19473. private _syncActiveTargets;
  19474. /**
  19475. * Syncrhonize the targets with all the meshes using this morph target manager
  19476. */
  19477. synchronize(): void;
  19478. /**
  19479. * Creates a new MorphTargetManager from serialized data
  19480. * @param serializationObject defines the serialized data
  19481. * @param scene defines the hosting scene
  19482. * @returns the new MorphTargetManager
  19483. */
  19484. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19485. }
  19486. }
  19487. declare module BABYLON {
  19488. /**
  19489. * Class used to store all common mesh properties
  19490. */
  19491. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19492. /** No occlusion */
  19493. static OCCLUSION_TYPE_NONE: number;
  19494. /** Occlusion set to optimisitic */
  19495. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19496. /** Occlusion set to strict */
  19497. static OCCLUSION_TYPE_STRICT: number;
  19498. /** Use an accurante occlusion algorithm */
  19499. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19500. /** Use a conservative occlusion algorithm */
  19501. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19502. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19503. static readonly CULLINGSTRATEGY_STANDARD: number;
  19504. /** Culling strategy with bounding sphere only and then frustum culling */
  19505. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19506. /**
  19507. * No billboard
  19508. */
  19509. static readonly BILLBOARDMODE_NONE: number;
  19510. /** Billboard on X axis */
  19511. static readonly BILLBOARDMODE_X: number;
  19512. /** Billboard on Y axis */
  19513. static readonly BILLBOARDMODE_Y: number;
  19514. /** Billboard on Z axis */
  19515. static readonly BILLBOARDMODE_Z: number;
  19516. /** Billboard on all axes */
  19517. static readonly BILLBOARDMODE_ALL: number;
  19518. private _facetPositions;
  19519. private _facetNormals;
  19520. private _facetPartitioning;
  19521. private _facetNb;
  19522. private _partitioningSubdivisions;
  19523. private _partitioningBBoxRatio;
  19524. private _facetDataEnabled;
  19525. private _facetParameters;
  19526. private _bbSize;
  19527. private _subDiv;
  19528. private _facetDepthSort;
  19529. private _facetDepthSortEnabled;
  19530. private _depthSortedIndices;
  19531. private _depthSortedFacets;
  19532. private _facetDepthSortFunction;
  19533. private _facetDepthSortFrom;
  19534. private _facetDepthSortOrigin;
  19535. private _invertedMatrix;
  19536. /** Gets ot sets the culling strategy to use to find visible meshes */
  19537. cullingStrategy: number;
  19538. /**
  19539. * Gets the number of facets in the mesh
  19540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19541. */
  19542. readonly facetNb: number;
  19543. /**
  19544. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19546. */
  19547. partitioningSubdivisions: number;
  19548. /**
  19549. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19550. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19552. */
  19553. partitioningBBoxRatio: number;
  19554. /**
  19555. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19556. * Works only for updatable meshes.
  19557. * Doesn't work with multi-materials
  19558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19559. */
  19560. mustDepthSortFacets: boolean;
  19561. /**
  19562. * The location (Vector3) where the facet depth sort must be computed from.
  19563. * By default, the active camera position.
  19564. * Used only when facet depth sort is enabled
  19565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19566. */
  19567. facetDepthSortFrom: Vector3;
  19568. /**
  19569. * gets a boolean indicating if facetData is enabled
  19570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19571. */
  19572. readonly isFacetDataEnabled: boolean;
  19573. /** @hidden */
  19574. _updateNonUniformScalingState(value: boolean): boolean;
  19575. /**
  19576. * An event triggered when this mesh collides with another one
  19577. */
  19578. onCollideObservable: Observable<AbstractMesh>;
  19579. private _onCollideObserver;
  19580. /** Set a function to call when this mesh collides with another one */
  19581. onCollide: () => void;
  19582. /**
  19583. * An event triggered when the collision's position changes
  19584. */
  19585. onCollisionPositionChangeObservable: Observable<Vector3>;
  19586. private _onCollisionPositionChangeObserver;
  19587. /** Set a function to call when the collision's position changes */
  19588. onCollisionPositionChange: () => void;
  19589. /**
  19590. * An event triggered when material is changed
  19591. */
  19592. onMaterialChangedObservable: Observable<AbstractMesh>;
  19593. /**
  19594. * Gets or sets the orientation for POV movement & rotation
  19595. */
  19596. definedFacingForward: boolean;
  19597. /**
  19598. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19599. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19600. * * 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.
  19601. * @see http://doc.babylonjs.com/features/occlusionquery
  19602. */
  19603. occlusionQueryAlgorithmType: number;
  19604. /**
  19605. * 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:
  19606. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19607. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19608. * * 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.
  19609. * @see http://doc.babylonjs.com/features/occlusionquery
  19610. */
  19611. occlusionType: number;
  19612. /**
  19613. * 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.
  19614. * The default value is -1 which means don't break the query and wait till the result
  19615. * @see http://doc.babylonjs.com/features/occlusionquery
  19616. */
  19617. occlusionRetryCount: number;
  19618. /** @hidden */
  19619. _occlusionInternalRetryCounter: number;
  19620. /** @hidden */
  19621. _isOccluded: boolean;
  19622. /**
  19623. * 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
  19624. * @see http://doc.babylonjs.com/features/occlusionquery
  19625. */
  19626. isOccluded: boolean;
  19627. /** @hidden */
  19628. _isOcclusionQueryInProgress: boolean;
  19629. /**
  19630. * Flag to check the progress status of the query
  19631. * @see http://doc.babylonjs.com/features/occlusionquery
  19632. */
  19633. readonly isOcclusionQueryInProgress: boolean;
  19634. /** @hidden */
  19635. _occlusionQuery: Nullable<WebGLQuery>;
  19636. private _visibility;
  19637. /**
  19638. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19639. */
  19640. /**
  19641. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19642. */
  19643. visibility: number;
  19644. /** Gets or sets the alpha index used to sort transparent meshes
  19645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19646. */
  19647. alphaIndex: number;
  19648. /**
  19649. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19650. */
  19651. isVisible: boolean;
  19652. /**
  19653. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19654. */
  19655. isPickable: boolean;
  19656. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19657. showSubMeshesBoundingBox: boolean;
  19658. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19659. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19660. */
  19661. isBlocker: boolean;
  19662. /**
  19663. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19664. */
  19665. enablePointerMoveEvents: boolean;
  19666. /**
  19667. * Specifies the rendering group id for this mesh (0 by default)
  19668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19669. */
  19670. renderingGroupId: number;
  19671. private _material;
  19672. /** Gets or sets current material */
  19673. material: Nullable<Material>;
  19674. private _receiveShadows;
  19675. /**
  19676. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19677. * @see http://doc.babylonjs.com/babylon101/shadows
  19678. */
  19679. receiveShadows: boolean;
  19680. /**
  19681. * Gets or sets a boolean indicating if the outline must be rendered as well
  19682. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19683. */
  19684. renderOutline: boolean;
  19685. /** Defines color to use when rendering outline */
  19686. outlineColor: Color3;
  19687. /** Define width to use when rendering outline */
  19688. outlineWidth: number;
  19689. /**
  19690. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19691. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19692. */
  19693. renderOverlay: boolean;
  19694. /** Defines color to use when rendering overlay */
  19695. overlayColor: Color3;
  19696. /** Defines alpha to use when rendering overlay */
  19697. overlayAlpha: number;
  19698. private _hasVertexAlpha;
  19699. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19700. hasVertexAlpha: boolean;
  19701. private _useVertexColors;
  19702. /** 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) */
  19703. useVertexColors: boolean;
  19704. private _computeBonesUsingShaders;
  19705. /**
  19706. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19707. */
  19708. computeBonesUsingShaders: boolean;
  19709. private _numBoneInfluencers;
  19710. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19711. numBoneInfluencers: number;
  19712. private _applyFog;
  19713. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19714. applyFog: boolean;
  19715. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19716. useOctreeForRenderingSelection: boolean;
  19717. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19718. useOctreeForPicking: boolean;
  19719. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19720. useOctreeForCollisions: boolean;
  19721. private _layerMask;
  19722. /**
  19723. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19724. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19725. */
  19726. layerMask: number;
  19727. /**
  19728. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19729. */
  19730. alwaysSelectAsActiveMesh: boolean;
  19731. /**
  19732. * Gets or sets the current action manager
  19733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19734. */
  19735. actionManager: Nullable<ActionManager>;
  19736. /**
  19737. * Gets or sets impostor used for physic simulation
  19738. * @see http://doc.babylonjs.com/features/physics_engine
  19739. */
  19740. physicsImpostor: Nullable<PhysicsImpostor>;
  19741. private _checkCollisions;
  19742. private _collisionMask;
  19743. private _collisionGroup;
  19744. /**
  19745. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19747. */
  19748. ellipsoid: Vector3;
  19749. /**
  19750. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19751. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19752. */
  19753. ellipsoidOffset: Vector3;
  19754. private _collider;
  19755. private _oldPositionForCollisions;
  19756. private _diffPositionForCollisions;
  19757. /**
  19758. * Gets or sets a collision mask used to mask collisions (default is -1).
  19759. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19760. */
  19761. collisionMask: number;
  19762. /**
  19763. * Gets or sets the current collision group mask (-1 by default).
  19764. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19765. */
  19766. collisionGroup: number;
  19767. /**
  19768. * Defines edge width used when edgesRenderer is enabled
  19769. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19770. */
  19771. edgesWidth: number;
  19772. /**
  19773. * Defines edge color used when edgesRenderer is enabled
  19774. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19775. */
  19776. edgesColor: Color4;
  19777. /** @hidden */
  19778. _edgesRenderer: Nullable<EdgesRenderer>;
  19779. private _collisionsTransformMatrix;
  19780. private _collisionsScalingMatrix;
  19781. /** @hidden */
  19782. _masterMesh: Nullable<AbstractMesh>;
  19783. /** @hidden */
  19784. _boundingInfo: Nullable<BoundingInfo>;
  19785. /** @hidden */
  19786. _renderId: number;
  19787. /**
  19788. * Gets or sets the list of subMeshes
  19789. * @see http://doc.babylonjs.com/how_to/multi_materials
  19790. */
  19791. subMeshes: SubMesh[];
  19792. /** @hidden */
  19793. _submeshesOctree: Octree<SubMesh>;
  19794. /** @hidden */
  19795. _intersectionsInProgress: AbstractMesh[];
  19796. /** @hidden */
  19797. _unIndexed: boolean;
  19798. /** @hidden */
  19799. _lightSources: Light[];
  19800. /** @hidden */
  19801. readonly _positions: Nullable<Vector3[]>;
  19802. /** @hidden */
  19803. _waitingActions: any;
  19804. /** @hidden */
  19805. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19806. private _skeleton;
  19807. /** @hidden */
  19808. _bonesTransformMatrices: Nullable<Float32Array>;
  19809. /**
  19810. * Gets or sets a skeleton to apply skining transformations
  19811. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19812. */
  19813. skeleton: Nullable<Skeleton>;
  19814. /**
  19815. * Creates a new AbstractMesh
  19816. * @param name defines the name of the mesh
  19817. * @param scene defines the hosting scene
  19818. */
  19819. constructor(name: string, scene?: Nullable<Scene>);
  19820. /**
  19821. * Returns the string "AbstractMesh"
  19822. * @returns "AbstractMesh"
  19823. */
  19824. getClassName(): string;
  19825. /**
  19826. * Gets a string representation of the current mesh
  19827. * @param fullDetails defines a boolean indicating if full details must be included
  19828. * @returns a string representation of the current mesh
  19829. */
  19830. toString(fullDetails?: boolean): string;
  19831. /** @hidden */
  19832. _rebuild(): void;
  19833. /** @hidden */
  19834. _resyncLightSources(): void;
  19835. /** @hidden */
  19836. _resyncLighSource(light: Light): void;
  19837. /** @hidden */
  19838. _unBindEffect(): void;
  19839. /** @hidden */
  19840. _removeLightSource(light: Light): void;
  19841. private _markSubMeshesAsDirty;
  19842. /** @hidden */
  19843. _markSubMeshesAsLightDirty(): void;
  19844. /** @hidden */
  19845. _markSubMeshesAsAttributesDirty(): void;
  19846. /** @hidden */
  19847. _markSubMeshesAsMiscDirty(): void;
  19848. /**
  19849. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19850. */
  19851. scaling: Vector3;
  19852. /**
  19853. * Disables the mesh edge rendering mode
  19854. * @returns the currentAbstractMesh
  19855. */
  19856. disableEdgesRendering(): AbstractMesh;
  19857. /**
  19858. * Enables the edge rendering mode on the mesh.
  19859. * This mode makes the mesh edges visible
  19860. * @param epsilon defines the maximal distance between two angles to detect a face
  19861. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19862. * @returns the currentAbstractMesh
  19863. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19864. */
  19865. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19866. /**
  19867. * Gets the edgesRenderer associated with the mesh
  19868. */
  19869. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19870. /**
  19871. * Returns true if the mesh is blocked. Implemented by child classes
  19872. */
  19873. readonly isBlocked: boolean;
  19874. /**
  19875. * Returns the mesh itself by default. Implemented by child classes
  19876. * @param camera defines the camera to use to pick the right LOD level
  19877. * @returns the currentAbstractMesh
  19878. */
  19879. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19880. /**
  19881. * Returns 0 by default. Implemented by child classes
  19882. * @returns an integer
  19883. */
  19884. getTotalVertices(): number;
  19885. /**
  19886. * Returns null by default. Implemented by child classes
  19887. * @returns null
  19888. */
  19889. getIndices(): Nullable<IndicesArray>;
  19890. /**
  19891. * Returns the array of the requested vertex data kind. Implemented by child classes
  19892. * @param kind defines the vertex data kind to use
  19893. * @returns null
  19894. */
  19895. getVerticesData(kind: string): Nullable<FloatArray>;
  19896. /**
  19897. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19898. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19899. * Note that a new underlying VertexBuffer object is created each call.
  19900. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19901. * @param kind defines vertex data kind:
  19902. * * BABYLON.VertexBuffer.PositionKind
  19903. * * BABYLON.VertexBuffer.UVKind
  19904. * * BABYLON.VertexBuffer.UV2Kind
  19905. * * BABYLON.VertexBuffer.UV3Kind
  19906. * * BABYLON.VertexBuffer.UV4Kind
  19907. * * BABYLON.VertexBuffer.UV5Kind
  19908. * * BABYLON.VertexBuffer.UV6Kind
  19909. * * BABYLON.VertexBuffer.ColorKind
  19910. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19911. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19912. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19913. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19914. * @param data defines the data source
  19915. * @param updatable defines if the data must be flagged as updatable (or static)
  19916. * @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
  19917. * @returns the current mesh
  19918. */
  19919. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19920. /**
  19921. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19922. * If the mesh has no geometry, it is simply returned as it is.
  19923. * @param kind defines vertex data kind:
  19924. * * BABYLON.VertexBuffer.PositionKind
  19925. * * BABYLON.VertexBuffer.UVKind
  19926. * * BABYLON.VertexBuffer.UV2Kind
  19927. * * BABYLON.VertexBuffer.UV3Kind
  19928. * * BABYLON.VertexBuffer.UV4Kind
  19929. * * BABYLON.VertexBuffer.UV5Kind
  19930. * * BABYLON.VertexBuffer.UV6Kind
  19931. * * BABYLON.VertexBuffer.ColorKind
  19932. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19933. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19934. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19935. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19936. * @param data defines the data source
  19937. * @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
  19938. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19939. * @returns the current mesh
  19940. */
  19941. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19942. /**
  19943. * Sets the mesh indices,
  19944. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19945. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19946. * @param totalVertices Defines the total number of vertices
  19947. * @returns the current mesh
  19948. */
  19949. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19950. /**
  19951. * Gets a boolean indicating if specific vertex data is present
  19952. * @param kind defines the vertex data kind to use
  19953. * @returns true is data kind is present
  19954. */
  19955. isVerticesDataPresent(kind: string): boolean;
  19956. /**
  19957. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19958. * @returns a BoundingInfo
  19959. */
  19960. getBoundingInfo(): BoundingInfo;
  19961. /**
  19962. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19963. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19964. * @returns the current mesh
  19965. */
  19966. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19967. /**
  19968. * Overwrite the current bounding info
  19969. * @param boundingInfo defines the new bounding info
  19970. * @returns the current mesh
  19971. */
  19972. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19973. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19974. readonly useBones: boolean;
  19975. /** @hidden */
  19976. _preActivate(): void;
  19977. /** @hidden */
  19978. _preActivateForIntermediateRendering(renderId: number): void;
  19979. /** @hidden */
  19980. _activate(renderId: number): void;
  19981. /**
  19982. * Gets the current world matrix
  19983. * @returns a Matrix
  19984. */
  19985. getWorldMatrix(): Matrix;
  19986. /** @hidden */
  19987. _getWorldMatrixDeterminant(): number;
  19988. /**
  19989. * Perform relative position change from the point of view of behind the front of the mesh.
  19990. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19991. * Supports definition of mesh facing forward or backward
  19992. * @param amountRight defines the distance on the right axis
  19993. * @param amountUp defines the distance on the up axis
  19994. * @param amountForward defines the distance on the forward axis
  19995. * @returns the current mesh
  19996. */
  19997. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19998. /**
  19999. * Calculate relative position change from the point of view of behind the front of the mesh.
  20000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20001. * Supports definition of mesh facing forward or backward
  20002. * @param amountRight defines the distance on the right axis
  20003. * @param amountUp defines the distance on the up axis
  20004. * @param amountForward defines the distance on the forward axis
  20005. * @returns the new displacement vector
  20006. */
  20007. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20008. /**
  20009. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20010. * Supports definition of mesh facing forward or backward
  20011. * @param flipBack defines the flip
  20012. * @param twirlClockwise defines the twirl
  20013. * @param tiltRight defines the tilt
  20014. * @returns the current mesh
  20015. */
  20016. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20017. /**
  20018. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20019. * Supports definition of mesh facing forward or backward.
  20020. * @param flipBack defines the flip
  20021. * @param twirlClockwise defines the twirl
  20022. * @param tiltRight defines the tilt
  20023. * @returns the new rotation vector
  20024. */
  20025. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  20026. /**
  20027. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  20028. * @param includeDescendants Include bounding info from descendants as well (true by default)
  20029. * @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
  20030. * @returns the new bounding vectors
  20031. */
  20032. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  20033. min: Vector3;
  20034. max: Vector3;
  20035. };
  20036. /** @hidden */
  20037. _updateBoundingInfo(): AbstractMesh;
  20038. /** @hidden */
  20039. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  20040. /** @hidden */
  20041. protected _afterComputeWorldMatrix(): void;
  20042. /**
  20043. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20044. * A mesh is in the frustum if its bounding box intersects the frustum
  20045. * @param frustumPlanes defines the frustum to test
  20046. * @returns true if the mesh is in the frustum planes
  20047. */
  20048. isInFrustum(frustumPlanes: Plane[]): boolean;
  20049. /**
  20050. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  20051. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  20052. * @param frustumPlanes defines the frustum to test
  20053. * @returns true if the mesh is completely in the frustum planes
  20054. */
  20055. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20056. /**
  20057. * True if the mesh intersects another mesh or a SolidParticle object
  20058. * @param mesh defines a target mesh or SolidParticle to test
  20059. * @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)
  20060. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  20061. * @returns true if there is an intersection
  20062. */
  20063. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  20064. /**
  20065. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  20066. * @param point defines the point to test
  20067. * @returns true if there is an intersection
  20068. */
  20069. intersectsPoint(point: Vector3): boolean;
  20070. /**
  20071. * Gets the current physics impostor
  20072. * @see http://doc.babylonjs.com/features/physics_engine
  20073. * @returns a physics impostor or null
  20074. */
  20075. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  20076. /**
  20077. * Gets the position of the current mesh in camera space
  20078. * @param camera defines the camera to use
  20079. * @returns a position
  20080. */
  20081. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20082. /**
  20083. * Returns the distance from the mesh to the active camera
  20084. * @param camera defines the camera to use
  20085. * @returns the distance
  20086. */
  20087. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20088. /**
  20089. * Apply a physic impulse to the mesh
  20090. * @param force defines the force to apply
  20091. * @param contactPoint defines where to apply the force
  20092. * @returns the current mesh
  20093. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20094. */
  20095. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  20096. /**
  20097. * Creates a physic joint between two meshes
  20098. * @param otherMesh defines the other mesh to use
  20099. * @param pivot1 defines the pivot to use on this mesh
  20100. * @param pivot2 defines the pivot to use on the other mesh
  20101. * @param options defines additional options (can be plugin dependent)
  20102. * @returns the current mesh
  20103. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  20104. */
  20105. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  20106. /**
  20107. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  20108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20109. */
  20110. checkCollisions: boolean;
  20111. /**
  20112. * Gets Collider object used to compute collisions (not physics)
  20113. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20114. */
  20115. readonly collider: Collider;
  20116. /**
  20117. * Move the mesh using collision engine
  20118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20119. * @param displacement defines the requested displacement vector
  20120. * @returns the current mesh
  20121. */
  20122. moveWithCollisions(displacement: Vector3): AbstractMesh;
  20123. private _onCollisionPositionChange;
  20124. /**
  20125. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  20126. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20127. * @param maxCapacity defines the maximum size of each block (64 by default)
  20128. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  20129. * @returns the new octree
  20130. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  20131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  20132. */
  20133. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  20134. /** @hidden */
  20135. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  20136. /** @hidden */
  20137. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  20138. /** @hidden */
  20139. _checkCollision(collider: Collider): AbstractMesh;
  20140. /** @hidden */
  20141. _generatePointsArray(): boolean;
  20142. /**
  20143. * Checks if the passed Ray intersects with the mesh
  20144. * @param ray defines the ray to use
  20145. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20146. * @returns the picking info
  20147. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20148. */
  20149. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20150. /**
  20151. * Clones the current mesh
  20152. * @param name defines the mesh name
  20153. * @param newParent defines the new mesh parent
  20154. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20155. * @returns the new mesh
  20156. */
  20157. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20158. /**
  20159. * Disposes all the submeshes of the current meshnp
  20160. * @returns the current mesh
  20161. */
  20162. releaseSubMeshes(): AbstractMesh;
  20163. /**
  20164. * Releases resources associated with this abstract mesh.
  20165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20167. */
  20168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20169. /**
  20170. * Adds the passed mesh as a child to the current mesh
  20171. * @param mesh defines the child mesh
  20172. * @returns the current mesh
  20173. */
  20174. addChild(mesh: AbstractMesh): AbstractMesh;
  20175. /**
  20176. * Removes the passed mesh from the current mesh children list
  20177. * @param mesh defines the child mesh
  20178. * @returns the current mesh
  20179. */
  20180. removeChild(mesh: AbstractMesh): AbstractMesh;
  20181. /** @hidden */
  20182. private _initFacetData;
  20183. /**
  20184. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20185. * This method can be called within the render loop.
  20186. * 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
  20187. * @returns the current mesh
  20188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20189. */
  20190. updateFacetData(): AbstractMesh;
  20191. /**
  20192. * Returns the facetLocalNormals array.
  20193. * The normals are expressed in the mesh local spac
  20194. * @returns an array of Vector3
  20195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20196. */
  20197. getFacetLocalNormals(): Vector3[];
  20198. /**
  20199. * Returns the facetLocalPositions array.
  20200. * The facet positions are expressed in the mesh local space
  20201. * @returns an array of Vector3
  20202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20203. */
  20204. getFacetLocalPositions(): Vector3[];
  20205. /**
  20206. * Returns the facetLocalPartioning array
  20207. * @returns an array of array of numbers
  20208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20209. */
  20210. getFacetLocalPartitioning(): number[][];
  20211. /**
  20212. * Returns the i-th facet position in the world system.
  20213. * This method allocates a new Vector3 per call
  20214. * @param i defines the facet index
  20215. * @returns a new Vector3
  20216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20217. */
  20218. getFacetPosition(i: number): Vector3;
  20219. /**
  20220. * Sets the reference Vector3 with the i-th facet position in the world system
  20221. * @param i defines the facet index
  20222. * @param ref defines the target vector
  20223. * @returns the current mesh
  20224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20225. */
  20226. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20227. /**
  20228. * Returns the i-th facet normal in the world system.
  20229. * This method allocates a new Vector3 per call
  20230. * @param i defines the facet index
  20231. * @returns a new Vector3
  20232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20233. */
  20234. getFacetNormal(i: number): Vector3;
  20235. /**
  20236. * Sets the reference Vector3 with the i-th facet normal in the world system
  20237. * @param i defines the facet index
  20238. * @param ref defines the target vector
  20239. * @returns the current mesh
  20240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20241. */
  20242. getFacetNormalToRef(i: number, ref: Vector3): this;
  20243. /**
  20244. * 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)
  20245. * @param x defines x coordinate
  20246. * @param y defines y coordinate
  20247. * @param z defines z coordinate
  20248. * @returns the array of facet indexes
  20249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20250. */
  20251. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20252. /**
  20253. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20254. * @param projected sets as the (x,y,z) world projection on the facet
  20255. * @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
  20256. * @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
  20257. * @param x defines x coordinate
  20258. * @param y defines y coordinate
  20259. * @param z defines z coordinate
  20260. * @returns the face index if found (or null instead)
  20261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20262. */
  20263. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20264. /**
  20265. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20266. * @param projected sets as the (x,y,z) local projection on the facet
  20267. * @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
  20268. * @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
  20269. * @param x defines x coordinate
  20270. * @param y defines y coordinate
  20271. * @param z defines z coordinate
  20272. * @returns the face index if found (or null instead)
  20273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20274. */
  20275. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20276. /**
  20277. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20278. * @returns the parameters
  20279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20280. */
  20281. getFacetDataParameters(): any;
  20282. /**
  20283. * Disables the feature FacetData and frees the related memory
  20284. * @returns the current mesh
  20285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20286. */
  20287. disableFacetData(): AbstractMesh;
  20288. /**
  20289. * Updates the AbstractMesh indices array
  20290. * @param indices defines the data source
  20291. * @returns the current mesh
  20292. */
  20293. updateIndices(indices: IndicesArray): AbstractMesh;
  20294. /**
  20295. * Creates new normals data for the mesh
  20296. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20297. * @returns the current mesh
  20298. */
  20299. createNormals(updatable: boolean): AbstractMesh;
  20300. /**
  20301. * Align the mesh with a normal
  20302. * @param normal defines the normal to use
  20303. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20304. * @returns the current mesh
  20305. */
  20306. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20307. /** @hidden */
  20308. _checkOcclusionQuery(): void;
  20309. }
  20310. }
  20311. declare module BABYLON {
  20312. class Buffer {
  20313. private _engine;
  20314. private _buffer;
  20315. /** @hidden */
  20316. _data: Nullable<DataArray>;
  20317. private _updatable;
  20318. private _instanced;
  20319. /**
  20320. * Gets the byte stride.
  20321. */
  20322. readonly byteStride: number;
  20323. /**
  20324. * Constructor
  20325. * @param engine the engine
  20326. * @param data the data to use for this buffer
  20327. * @param updatable whether the data is updatable
  20328. * @param stride the stride (optional)
  20329. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20330. * @param instanced whether the buffer is instanced (optional)
  20331. * @param useBytes set to true if the stride in in bytes (optional)
  20332. */
  20333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20334. /**
  20335. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20337. * @param offset defines offset in the buffer (0 by default)
  20338. * @param size defines the size in floats of attributes (position is 3 for instance)
  20339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20340. * @param instanced defines if the vertex buffer contains indexed data
  20341. * @param useBytes defines if the offset and stride are in bytes
  20342. * @returns the new vertex buffer
  20343. */
  20344. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20345. isUpdatable(): boolean;
  20346. getData(): Nullable<DataArray>;
  20347. getBuffer(): Nullable<WebGLBuffer>;
  20348. /**
  20349. * Gets the stride in float32 units (i.e. byte stride / 4).
  20350. * May not be an integer if the byte stride is not divisible by 4.
  20351. * DEPRECATED. Use byteStride instead.
  20352. * @returns the stride in float32 units
  20353. */
  20354. getStrideSize(): number;
  20355. create(data?: Nullable<DataArray>): void;
  20356. /** @hidden */
  20357. _rebuild(): void;
  20358. update(data: DataArray): void;
  20359. /**
  20360. * Updates the data directly.
  20361. * @param data the new data
  20362. * @param offset the new offset
  20363. * @param vertexCount the vertex count (optional)
  20364. * @param useBytes set to true if the offset is in bytes
  20365. */
  20366. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20367. dispose(): void;
  20368. }
  20369. }
  20370. declare module BABYLON {
  20371. class CSG {
  20372. private polygons;
  20373. matrix: Matrix;
  20374. position: Vector3;
  20375. rotation: Vector3;
  20376. rotationQuaternion: Nullable<Quaternion>;
  20377. scaling: Vector3;
  20378. static FromMesh(mesh: Mesh): CSG;
  20379. private static FromPolygons;
  20380. clone(): CSG;
  20381. union(csg: CSG): CSG;
  20382. unionInPlace(csg: CSG): void;
  20383. subtract(csg: CSG): CSG;
  20384. subtractInPlace(csg: CSG): void;
  20385. intersect(csg: CSG): CSG;
  20386. intersectInPlace(csg: CSG): void;
  20387. inverse(): CSG;
  20388. inverseInPlace(): void;
  20389. copyTransformAttributes(csg: CSG): CSG;
  20390. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20391. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20392. }
  20393. }
  20394. declare module BABYLON {
  20395. /**
  20396. * Class used to store geometry data (vertex buffers + index buffer)
  20397. */
  20398. class Geometry implements IGetSetVerticesData {
  20399. /**
  20400. * Gets or sets the unique ID of the geometry
  20401. */
  20402. id: string;
  20403. /**
  20404. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20405. */
  20406. delayLoadState: number;
  20407. /**
  20408. * Gets the file containing the data to load when running in delay load state
  20409. */
  20410. delayLoadingFile: Nullable<string>;
  20411. /**
  20412. * Callback called when the geometry is updated
  20413. */
  20414. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20415. private _scene;
  20416. private _engine;
  20417. private _meshes;
  20418. private _totalVertices;
  20419. /** @hidden */
  20420. _indices: IndicesArray;
  20421. /** @hidden */
  20422. _vertexBuffers: {
  20423. [key: string]: VertexBuffer;
  20424. };
  20425. private _isDisposed;
  20426. private _extend;
  20427. private _boundingBias;
  20428. /** @hidden */
  20429. _delayInfo: Array<string>;
  20430. private _indexBuffer;
  20431. private _indexBufferIsUpdatable;
  20432. /** @hidden */
  20433. _boundingInfo: Nullable<BoundingInfo>;
  20434. /** @hidden */
  20435. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20436. /** @hidden */
  20437. _softwareSkinningRenderId: number;
  20438. private _vertexArrayObjects;
  20439. private _updatable;
  20440. /** @hidden */
  20441. _positions: Nullable<Vector3[]>;
  20442. /**
  20443. * 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
  20444. */
  20445. /**
  20446. * 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
  20447. */
  20448. boundingBias: Vector2;
  20449. /**
  20450. * Static function used to attach a new empty geometry to a mesh
  20451. * @param mesh defines the mesh to attach the geometry to
  20452. * @returns the new {BABYLON.Geometry}
  20453. */
  20454. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20455. /**
  20456. * Creates a new geometry
  20457. * @param id defines the unique ID
  20458. * @param scene defines the hosting scene
  20459. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20460. * @param updatable defines if geometry must be updatable (false by default)
  20461. * @param mesh defines the mesh that will be associated with the geometry
  20462. */
  20463. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20464. /**
  20465. * Gets the current extend of the geometry
  20466. */
  20467. readonly extend: {
  20468. minimum: Vector3;
  20469. maximum: Vector3;
  20470. };
  20471. /**
  20472. * Gets the hosting scene
  20473. * @returns the hosting {BABYLON.Scene}
  20474. */
  20475. getScene(): Scene;
  20476. /**
  20477. * Gets the hosting engine
  20478. * @returns the hosting {BABYLON.Engine}
  20479. */
  20480. getEngine(): Engine;
  20481. /**
  20482. * Defines if the geometry is ready to use
  20483. * @returns true if the geometry is ready to be used
  20484. */
  20485. isReady(): boolean;
  20486. /**
  20487. * Gets a value indicating that the geometry should not be serialized
  20488. */
  20489. readonly doNotSerialize: boolean;
  20490. /** @hidden */
  20491. _rebuild(): void;
  20492. /**
  20493. * Affects all geometry data in one call
  20494. * @param vertexData defines the geometry data
  20495. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20496. */
  20497. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20498. /**
  20499. * Set specific vertex data
  20500. * @param kind defines the data kind (Position, normal, etc...)
  20501. * @param data defines the vertex data to use
  20502. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20503. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20504. */
  20505. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20506. /**
  20507. * Removes a specific vertex data
  20508. * @param kind defines the data kind (Position, normal, etc...)
  20509. */
  20510. removeVerticesData(kind: string): void;
  20511. /**
  20512. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20513. * @param buffer defines the vertex buffer to use
  20514. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20515. */
  20516. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20517. /**
  20518. * Update a specific vertex buffer
  20519. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20520. * It will do nothing if the buffer is not updatable
  20521. * @param kind defines the data kind (Position, normal, etc...)
  20522. * @param data defines the data to use
  20523. * @param offset defines the offset in the target buffer where to store the data
  20524. * @param useBytes set to true if the offset is in bytes
  20525. */
  20526. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20527. /**
  20528. * Update a specific vertex buffer
  20529. * This function will create a new buffer if the current one is not updatable
  20530. * @param kind defines the data kind (Position, normal, etc...)
  20531. * @param data defines the data to use
  20532. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20533. */
  20534. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20535. private _updateBoundingInfo;
  20536. /** @hidden */
  20537. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20538. /**
  20539. * Gets total number of vertices
  20540. * @returns the total number of vertices
  20541. */
  20542. getTotalVertices(): number;
  20543. /**
  20544. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20545. * @param kind defines the data kind (Position, normal, etc...)
  20546. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20547. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20548. * @returns a float array containing vertex data
  20549. */
  20550. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20551. /**
  20552. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20553. * @param kind defines the data kind (Position, normal, etc...)
  20554. * @returns true if the vertex buffer with the specified kind is updatable
  20555. */
  20556. isVertexBufferUpdatable(kind: string): boolean;
  20557. /**
  20558. * Gets a specific vertex buffer
  20559. * @param kind defines the data kind (Position, normal, etc...)
  20560. * @returns a {BABYLON.VertexBuffer}
  20561. */
  20562. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20563. /**
  20564. * Returns all vertex buffers
  20565. * @return an object holding all vertex buffers indexed by kind
  20566. */
  20567. getVertexBuffers(): Nullable<{
  20568. [key: string]: VertexBuffer;
  20569. }>;
  20570. /**
  20571. * Gets a boolean indicating if specific vertex buffer is present
  20572. * @param kind defines the data kind (Position, normal, etc...)
  20573. * @returns true if data is present
  20574. */
  20575. isVerticesDataPresent(kind: string): boolean;
  20576. /**
  20577. * Gets a list of all attached data kinds (Position, normal, etc...)
  20578. * @returns a list of string containing all kinds
  20579. */
  20580. getVerticesDataKinds(): string[];
  20581. /**
  20582. * Update index buffer
  20583. * @param indices defines the indices to store in the index buffer
  20584. * @param offset defines the offset in the target buffer where to store the data
  20585. */
  20586. updateIndices(indices: IndicesArray, offset?: number): void;
  20587. /**
  20588. * Creates a new index buffer
  20589. * @param indices defines the indices to store in the index buffer
  20590. * @param totalVertices defines the total number of vertices (could be null)
  20591. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20592. */
  20593. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20594. /**
  20595. * Return the total number of indices
  20596. * @returns the total number of indices
  20597. */
  20598. getTotalIndices(): number;
  20599. /**
  20600. * Gets the index buffer array
  20601. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20602. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20603. * @returns the index buffer array
  20604. */
  20605. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20606. /**
  20607. * Gets the index buffer
  20608. * @return the index buffer
  20609. */
  20610. getIndexBuffer(): Nullable<WebGLBuffer>;
  20611. /** @hidden */
  20612. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20613. /**
  20614. * Release the associated resources for a specific mesh
  20615. * @param mesh defines the source mesh
  20616. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20617. */
  20618. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20619. /**
  20620. * Apply current geometry to a given mesh
  20621. * @param mesh defines the mesh to apply geometry to
  20622. */
  20623. applyToMesh(mesh: Mesh): void;
  20624. private _updateExtend;
  20625. private _applyToMesh;
  20626. private notifyUpdate;
  20627. /**
  20628. * Load the geometry if it was flagged as delay loaded
  20629. * @param scene defines the hosting scene
  20630. * @param onLoaded defines a callback called when the geometry is loaded
  20631. */
  20632. load(scene: Scene, onLoaded?: () => void): void;
  20633. private _queueLoad;
  20634. /**
  20635. * Invert the geometry to move from a right handed system to a left handed one.
  20636. */
  20637. toLeftHanded(): void;
  20638. /** @hidden */
  20639. _resetPointsArrayCache(): void;
  20640. /** @hidden */
  20641. _generatePointsArray(): boolean;
  20642. /**
  20643. * Gets a value indicating if the geometry is disposed
  20644. * @returns true if the geometry was disposed
  20645. */
  20646. isDisposed(): boolean;
  20647. private _disposeVertexArrayObjects;
  20648. /**
  20649. * Free all associated resources
  20650. */
  20651. dispose(): void;
  20652. /**
  20653. * Clone the current geometry into a new geometry
  20654. * @param id defines the unique ID of the new geometry
  20655. * @returns a new geometry object
  20656. */
  20657. copy(id: string): Geometry;
  20658. /**
  20659. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20660. * @return a JSON representation of the current geometry data (without the vertices data)
  20661. */
  20662. serialize(): any;
  20663. private toNumberArray;
  20664. /**
  20665. * Serialize all vertices data into a JSON oject
  20666. * @returns a JSON representation of the current geometry data
  20667. */
  20668. serializeVerticeData(): any;
  20669. /**
  20670. * Extracts a clone of a mesh geometry
  20671. * @param mesh defines the source mesh
  20672. * @param id defines the unique ID of the new geometry object
  20673. * @returns the new geometry object
  20674. */
  20675. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20676. /**
  20677. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20678. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20679. * Be aware Math.random() could cause collisions, but:
  20680. * "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"
  20681. * @returns a string containing a new GUID
  20682. */
  20683. static RandomId(): string;
  20684. /** @hidden */
  20685. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20686. private static _CleanMatricesWeights;
  20687. /**
  20688. * Create a new geometry from persisted data (Using .babylon file format)
  20689. * @param parsedVertexData defines the persisted data
  20690. * @param scene defines the hosting scene
  20691. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20692. * @returns the new geometry object
  20693. */
  20694. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20695. }
  20696. /**
  20697. * Abstract class used to provide common services for all typed geometries
  20698. * @hidden
  20699. */
  20700. class _PrimitiveGeometry extends Geometry {
  20701. private _canBeRegenerated;
  20702. private _beingRegenerated;
  20703. /**
  20704. * Creates a new typed geometry
  20705. * @param id defines the unique ID of the geometry
  20706. * @param scene defines the hosting scene
  20707. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20708. * @param mesh defines the hosting mesh (can be null)
  20709. */
  20710. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20711. /**
  20712. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20713. * @returns true if the geometry can be regenerated
  20714. */
  20715. canBeRegenerated(): boolean;
  20716. /**
  20717. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20718. */
  20719. regenerate(): void;
  20720. /**
  20721. * Clone the geometry
  20722. * @param id defines the unique ID of the new geometry
  20723. * @returns the new geometry
  20724. */
  20725. asNewGeometry(id: string): Geometry;
  20726. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20727. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20728. /** @hidden */
  20729. _regenerateVertexData(): VertexData;
  20730. copy(id: string): Geometry;
  20731. serialize(): any;
  20732. }
  20733. /**
  20734. * Creates a ribbon geometry
  20735. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20736. */
  20737. class RibbonGeometry extends _PrimitiveGeometry {
  20738. /**
  20739. * Defines the array of paths to use
  20740. */
  20741. pathArray: Vector3[][];
  20742. /**
  20743. * Defines if the last and first points of each path in your pathArray must be joined
  20744. */
  20745. closeArray: boolean;
  20746. /**
  20747. * Defines if the last and first points of each path in your pathArray must be joined
  20748. */
  20749. closePath: boolean;
  20750. /**
  20751. * Defines the offset between points
  20752. */
  20753. offset: number;
  20754. /**
  20755. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20756. */
  20757. side: number;
  20758. /**
  20759. * Creates a ribbon geometry
  20760. * @param id defines the unique ID of the geometry
  20761. * @param scene defines the hosting scene
  20762. * @param pathArray defines the array of paths to use
  20763. * @param closeArray defines if the last path and the first path must be joined
  20764. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20765. * @param offset defines the offset between points
  20766. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20767. * @param mesh defines the hosting mesh (can be null)
  20768. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20769. */
  20770. constructor(id: string, scene: Scene,
  20771. /**
  20772. * Defines the array of paths to use
  20773. */
  20774. pathArray: Vector3[][],
  20775. /**
  20776. * Defines if the last and first points of each path in your pathArray must be joined
  20777. */
  20778. closeArray: boolean,
  20779. /**
  20780. * Defines if the last and first points of each path in your pathArray must be joined
  20781. */
  20782. closePath: boolean,
  20783. /**
  20784. * Defines the offset between points
  20785. */
  20786. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20787. /**
  20788. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20789. */
  20790. side?: number);
  20791. /** @hidden */
  20792. _regenerateVertexData(): VertexData;
  20793. copy(id: string): Geometry;
  20794. }
  20795. /**
  20796. * Creates a box geometry
  20797. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20798. */
  20799. class BoxGeometry extends _PrimitiveGeometry {
  20800. /**
  20801. * Defines the zise of the box (width, height and depth are the same)
  20802. */
  20803. size: number;
  20804. /**
  20805. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20806. */
  20807. side: number;
  20808. /**
  20809. * Creates a box geometry
  20810. * @param id defines the unique ID of the geometry
  20811. * @param scene defines the hosting scene
  20812. * @param size defines the zise of the box (width, height and depth are the same)
  20813. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20814. * @param mesh defines the hosting mesh (can be null)
  20815. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20816. */
  20817. constructor(id: string, scene: Scene,
  20818. /**
  20819. * Defines the zise of the box (width, height and depth are the same)
  20820. */
  20821. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20822. /**
  20823. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20824. */
  20825. side?: number);
  20826. /** @hidden */
  20827. _regenerateVertexData(): VertexData;
  20828. copy(id: string): Geometry;
  20829. serialize(): any;
  20830. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20831. }
  20832. /**
  20833. * Creates a sphere geometry
  20834. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20835. */
  20836. class SphereGeometry extends _PrimitiveGeometry {
  20837. /**
  20838. * Defines the number of segments to use to create the sphere
  20839. */
  20840. segments: number;
  20841. /**
  20842. * Defines the diameter of the sphere
  20843. */
  20844. diameter: number;
  20845. /**
  20846. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20847. */
  20848. side: number;
  20849. /**
  20850. * Create a new sphere geometry
  20851. * @param id defines the unique ID of the geometry
  20852. * @param scene defines the hosting scene
  20853. * @param segments defines the number of segments to use to create the sphere
  20854. * @param diameter defines the diameter of the sphere
  20855. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20856. * @param mesh defines the hosting mesh (can be null)
  20857. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20858. */
  20859. constructor(id: string, scene: Scene,
  20860. /**
  20861. * Defines the number of segments to use to create the sphere
  20862. */
  20863. segments: number,
  20864. /**
  20865. * Defines the diameter of the sphere
  20866. */
  20867. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20868. /**
  20869. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20870. */
  20871. side?: number);
  20872. /** @hidden */
  20873. _regenerateVertexData(): VertexData;
  20874. copy(id: string): Geometry;
  20875. serialize(): any;
  20876. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20877. }
  20878. /**
  20879. * Creates a disc geometry
  20880. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20881. */
  20882. class DiscGeometry extends _PrimitiveGeometry {
  20883. /**
  20884. * Defines the radius of the disc
  20885. */
  20886. radius: number;
  20887. /**
  20888. * Defines the tesselation factor to apply to the disc
  20889. */
  20890. tessellation: number;
  20891. /**
  20892. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20893. */
  20894. side: number;
  20895. /**
  20896. * Creates a new disc geometry
  20897. * @param id defines the unique ID of the geometry
  20898. * @param scene defines the hosting scene
  20899. * @param radius defines the radius of the disc
  20900. * @param tessellation defines the tesselation factor to apply to the disc
  20901. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20902. * @param mesh defines the hosting mesh (can be null)
  20903. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20904. */
  20905. constructor(id: string, scene: Scene,
  20906. /**
  20907. * Defines the radius of the disc
  20908. */
  20909. radius: number,
  20910. /**
  20911. * Defines the tesselation factor to apply to the disc
  20912. */
  20913. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20914. /**
  20915. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20916. */
  20917. side?: number);
  20918. /** @hidden */
  20919. _regenerateVertexData(): VertexData;
  20920. copy(id: string): Geometry;
  20921. }
  20922. /**
  20923. * Creates a new cylinder geometry
  20924. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20925. */
  20926. class CylinderGeometry extends _PrimitiveGeometry {
  20927. /**
  20928. * Defines the height of the cylinder
  20929. */
  20930. height: number;
  20931. /**
  20932. * Defines the diameter of the cylinder's top cap
  20933. */
  20934. diameterTop: number;
  20935. /**
  20936. * Defines the diameter of the cylinder's bottom cap
  20937. */
  20938. diameterBottom: number;
  20939. /**
  20940. * Defines the tessellation factor to apply to the cylinder
  20941. */
  20942. tessellation: number;
  20943. /**
  20944. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20945. */
  20946. subdivisions: number;
  20947. /**
  20948. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20949. */
  20950. side: number;
  20951. /**
  20952. * Creates a new cylinder geometry
  20953. * @param id defines the unique ID of the geometry
  20954. * @param scene defines the hosting scene
  20955. * @param height defines the height of the cylinder
  20956. * @param diameterTop defines the diameter of the cylinder's top cap
  20957. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20958. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20959. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20960. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20961. * @param mesh defines the hosting mesh (can be null)
  20962. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20963. */
  20964. constructor(id: string, scene: Scene,
  20965. /**
  20966. * Defines the height of the cylinder
  20967. */
  20968. height: number,
  20969. /**
  20970. * Defines the diameter of the cylinder's top cap
  20971. */
  20972. diameterTop: number,
  20973. /**
  20974. * Defines the diameter of the cylinder's bottom cap
  20975. */
  20976. diameterBottom: number,
  20977. /**
  20978. * Defines the tessellation factor to apply to the cylinder
  20979. */
  20980. tessellation: number,
  20981. /**
  20982. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20983. */
  20984. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20985. /**
  20986. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20987. */
  20988. side?: number);
  20989. /** @hidden */
  20990. _regenerateVertexData(): VertexData;
  20991. copy(id: string): Geometry;
  20992. serialize(): any;
  20993. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20994. }
  20995. /**
  20996. * Creates a new torus geometry
  20997. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20998. */
  20999. class TorusGeometry extends _PrimitiveGeometry {
  21000. /**
  21001. * Defines the diameter of the torus
  21002. */
  21003. diameter: number;
  21004. /**
  21005. * Defines the thickness of the torus (ie. internal diameter)
  21006. */
  21007. thickness: number;
  21008. /**
  21009. * Defines the tesselation factor to apply to the torus
  21010. */
  21011. tessellation: number;
  21012. /**
  21013. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21014. */
  21015. side: number;
  21016. /**
  21017. * Creates a new torus geometry
  21018. * @param id defines the unique ID of the geometry
  21019. * @param scene defines the hosting scene
  21020. * @param diameter defines the diameter of the torus
  21021. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21022. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21023. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21024. * @param mesh defines the hosting mesh (can be null)
  21025. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21026. */
  21027. constructor(id: string, scene: Scene,
  21028. /**
  21029. * Defines the diameter of the torus
  21030. */
  21031. diameter: number,
  21032. /**
  21033. * Defines the thickness of the torus (ie. internal diameter)
  21034. */
  21035. thickness: number,
  21036. /**
  21037. * Defines the tesselation factor to apply to the torus
  21038. */
  21039. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21040. /**
  21041. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21042. */
  21043. side?: number);
  21044. /** @hidden */
  21045. _regenerateVertexData(): VertexData;
  21046. copy(id: string): Geometry;
  21047. serialize(): any;
  21048. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  21049. }
  21050. /**
  21051. * Creates a new ground geometry
  21052. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  21053. */
  21054. class GroundGeometry extends _PrimitiveGeometry {
  21055. /**
  21056. * Defines the width of the ground
  21057. */
  21058. width: number;
  21059. /**
  21060. * Defines the height of the ground
  21061. */
  21062. height: number;
  21063. /**
  21064. * Defines the subdivisions to apply to the ground
  21065. */
  21066. subdivisions: number;
  21067. /**
  21068. * Creates a new ground geometry
  21069. * @param id defines the unique ID of the geometry
  21070. * @param scene defines the hosting scene
  21071. * @param width defines the width of the ground
  21072. * @param height defines the height of the ground
  21073. * @param subdivisions defines the subdivisions to apply to the ground
  21074. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21075. * @param mesh defines the hosting mesh (can be null)
  21076. */
  21077. constructor(id: string, scene: Scene,
  21078. /**
  21079. * Defines the width of the ground
  21080. */
  21081. width: number,
  21082. /**
  21083. * Defines the height of the ground
  21084. */
  21085. height: number,
  21086. /**
  21087. * Defines the subdivisions to apply to the ground
  21088. */
  21089. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21090. /** @hidden */
  21091. _regenerateVertexData(): VertexData;
  21092. copy(id: string): Geometry;
  21093. serialize(): any;
  21094. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  21095. }
  21096. /**
  21097. * Creates a tiled ground geometry
  21098. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  21099. */
  21100. class TiledGroundGeometry extends _PrimitiveGeometry {
  21101. /**
  21102. * Defines the minimum value on X axis
  21103. */
  21104. xmin: number;
  21105. /**
  21106. * Defines the minimum value on Z axis
  21107. */
  21108. zmin: number;
  21109. /**
  21110. * Defines the maximum value on X axis
  21111. */
  21112. xmax: number;
  21113. /**
  21114. * Defines the maximum value on Z axis
  21115. */
  21116. zmax: number;
  21117. /**
  21118. * Defines the subdivisions to apply to the ground
  21119. */
  21120. subdivisions: {
  21121. w: number;
  21122. h: number;
  21123. };
  21124. /**
  21125. * Defines the precision to use when computing the tiles
  21126. */
  21127. precision: {
  21128. w: number;
  21129. h: number;
  21130. };
  21131. /**
  21132. * Creates a tiled ground geometry
  21133. * @param id defines the unique ID of the geometry
  21134. * @param scene defines the hosting scene
  21135. * @param xmin defines the minimum value on X axis
  21136. * @param zmin defines the minimum value on Z axis
  21137. * @param xmax defines the maximum value on X axis
  21138. * @param zmax defines the maximum value on Z axis
  21139. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  21140. * @param precision defines the precision to use when computing the tiles
  21141. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21142. * @param mesh defines the hosting mesh (can be null)
  21143. */
  21144. constructor(id: string, scene: Scene,
  21145. /**
  21146. * Defines the minimum value on X axis
  21147. */
  21148. xmin: number,
  21149. /**
  21150. * Defines the minimum value on Z axis
  21151. */
  21152. zmin: number,
  21153. /**
  21154. * Defines the maximum value on X axis
  21155. */
  21156. xmax: number,
  21157. /**
  21158. * Defines the maximum value on Z axis
  21159. */
  21160. zmax: number,
  21161. /**
  21162. * Defines the subdivisions to apply to the ground
  21163. */
  21164. subdivisions: {
  21165. w: number;
  21166. h: number;
  21167. },
  21168. /**
  21169. * Defines the precision to use when computing the tiles
  21170. */
  21171. precision: {
  21172. w: number;
  21173. h: number;
  21174. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21175. /** @hidden */
  21176. _regenerateVertexData(): VertexData;
  21177. copy(id: string): Geometry;
  21178. }
  21179. /**
  21180. * Creates a plane geometry
  21181. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21182. */
  21183. class PlaneGeometry extends _PrimitiveGeometry {
  21184. /**
  21185. * Defines the size of the plane (width === height)
  21186. */
  21187. size: number;
  21188. /**
  21189. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21190. */
  21191. side: number;
  21192. /**
  21193. * Creates a plane geometry
  21194. * @param id defines the unique ID of the geometry
  21195. * @param scene defines the hosting scene
  21196. * @param size defines the size of the plane (width === height)
  21197. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21198. * @param mesh defines the hosting mesh (can be null)
  21199. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21200. */
  21201. constructor(id: string, scene: Scene,
  21202. /**
  21203. * Defines the size of the plane (width === height)
  21204. */
  21205. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21206. /**
  21207. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21208. */
  21209. side?: number);
  21210. /** @hidden */
  21211. _regenerateVertexData(): VertexData;
  21212. copy(id: string): Geometry;
  21213. serialize(): any;
  21214. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21215. }
  21216. /**
  21217. * Creates a torus knot geometry
  21218. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21219. */
  21220. class TorusKnotGeometry extends _PrimitiveGeometry {
  21221. /**
  21222. * Defines the radius of the torus knot
  21223. */
  21224. radius: number;
  21225. /**
  21226. * Defines the thickness of the torus knot tube
  21227. */
  21228. tube: number;
  21229. /**
  21230. * Defines the number of radial segments
  21231. */
  21232. radialSegments: number;
  21233. /**
  21234. * Defines the number of tubular segments
  21235. */
  21236. tubularSegments: number;
  21237. /**
  21238. * Defines the first number of windings
  21239. */
  21240. p: number;
  21241. /**
  21242. * Defines the second number of windings
  21243. */
  21244. q: number;
  21245. /**
  21246. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21247. */
  21248. side: number;
  21249. /**
  21250. * Creates a torus knot geometry
  21251. * @param id defines the unique ID of the geometry
  21252. * @param scene defines the hosting scene
  21253. * @param radius defines the radius of the torus knot
  21254. * @param tube defines the thickness of the torus knot tube
  21255. * @param radialSegments defines the number of radial segments
  21256. * @param tubularSegments defines the number of tubular segments
  21257. * @param p defines the first number of windings
  21258. * @param q defines the second number of windings
  21259. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21260. * @param mesh defines the hosting mesh (can be null)
  21261. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21262. */
  21263. constructor(id: string, scene: Scene,
  21264. /**
  21265. * Defines the radius of the torus knot
  21266. */
  21267. radius: number,
  21268. /**
  21269. * Defines the thickness of the torus knot tube
  21270. */
  21271. tube: number,
  21272. /**
  21273. * Defines the number of radial segments
  21274. */
  21275. radialSegments: number,
  21276. /**
  21277. * Defines the number of tubular segments
  21278. */
  21279. tubularSegments: number,
  21280. /**
  21281. * Defines the first number of windings
  21282. */
  21283. p: number,
  21284. /**
  21285. * Defines the second number of windings
  21286. */
  21287. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21288. /**
  21289. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21290. */
  21291. side?: number);
  21292. /** @hidden */
  21293. _regenerateVertexData(): VertexData;
  21294. copy(id: string): Geometry;
  21295. serialize(): any;
  21296. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21297. }
  21298. }
  21299. declare module BABYLON {
  21300. class GroundMesh extends Mesh {
  21301. generateOctree: boolean;
  21302. private _heightQuads;
  21303. /** @hidden */
  21304. _subdivisionsX: number;
  21305. /** @hidden */
  21306. _subdivisionsY: number;
  21307. /** @hidden */
  21308. _width: number;
  21309. /** @hidden */
  21310. _height: number;
  21311. /** @hidden */
  21312. _minX: number;
  21313. /** @hidden */
  21314. _maxX: number;
  21315. /** @hidden */
  21316. _minZ: number;
  21317. /** @hidden */
  21318. _maxZ: number;
  21319. constructor(name: string, scene: Scene);
  21320. getClassName(): string;
  21321. readonly subdivisions: number;
  21322. readonly subdivisionsX: number;
  21323. readonly subdivisionsY: number;
  21324. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21325. /**
  21326. * Returns a height (y) value in the Worl system :
  21327. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21328. * Returns the ground y position if (x, z) are outside the ground surface.
  21329. */
  21330. getHeightAtCoordinates(x: number, z: number): number;
  21331. /**
  21332. * Returns a normalized vector (Vector3) orthogonal to the ground
  21333. * at the ground coordinates (x, z) expressed in the World system.
  21334. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21335. */
  21336. getNormalAtCoordinates(x: number, z: number): Vector3;
  21337. /**
  21338. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21339. * at the ground coordinates (x, z) expressed in the World system.
  21340. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21341. * Returns the GroundMesh.
  21342. */
  21343. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21344. /**
  21345. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21346. * if the ground has been updated.
  21347. * This can be used in the render loop.
  21348. * Returns the GroundMesh.
  21349. */
  21350. updateCoordinateHeights(): GroundMesh;
  21351. private _getFacetAt;
  21352. private _initHeightQuads;
  21353. private _computeHeightQuads;
  21354. serialize(serializationObject: any): void;
  21355. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21356. }
  21357. }
  21358. declare module BABYLON {
  21359. /**
  21360. * Creates an instance based on a source mesh.
  21361. */
  21362. class InstancedMesh extends AbstractMesh {
  21363. private _sourceMesh;
  21364. private _currentLOD;
  21365. constructor(name: string, source: Mesh);
  21366. /**
  21367. * Returns the string "InstancedMesh".
  21368. */
  21369. getClassName(): string;
  21370. readonly receiveShadows: boolean;
  21371. readonly material: Nullable<Material>;
  21372. readonly visibility: number;
  21373. readonly skeleton: Nullable<Skeleton>;
  21374. renderingGroupId: number;
  21375. /**
  21376. * Returns the total number of vertices (integer).
  21377. */
  21378. getTotalVertices(): number;
  21379. readonly sourceMesh: Mesh;
  21380. /**
  21381. * Is this node ready to be used/rendered
  21382. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21383. * @return {boolean} is it ready
  21384. */
  21385. isReady(completeCheck?: boolean): boolean;
  21386. /**
  21387. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21388. */
  21389. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21390. /**
  21391. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21392. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21393. * The `data` are either a numeric array either a Float32Array.
  21394. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21395. * 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).
  21396. * Note that a new underlying VertexBuffer object is created each call.
  21397. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21398. *
  21399. * Possible `kind` values :
  21400. * - BABYLON.VertexBuffer.PositionKind
  21401. * - BABYLON.VertexBuffer.UVKind
  21402. * - BABYLON.VertexBuffer.UV2Kind
  21403. * - BABYLON.VertexBuffer.UV3Kind
  21404. * - BABYLON.VertexBuffer.UV4Kind
  21405. * - BABYLON.VertexBuffer.UV5Kind
  21406. * - BABYLON.VertexBuffer.UV6Kind
  21407. * - BABYLON.VertexBuffer.ColorKind
  21408. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21409. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21410. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21411. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21412. *
  21413. * Returns the Mesh.
  21414. */
  21415. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21416. /**
  21417. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21418. * If the mesh has no geometry, it is simply returned as it is.
  21419. * The `data` are either a numeric array either a Float32Array.
  21420. * No new underlying VertexBuffer object is created.
  21421. * 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.
  21422. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21423. *
  21424. * Possible `kind` values :
  21425. * - BABYLON.VertexBuffer.PositionKind
  21426. * - BABYLON.VertexBuffer.UVKind
  21427. * - BABYLON.VertexBuffer.UV2Kind
  21428. * - BABYLON.VertexBuffer.UV3Kind
  21429. * - BABYLON.VertexBuffer.UV4Kind
  21430. * - BABYLON.VertexBuffer.UV5Kind
  21431. * - BABYLON.VertexBuffer.UV6Kind
  21432. * - BABYLON.VertexBuffer.ColorKind
  21433. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21434. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21435. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21436. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21437. *
  21438. * Returns the Mesh.
  21439. */
  21440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21441. /**
  21442. * Sets the mesh indices.
  21443. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21444. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21445. * This method creates a new index buffer each call.
  21446. * Returns the Mesh.
  21447. */
  21448. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21449. /**
  21450. * Boolean : True if the mesh owns the requested kind of data.
  21451. */
  21452. isVerticesDataPresent(kind: string): boolean;
  21453. /**
  21454. * Returns an array of indices (IndicesArray).
  21455. */
  21456. getIndices(): Nullable<IndicesArray>;
  21457. readonly _positions: Nullable<Vector3[]>;
  21458. /**
  21459. * Sets a new updated BoundingInfo to the mesh.
  21460. * Returns the mesh.
  21461. */
  21462. refreshBoundingInfo(): InstancedMesh;
  21463. /** @hidden */
  21464. _preActivate(): InstancedMesh;
  21465. /** @hidden */
  21466. _activate(renderId: number): InstancedMesh;
  21467. /**
  21468. * Returns the current associated LOD AbstractMesh.
  21469. */
  21470. getLOD(camera: Camera): AbstractMesh;
  21471. /** @hidden */
  21472. _syncSubMeshes(): InstancedMesh;
  21473. /** @hidden */
  21474. _generatePointsArray(): boolean;
  21475. /**
  21476. * Creates a new InstancedMesh from the current mesh.
  21477. * - name (string) : the cloned mesh name
  21478. * - newParent (optional Node) : the optional Node to parent the clone to.
  21479. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21480. *
  21481. * Returns the clone.
  21482. */
  21483. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21484. /**
  21485. * Disposes the InstancedMesh.
  21486. * Returns nothing.
  21487. */
  21488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21489. }
  21490. }
  21491. declare module BABYLON {
  21492. class LinesMesh extends Mesh {
  21493. useVertexColor?: boolean | undefined;
  21494. useVertexAlpha?: boolean | undefined;
  21495. color: Color3;
  21496. alpha: number;
  21497. /**
  21498. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21499. * This margin is expressed in world space coordinates, so its value may vary.
  21500. * Default value is 0.1
  21501. * @returns the intersection Threshold value.
  21502. */
  21503. /**
  21504. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21505. * This margin is expressed in world space coordinates, so its value may vary.
  21506. * @param value the new threshold to apply
  21507. */
  21508. intersectionThreshold: number;
  21509. private _intersectionThreshold;
  21510. private _colorShader;
  21511. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21512. /**
  21513. * Returns the string "LineMesh"
  21514. */
  21515. getClassName(): string;
  21516. /**
  21517. * @hidden
  21518. */
  21519. /**
  21520. * @hidden
  21521. */
  21522. material: Material;
  21523. /**
  21524. * @hidden
  21525. */
  21526. readonly checkCollisions: boolean;
  21527. createInstance(name: string): InstancedMesh;
  21528. /** @hidden */
  21529. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21530. /** @hidden */
  21531. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21532. dispose(doNotRecurse?: boolean): void;
  21533. /**
  21534. * Returns a new LineMesh object cloned from the current one.
  21535. */
  21536. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21537. /**
  21538. * Enables the edge rendering mode on the mesh.
  21539. * This mode makes the mesh edges visible
  21540. * @param epsilon defines the maximal distance between two angles to detect a face
  21541. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21542. * @returns the currentAbstractMesh
  21543. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21544. */
  21545. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21546. }
  21547. }
  21548. declare module BABYLON {
  21549. /**
  21550. * @hidden
  21551. **/
  21552. class _InstancesBatch {
  21553. mustReturn: boolean;
  21554. visibleInstances: Nullable<InstancedMesh[]>[];
  21555. renderSelf: boolean[];
  21556. }
  21557. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21558. static _FRONTSIDE: number;
  21559. static _BACKSIDE: number;
  21560. static _DOUBLESIDE: number;
  21561. static _DEFAULTSIDE: number;
  21562. static _NO_CAP: number;
  21563. static _CAP_START: number;
  21564. static _CAP_END: number;
  21565. static _CAP_ALL: number;
  21566. /**
  21567. * Mesh side orientation : usually the external or front surface
  21568. */
  21569. static readonly FRONTSIDE: number;
  21570. /**
  21571. * Mesh side orientation : usually the internal or back surface
  21572. */
  21573. static readonly BACKSIDE: number;
  21574. /**
  21575. * Mesh side orientation : both internal and external or front and back surfaces
  21576. */
  21577. static readonly DOUBLESIDE: number;
  21578. /**
  21579. * Mesh side orientation : by default, `FRONTSIDE`
  21580. */
  21581. static readonly DEFAULTSIDE: number;
  21582. /**
  21583. * Mesh cap setting : no cap
  21584. */
  21585. static readonly NO_CAP: number;
  21586. /**
  21587. * Mesh cap setting : one cap at the beginning of the mesh
  21588. */
  21589. static readonly CAP_START: number;
  21590. /**
  21591. * Mesh cap setting : one cap at the end of the mesh
  21592. */
  21593. static readonly CAP_END: number;
  21594. /**
  21595. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21596. */
  21597. static readonly CAP_ALL: number;
  21598. private _onBeforeRenderObservable;
  21599. private _onAfterRenderObservable;
  21600. private _onBeforeDrawObservable;
  21601. /**
  21602. * An event triggered before rendering the mesh
  21603. */
  21604. readonly onBeforeRenderObservable: Observable<Mesh>;
  21605. /**
  21606. * An event triggered after rendering the mesh
  21607. */
  21608. readonly onAfterRenderObservable: Observable<Mesh>;
  21609. /**
  21610. * An event triggered before drawing the mesh
  21611. */
  21612. readonly onBeforeDrawObservable: Observable<Mesh>;
  21613. private _onBeforeDrawObserver;
  21614. onBeforeDraw: () => void;
  21615. delayLoadState: number;
  21616. instances: InstancedMesh[];
  21617. delayLoadingFile: string;
  21618. /** @hidden */
  21619. _binaryInfo: any;
  21620. private _LODLevels;
  21621. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21622. private _morphTargetManager;
  21623. morphTargetManager: Nullable<MorphTargetManager>;
  21624. /** @hidden */
  21625. _geometry: Nullable<Geometry>;
  21626. /** @hidden */
  21627. _delayInfo: Array<string>;
  21628. /** @hidden */
  21629. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21630. /** @hidden */
  21631. _visibleInstances: any;
  21632. private _renderIdForInstances;
  21633. private _batchCache;
  21634. private _instancesBufferSize;
  21635. private _instancesBuffer;
  21636. private _instancesData;
  21637. private _overridenInstanceCount;
  21638. private _effectiveMaterial;
  21639. /** @hidden */
  21640. _shouldGenerateFlatShading: boolean;
  21641. private _preActivateId;
  21642. /** @hidden */
  21643. _originalBuilderSideOrientation: number;
  21644. overrideMaterialSideOrientation: Nullable<number>;
  21645. private _areNormalsFrozen;
  21646. private _sourcePositions;
  21647. private _sourceNormals;
  21648. private _source;
  21649. readonly source: Nullable<Mesh>;
  21650. isUnIndexed: boolean;
  21651. /**
  21652. * @constructor
  21653. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21654. * @param {Scene} scene The scene to add this mesh to.
  21655. * @param {Node} parent The parent of this mesh, if it has one
  21656. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21657. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21658. * When false, achieved by calling a clone(), also passing False.
  21659. * This will make creation of children, recursive.
  21660. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21661. */
  21662. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21663. /**
  21664. * Returns the string "Mesh".
  21665. */
  21666. getClassName(): string;
  21667. /**
  21668. * Returns a string.
  21669. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21670. */
  21671. toString(fullDetails?: boolean): string;
  21672. /** @hidden */
  21673. _unBindEffect(): void;
  21674. /**
  21675. * True if the mesh has some Levels Of Details (LOD).
  21676. * Returns a boolean.
  21677. */
  21678. readonly hasLODLevels: boolean;
  21679. /**
  21680. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21681. * @returns an array of {BABYLON.MeshLODLevel}
  21682. */
  21683. getLODLevels(): MeshLODLevel[];
  21684. private _sortLODLevels;
  21685. /**
  21686. * Add a mesh as LOD level triggered at the given distance.
  21687. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21688. * @param distance The distance from the center of the object to show this level
  21689. * @param mesh The mesh to be added as LOD level (can be null)
  21690. * @return This mesh (for chaining)
  21691. */
  21692. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21693. /**
  21694. * Returns the LOD level mesh at the passed distance or null if not found.
  21695. * It is related to the method `addLODLevel(distance, mesh)`.
  21696. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21697. * Returns an object Mesh or `null`.
  21698. */
  21699. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21700. /**
  21701. * Remove a mesh from the LOD array
  21702. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21703. * @param {Mesh} mesh The mesh to be removed.
  21704. * @return {Mesh} This mesh (for chaining)
  21705. */
  21706. removeLODLevel(mesh: Mesh): Mesh;
  21707. /**
  21708. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21709. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21710. */
  21711. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21712. /**
  21713. * Returns the mesh internal Geometry object.
  21714. */
  21715. readonly geometry: Nullable<Geometry>;
  21716. /**
  21717. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21718. */
  21719. getTotalVertices(): number;
  21720. /**
  21721. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21722. * 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.
  21723. * You can force the copy with forceCopy === true
  21724. * Returns null if the mesh has no geometry or no vertex buffer.
  21725. * Possible `kind` values :
  21726. * - BABYLON.VertexBuffer.PositionKind
  21727. * - BABYLON.VertexBuffer.UVKind
  21728. * - BABYLON.VertexBuffer.UV2Kind
  21729. * - BABYLON.VertexBuffer.UV3Kind
  21730. * - BABYLON.VertexBuffer.UV4Kind
  21731. * - BABYLON.VertexBuffer.UV5Kind
  21732. * - BABYLON.VertexBuffer.UV6Kind
  21733. * - BABYLON.VertexBuffer.ColorKind
  21734. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21735. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21736. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21737. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21738. */
  21739. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21740. /**
  21741. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21742. * Returns `null` if the mesh has no geometry.
  21743. * Possible `kind` values :
  21744. * - BABYLON.VertexBuffer.PositionKind
  21745. * - BABYLON.VertexBuffer.UVKind
  21746. * - BABYLON.VertexBuffer.UV2Kind
  21747. * - BABYLON.VertexBuffer.UV3Kind
  21748. * - BABYLON.VertexBuffer.UV4Kind
  21749. * - BABYLON.VertexBuffer.UV5Kind
  21750. * - BABYLON.VertexBuffer.UV6Kind
  21751. * - BABYLON.VertexBuffer.ColorKind
  21752. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21753. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21754. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21755. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21756. */
  21757. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21758. isVerticesDataPresent(kind: string): boolean;
  21759. /**
  21760. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21761. * Possible `kind` values :
  21762. * - BABYLON.VertexBuffer.PositionKind
  21763. * - BABYLON.VertexBuffer.UVKind
  21764. * - BABYLON.VertexBuffer.UV2Kind
  21765. * - BABYLON.VertexBuffer.UV3Kind
  21766. * - BABYLON.VertexBuffer.UV4Kind
  21767. * - BABYLON.VertexBuffer.UV5Kind
  21768. * - BABYLON.VertexBuffer.UV6Kind
  21769. * - BABYLON.VertexBuffer.ColorKind
  21770. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21771. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21772. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21773. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21774. */
  21775. isVertexBufferUpdatable(kind: string): boolean;
  21776. /**
  21777. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21778. * Possible `kind` values :
  21779. * - BABYLON.VertexBuffer.PositionKind
  21780. * - BABYLON.VertexBuffer.UVKind
  21781. * - BABYLON.VertexBuffer.UV2Kind
  21782. * - BABYLON.VertexBuffer.UV3Kind
  21783. * - BABYLON.VertexBuffer.UV4Kind
  21784. * - BABYLON.VertexBuffer.UV5Kind
  21785. * - BABYLON.VertexBuffer.UV6Kind
  21786. * - BABYLON.VertexBuffer.ColorKind
  21787. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21788. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21789. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21790. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21791. */
  21792. getVerticesDataKinds(): string[];
  21793. /**
  21794. * Returns a positive integer : the total number of indices in this mesh geometry.
  21795. * Returns zero if the mesh has no geometry.
  21796. */
  21797. getTotalIndices(): number;
  21798. /**
  21799. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21800. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21802. * @returns the indices array or an empty array if the mesh has no geometry
  21803. */
  21804. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21805. readonly isBlocked: boolean;
  21806. /**
  21807. * Determine if the current mesh is ready to be rendered
  21808. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21809. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21810. * @returns true if all associated assets are ready (material, textures, shaders)
  21811. */
  21812. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21813. /**
  21814. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21815. * This property is pertinent only for updatable parametric shapes.
  21816. */
  21817. readonly areNormalsFrozen: boolean;
  21818. /**
  21819. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21820. * It has no effect at all on other shapes.
  21821. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21822. * Returns the Mesh.
  21823. */
  21824. freezeNormals(): Mesh;
  21825. /**
  21826. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21827. * It has no effect at all on other shapes.
  21828. * It reactivates the mesh normals computation if it was previously frozen.
  21829. * Returns the Mesh.
  21830. */
  21831. unfreezeNormals(): Mesh;
  21832. /**
  21833. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21834. */
  21835. overridenInstanceCount: number;
  21836. /** @hidden */
  21837. _preActivate(): Mesh;
  21838. /** @hidden */
  21839. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21840. /** @hidden */
  21841. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21842. /**
  21843. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21844. * This means the mesh underlying bounding box and sphere are recomputed.
  21845. * Returns the Mesh.
  21846. */
  21847. refreshBoundingInfo(): Mesh;
  21848. /** @hidden */
  21849. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21850. private _getPositionData;
  21851. /** @hidden */
  21852. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21853. subdivide(count: number): void;
  21854. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21855. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21856. /**
  21857. * Sets the mesh VertexBuffer.
  21858. * Returns the Mesh.
  21859. */
  21860. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21862. /**
  21863. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21864. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21865. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21866. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21867. * Returns the Mesh.
  21868. */
  21869. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21870. /**
  21871. * Creates a un-shared specific occurence of the geometry for the mesh.
  21872. * Returns the Mesh.
  21873. */
  21874. makeGeometryUnique(): Mesh;
  21875. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21876. /**
  21877. * Update the current index buffer
  21878. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21879. * Returns the Mesh.
  21880. */
  21881. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21882. /**
  21883. * Invert the geometry to move from a right handed system to a left handed one.
  21884. * Returns the Mesh.
  21885. */
  21886. toLeftHanded(): Mesh;
  21887. /** @hidden */
  21888. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21889. /** @hidden */
  21890. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21891. /**
  21892. * Registers for this mesh a javascript function called just before the rendering process.
  21893. * This function is passed the current mesh.
  21894. * Return the Mesh.
  21895. */
  21896. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21897. /**
  21898. * Disposes a previously registered javascript function called before the rendering.
  21899. * This function is passed the current mesh.
  21900. * Returns the Mesh.
  21901. */
  21902. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21903. /**
  21904. * Registers for this mesh a javascript function called just after the rendering is complete.
  21905. * This function is passed the current mesh.
  21906. * Returns the Mesh.
  21907. */
  21908. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21909. /**
  21910. * Disposes a previously registered javascript function called after the rendering.
  21911. * This function is passed the current mesh.
  21912. * Return the Mesh.
  21913. */
  21914. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21915. /** @hidden */
  21916. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21917. /** @hidden */
  21918. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21919. /** @hidden */
  21920. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21921. /**
  21922. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21923. * @param subMesh defines the subMesh to render
  21924. * @param enableAlphaMode defines if alpha mode can be changed
  21925. * @returns the current mesh
  21926. */
  21927. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21928. private _onBeforeDraw;
  21929. /**
  21930. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21931. */
  21932. getEmittedParticleSystems(): IParticleSystem[];
  21933. /**
  21934. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21935. */
  21936. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21937. /**
  21938. * Normalize matrix weights so that all vertices have a total weight set to 1
  21939. */
  21940. cleanMatrixWeights(): void;
  21941. /** @hidden */
  21942. _checkDelayState(): Mesh;
  21943. private _queueLoad;
  21944. /**
  21945. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21946. * A mesh is in the frustum if its bounding box intersects the frustum
  21947. * @param frustumPlanes defines the frustum to test
  21948. * @returns true if the mesh is in the frustum planes
  21949. */
  21950. isInFrustum(frustumPlanes: Plane[]): boolean;
  21951. /**
  21952. * Sets the mesh material by the material or multiMaterial `id` property.
  21953. * The material `id` is a string identifying the material or the multiMaterial.
  21954. * This method returns the Mesh.
  21955. */
  21956. setMaterialByID(id: string): Mesh;
  21957. /**
  21958. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21959. */
  21960. getAnimatables(): IAnimatable[];
  21961. /**
  21962. * Modifies the mesh geometry according to the passed transformation matrix.
  21963. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21964. * The mesh normals are modified accordingly the same transformation.
  21965. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21966. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21967. * Returns the Mesh.
  21968. */
  21969. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21970. /**
  21971. * Modifies the mesh geometry according to its own current World Matrix.
  21972. * The mesh World Matrix is then reset.
  21973. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21974. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21975. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21976. * Returns the Mesh.
  21977. */
  21978. bakeCurrentTransformIntoVertices(): Mesh;
  21979. readonly _positions: Nullable<Vector3[]>;
  21980. /** @hidden */
  21981. _resetPointsArrayCache(): Mesh;
  21982. /** @hidden */
  21983. _generatePointsArray(): boolean;
  21984. /**
  21985. * Returns a new Mesh object generated from the current mesh properties.
  21986. * This method must not get confused with createInstance().
  21987. * The parameter `name` is a string, the name given to the new mesh.
  21988. * The optional parameter `newParent` can be any Node object (default `null`).
  21989. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21990. * 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.
  21991. */
  21992. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21993. /**
  21994. * Releases resources associated with this mesh.
  21995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21997. */
  21998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21999. /**
  22000. * Modifies the mesh geometry according to a displacement map.
  22001. * 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.
  22002. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22003. * This method returns nothing.
  22004. * @param url is a string, the URL from the image file is to be downloaded.
  22005. * @param minHeight is the lower limit of the displacement.
  22006. * @param maxHeight is the upper limit of the displacement.
  22007. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  22008. * @param uvOffset is an optional vector2 used to offset UV.
  22009. * @param uvScale is an optional vector2 used to scale UV.
  22010. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  22011. * @returns the Mesh.
  22012. */
  22013. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22014. /**
  22015. * Modifies the mesh geometry according to a displacementMap buffer.
  22016. * 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.
  22017. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22018. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22019. * @param heightMapWidth is the width of the buffer image.
  22020. * @param heightMapHeight is the height of the buffer image.
  22021. * @param minHeight is the lower limit of the displacement.
  22022. * @param maxHeight is the upper limit of the displacement.
  22023. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  22024. * @param uvOffset is an optional vector2 used to offset UV.
  22025. * @param uvScale is an optional vector2 used to scale UV.
  22026. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  22027. * @returns the Mesh.
  22028. */
  22029. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22030. /**
  22031. * Modify the mesh to get a flat shading rendering.
  22032. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22033. * This method returns the Mesh.
  22034. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22035. */
  22036. convertToFlatShadedMesh(): Mesh;
  22037. /**
  22038. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22039. * In other words, more vertices, no more indices and a single bigger VBO.
  22040. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22041. * Returns the Mesh.
  22042. */
  22043. convertToUnIndexedMesh(): Mesh;
  22044. /**
  22045. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  22046. * This method returns the Mesh.
  22047. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22048. */
  22049. flipFaces(flipNormals?: boolean): Mesh;
  22050. /**
  22051. * Creates a new InstancedMesh object from the mesh model.
  22052. * An instance shares the same properties and the same material than its model.
  22053. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  22054. * Only these properties of each instance can then be set individually :
  22055. * - position
  22056. * - rotation
  22057. * - rotationQuaternion
  22058. * - setPivotMatrix
  22059. * - scaling
  22060. *
  22061. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22062. * Warning : this method is not supported for Line mesh and LineSystem
  22063. */
  22064. createInstance(name: string): InstancedMesh;
  22065. /**
  22066. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22067. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22068. * This method returns the Mesh.
  22069. */
  22070. synchronizeInstances(): Mesh;
  22071. /**
  22072. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22073. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22074. * This should be used together with the simplification to avoid disappearing triangles.
  22075. * Returns the Mesh.
  22076. * @param successCallback an optional success callback to be called after the optimization finished.
  22077. */
  22078. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22079. serialize(serializationObject: any): void;
  22080. /** @hidden */
  22081. _syncGeometryWithMorphTargetManager(): void;
  22082. /**
  22083. * Returns a new Mesh object parsed from the source provided.
  22084. * The parameter `parsedMesh` is the source.
  22085. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22086. */
  22087. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22088. /**
  22089. * Creates a ribbon mesh.
  22090. * Please consider using the same method from the MeshBuilder class instead.
  22091. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22092. *
  22093. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22094. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22095. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  22096. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  22097. * 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.
  22098. * 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.
  22099. * 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
  22100. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22101. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22102. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22103. */
  22104. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22105. /**
  22106. * Creates a plane polygonal mesh. By default, this is a disc.
  22107. * Please consider using the same method from the MeshBuilder class instead.
  22108. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  22109. * 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.
  22110. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22111. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22112. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22113. */
  22114. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22115. /**
  22116. * Creates a box mesh.
  22117. * Please consider using the same method from the MeshBuilder class instead.
  22118. * The parameter `size` sets the size (float) of each box side (default 1).
  22119. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22120. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22121. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22122. */
  22123. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22124. /**
  22125. * Creates a sphere mesh.
  22126. * Please consider using the same method from the MeshBuilder class instead.
  22127. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  22128. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  22129. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22130. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22131. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22132. */
  22133. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22134. /**
  22135. * Creates a cylinder or a cone mesh.
  22136. * Please consider using the same method from the MeshBuilder class instead.
  22137. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22138. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22139. * 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.
  22140. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22141. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22142. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22143. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22144. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22145. */
  22146. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22147. /**
  22148. * Creates a torus mesh.
  22149. * Please consider using the same method from the MeshBuilder class instead.
  22150. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  22151. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22152. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22153. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22154. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22155. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22156. */
  22157. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22158. /**
  22159. * Creates a torus knot mesh.
  22160. * Please consider using the same method from the MeshBuilder class instead.
  22161. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22162. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22163. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22164. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22165. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22166. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22167. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22168. */
  22169. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22170. /**
  22171. * Creates a line mesh.
  22172. * Please consider using the same method from the MeshBuilder class instead.
  22173. * 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.
  22174. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22175. * The parameter `points` is an array successive Vector3.
  22176. * 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
  22177. * When updating an instance, remember that only point positions can change, not the number of points.
  22178. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22179. */
  22180. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22181. /**
  22182. * Creates a dashed line mesh.
  22183. * Please consider using the same method from the MeshBuilder class instead.
  22184. * 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.
  22185. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22186. * The parameter `points` is an array successive Vector3.
  22187. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22188. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22189. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22190. * 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
  22191. * When updating an instance, remember that only point positions can change, not the number of points.
  22192. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22193. */
  22194. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22195. /**
  22196. * Creates a polygon mesh.
  22197. * Please consider using the same method from the MeshBuilder class instead.
  22198. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22199. * 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.
  22200. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22201. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22202. * Remember you can only change the shape positions, not their number when updating a polygon.
  22203. */
  22204. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22205. /**
  22206. * Creates an extruded polygon mesh, with depth in the Y direction.
  22207. * Please consider using the same method from the MeshBuilder class instead.
  22208. */
  22209. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22210. /**
  22211. * Creates an extruded shape mesh.
  22212. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22213. * Please consider using the same method from the MeshBuilder class instead.
  22214. *
  22215. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22216. * 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
  22217. * extruded along the Z axis.
  22218. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22219. * 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.
  22220. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22221. * 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
  22222. * 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
  22223. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22224. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22225. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22226. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22227. */
  22228. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22229. /**
  22230. * Creates an custom extruded shape mesh.
  22231. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22232. * Please consider using the same method from the MeshBuilder class instead.
  22233. *
  22234. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22235. * 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
  22236. * extruded along the Z axis.
  22237. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22238. * 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
  22239. * and the distance of this point from the begining of the path :
  22240. * ```javascript
  22241. * var rotationFunction = function(i, distance) {
  22242. * // do things
  22243. * return rotationValue; }
  22244. * ```
  22245. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22246. * 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
  22247. * and the distance of this point from the begining of the path :
  22248. * ```javascript
  22249. * var scaleFunction = function(i, distance) {
  22250. * // do things
  22251. * return scaleValue;}
  22252. * ```
  22253. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22254. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22255. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22256. * 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
  22257. * 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
  22258. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22259. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22260. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22261. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22262. */
  22263. 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;
  22264. /**
  22265. * Creates lathe mesh.
  22266. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22267. * Please consider using the same method from the MeshBuilder class instead.
  22268. * 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
  22269. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22270. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22271. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22272. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22273. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22274. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22275. */
  22276. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22277. /**
  22278. * Creates a plane mesh.
  22279. * Please consider using the same method from the MeshBuilder class instead.
  22280. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22281. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22282. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22283. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22284. */
  22285. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22286. /**
  22287. * Creates a ground mesh.
  22288. * Please consider using the same method from the MeshBuilder class instead.
  22289. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22290. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22291. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22292. */
  22293. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22294. /**
  22295. * Creates a tiled ground mesh.
  22296. * Please consider using the same method from the MeshBuilder class instead.
  22297. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22298. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22299. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22300. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22301. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22302. * numbers of subdivisions on the ground width and height of each tile.
  22303. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22304. */
  22305. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22306. w: number;
  22307. h: number;
  22308. }, precision: {
  22309. w: number;
  22310. h: number;
  22311. }, scene: Scene, updatable?: boolean): Mesh;
  22312. /**
  22313. * Creates a ground mesh from a height map.
  22314. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22315. * Please consider using the same method from the MeshBuilder class instead.
  22316. * The parameter `url` sets the URL of the height map image resource.
  22317. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22318. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22319. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22320. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22321. * 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).
  22322. * This function is passed the newly built mesh :
  22323. * ```javascript
  22324. * function(mesh) { // do things
  22325. * return; }
  22326. * ```
  22327. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22328. */
  22329. 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;
  22330. /**
  22331. * Creates a tube mesh.
  22332. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22333. * Please consider using the same method from the MeshBuilder class instead.
  22334. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22335. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22336. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22337. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22338. * 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.
  22339. * It must return a radius value (positive float) :
  22340. * ```javascript
  22341. * var radiusFunction = function(i, distance) {
  22342. * // do things
  22343. * return radius; }
  22344. * ```
  22345. * 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
  22346. * 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
  22347. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22348. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22349. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22350. */
  22351. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22352. (i: number, distance: number): number;
  22353. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22354. /**
  22355. * Creates a polyhedron mesh.
  22356. * Please consider using the same method from the MeshBuilder class instead.
  22357. * 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
  22358. * to choose the wanted type.
  22359. * The parameter `size` (positive float, default 1) sets the polygon size.
  22360. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22361. * 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`.
  22362. * 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
  22363. * 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)`).
  22364. * 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
  22365. * 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.
  22366. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22367. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22368. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22369. */
  22370. static CreatePolyhedron(name: string, options: {
  22371. type?: number;
  22372. size?: number;
  22373. sizeX?: number;
  22374. sizeY?: number;
  22375. sizeZ?: number;
  22376. custom?: any;
  22377. faceUV?: Vector4[];
  22378. faceColors?: Color4[];
  22379. updatable?: boolean;
  22380. sideOrientation?: number;
  22381. }, scene: Scene): Mesh;
  22382. /**
  22383. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22384. * Please consider using the same method from the MeshBuilder class instead.
  22385. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22386. * 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`).
  22387. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22388. * 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.
  22389. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22390. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22391. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22392. */
  22393. static CreateIcoSphere(name: string, options: {
  22394. radius?: number;
  22395. flat?: boolean;
  22396. subdivisions?: number;
  22397. sideOrientation?: number;
  22398. updatable?: boolean;
  22399. }, scene: Scene): Mesh;
  22400. /**
  22401. * Creates a decal mesh.
  22402. * Please consider using the same method from the MeshBuilder class instead.
  22403. * 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.
  22404. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22405. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22406. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22407. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22408. */
  22409. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22410. /**
  22411. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22412. */
  22413. setPositionsForCPUSkinning(): Float32Array;
  22414. /**
  22415. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22416. */
  22417. setNormalsForCPUSkinning(): Float32Array;
  22418. /**
  22419. * Updates the vertex buffer by applying transformation from the bones.
  22420. * Returns the Mesh.
  22421. *
  22422. * @param {skeleton} skeleton to apply
  22423. */
  22424. applySkeleton(skeleton: Skeleton): Mesh;
  22425. /**
  22426. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22427. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22428. */
  22429. static MinMax(meshes: AbstractMesh[]): {
  22430. min: Vector3;
  22431. max: Vector3;
  22432. };
  22433. /**
  22434. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22435. */
  22436. static Center(meshesOrMinMaxVector: {
  22437. min: Vector3;
  22438. max: Vector3;
  22439. } | AbstractMesh[]): Vector3;
  22440. /**
  22441. * Merge the array of meshes into a single mesh for performance reasons.
  22442. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22443. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22444. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22445. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22446. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22447. */
  22448. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22449. }
  22450. }
  22451. declare module BABYLON {
  22452. /**
  22453. * Define an interface for all classes that will get and set the data on vertices
  22454. */
  22455. interface IGetSetVerticesData {
  22456. isVerticesDataPresent(kind: string): boolean;
  22457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22458. /**
  22459. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22460. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22462. * @returns the indices array or an empty array if the mesh has no geometry
  22463. */
  22464. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22465. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22466. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22467. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22468. }
  22469. /**
  22470. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22471. */
  22472. class VertexData {
  22473. /**
  22474. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22475. */
  22476. positions: Nullable<FloatArray>;
  22477. /**
  22478. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22479. */
  22480. normals: Nullable<FloatArray>;
  22481. /**
  22482. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22483. */
  22484. tangents: Nullable<FloatArray>;
  22485. /**
  22486. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22487. */
  22488. uvs: Nullable<FloatArray>;
  22489. /**
  22490. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22491. */
  22492. uvs2: Nullable<FloatArray>;
  22493. /**
  22494. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22495. */
  22496. uvs3: Nullable<FloatArray>;
  22497. /**
  22498. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22499. */
  22500. uvs4: Nullable<FloatArray>;
  22501. /**
  22502. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22503. */
  22504. uvs5: Nullable<FloatArray>;
  22505. /**
  22506. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22507. */
  22508. uvs6: Nullable<FloatArray>;
  22509. /**
  22510. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22511. */
  22512. colors: Nullable<FloatArray>;
  22513. /**
  22514. * 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).
  22515. */
  22516. matricesIndices: Nullable<FloatArray>;
  22517. /**
  22518. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22519. */
  22520. matricesWeights: Nullable<FloatArray>;
  22521. /**
  22522. * An array extending the number of possible indices
  22523. */
  22524. matricesIndicesExtra: Nullable<FloatArray>;
  22525. /**
  22526. * An array extending the number of possible weights when the number of indices is extended
  22527. */
  22528. matricesWeightsExtra: Nullable<FloatArray>;
  22529. /**
  22530. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22531. */
  22532. indices: Nullable<IndicesArray>;
  22533. /**
  22534. * Uses the passed data array to set the set the values for the specified kind of data
  22535. * @param data a linear array of floating numbers
  22536. * @param kind the type of data that is being set, eg positions, colors etc
  22537. */
  22538. set(data: FloatArray, kind: string): void;
  22539. /**
  22540. * Associates the vertexData to the passed Mesh.
  22541. * Sets it as updatable or not (default `false`)
  22542. * @param mesh the mesh the vertexData is applied to
  22543. * @param updatable when used and having the value true allows new data to update the vertexData
  22544. * @returns the VertexData
  22545. */
  22546. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22547. /**
  22548. * Associates the vertexData to the passed Geometry.
  22549. * Sets it as updatable or not (default `false`)
  22550. * @param geometry the geometry the vertexData is applied to
  22551. * @param updatable when used and having the value true allows new data to update the vertexData
  22552. * @returns VertexData
  22553. */
  22554. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22555. /**
  22556. * Updates the associated mesh
  22557. * @param mesh the mesh to be updated
  22558. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22559. * @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
  22560. * @returns VertexData
  22561. */
  22562. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22563. /**
  22564. * Updates the associated geometry
  22565. * @param geometry the geometry to be updated
  22566. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22567. * @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
  22568. * @returns VertexData.
  22569. */
  22570. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22571. private _applyTo;
  22572. private _update;
  22573. /**
  22574. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22575. * @param matrix the transforming matrix
  22576. * @returns the VertexData
  22577. */
  22578. transform(matrix: Matrix): VertexData;
  22579. /**
  22580. * Merges the passed VertexData into the current one
  22581. * @param other the VertexData to be merged into the current one
  22582. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22583. * @returns the modified VertexData
  22584. */
  22585. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22586. private _mergeElement;
  22587. private _validate;
  22588. /**
  22589. * Serializes the VertexData
  22590. * @returns a serialized object
  22591. */
  22592. serialize(): any;
  22593. /**
  22594. * Extracts the vertexData from a mesh
  22595. * @param mesh the mesh from which to extract the VertexData
  22596. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22597. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22598. * @returns the object VertexData associated to the passed mesh
  22599. */
  22600. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22601. /**
  22602. * Extracts the vertexData from the geometry
  22603. * @param geometry the geometry from which to extract the VertexData
  22604. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22605. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22606. * @returns the object VertexData associated to the passed mesh
  22607. */
  22608. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22609. private static _ExtractFrom;
  22610. /**
  22611. * Creates the VertexData for a Ribbon
  22612. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22613. * * pathArray array of paths, each of which an array of successive Vector3
  22614. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22615. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22616. * * 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
  22617. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22618. * * 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)
  22619. * * 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)
  22620. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22621. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22622. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22623. * @returns the VertexData of the ribbon
  22624. */
  22625. static CreateRibbon(options: {
  22626. pathArray: Vector3[][];
  22627. closeArray?: boolean;
  22628. closePath?: boolean;
  22629. offset?: number;
  22630. sideOrientation?: number;
  22631. frontUVs?: Vector4;
  22632. backUVs?: Vector4;
  22633. invertUV?: boolean;
  22634. uvs?: Vector2[];
  22635. colors?: Color4[];
  22636. }): VertexData;
  22637. /**
  22638. * Creates the VertexData for a box
  22639. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22640. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22641. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22642. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22643. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22644. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22645. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22646. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22647. * * 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)
  22648. * * 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)
  22649. * @returns the VertexData of the box
  22650. */
  22651. static CreateBox(options: {
  22652. size?: number;
  22653. width?: number;
  22654. height?: number;
  22655. depth?: number;
  22656. faceUV?: Vector4[];
  22657. faceColors?: Color4[];
  22658. sideOrientation?: number;
  22659. frontUVs?: Vector4;
  22660. backUVs?: Vector4;
  22661. }): VertexData;
  22662. /**
  22663. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22664. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22665. * * segments sets the number of horizontal strips optional, default 32
  22666. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22667. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22668. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22669. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22670. * * 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
  22671. * * 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
  22672. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22673. * * 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)
  22674. * * 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)
  22675. * @returns the VertexData of the ellipsoid
  22676. */
  22677. static CreateSphere(options: {
  22678. segments?: number;
  22679. diameter?: number;
  22680. diameterX?: number;
  22681. diameterY?: number;
  22682. diameterZ?: number;
  22683. arc?: number;
  22684. slice?: number;
  22685. sideOrientation?: number;
  22686. frontUVs?: Vector4;
  22687. backUVs?: Vector4;
  22688. }): VertexData;
  22689. /**
  22690. * Creates the VertexData for a cylinder, cone or prism
  22691. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22692. * * height sets the height (y direction) of the cylinder, optional, default 2
  22693. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22694. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22695. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22696. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22697. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22698. * * 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
  22699. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22700. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22701. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22702. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22703. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22704. * * 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)
  22705. * * 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)
  22706. * @returns the VertexData of the cylinder, cone or prism
  22707. */
  22708. static CreateCylinder(options: {
  22709. height?: number;
  22710. diameterTop?: number;
  22711. diameterBottom?: number;
  22712. diameter?: number;
  22713. tessellation?: number;
  22714. subdivisions?: number;
  22715. arc?: number;
  22716. faceColors?: Color4[];
  22717. faceUV?: Vector4[];
  22718. hasRings?: boolean;
  22719. enclose?: boolean;
  22720. sideOrientation?: number;
  22721. frontUVs?: Vector4;
  22722. backUVs?: Vector4;
  22723. }): VertexData;
  22724. /**
  22725. * Creates the VertexData for a torus
  22726. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22727. * * diameter the diameter of the torus, optional default 1
  22728. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22729. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22730. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22731. * * 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)
  22732. * * 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)
  22733. * @returns the VertexData of the torus
  22734. */
  22735. static CreateTorus(options: {
  22736. diameter?: number;
  22737. thickness?: number;
  22738. tessellation?: number;
  22739. sideOrientation?: number;
  22740. frontUVs?: Vector4;
  22741. backUVs?: Vector4;
  22742. }): VertexData;
  22743. /**
  22744. * Creates the VertexData of the LineSystem
  22745. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22746. * - lines an array of lines, each line being an array of successive Vector3
  22747. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22748. * @returns the VertexData of the LineSystem
  22749. */
  22750. static CreateLineSystem(options: {
  22751. lines: Vector3[][];
  22752. colors?: Nullable<Color4[][]>;
  22753. }): VertexData;
  22754. /**
  22755. * Create the VertexData for a DashedLines
  22756. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22757. * - points an array successive Vector3
  22758. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22759. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22760. * - dashNb the intended total number of dashes, optional, default 200
  22761. * @returns the VertexData for the DashedLines
  22762. */
  22763. static CreateDashedLines(options: {
  22764. points: Vector3[];
  22765. dashSize?: number;
  22766. gapSize?: number;
  22767. dashNb?: number;
  22768. }): VertexData;
  22769. /**
  22770. * Creates the VertexData for a Ground
  22771. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22772. * - width the width (x direction) of the ground, optional, default 1
  22773. * - height the height (z direction) of the ground, optional, default 1
  22774. * - subdivisions the number of subdivisions per side, optional, default 1
  22775. * @returns the VertexData of the Ground
  22776. */
  22777. static CreateGround(options: {
  22778. width?: number;
  22779. height?: number;
  22780. subdivisions?: number;
  22781. subdivisionsX?: number;
  22782. subdivisionsY?: number;
  22783. }): VertexData;
  22784. /**
  22785. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22786. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22787. * * xmin the ground minimum X coordinate, optional, default -1
  22788. * * zmin the ground minimum Z coordinate, optional, default -1
  22789. * * xmax the ground maximum X coordinate, optional, default 1
  22790. * * zmax the ground maximum Z coordinate, optional, default 1
  22791. * * 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}
  22792. * * 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}
  22793. * @returns the VertexData of the TiledGround
  22794. */
  22795. static CreateTiledGround(options: {
  22796. xmin: number;
  22797. zmin: number;
  22798. xmax: number;
  22799. zmax: number;
  22800. subdivisions?: {
  22801. w: number;
  22802. h: number;
  22803. };
  22804. precision?: {
  22805. w: number;
  22806. h: number;
  22807. };
  22808. }): VertexData;
  22809. /**
  22810. * Creates the VertexData of the Ground designed from a heightmap
  22811. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22812. * * width the width (x direction) of the ground
  22813. * * height the height (z direction) of the ground
  22814. * * subdivisions the number of subdivisions per side
  22815. * * minHeight the minimum altitude on the ground, optional, default 0
  22816. * * maxHeight the maximum altitude on the ground, optional default 1
  22817. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22818. * * buffer the array holding the image color data
  22819. * * bufferWidth the width of image
  22820. * * bufferHeight the height of image
  22821. * @returns the VertexData of the Ground designed from a heightmap
  22822. */
  22823. static CreateGroundFromHeightMap(options: {
  22824. width: number;
  22825. height: number;
  22826. subdivisions: number;
  22827. minHeight: number;
  22828. maxHeight: number;
  22829. colorFilter: Color3;
  22830. buffer: Uint8Array;
  22831. bufferWidth: number;
  22832. bufferHeight: number;
  22833. }): VertexData;
  22834. /**
  22835. * Creates the VertexData for a Plane
  22836. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22837. * * size sets the width and height of the plane to the value of size, optional default 1
  22838. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22839. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22840. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22841. * * 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)
  22842. * * 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)
  22843. * @returns the VertexData of the box
  22844. */
  22845. static CreatePlane(options: {
  22846. size?: number;
  22847. width?: number;
  22848. height?: number;
  22849. sideOrientation?: number;
  22850. frontUVs?: Vector4;
  22851. backUVs?: Vector4;
  22852. }): VertexData;
  22853. /**
  22854. * Creates the VertexData of the Disc or regular Polygon
  22855. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22856. * * radius the radius of the disc, optional default 0.5
  22857. * * tessellation the number of polygon sides, optional, default 64
  22858. * * 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
  22859. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22860. * * 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)
  22861. * * 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)
  22862. * @returns the VertexData of the box
  22863. */
  22864. static CreateDisc(options: {
  22865. radius?: number;
  22866. tessellation?: number;
  22867. arc?: number;
  22868. sideOrientation?: number;
  22869. frontUVs?: Vector4;
  22870. backUVs?: Vector4;
  22871. }): VertexData;
  22872. /**
  22873. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22874. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22875. * @param polygon a mesh built from polygonTriangulation.build()
  22876. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22877. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22878. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22879. * @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)
  22880. * @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)
  22881. * @returns the VertexData of the Polygon
  22882. */
  22883. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22884. /**
  22885. * Creates the VertexData of the IcoSphere
  22886. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22887. * * radius the radius of the IcoSphere, optional default 1
  22888. * * radiusX allows stretching in the x direction, optional, default radius
  22889. * * radiusY allows stretching in the y direction, optional, default radius
  22890. * * radiusZ allows stretching in the z direction, optional, default radius
  22891. * * flat when true creates a flat shaded mesh, optional, default true
  22892. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22893. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22894. * * 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)
  22895. * * 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)
  22896. * @returns the VertexData of the IcoSphere
  22897. */
  22898. static CreateIcoSphere(options: {
  22899. radius?: number;
  22900. radiusX?: number;
  22901. radiusY?: number;
  22902. radiusZ?: number;
  22903. flat?: boolean;
  22904. subdivisions?: number;
  22905. sideOrientation?: number;
  22906. frontUVs?: Vector4;
  22907. backUVs?: Vector4;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData for a Polyhedron
  22911. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22912. * * type provided types are:
  22913. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22914. * * 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)
  22915. * * size the size of the IcoSphere, optional default 1
  22916. * * sizeX allows stretching in the x direction, optional, default size
  22917. * * sizeY allows stretching in the y direction, optional, default size
  22918. * * sizeZ allows stretching in the z direction, optional, default size
  22919. * * 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
  22920. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22921. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22922. * * flat when true creates a flat shaded mesh, optional, default true
  22923. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22924. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22925. * * 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)
  22926. * * 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)
  22927. * @returns the VertexData of the Polyhedron
  22928. */
  22929. static CreatePolyhedron(options: {
  22930. type?: number;
  22931. size?: number;
  22932. sizeX?: number;
  22933. sizeY?: number;
  22934. sizeZ?: number;
  22935. custom?: any;
  22936. faceUV?: Vector4[];
  22937. faceColors?: Color4[];
  22938. flat?: boolean;
  22939. sideOrientation?: number;
  22940. frontUVs?: Vector4;
  22941. backUVs?: Vector4;
  22942. }): VertexData;
  22943. /**
  22944. * Creates the VertexData for a TorusKnot
  22945. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22946. * * radius the radius of the torus knot, optional, default 2
  22947. * * tube the thickness of the tube, optional, default 0.5
  22948. * * radialSegments the number of sides on each tube segments, optional, default 32
  22949. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22950. * * p the number of windings around the z axis, optional, default 2
  22951. * * q the number of windings around the x axis, optional, default 3
  22952. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22953. * * 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)
  22954. * * 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)
  22955. * @returns the VertexData of the Torus Knot
  22956. */
  22957. static CreateTorusKnot(options: {
  22958. radius?: number;
  22959. tube?: number;
  22960. radialSegments?: number;
  22961. tubularSegments?: number;
  22962. p?: number;
  22963. q?: number;
  22964. sideOrientation?: number;
  22965. frontUVs?: Vector4;
  22966. backUVs?: Vector4;
  22967. }): VertexData;
  22968. /**
  22969. * Compute normals for given positions and indices
  22970. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22971. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22972. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22973. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22974. * * facetNormals : optional array of facet normals (vector3)
  22975. * * facetPositions : optional array of facet positions (vector3)
  22976. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22977. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22978. * * bInfo : optional bounding info, required for facetPartitioning computation
  22979. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22980. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22981. * * useRightHandedSystem: optional boolean to for right handed system computation
  22982. * * depthSort : optional boolean to enable the facet depth sort computation
  22983. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22984. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22985. */
  22986. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22987. facetNormals?: any;
  22988. facetPositions?: any;
  22989. facetPartitioning?: any;
  22990. ratio?: number;
  22991. bInfo?: any;
  22992. bbSize?: Vector3;
  22993. subDiv?: any;
  22994. useRightHandedSystem?: boolean;
  22995. depthSort?: boolean;
  22996. distanceTo?: Vector3;
  22997. depthSortedFacets?: any;
  22998. }): void;
  22999. private static _ComputeSides;
  23000. /**
  23001. * Applies VertexData created from the imported parameters to the geometry
  23002. * @param parsedVertexData the parsed data from an imported file
  23003. * @param geometry the geometry to apply the VertexData to
  23004. */
  23005. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23006. }
  23007. }
  23008. declare module BABYLON {
  23009. /**
  23010. * Class containing static functions to help procedurally build meshes
  23011. */
  23012. class MeshBuilder {
  23013. private static updateSideOrientation;
  23014. /**
  23015. * Creates a box mesh
  23016. * * The parameter `size` sets the size (float) of each box side (default 1)
  23017. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  23018. * * 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)
  23019. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23021. * * 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
  23022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23023. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  23024. * @param name defines the name of the mesh
  23025. * @param options defines the options used to create the mesh
  23026. * @param scene defines the hosting scene
  23027. * @returns the box mesh
  23028. */
  23029. static CreateBox(name: string, options: {
  23030. size?: number;
  23031. width?: number;
  23032. height?: number;
  23033. depth?: number;
  23034. faceUV?: Vector4[];
  23035. faceColors?: Color4[];
  23036. sideOrientation?: number;
  23037. frontUVs?: Vector4;
  23038. backUVs?: Vector4;
  23039. updatable?: boolean;
  23040. }, scene?: Nullable<Scene>): Mesh;
  23041. /**
  23042. * Creates a sphere mesh
  23043. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23044. * * 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`)
  23045. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23046. * * 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
  23047. * * 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)
  23048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23049. * * 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
  23050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23051. * @param name defines the name of the mesh
  23052. * @param options defines the options used to create the mesh
  23053. * @param scene defines the hosting scene
  23054. * @returns the sphere mesh
  23055. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  23056. */
  23057. static CreateSphere(name: string, options: {
  23058. segments?: number;
  23059. diameter?: number;
  23060. diameterX?: number;
  23061. diameterY?: number;
  23062. diameterZ?: number;
  23063. arc?: number;
  23064. slice?: number;
  23065. sideOrientation?: number;
  23066. frontUVs?: Vector4;
  23067. backUVs?: Vector4;
  23068. updatable?: boolean;
  23069. }, scene: any): Mesh;
  23070. /**
  23071. * Creates a plane polygonal mesh. By default, this is a disc
  23072. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23073. * * 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
  23074. * * 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
  23075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23076. * * 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
  23077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23078. * @param name defines the name of the mesh
  23079. * @param options defines the options used to create the mesh
  23080. * @param scene defines the hosting scene
  23081. * @returns the plane polygonal mesh
  23082. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23083. */
  23084. static CreateDisc(name: string, options: {
  23085. radius?: number;
  23086. tessellation?: number;
  23087. arc?: number;
  23088. updatable?: boolean;
  23089. sideOrientation?: number;
  23090. frontUVs?: Vector4;
  23091. backUVs?: Vector4;
  23092. }, scene?: Nullable<Scene>): Mesh;
  23093. /**
  23094. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23095. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23096. * * 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`)
  23097. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23098. * * 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
  23099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23100. * * 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
  23101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23102. * @param name defines the name of the mesh
  23103. * @param options defines the options used to create the mesh
  23104. * @param scene defines the hosting scene
  23105. * @returns the icosahedron mesh
  23106. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23107. */
  23108. static CreateIcoSphere(name: string, options: {
  23109. radius?: number;
  23110. radiusX?: number;
  23111. radiusY?: number;
  23112. radiusZ?: number;
  23113. flat?: boolean;
  23114. subdivisions?: number;
  23115. sideOrientation?: number;
  23116. frontUVs?: Vector4;
  23117. backUVs?: Vector4;
  23118. updatable?: boolean;
  23119. }, scene: Scene): Mesh;
  23120. /**
  23121. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23122. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23123. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23124. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23125. * * 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
  23126. * * 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
  23127. * * 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
  23128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23129. * * 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
  23130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23131. * * 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
  23132. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23133. * * 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
  23134. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23136. * @param name defines the name of the mesh
  23137. * @param options defines the options used to create the mesh
  23138. * @param scene defines the hosting scene
  23139. * @returns the ribbon mesh
  23140. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23141. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23142. */
  23143. static CreateRibbon(name: string, options: {
  23144. pathArray: Vector3[][];
  23145. closeArray?: boolean;
  23146. closePath?: boolean;
  23147. offset?: number;
  23148. updatable?: boolean;
  23149. sideOrientation?: number;
  23150. frontUVs?: Vector4;
  23151. backUVs?: Vector4;
  23152. instance?: Mesh;
  23153. invertUV?: boolean;
  23154. uvs?: Vector2[];
  23155. colors?: Color4[];
  23156. }, scene?: Nullable<Scene>): Mesh;
  23157. /**
  23158. * Creates a cylinder or a cone mesh
  23159. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23160. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23161. * * 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.
  23162. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23163. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23164. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23165. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23166. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23167. * * 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).
  23168. * * 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
  23169. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23170. * * 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
  23171. * * 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.
  23172. * * If `enclose` is false, a ring surface is one element.
  23173. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23174. * * 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
  23175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23176. * * 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
  23177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23178. * @param name defines the name of the mesh
  23179. * @param options defines the options used to create the mesh
  23180. * @param scene defines the hosting scene
  23181. * @returns the cylinder mesh
  23182. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23183. */
  23184. static CreateCylinder(name: string, options: {
  23185. height?: number;
  23186. diameterTop?: number;
  23187. diameterBottom?: number;
  23188. diameter?: number;
  23189. tessellation?: number;
  23190. subdivisions?: number;
  23191. arc?: number;
  23192. faceColors?: Color4[];
  23193. faceUV?: Vector4[];
  23194. updatable?: boolean;
  23195. hasRings?: boolean;
  23196. enclose?: boolean;
  23197. sideOrientation?: number;
  23198. frontUVs?: Vector4;
  23199. backUVs?: Vector4;
  23200. }, scene: any): Mesh;
  23201. /**
  23202. * Creates a torus mesh
  23203. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23204. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23205. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23207. * * 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
  23208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23209. * @param name defines the name of the mesh
  23210. * @param options defines the options used to create the mesh
  23211. * @param scene defines the hosting scene
  23212. * @returns the torus mesh
  23213. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23214. */
  23215. static CreateTorus(name: string, options: {
  23216. diameter?: number;
  23217. thickness?: number;
  23218. tessellation?: number;
  23219. updatable?: boolean;
  23220. sideOrientation?: number;
  23221. frontUVs?: Vector4;
  23222. backUVs?: Vector4;
  23223. }, scene: any): Mesh;
  23224. /**
  23225. * Creates a torus knot mesh
  23226. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23227. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23228. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23229. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23231. * * 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
  23232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23233. * @param name defines the name of the mesh
  23234. * @param options defines the options used to create the mesh
  23235. * @param scene defines the hosting scene
  23236. * @returns the torus knot mesh
  23237. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23238. */
  23239. static CreateTorusKnot(name: string, options: {
  23240. radius?: number;
  23241. tube?: number;
  23242. radialSegments?: number;
  23243. tubularSegments?: number;
  23244. p?: number;
  23245. q?: number;
  23246. updatable?: boolean;
  23247. sideOrientation?: number;
  23248. frontUVs?: Vector4;
  23249. backUVs?: Vector4;
  23250. }, scene: any): Mesh;
  23251. /**
  23252. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23253. * * 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
  23254. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23255. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23256. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23257. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23259. * * 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
  23260. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23262. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23263. * @param name defines the name of the new line system
  23264. * @param options defines the options used to create the line system
  23265. * @param scene defines the hosting scene
  23266. * @returns a new line system mesh
  23267. */
  23268. static CreateLineSystem(name: string, options: {
  23269. lines: Vector3[][];
  23270. updatable?: boolean;
  23271. instance?: Nullable<LinesMesh>;
  23272. colors?: Nullable<Color4[][]>;
  23273. useVertexAlpha?: boolean;
  23274. }, scene: Nullable<Scene>): LinesMesh;
  23275. /**
  23276. * Creates a line mesh
  23277. * 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
  23278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23279. * * The parameter `points` is an array successive Vector3
  23280. * * 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
  23281. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23283. * * When updating an instance, remember that only point positions can change, not the number of points
  23284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23286. * @param name defines the name of the new line system
  23287. * @param options defines the options used to create the line system
  23288. * @param scene defines the hosting scene
  23289. * @returns a new line mesh
  23290. */
  23291. static CreateLines(name: string, options: {
  23292. points: Vector3[];
  23293. updatable?: boolean;
  23294. instance?: Nullable<LinesMesh>;
  23295. colors?: Color4[];
  23296. useVertexAlpha?: boolean;
  23297. }, scene?: Nullable<Scene>): LinesMesh;
  23298. /**
  23299. * Creates a dashed line mesh
  23300. * * 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
  23301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23302. * * The parameter `points` is an array successive Vector3
  23303. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23304. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23305. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23306. * * 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
  23307. * * When updating an instance, remember that only point positions can change, not the number of points
  23308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23309. * @param name defines the name of the mesh
  23310. * @param options defines the options used to create the mesh
  23311. * @param scene defines the hosting scene
  23312. * @returns the dashed line mesh
  23313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23314. */
  23315. static CreateDashedLines(name: string, options: {
  23316. points: Vector3[];
  23317. dashSize?: number;
  23318. gapSize?: number;
  23319. dashNb?: number;
  23320. updatable?: boolean;
  23321. instance?: LinesMesh;
  23322. }, scene?: Nullable<Scene>): LinesMesh;
  23323. /**
  23324. * 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.
  23325. * * 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.
  23326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23327. * * 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.
  23328. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23329. * * 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
  23330. * * 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
  23331. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23333. * * 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
  23334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23336. * @param name defines the name of the mesh
  23337. * @param options defines the options used to create the mesh
  23338. * @param scene defines the hosting scene
  23339. * @returns the extruded shape mesh
  23340. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23341. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23342. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23343. */
  23344. static ExtrudeShape(name: string, options: {
  23345. shape: Vector3[];
  23346. path: Vector3[];
  23347. scale?: number;
  23348. rotation?: number;
  23349. cap?: number;
  23350. updatable?: boolean;
  23351. sideOrientation?: number;
  23352. frontUVs?: Vector4;
  23353. backUVs?: Vector4;
  23354. instance?: Mesh;
  23355. invertUV?: boolean;
  23356. }, scene?: Nullable<Scene>): Mesh;
  23357. /**
  23358. * Creates an custom extruded shape mesh.
  23359. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23360. * * 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.
  23361. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23362. * * 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
  23363. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23364. * * 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
  23365. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23366. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23367. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23368. * * 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
  23369. * * 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
  23370. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23372. * * 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
  23373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23375. * @param name defines the name of the mesh
  23376. * @param options defines the options used to create the mesh
  23377. * @param scene defines the hosting scene
  23378. * @returns the custom extruded shape mesh
  23379. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23380. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23382. */
  23383. static ExtrudeShapeCustom(name: string, options: {
  23384. shape: Vector3[];
  23385. path: Vector3[];
  23386. scaleFunction?: any;
  23387. rotationFunction?: any;
  23388. ribbonCloseArray?: boolean;
  23389. ribbonClosePath?: boolean;
  23390. cap?: number;
  23391. updatable?: boolean;
  23392. sideOrientation?: number;
  23393. frontUVs?: Vector4;
  23394. backUVs?: Vector4;
  23395. instance?: Mesh;
  23396. invertUV?: boolean;
  23397. }, scene: Scene): Mesh;
  23398. /**
  23399. * Creates lathe mesh.
  23400. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23401. * * 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
  23402. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23403. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23404. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23405. * * 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
  23406. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23407. * * 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
  23408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23409. * * 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
  23410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23412. * @param name defines the name of the mesh
  23413. * @param options defines the options used to create the mesh
  23414. * @param scene defines the hosting scene
  23415. * @returns the lathe mesh
  23416. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23417. */
  23418. static CreateLathe(name: string, options: {
  23419. shape: Vector3[];
  23420. radius?: number;
  23421. tessellation?: number;
  23422. clip?: number;
  23423. arc?: number;
  23424. closed?: boolean;
  23425. updatable?: boolean;
  23426. sideOrientation?: number;
  23427. frontUVs?: Vector4;
  23428. backUVs?: Vector4;
  23429. cap?: number;
  23430. invertUV?: boolean;
  23431. }, scene: Scene): Mesh;
  23432. /**
  23433. * Creates a plane mesh
  23434. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23435. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23436. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23438. * * 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
  23439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23440. * @param name defines the name of the mesh
  23441. * @param options defines the options used to create the mesh
  23442. * @param scene defines the hosting scene
  23443. * @returns the plane mesh
  23444. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23445. */
  23446. static CreatePlane(name: string, options: {
  23447. size?: number;
  23448. width?: number;
  23449. height?: number;
  23450. sideOrientation?: number;
  23451. frontUVs?: Vector4;
  23452. backUVs?: Vector4;
  23453. updatable?: boolean;
  23454. sourcePlane?: Plane;
  23455. }, scene: Scene): Mesh;
  23456. /**
  23457. * Creates a ground mesh
  23458. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23459. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23461. * @param name defines the name of the mesh
  23462. * @param options defines the options used to create the mesh
  23463. * @param scene defines the hosting scene
  23464. * @returns the ground mesh
  23465. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23466. */
  23467. static CreateGround(name: string, options: {
  23468. width?: number;
  23469. height?: number;
  23470. subdivisions?: number;
  23471. subdivisionsX?: number;
  23472. subdivisionsY?: number;
  23473. updatable?: boolean;
  23474. }, scene: any): Mesh;
  23475. /**
  23476. * Creates a tiled ground mesh
  23477. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23478. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23479. * * 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
  23480. * * 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
  23481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23482. * @param name defines the name of the mesh
  23483. * @param options defines the options used to create the mesh
  23484. * @param scene defines the hosting scene
  23485. * @returns the tiled ground mesh
  23486. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23487. */
  23488. static CreateTiledGround(name: string, options: {
  23489. xmin: number;
  23490. zmin: number;
  23491. xmax: number;
  23492. zmax: number;
  23493. subdivisions?: {
  23494. w: number;
  23495. h: number;
  23496. };
  23497. precision?: {
  23498. w: number;
  23499. h: number;
  23500. };
  23501. updatable?: boolean;
  23502. }, scene: Scene): Mesh;
  23503. /**
  23504. * Creates a ground mesh from a height map
  23505. * * The parameter `url` sets the URL of the height map image resource.
  23506. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23507. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23508. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23509. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23510. * * 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.
  23511. * * 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).
  23512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23513. * @param name defines the name of the mesh
  23514. * @param url defines the url to the height map
  23515. * @param options defines the options used to create the mesh
  23516. * @param scene defines the hosting scene
  23517. * @returns the ground mesh
  23518. * @see http://doc.babylonjs.com/babylon101/height_map
  23519. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23520. */
  23521. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23522. width?: number;
  23523. height?: number;
  23524. subdivisions?: number;
  23525. minHeight?: number;
  23526. maxHeight?: number;
  23527. colorFilter?: Color3;
  23528. updatable?: boolean;
  23529. onReady?: (mesh: GroundMesh) => void;
  23530. }, scene: Scene): GroundMesh;
  23531. /**
  23532. * Creates a polygon mesh
  23533. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23534. * * 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
  23535. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23537. * * 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)
  23538. * * Remember you can only change the shape positions, not their number when updating a polygon
  23539. * @param name defines the name of the mesh
  23540. * @param options defines the options used to create the mesh
  23541. * @param scene defines the hosting scene
  23542. * @returns the polygon mesh
  23543. */
  23544. static CreatePolygon(name: string, options: {
  23545. shape: Vector3[];
  23546. holes?: Vector3[][];
  23547. depth?: number;
  23548. faceUV?: Vector4[];
  23549. faceColors?: Color4[];
  23550. updatable?: boolean;
  23551. sideOrientation?: number;
  23552. frontUVs?: Vector4;
  23553. backUVs?: Vector4;
  23554. }, scene: Scene): Mesh;
  23555. /**
  23556. * Creates an extruded polygon mesh, with depth in the Y direction.
  23557. * * 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)
  23558. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23559. * @param name defines the name of the mesh
  23560. * @param options defines the options used to create the mesh
  23561. * @param scene defines the hosting scene
  23562. * @returns the polygon mesh
  23563. */
  23564. static ExtrudePolygon(name: string, options: {
  23565. shape: Vector3[];
  23566. holes?: Vector3[][];
  23567. depth?: number;
  23568. faceUV?: Vector4[];
  23569. faceColors?: Color4[];
  23570. updatable?: boolean;
  23571. sideOrientation?: number;
  23572. frontUVs?: Vector4;
  23573. backUVs?: Vector4;
  23574. }, scene: Scene): Mesh;
  23575. /**
  23576. * Creates a tube mesh.
  23577. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23578. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23579. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23580. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23581. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23582. * * 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)
  23583. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23584. * * 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
  23585. * * 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
  23586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23587. * * 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
  23588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23590. * @param name defines the name of the mesh
  23591. * @param options defines the options used to create the mesh
  23592. * @param scene defines the hosting scene
  23593. * @returns the tube mesh
  23594. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23595. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23596. */
  23597. static CreateTube(name: string, options: {
  23598. path: Vector3[];
  23599. radius?: number;
  23600. tessellation?: number;
  23601. radiusFunction?: {
  23602. (i: number, distance: number): number;
  23603. };
  23604. cap?: number;
  23605. arc?: number;
  23606. updatable?: boolean;
  23607. sideOrientation?: number;
  23608. frontUVs?: Vector4;
  23609. backUVs?: Vector4;
  23610. instance?: Mesh;
  23611. invertUV?: boolean;
  23612. }, scene: Scene): Mesh;
  23613. /**
  23614. * Creates a polyhedron mesh
  23615. * * 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
  23616. * * The parameter `size` (positive float, default 1) sets the polygon size
  23617. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23618. * * 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`
  23619. * * 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
  23620. * * 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)`)
  23621. * * 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
  23622. * * 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
  23623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23624. * * 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
  23625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23626. * @param name defines the name of the mesh
  23627. * @param options defines the options used to create the mesh
  23628. * @param scene defines the hosting scene
  23629. * @returns the polyhedron mesh
  23630. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23631. */
  23632. static CreatePolyhedron(name: string, options: {
  23633. type?: number;
  23634. size?: number;
  23635. sizeX?: number;
  23636. sizeY?: number;
  23637. sizeZ?: number;
  23638. custom?: any;
  23639. faceUV?: Vector4[];
  23640. faceColors?: Color4[];
  23641. flat?: boolean;
  23642. updatable?: boolean;
  23643. sideOrientation?: number;
  23644. frontUVs?: Vector4;
  23645. backUVs?: Vector4;
  23646. }, scene: Scene): Mesh;
  23647. /**
  23648. * Creates a decal mesh.
  23649. * 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
  23650. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23651. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23652. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23653. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23654. * @param name defines the name of the mesh
  23655. * @param sourceMesh defines the mesh where the decal must be applied
  23656. * @param options defines the options used to create the mesh
  23657. * @param scene defines the hosting scene
  23658. * @returns the decal mesh
  23659. * @see http://doc.babylonjs.com/how_to/decals
  23660. */
  23661. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23662. position?: Vector3;
  23663. normal?: Vector3;
  23664. size?: Vector3;
  23665. angle?: number;
  23666. }): Mesh;
  23667. private static _ExtrudeShapeGeneric;
  23668. }
  23669. }
  23670. declare module BABYLON {
  23671. class MeshLODLevel {
  23672. distance: number;
  23673. mesh: Nullable<Mesh>;
  23674. constructor(distance: number, mesh: Nullable<Mesh>);
  23675. }
  23676. }
  23677. declare module BABYLON {
  23678. /**
  23679. * A simplifier interface for future simplification implementations.
  23680. */
  23681. interface ISimplifier {
  23682. /**
  23683. * Simplification of a given mesh according to the given settings.
  23684. * Since this requires computation, it is assumed that the function runs async.
  23685. * @param settings The settings of the simplification, including quality and distance
  23686. * @param successCallback A callback that will be called after the mesh was simplified.
  23687. * @param errorCallback in case of an error, this callback will be called. optional.
  23688. */
  23689. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23690. }
  23691. /**
  23692. * Expected simplification settings.
  23693. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23694. */
  23695. interface ISimplificationSettings {
  23696. quality: number;
  23697. distance: number;
  23698. optimizeMesh?: boolean;
  23699. }
  23700. class SimplificationSettings implements ISimplificationSettings {
  23701. quality: number;
  23702. distance: number;
  23703. optimizeMesh?: boolean | undefined;
  23704. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23705. }
  23706. interface ISimplificationTask {
  23707. settings: Array<ISimplificationSettings>;
  23708. simplificationType: SimplificationType;
  23709. mesh: Mesh;
  23710. successCallback?: () => void;
  23711. parallelProcessing: boolean;
  23712. }
  23713. class SimplificationQueue {
  23714. private _simplificationArray;
  23715. running: boolean;
  23716. constructor();
  23717. addTask(task: ISimplificationTask): void;
  23718. executeNext(): void;
  23719. runSimplification(task: ISimplificationTask): void;
  23720. private getSimplifier;
  23721. }
  23722. /**
  23723. * The implemented types of simplification
  23724. * At the moment only Quadratic Error Decimation is implemented
  23725. */
  23726. enum SimplificationType {
  23727. /** Quadratic error decimation */
  23728. QUADRATIC = 0
  23729. }
  23730. class DecimationTriangle {
  23731. vertices: Array<DecimationVertex>;
  23732. normal: Vector3;
  23733. error: Array<number>;
  23734. deleted: boolean;
  23735. isDirty: boolean;
  23736. borderFactor: number;
  23737. deletePending: boolean;
  23738. originalOffset: number;
  23739. constructor(vertices: Array<DecimationVertex>);
  23740. }
  23741. class DecimationVertex {
  23742. position: Vector3;
  23743. id: number;
  23744. q: QuadraticMatrix;
  23745. isBorder: boolean;
  23746. triangleStart: number;
  23747. triangleCount: number;
  23748. originalOffsets: Array<number>;
  23749. constructor(position: Vector3, id: number);
  23750. updatePosition(newPosition: Vector3): void;
  23751. }
  23752. class QuadraticMatrix {
  23753. data: Array<number>;
  23754. constructor(data?: Array<number>);
  23755. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23756. addInPlace(matrix: QuadraticMatrix): void;
  23757. addArrayInPlace(data: Array<number>): void;
  23758. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23759. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23760. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23761. }
  23762. class Reference {
  23763. vertexId: number;
  23764. triangleId: number;
  23765. constructor(vertexId: number, triangleId: number);
  23766. }
  23767. /**
  23768. * An implementation of the Quadratic Error simplification algorithm.
  23769. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23770. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23771. * @author RaananW
  23772. */
  23773. class QuadraticErrorSimplification implements ISimplifier {
  23774. private _mesh;
  23775. private triangles;
  23776. private vertices;
  23777. private references;
  23778. private _reconstructedMesh;
  23779. syncIterations: number;
  23780. aggressiveness: number;
  23781. decimationIterations: number;
  23782. boundingBoxEpsilon: number;
  23783. constructor(_mesh: Mesh);
  23784. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23785. private runDecimation;
  23786. private initWithMesh;
  23787. private init;
  23788. private reconstructMesh;
  23789. private initDecimatedMesh;
  23790. private isFlipped;
  23791. private updateTriangles;
  23792. private identifyBorder;
  23793. private updateMesh;
  23794. private vertexError;
  23795. private calculateError;
  23796. }
  23797. }
  23798. declare module BABYLON {
  23799. interface Scene {
  23800. /** @hidden (Backing field) */
  23801. _simplificationQueue: SimplificationQueue;
  23802. /**
  23803. * Gets or sets the simplification queue attached to the scene
  23804. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23805. */
  23806. simplificationQueue: SimplificationQueue;
  23807. }
  23808. interface Mesh {
  23809. /**
  23810. * Simplify the mesh according to the given array of settings.
  23811. * Function will return immediately and will simplify async. It returns the Mesh.
  23812. * @param settings a collection of simplification settings.
  23813. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23814. * @param type the type of simplification to run.
  23815. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23816. */
  23817. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23818. }
  23819. /**
  23820. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23821. * created in a scene
  23822. */
  23823. class SimplicationQueueSceneComponent implements ISceneComponent {
  23824. /**
  23825. * The component name helpfull to identify the component in the list of scene components.
  23826. */
  23827. readonly name: string;
  23828. /**
  23829. * The scene the component belongs to.
  23830. */
  23831. scene: Scene;
  23832. /**
  23833. * Creates a new instance of the component for the given scene
  23834. * @param scene Defines the scene to register the component in
  23835. */
  23836. constructor(scene: Scene);
  23837. /**
  23838. * Registers the component in a given scene
  23839. */
  23840. register(): void;
  23841. /**
  23842. * Rebuilds the elements related to this component in case of
  23843. * context lost for instance.
  23844. */
  23845. rebuild(): void;
  23846. /**
  23847. * Disposes the component and the associated ressources
  23848. */
  23849. dispose(): void;
  23850. private _beforeCameraUpdate;
  23851. }
  23852. }
  23853. declare module BABYLON {
  23854. class Polygon {
  23855. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23856. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23857. static Parse(input: string): Vector2[];
  23858. static StartingAt(x: number, y: number): Path2;
  23859. }
  23860. class PolygonMeshBuilder {
  23861. private _points;
  23862. private _outlinepoints;
  23863. private _holes;
  23864. private _name;
  23865. private _scene;
  23866. private _epoints;
  23867. private _eholes;
  23868. private _addToepoint;
  23869. constructor(name: string, contours: Path2, scene: Scene);
  23870. constructor(name: string, contours: Vector2[], scene: Scene);
  23871. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23872. build(updatable?: boolean, depth?: number): Mesh;
  23873. private addSide;
  23874. }
  23875. }
  23876. declare module BABYLON {
  23877. class BaseSubMesh {
  23878. /** @hidden */
  23879. _materialDefines: Nullable<MaterialDefines>;
  23880. /** @hidden */
  23881. _materialEffect: Nullable<Effect>;
  23882. readonly effect: Nullable<Effect>;
  23883. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23884. }
  23885. class SubMesh extends BaseSubMesh implements ICullable {
  23886. materialIndex: number;
  23887. verticesStart: number;
  23888. verticesCount: number;
  23889. indexStart: number;
  23890. indexCount: number;
  23891. linesIndexCount: number;
  23892. private _mesh;
  23893. private _renderingMesh;
  23894. private _boundingInfo;
  23895. private _linesIndexBuffer;
  23896. /** @hidden */
  23897. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23898. /** @hidden */
  23899. _trianglePlanes: Plane[];
  23900. /** @hidden */
  23901. _lastColliderTransformMatrix: Matrix;
  23902. /** @hidden */
  23903. _renderId: number;
  23904. /** @hidden */
  23905. _alphaIndex: number;
  23906. /** @hidden */
  23907. _distanceToCamera: number;
  23908. /** @hidden */
  23909. _id: number;
  23910. private _currentMaterial;
  23911. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23912. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23913. readonly IsGlobal: boolean;
  23914. /**
  23915. * Returns the submesh BoudingInfo object.
  23916. */
  23917. getBoundingInfo(): BoundingInfo;
  23918. /**
  23919. * Sets the submesh BoundingInfo.
  23920. * Return the SubMesh.
  23921. */
  23922. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23923. /**
  23924. * Returns the mesh of the current submesh.
  23925. */
  23926. getMesh(): AbstractMesh;
  23927. /**
  23928. * Returns the rendering mesh of the submesh.
  23929. */
  23930. getRenderingMesh(): Mesh;
  23931. /**
  23932. * Returns the submesh material.
  23933. */
  23934. getMaterial(): Nullable<Material>;
  23935. /**
  23936. * Sets a new updated BoundingInfo object to the submesh.
  23937. * Returns the SubMesh.
  23938. */
  23939. refreshBoundingInfo(): SubMesh;
  23940. /** @hidden */
  23941. _checkCollision(collider: Collider): boolean;
  23942. /**
  23943. * Updates the submesh BoundingInfo.
  23944. * Returns the Submesh.
  23945. */
  23946. updateBoundingInfo(world: Matrix): SubMesh;
  23947. /**
  23948. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23949. * Boolean returned.
  23950. */
  23951. isInFrustum(frustumPlanes: Plane[]): boolean;
  23952. /**
  23953. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23954. * Boolean returned.
  23955. */
  23956. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23957. /**
  23958. * Renders the submesh.
  23959. * Returns it.
  23960. */
  23961. render(enableAlphaMode: boolean): SubMesh;
  23962. /**
  23963. * Returns a new Index Buffer.
  23964. * Type returned : WebGLBuffer.
  23965. */
  23966. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23967. /**
  23968. * True is the passed Ray intersects the submesh bounding box.
  23969. * Boolean returned.
  23970. */
  23971. canIntersects(ray: Ray): boolean;
  23972. /**
  23973. * Returns an object IntersectionInfo.
  23974. */
  23975. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23976. /** @hidden */
  23977. _rebuild(): void;
  23978. /**
  23979. * Creates a new Submesh from the passed Mesh.
  23980. */
  23981. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23982. /**
  23983. * Disposes the Submesh.
  23984. * Returns nothing.
  23985. */
  23986. dispose(): void;
  23987. /**
  23988. * Creates a new Submesh from the passed parameters :
  23989. * - materialIndex (integer) : the index of the main mesh material.
  23990. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23991. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23992. * - mesh (Mesh) : the main mesh to create the submesh from.
  23993. * - renderingMesh (optional Mesh) : rendering mesh.
  23994. */
  23995. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23996. }
  23997. }
  23998. declare module BABYLON {
  23999. class TransformNode extends Node {
  24000. static BILLBOARDMODE_NONE: number;
  24001. static BILLBOARDMODE_X: number;
  24002. static BILLBOARDMODE_Y: number;
  24003. static BILLBOARDMODE_Z: number;
  24004. static BILLBOARDMODE_ALL: number;
  24005. private _forward;
  24006. private _forwardInverted;
  24007. private _up;
  24008. private _right;
  24009. private _rightInverted;
  24010. private _rotation;
  24011. private _rotationQuaternion;
  24012. protected _scaling: Vector3;
  24013. protected _isDirty: boolean;
  24014. private _transformToBoneReferal;
  24015. /**
  24016. * Set the billboard mode. Default is 0.
  24017. *
  24018. * | Value | Type | Description |
  24019. * | --- | --- | --- |
  24020. * | 0 | BILLBOARDMODE_NONE | |
  24021. * | 1 | BILLBOARDMODE_X | |
  24022. * | 2 | BILLBOARDMODE_Y | |
  24023. * | 4 | BILLBOARDMODE_Z | |
  24024. * | 7 | BILLBOARDMODE_ALL | |
  24025. *
  24026. */
  24027. billboardMode: number;
  24028. scalingDeterminant: number;
  24029. infiniteDistance: boolean;
  24030. /**
  24031. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  24032. * By default the system will update normals to compensate
  24033. */
  24034. ignoreNonUniformScaling: boolean;
  24035. position: Vector3;
  24036. /** @hidden */
  24037. _poseMatrix: Matrix;
  24038. private _localWorld;
  24039. /** @hidden */
  24040. _worldMatrix: Matrix;
  24041. /** @hidden */
  24042. _worldMatrixDeterminant: number;
  24043. private _absolutePosition;
  24044. private _pivotMatrix;
  24045. private _pivotMatrixInverse;
  24046. private _postMultiplyPivotMatrix;
  24047. protected _isWorldMatrixFrozen: boolean;
  24048. /**
  24049. * An event triggered after the world matrix is updated
  24050. */
  24051. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  24052. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  24053. /**
  24054. * Gets a string identifying the name of the class
  24055. * @returns "TransformNode" string
  24056. */
  24057. getClassName(): string;
  24058. /**
  24059. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  24060. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  24061. * Default : (0.0, 0.0, 0.0)
  24062. */
  24063. rotation: Vector3;
  24064. /**
  24065. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24066. * Default : (1.0, 1.0, 1.0)
  24067. */
  24068. /**
  24069. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24070. * Default : (1.0, 1.0, 1.0)
  24071. */
  24072. scaling: Vector3;
  24073. /**
  24074. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  24075. * It's null by default.
  24076. * 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)
  24077. */
  24078. rotationQuaternion: Nullable<Quaternion>;
  24079. /**
  24080. * The forward direction of that transform in world space.
  24081. */
  24082. readonly forward: Vector3;
  24083. /**
  24084. * The up direction of that transform in world space.
  24085. */
  24086. readonly up: Vector3;
  24087. /**
  24088. * The right direction of that transform in world space.
  24089. */
  24090. readonly right: Vector3;
  24091. /**
  24092. * Returns the latest update of the World matrix
  24093. * Returns a Matrix.
  24094. */
  24095. getWorldMatrix(): Matrix;
  24096. /** @hidden */
  24097. _getWorldMatrixDeterminant(): number;
  24098. /**
  24099. * Returns directly the latest state of the mesh World matrix.
  24100. * A Matrix is returned.
  24101. */
  24102. readonly worldMatrixFromCache: Matrix;
  24103. /**
  24104. * Copies the parameter passed Matrix into the mesh Pose matrix.
  24105. * Returns the TransformNode.
  24106. */
  24107. updatePoseMatrix(matrix: Matrix): TransformNode;
  24108. /**
  24109. * Returns the mesh Pose matrix.
  24110. * Returned object : Matrix
  24111. */
  24112. getPoseMatrix(): Matrix;
  24113. /** @hidden */
  24114. _isSynchronized(): boolean;
  24115. /** @hidden */
  24116. _initCache(): void;
  24117. markAsDirty(property: string): TransformNode;
  24118. /**
  24119. * Returns the current mesh absolute position.
  24120. * Returns a Vector3.
  24121. */
  24122. readonly absolutePosition: Vector3;
  24123. /**
  24124. * Sets a new matrix to apply before all other transformation
  24125. * @param matrix defines the transform matrix
  24126. * @returns the current TransformNode
  24127. */
  24128. setPreTransformMatrix(matrix: Matrix): TransformNode;
  24129. /**
  24130. * Sets a new pivot matrix to the current node
  24131. * @param matrix defines the new pivot matrix to use
  24132. * @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
  24133. * @returns the current TransformNode
  24134. */
  24135. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  24136. /**
  24137. * Returns the mesh pivot matrix.
  24138. * Default : Identity.
  24139. * A Matrix is returned.
  24140. */
  24141. getPivotMatrix(): Matrix;
  24142. /**
  24143. * Prevents the World matrix to be computed any longer.
  24144. * Returns the TransformNode.
  24145. */
  24146. freezeWorldMatrix(): TransformNode;
  24147. /**
  24148. * Allows back the World matrix computation.
  24149. * Returns the TransformNode.
  24150. */
  24151. unfreezeWorldMatrix(): this;
  24152. /**
  24153. * True if the World matrix has been frozen.
  24154. * Returns a boolean.
  24155. */
  24156. readonly isWorldMatrixFrozen: boolean;
  24157. /**
  24158. * Retuns the mesh absolute position in the World.
  24159. * Returns a Vector3.
  24160. */
  24161. getAbsolutePosition(): Vector3;
  24162. /**
  24163. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  24164. * Returns the TransformNode.
  24165. */
  24166. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24167. /**
  24168. * Sets the mesh position in its local space.
  24169. * Returns the TransformNode.
  24170. */
  24171. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24172. /**
  24173. * Returns the mesh position in the local space from the current World matrix values.
  24174. * Returns a new Vector3.
  24175. */
  24176. getPositionExpressedInLocalSpace(): Vector3;
  24177. /**
  24178. * Translates the mesh along the passed Vector3 in its local space.
  24179. * Returns the TransformNode.
  24180. */
  24181. locallyTranslate(vector3: Vector3): TransformNode;
  24182. private static _lookAtVectorCache;
  24183. /**
  24184. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24185. * @param targetPoint the position (must be in same space as current mesh) to look at
  24186. * @param yawCor optional yaw (y-axis) correction in radians
  24187. * @param pitchCor optional pitch (x-axis) correction in radians
  24188. * @param rollCor optional roll (z-axis) correction in radians
  24189. * @param space the choosen space of the target
  24190. * @returns the TransformNode.
  24191. */
  24192. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24193. /**
  24194. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24195. * This Vector3 is expressed in the World space.
  24196. */
  24197. getDirection(localAxis: Vector3): Vector3;
  24198. /**
  24199. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24200. * localAxis is expressed in the mesh local space.
  24201. * result is computed in the Wordl space from the mesh World matrix.
  24202. * Returns the TransformNode.
  24203. */
  24204. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24205. /**
  24206. * Sets a new pivot point to the current node
  24207. * @param point defines the new pivot point to use
  24208. * @param space defines if the point is in world or local space (local by default)
  24209. * @returns the current TransformNode
  24210. */
  24211. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24212. /**
  24213. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24214. */
  24215. getPivotPoint(): Vector3;
  24216. /**
  24217. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24218. * Returns the TransformNode.
  24219. */
  24220. getPivotPointToRef(result: Vector3): TransformNode;
  24221. /**
  24222. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24223. */
  24224. getAbsolutePivotPoint(): Vector3;
  24225. /**
  24226. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24227. * Returns the TransformNode.
  24228. */
  24229. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24230. /**
  24231. * Defines the passed node as the parent of the current node.
  24232. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24233. * Returns the TransformNode.
  24234. */
  24235. setParent(node: Nullable<Node>): TransformNode;
  24236. private _nonUniformScaling;
  24237. readonly nonUniformScaling: boolean;
  24238. /** @hidden */
  24239. _updateNonUniformScalingState(value: boolean): boolean;
  24240. /**
  24241. * Attach the current TransformNode to another TransformNode associated with a bone
  24242. * @param bone Bone affecting the TransformNode
  24243. * @param affectedTransformNode TransformNode associated with the bone
  24244. */
  24245. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24246. detachFromBone(): TransformNode;
  24247. private static _rotationAxisCache;
  24248. /**
  24249. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24250. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24251. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24252. * The passed axis is also normalized.
  24253. * Returns the TransformNode.
  24254. */
  24255. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24256. /**
  24257. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24258. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24259. * The passed axis is also normalized.
  24260. * Returns the TransformNode.
  24261. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24262. */
  24263. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24264. /**
  24265. * Translates the mesh along the axis vector for the passed distance in the given space.
  24266. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24267. * Returns the TransformNode.
  24268. */
  24269. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24270. /**
  24271. * Adds a rotation step to the mesh current rotation.
  24272. * x, y, z are Euler angles expressed in radians.
  24273. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24274. * This means this rotation is made in the mesh local space only.
  24275. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24276. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24277. * ```javascript
  24278. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24279. * ```
  24280. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24281. * 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.
  24282. * Returns the TransformNode.
  24283. */
  24284. addRotation(x: number, y: number, z: number): TransformNode;
  24285. /**
  24286. * Computes the mesh World matrix and returns it.
  24287. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24288. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24289. * If the parameter `force`is set to `true`, the actual computation is done.
  24290. * Returns the mesh World Matrix.
  24291. */
  24292. computeWorldMatrix(force?: boolean): Matrix;
  24293. protected _afterComputeWorldMatrix(): void;
  24294. /**
  24295. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24296. * @param func: callback function to add
  24297. *
  24298. * Returns the TransformNode.
  24299. */
  24300. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24301. /**
  24302. * Removes a registered callback function.
  24303. * Returns the TransformNode.
  24304. */
  24305. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24306. /**
  24307. * Clone the current transform node
  24308. * Returns the new transform node
  24309. * @param name Name of the new clone
  24310. * @param newParent New parent for the clone
  24311. * @param doNotCloneChildren Do not clone children hierarchy
  24312. */
  24313. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24314. serialize(currentSerializationObject?: any): any;
  24315. /**
  24316. * Returns a new TransformNode object parsed from the source provided.
  24317. * The parameter `parsedMesh` is the source.
  24318. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24319. */
  24320. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24321. /**
  24322. * Releases resources associated with this transform node.
  24323. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24324. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24325. */
  24326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24327. }
  24328. }
  24329. declare module BABYLON {
  24330. class VertexBuffer {
  24331. /** @hidden */
  24332. _buffer: Buffer;
  24333. private _kind;
  24334. private _size;
  24335. private _ownsBuffer;
  24336. private _instanced;
  24337. private _instanceDivisor;
  24338. /**
  24339. * The byte type.
  24340. */
  24341. static readonly BYTE: number;
  24342. /**
  24343. * The unsigned byte type.
  24344. */
  24345. static readonly UNSIGNED_BYTE: number;
  24346. /**
  24347. * The short type.
  24348. */
  24349. static readonly SHORT: number;
  24350. /**
  24351. * The unsigned short type.
  24352. */
  24353. static readonly UNSIGNED_SHORT: number;
  24354. /**
  24355. * The integer type.
  24356. */
  24357. static readonly INT: number;
  24358. /**
  24359. * The unsigned integer type.
  24360. */
  24361. static readonly UNSIGNED_INT: number;
  24362. /**
  24363. * The float type.
  24364. */
  24365. static readonly FLOAT: number;
  24366. /**
  24367. * Gets or sets the instance divisor when in instanced mode
  24368. */
  24369. instanceDivisor: number;
  24370. /**
  24371. * Gets the byte stride.
  24372. */
  24373. readonly byteStride: number;
  24374. /**
  24375. * Gets the byte offset.
  24376. */
  24377. readonly byteOffset: number;
  24378. /**
  24379. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24380. */
  24381. readonly normalized: boolean;
  24382. /**
  24383. * Gets the data type of each component in the array.
  24384. */
  24385. readonly type: number;
  24386. /**
  24387. * Constructor
  24388. * @param engine the engine
  24389. * @param data the data to use for this vertex buffer
  24390. * @param kind the vertex buffer kind
  24391. * @param updatable whether the data is updatable
  24392. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24393. * @param stride the stride (optional)
  24394. * @param instanced whether the buffer is instanced (optional)
  24395. * @param offset the offset of the data (optional)
  24396. * @param size the number of components (optional)
  24397. * @param type the type of the component (optional)
  24398. * @param normalized whether the data contains normalized data (optional)
  24399. * @param useBytes set to true if stride and offset are in bytes (optional)
  24400. */
  24401. 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);
  24402. /** @hidden */
  24403. _rebuild(): void;
  24404. /**
  24405. * Returns the kind of the VertexBuffer (string).
  24406. */
  24407. getKind(): string;
  24408. /**
  24409. * Boolean : is the VertexBuffer updatable ?
  24410. */
  24411. isUpdatable(): boolean;
  24412. /**
  24413. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24414. */
  24415. getData(): Nullable<DataArray>;
  24416. /**
  24417. * Returns the WebGLBuffer associated to the VertexBuffer.
  24418. */
  24419. getBuffer(): Nullable<WebGLBuffer>;
  24420. /**
  24421. * Returns the stride as a multiple of the type byte length.
  24422. * DEPRECATED. Use byteStride instead.
  24423. */
  24424. getStrideSize(): number;
  24425. /**
  24426. * Returns the offset as a multiple of the type byte length.
  24427. * DEPRECATED. Use byteOffset instead.
  24428. */
  24429. getOffset(): number;
  24430. /**
  24431. * Returns the number of components per vertex attribute (integer).
  24432. */
  24433. getSize(): number;
  24434. /**
  24435. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24436. */
  24437. getIsInstanced(): boolean;
  24438. /**
  24439. * Returns the instancing divisor, zero for non-instanced (integer).
  24440. */
  24441. getInstanceDivisor(): number;
  24442. /**
  24443. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24444. * Returns the created WebGLBuffer.
  24445. */
  24446. create(data?: DataArray): void;
  24447. /**
  24448. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24449. * This function will create a new buffer if the current one is not updatable
  24450. * Returns the updated WebGLBuffer.
  24451. */
  24452. update(data: DataArray): void;
  24453. /**
  24454. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24455. * Returns the directly updated WebGLBuffer.
  24456. * @param data the new data
  24457. * @param offset the new offset
  24458. * @param useBytes set to true if the offset is in bytes
  24459. */
  24460. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24461. /**
  24462. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24463. */
  24464. dispose(): void;
  24465. /**
  24466. * Enumerates each value of this vertex buffer as numbers.
  24467. * @param count the number of values to enumerate
  24468. * @param callback the callback function called for each value
  24469. */
  24470. forEach(count: number, callback: (value: number, index: number) => void): void;
  24471. private static _PositionKind;
  24472. private static _NormalKind;
  24473. private static _TangentKind;
  24474. private static _UVKind;
  24475. private static _UV2Kind;
  24476. private static _UV3Kind;
  24477. private static _UV4Kind;
  24478. private static _UV5Kind;
  24479. private static _UV6Kind;
  24480. private static _ColorKind;
  24481. private static _MatricesIndicesKind;
  24482. private static _MatricesWeightsKind;
  24483. private static _MatricesIndicesExtraKind;
  24484. private static _MatricesWeightsExtraKind;
  24485. static readonly PositionKind: string;
  24486. static readonly NormalKind: string;
  24487. static readonly TangentKind: string;
  24488. static readonly UVKind: string;
  24489. static readonly UV2Kind: string;
  24490. static readonly UV3Kind: string;
  24491. static readonly UV4Kind: string;
  24492. static readonly UV5Kind: string;
  24493. static readonly UV6Kind: string;
  24494. static readonly ColorKind: string;
  24495. static readonly MatricesIndicesKind: string;
  24496. static readonly MatricesWeightsKind: string;
  24497. static readonly MatricesIndicesExtraKind: string;
  24498. static readonly MatricesWeightsExtraKind: string;
  24499. /**
  24500. * Deduces the stride given a kind.
  24501. * @param kind The kind string to deduce
  24502. * @returns The deduced stride
  24503. */
  24504. static DeduceStride(kind: string): number;
  24505. /**
  24506. * Gets the byte length of the given type.
  24507. * @param type the type
  24508. * @returns the number of bytes
  24509. */
  24510. static GetTypeByteLength(type: number): number;
  24511. /**
  24512. * Enumerates each value of the given parameters as numbers.
  24513. * @param data the data to enumerate
  24514. * @param byteOffset the byte offset of the data
  24515. * @param byteStride the byte stride of the data
  24516. * @param componentCount the number of components per element
  24517. * @param componentType the type of the component
  24518. * @param count the total number of components
  24519. * @param normalized whether the data is normalized
  24520. * @param callback the callback function called for each value
  24521. */
  24522. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24523. private static _GetFloatValue;
  24524. }
  24525. }
  24526. declare module BABYLON {
  24527. /**
  24528. * This represents the base class for particle system in Babylon.
  24529. * 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.
  24530. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24531. * @example https://doc.babylonjs.com/babylon101/particles
  24532. */
  24533. class BaseParticleSystem {
  24534. /**
  24535. * Source color is added to the destination color without alpha affecting the result.
  24536. */
  24537. static BLENDMODE_ONEONE: number;
  24538. /**
  24539. * Blend current color and particle color using particle’s alpha.
  24540. */
  24541. static BLENDMODE_STANDARD: number;
  24542. /**
  24543. * Add current color and particle color multiplied by particle’s alpha.
  24544. */
  24545. static BLENDMODE_ADD: number;
  24546. /**
  24547. * List of animations used by the particle system.
  24548. */
  24549. animations: Animation[];
  24550. /**
  24551. * The id of the Particle system.
  24552. */
  24553. id: string;
  24554. /**
  24555. * The friendly name of the Particle system.
  24556. */
  24557. name: string;
  24558. /**
  24559. * The rendering group used by the Particle system to chose when to render.
  24560. */
  24561. renderingGroupId: number;
  24562. /**
  24563. * The emitter represents the Mesh or position we are attaching the particle system to.
  24564. */
  24565. emitter: Nullable<AbstractMesh | Vector3>;
  24566. /**
  24567. * The maximum number of particles to emit per frame
  24568. */
  24569. emitRate: number;
  24570. /**
  24571. * If you want to launch only a few particles at once, that can be done, as well.
  24572. */
  24573. manualEmitCount: number;
  24574. /**
  24575. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24576. */
  24577. updateSpeed: number;
  24578. /**
  24579. * The amount of time the particle system is running (depends of the overall update speed).
  24580. */
  24581. targetStopDuration: number;
  24582. /**
  24583. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24584. */
  24585. disposeOnStop: boolean;
  24586. /**
  24587. * Minimum power of emitting particles.
  24588. */
  24589. minEmitPower: number;
  24590. /**
  24591. * Maximum power of emitting particles.
  24592. */
  24593. maxEmitPower: number;
  24594. /**
  24595. * Minimum life time of emitting particles.
  24596. */
  24597. minLifeTime: number;
  24598. /**
  24599. * Maximum life time of emitting particles.
  24600. */
  24601. maxLifeTime: number;
  24602. /**
  24603. * Minimum Size of emitting particles.
  24604. */
  24605. minSize: number;
  24606. /**
  24607. * Maximum Size of emitting particles.
  24608. */
  24609. maxSize: number;
  24610. /**
  24611. * Minimum scale of emitting particles on X axis.
  24612. */
  24613. minScaleX: number;
  24614. /**
  24615. * Maximum scale of emitting particles on X axis.
  24616. */
  24617. maxScaleX: number;
  24618. /**
  24619. * Minimum scale of emitting particles on Y axis.
  24620. */
  24621. minScaleY: number;
  24622. /**
  24623. * Maximum scale of emitting particles on Y axis.
  24624. */
  24625. maxScaleY: number;
  24626. /**
  24627. * Gets or sets the minimal initial rotation in radians.
  24628. */
  24629. minInitialRotation: number;
  24630. /**
  24631. * Gets or sets the maximal initial rotation in radians.
  24632. */
  24633. maxInitialRotation: number;
  24634. /**
  24635. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24636. */
  24637. minAngularSpeed: number;
  24638. /**
  24639. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24640. */
  24641. maxAngularSpeed: number;
  24642. /**
  24643. * The texture used to render each particle. (this can be a spritesheet)
  24644. */
  24645. particleTexture: Nullable<Texture>;
  24646. /**
  24647. * The layer mask we are rendering the particles through.
  24648. */
  24649. layerMask: number;
  24650. /**
  24651. * This can help using your own shader to render the particle system.
  24652. * The according effect will be created
  24653. */
  24654. customShader: any;
  24655. /**
  24656. * By default particle system starts as soon as they are created. This prevents the
  24657. * automatic start to happen and let you decide when to start emitting particles.
  24658. */
  24659. preventAutoStart: boolean;
  24660. /**
  24661. * Gets or sets a texture used to add random noise to particle positions
  24662. */
  24663. noiseTexture: Nullable<BaseTexture>;
  24664. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24665. noiseStrength: Vector3;
  24666. /**
  24667. * Callback triggered when the particle animation is ending.
  24668. */
  24669. onAnimationEnd: Nullable<() => void>;
  24670. /**
  24671. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24672. */
  24673. blendMode: number;
  24674. /**
  24675. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24676. * to override the particles.
  24677. */
  24678. forceDepthWrite: boolean;
  24679. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24680. preWarmCycles: number;
  24681. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24682. preWarmStepOffset: number;
  24683. /**
  24684. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24685. */
  24686. spriteCellChangeSpeed: number;
  24687. /**
  24688. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24689. */
  24690. startSpriteCellID: number;
  24691. /**
  24692. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24693. */
  24694. endSpriteCellID: number;
  24695. /**
  24696. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24697. */
  24698. spriteCellWidth: number;
  24699. /**
  24700. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24701. */
  24702. spriteCellHeight: number;
  24703. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24704. translationPivot: Vector2;
  24705. /** @hidden */
  24706. protected _isAnimationSheetEnabled: boolean;
  24707. /**
  24708. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24709. */
  24710. isAnimationSheetEnabled: boolean;
  24711. /**
  24712. * You can use gravity if you want to give an orientation to your particles.
  24713. */
  24714. gravity: Vector3;
  24715. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24716. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24717. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24718. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24719. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24720. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24721. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24722. limitVelocityDamping: number;
  24723. /**
  24724. * Gets the current list of limit velocity gradients.
  24725. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24726. * @returns the list of limit velocity gradients
  24727. */
  24728. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24729. /**
  24730. * Gets the current list of color gradients.
  24731. * You must use addColorGradient and removeColorGradient to udpate this list
  24732. * @returns the list of color gradients
  24733. */
  24734. getColorGradients(): Nullable<Array<ColorGradient>>;
  24735. /**
  24736. * Gets the current list of size gradients.
  24737. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24738. * @returns the list of size gradients
  24739. */
  24740. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24741. /**
  24742. * Gets the current list of life time gradients.
  24743. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24744. * @returns the list of life time gradients
  24745. */
  24746. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24747. /**
  24748. * Gets the current list of angular speed gradients.
  24749. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24750. * @returns the list of angular speed gradients
  24751. */
  24752. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24753. /**
  24754. * Gets the current list of velocity gradients.
  24755. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24756. * @returns the list of velocity gradients
  24757. */
  24758. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24759. /**
  24760. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24761. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24762. */
  24763. direction1: Vector3;
  24764. /**
  24765. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24766. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24767. */
  24768. direction2: Vector3;
  24769. /**
  24770. * 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.
  24771. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24772. */
  24773. minEmitBox: Vector3;
  24774. /**
  24775. * 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.
  24776. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24777. */
  24778. maxEmitBox: Vector3;
  24779. /**
  24780. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24781. */
  24782. color1: Color4;
  24783. /**
  24784. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24785. */
  24786. color2: Color4;
  24787. /**
  24788. * Color the particle will have at the end of its lifetime
  24789. */
  24790. colorDead: Color4;
  24791. /**
  24792. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24793. */
  24794. textureMask: Color4;
  24795. /**
  24796. * The particle emitter type defines the emitter used by the particle system.
  24797. * It can be for example box, sphere, or cone...
  24798. */
  24799. particleEmitterType: IParticleEmitterType;
  24800. /**
  24801. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24802. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24803. */
  24804. billboardMode: number;
  24805. protected _isBillboardBased: boolean;
  24806. /**
  24807. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24808. */
  24809. isBillboardBased: boolean;
  24810. /**
  24811. * The scene the particle system belongs to.
  24812. */
  24813. protected _scene: Scene;
  24814. /**
  24815. * Local cache of defines for image processing.
  24816. */
  24817. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  24818. /**
  24819. * Default configuration related to image processing available in the standard Material.
  24820. */
  24821. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24822. /**
  24823. * Gets the image processing configuration used either in this material.
  24824. */
  24825. /**
  24826. * Sets the Default image processing configuration used either in the this material.
  24827. *
  24828. * If sets to null, the scene one is in use.
  24829. */
  24830. imageProcessingConfiguration: ImageProcessingConfiguration;
  24831. /**
  24832. * Attaches a new image processing configuration to the Standard Material.
  24833. * @param configuration
  24834. */
  24835. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24836. /** @hidden */
  24837. protected _reset(): void;
  24838. /**
  24839. * Instantiates a particle system.
  24840. * 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.
  24841. * @param name The name of the particle system
  24842. */
  24843. constructor(name: string);
  24844. /**
  24845. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  24846. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24847. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24848. * @returns the emitter
  24849. */
  24850. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  24851. /**
  24852. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  24853. * @param radius The radius of the hemisphere to emit from
  24854. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24855. * @returns the emitter
  24856. */
  24857. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  24858. /**
  24859. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  24860. * @param radius The radius of the sphere to emit from
  24861. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24862. * @returns the emitter
  24863. */
  24864. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  24865. /**
  24866. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  24867. * @param radius The radius of the sphere to emit from
  24868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24870. * @returns the emitter
  24871. */
  24872. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24873. /**
  24874. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  24875. * @param radius The radius of the cone to emit from
  24876. * @param angle The base angle of the cone
  24877. * @returns the emitter
  24878. */
  24879. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24880. /**
  24881. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24882. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24883. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24884. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24885. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24886. * @returns the emitter
  24887. */
  24888. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24889. }
  24890. }
  24891. declare module BABYLON {
  24892. /**
  24893. * This represents a GPU particle system in Babylon
  24894. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24895. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24896. */
  24897. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24898. /**
  24899. * The layer mask we are rendering the particles through.
  24900. */
  24901. layerMask: number;
  24902. private _capacity;
  24903. private _activeCount;
  24904. private _currentActiveCount;
  24905. private _accumulatedCount;
  24906. private _renderEffect;
  24907. private _updateEffect;
  24908. private _buffer0;
  24909. private _buffer1;
  24910. private _spriteBuffer;
  24911. private _updateVAO;
  24912. private _renderVAO;
  24913. private _targetIndex;
  24914. private _sourceBuffer;
  24915. private _targetBuffer;
  24916. private _engine;
  24917. private _currentRenderId;
  24918. private _started;
  24919. private _stopped;
  24920. private _timeDelta;
  24921. private _randomTexture;
  24922. private _randomTexture2;
  24923. private _attributesStrideSize;
  24924. private _updateEffectOptions;
  24925. private _randomTextureSize;
  24926. private _actualFrame;
  24927. private readonly _rawTextureWidth;
  24928. /**
  24929. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24930. */
  24931. static readonly IsSupported: boolean;
  24932. /**
  24933. * An event triggered when the system is disposed.
  24934. */
  24935. onDisposeObservable: Observable<GPUParticleSystem>;
  24936. /**
  24937. * Gets the maximum number of particles active at the same time.
  24938. * @returns The max number of active particles.
  24939. */
  24940. getCapacity(): number;
  24941. /**
  24942. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24943. * to override the particles.
  24944. */
  24945. forceDepthWrite: boolean;
  24946. /**
  24947. * Gets or set the number of active particles
  24948. */
  24949. activeParticleCount: number;
  24950. private _preWarmDone;
  24951. /**
  24952. * Is this system ready to be used/rendered
  24953. * @return true if the system is ready
  24954. */
  24955. isReady(): boolean;
  24956. /**
  24957. * Gets Wether the system has been started.
  24958. * @returns True if it has been started, otherwise false.
  24959. */
  24960. isStarted(): boolean;
  24961. /**
  24962. * Starts the particle system and begins to emit
  24963. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  24964. */
  24965. start(delay?: number): void;
  24966. /**
  24967. * Stops the particle system.
  24968. */
  24969. stop(): void;
  24970. /**
  24971. * Remove all active particles
  24972. */
  24973. reset(): void;
  24974. /**
  24975. * Returns the string "GPUParticleSystem"
  24976. * @returns a string containing the class name
  24977. */
  24978. getClassName(): string;
  24979. private _colorGradientsTexture;
  24980. private _removeGradient;
  24981. /**
  24982. * Adds a new color gradient
  24983. * @param gradient defines the gradient to use (between 0 and 1)
  24984. * @param color defines the color to affect to the specified gradient
  24985. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24986. * @returns the current particle system
  24987. */
  24988. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24989. /**
  24990. * Remove a specific color gradient
  24991. * @param gradient defines the gradient to remove
  24992. * @returns the current particle system
  24993. */
  24994. removeColorGradient(gradient: number): GPUParticleSystem;
  24995. private _angularSpeedGradientsTexture;
  24996. private _sizeGradientsTexture;
  24997. private _velocityGradientsTexture;
  24998. private _limitVelocityGradientsTexture;
  24999. private _addFactorGradient;
  25000. /**
  25001. * Adds a new size gradient
  25002. * @param gradient defines the gradient to use (between 0 and 1)
  25003. * @param factor defines the size factor to affect to the specified gradient
  25004. * @returns the current particle system
  25005. */
  25006. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  25007. /**
  25008. * Remove a specific size gradient
  25009. * @param gradient defines the gradient to remove
  25010. * @returns the current particle system
  25011. */
  25012. removeSizeGradient(gradient: number): GPUParticleSystem;
  25013. /**
  25014. * Adds a new angular speed gradient
  25015. * @param gradient defines the gradient to use (between 0 and 1)
  25016. * @param factor defines the angular speed to affect to the specified gradient
  25017. * @returns the current particle system
  25018. */
  25019. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25020. /**
  25021. * Remove a specific angular speed gradient
  25022. * @param gradient defines the gradient to remove
  25023. * @returns the current particle system
  25024. */
  25025. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25026. /**
  25027. * Adds a new velocity gradient
  25028. * @param gradient defines the gradient to use (between 0 and 1)
  25029. * @param factor defines the velocity to affect to the specified gradient
  25030. * @returns the current particle system
  25031. */
  25032. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25033. /**
  25034. * Remove a specific velocity gradient
  25035. * @param gradient defines the gradient to remove
  25036. * @returns the current particle system
  25037. */
  25038. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25039. /**
  25040. * Adds a new limit velocity gradient
  25041. * @param gradient defines the gradient to use (between 0 and 1)
  25042. * @param factor defines the limit velocity value to affect to the specified gradient
  25043. * @returns the current particle system
  25044. */
  25045. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25046. /**
  25047. * Remove a specific limit velocity gradient
  25048. * @param gradient defines the gradient to remove
  25049. * @returns the current particle system
  25050. */
  25051. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25052. /**
  25053. * Instantiates a GPU particle system.
  25054. * 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.
  25055. * @param name The name of the particle system
  25056. * @param options The options used to create the system
  25057. * @param scene The scene the particle system belongs to
  25058. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25059. */
  25060. constructor(name: string, options: Partial<{
  25061. capacity: number;
  25062. randomTextureSize: number;
  25063. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25064. protected _reset(): void;
  25065. private _createUpdateVAO;
  25066. private _createRenderVAO;
  25067. private _initialize;
  25068. /** @hidden */
  25069. _recreateUpdateEffect(): void;
  25070. /** @hidden */
  25071. _recreateRenderEffect(): void;
  25072. /**
  25073. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25074. * @param preWarm defines if we are in the pre-warmimg phase
  25075. */
  25076. animate(preWarm?: boolean): void;
  25077. private _createFactorGradientTexture;
  25078. private _createSizeGradientTexture;
  25079. private _createAngularSpeedGradientTexture;
  25080. private _createVelocityGradientTexture;
  25081. private _createColorGradientTexture;
  25082. /**
  25083. * Renders the particle system in its current state
  25084. * @param preWarm defines if the system should only update the particles but not render them
  25085. * @returns the current number of particles
  25086. */
  25087. render(preWarm?: boolean): number;
  25088. /**
  25089. * Rebuilds the particle system
  25090. */
  25091. rebuild(): void;
  25092. private _releaseBuffers;
  25093. private _releaseVAOs;
  25094. /**
  25095. * Disposes the particle system and free the associated resources
  25096. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25097. */
  25098. dispose(disposeTexture?: boolean): void;
  25099. /**
  25100. * Clones the particle system.
  25101. * @param name The name of the cloned object
  25102. * @param newEmitter The new emitter to use
  25103. * @returns the cloned particle system
  25104. */
  25105. clone(name: string, newEmitter: any): GPUParticleSystem;
  25106. /**
  25107. * Serializes the particle system to a JSON object.
  25108. * @returns the JSON object
  25109. */
  25110. serialize(): any;
  25111. /**
  25112. * Parses a JSON object to create a GPU particle system.
  25113. * @param parsedParticleSystem The JSON object to parse
  25114. * @param scene The scene to create the particle system in
  25115. * @param rootUrl The root url to use to load external dependencies like texture
  25116. * @returns the parsed GPU particle system
  25117. */
  25118. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25119. }
  25120. }
  25121. declare module BABYLON {
  25122. /**
  25123. * Interface representing a particle system in Babylon.js.
  25124. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25125. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25126. */
  25127. interface IParticleSystem {
  25128. /**
  25129. * List of animations used by the particle system.
  25130. */
  25131. animations: Animation[];
  25132. /**
  25133. * The id of the Particle system.
  25134. */
  25135. id: string;
  25136. /**
  25137. * The name of the Particle system.
  25138. */
  25139. name: string;
  25140. /**
  25141. * The emitter represents the Mesh or position we are attaching the particle system to.
  25142. */
  25143. emitter: Nullable<AbstractMesh | Vector3>;
  25144. /**
  25145. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25146. */
  25147. isBillboardBased: boolean;
  25148. /**
  25149. * The rendering group used by the Particle system to chose when to render.
  25150. */
  25151. renderingGroupId: number;
  25152. /**
  25153. * The layer mask we are rendering the particles through.
  25154. */
  25155. layerMask: number;
  25156. /**
  25157. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25158. */
  25159. updateSpeed: number;
  25160. /**
  25161. * The amount of time the particle system is running (depends of the overall update speed).
  25162. */
  25163. targetStopDuration: number;
  25164. /**
  25165. * The texture used to render each particle. (this can be a spritesheet)
  25166. */
  25167. particleTexture: Nullable<Texture>;
  25168. /**
  25169. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25170. */
  25171. blendMode: number;
  25172. /**
  25173. * Minimum life time of emitting particles.
  25174. */
  25175. minLifeTime: number;
  25176. /**
  25177. * Maximum life time of emitting particles.
  25178. */
  25179. maxLifeTime: number;
  25180. /**
  25181. * Minimum Size of emitting particles.
  25182. */
  25183. minSize: number;
  25184. /**
  25185. * Maximum Size of emitting particles.
  25186. */
  25187. maxSize: number;
  25188. /**
  25189. * Minimum scale of emitting particles on X axis.
  25190. */
  25191. minScaleX: number;
  25192. /**
  25193. * Maximum scale of emitting particles on X axis.
  25194. */
  25195. maxScaleX: number;
  25196. /**
  25197. * Minimum scale of emitting particles on Y axis.
  25198. */
  25199. minScaleY: number;
  25200. /**
  25201. * Maximum scale of emitting particles on Y axis.
  25202. */
  25203. maxScaleY: number;
  25204. /**
  25205. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25206. */
  25207. color1: Color4;
  25208. /**
  25209. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25210. */
  25211. color2: Color4;
  25212. /**
  25213. * Color the particle will have at the end of its lifetime.
  25214. */
  25215. colorDead: Color4;
  25216. /**
  25217. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25218. */
  25219. emitRate: number;
  25220. /**
  25221. * You can use gravity if you want to give an orientation to your particles.
  25222. */
  25223. gravity: Vector3;
  25224. /**
  25225. * Minimum power of emitting particles.
  25226. */
  25227. minEmitPower: number;
  25228. /**
  25229. * Maximum power of emitting particles.
  25230. */
  25231. maxEmitPower: number;
  25232. /**
  25233. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25234. */
  25235. minAngularSpeed: number;
  25236. /**
  25237. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25238. */
  25239. maxAngularSpeed: number;
  25240. /**
  25241. * Gets or sets the minimal initial rotation in radians.
  25242. */
  25243. minInitialRotation: number;
  25244. /**
  25245. * Gets or sets the maximal initial rotation in radians.
  25246. */
  25247. maxInitialRotation: number;
  25248. /**
  25249. * The particle emitter type defines the emitter used by the particle system.
  25250. * It can be for example box, sphere, or cone...
  25251. */
  25252. particleEmitterType: Nullable<IParticleEmitterType>;
  25253. /**
  25254. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  25255. */
  25256. preWarmCycles: number;
  25257. /**
  25258. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25259. */
  25260. preWarmStepOffset: number;
  25261. /**
  25262. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  25263. */
  25264. spriteCellChangeSpeed: number;
  25265. /**
  25266. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25267. */
  25268. startSpriteCellID: number;
  25269. /**
  25270. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25271. */
  25272. endSpriteCellID: number;
  25273. /**
  25274. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25275. */
  25276. spriteCellWidth: number;
  25277. /**
  25278. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25279. */
  25280. spriteCellHeight: number;
  25281. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25282. translationPivot: Vector2;
  25283. /**
  25284. * Gets or sets a texture used to add random noise to particle positions
  25285. */
  25286. noiseTexture: Nullable<BaseTexture>;
  25287. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25288. noiseStrength: Vector3;
  25289. /**
  25290. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25291. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25292. */
  25293. billboardMode: number;
  25294. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25295. limitVelocityDamping: number;
  25296. /**
  25297. * Gets the maximum number of particles active at the same time.
  25298. * @returns The max number of active particles.
  25299. */
  25300. getCapacity(): number;
  25301. /**
  25302. * Gets Wether the system has been started.
  25303. * @returns True if it has been started, otherwise false.
  25304. */
  25305. isStarted(): boolean;
  25306. /**
  25307. * Gets if the particle system has been started.
  25308. * @return true if the system has been started, otherwise false.
  25309. */
  25310. isStarted(): boolean;
  25311. /**
  25312. * Animates the particle system for this frame.
  25313. */
  25314. animate(): void;
  25315. /**
  25316. * Renders the particle system in its current state.
  25317. * @returns the current number of particles
  25318. */
  25319. render(): number;
  25320. /**
  25321. * Dispose the particle system and frees its associated resources.
  25322. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25323. */
  25324. dispose(disposeTexture?: boolean): void;
  25325. /**
  25326. * Clones the particle system.
  25327. * @param name The name of the cloned object
  25328. * @param newEmitter The new emitter to use
  25329. * @returns the cloned particle system
  25330. */
  25331. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25332. /**
  25333. * Serializes the particle system to a JSON object.
  25334. * @returns the JSON object
  25335. */
  25336. serialize(): any;
  25337. /**
  25338. * Rebuild the particle system
  25339. */
  25340. rebuild(): void;
  25341. /**
  25342. * Starts the particle system and begins to emit
  25343. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25344. */
  25345. start(delay?: number): void;
  25346. /**
  25347. * Stops the particle system.
  25348. */
  25349. stop(): void;
  25350. /**
  25351. * Remove all active particles
  25352. */
  25353. reset(): void;
  25354. /**
  25355. * Is this system ready to be used/rendered
  25356. * @return true if the system is ready
  25357. */
  25358. isReady(): boolean;
  25359. /**
  25360. * Adds a new color gradient
  25361. * @param gradient defines the gradient to use (between 0 and 1)
  25362. * @param color defines the color to affect to the specified gradient
  25363. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25364. * @returns the current particle system
  25365. */
  25366. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25367. /**
  25368. * Remove a specific color gradient
  25369. * @param gradient defines the gradient to remove
  25370. * @returns the current particle system
  25371. */
  25372. removeColorGradient(gradient: number): IParticleSystem;
  25373. /**
  25374. * Adds a new size gradient
  25375. * @param gradient defines the gradient to use (between 0 and 1)
  25376. * @param factor defines the size factor to affect to the specified gradient
  25377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25378. * @returns the current particle system
  25379. */
  25380. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25381. /**
  25382. * Remove a specific size gradient
  25383. * @param gradient defines the gradient to remove
  25384. * @returns the current particle system
  25385. */
  25386. removeSizeGradient(gradient: number): IParticleSystem;
  25387. /**
  25388. * Gets the current list of color gradients.
  25389. * You must use addColorGradient and removeColorGradient to udpate this list
  25390. * @returns the list of color gradients
  25391. */
  25392. getColorGradients(): Nullable<Array<ColorGradient>>;
  25393. /**
  25394. * Gets the current list of size gradients.
  25395. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25396. * @returns the list of size gradients
  25397. */
  25398. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25399. /**
  25400. * Gets the current list of angular speed gradients.
  25401. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25402. * @returns the list of angular speed gradients
  25403. */
  25404. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25405. /**
  25406. * Adds a new angular speed gradient
  25407. * @param gradient defines the gradient to use (between 0 and 1)
  25408. * @param factor defines the angular speed to affect to the specified gradient
  25409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25410. * @returns the current particle system
  25411. */
  25412. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25413. /**
  25414. * Remove a specific angular speed gradient
  25415. * @param gradient defines the gradient to remove
  25416. * @returns the current particle system
  25417. */
  25418. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25419. /**
  25420. * Gets the current list of velocity gradients.
  25421. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25422. * @returns the list of velocity gradients
  25423. */
  25424. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25425. /**
  25426. * Adds a new velocity gradient
  25427. * @param gradient defines the gradient to use (between 0 and 1)
  25428. * @param factor defines the velocity to affect to the specified gradient
  25429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25430. * @returns the current particle system
  25431. */
  25432. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25433. /**
  25434. * Remove a specific velocity gradient
  25435. * @param gradient defines the gradient to remove
  25436. * @returns the current particle system
  25437. */
  25438. removeVelocityGradient(gradient: number): IParticleSystem;
  25439. /**
  25440. * Gets the current list of limit velocity gradients.
  25441. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25442. * @returns the list of limit velocity gradients
  25443. */
  25444. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25445. /**
  25446. * Adds a new limit velocity gradient
  25447. * @param gradient defines the gradient to use (between 0 and 1)
  25448. * @param factor defines the limit velocity to affect to the specified gradient
  25449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25450. * @returns the current particle system
  25451. */
  25452. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25453. /**
  25454. * Remove a specific limit velocity gradient
  25455. * @param gradient defines the gradient to remove
  25456. * @returns the current particle system
  25457. */
  25458. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25459. }
  25460. }
  25461. declare module BABYLON {
  25462. /**
  25463. * A particle represents one of the element emitted by a particle system.
  25464. * This is mainly define by its coordinates, direction, velocity and age.
  25465. */
  25466. class Particle {
  25467. /**
  25468. * particleSystem the particle system the particle belongs to.
  25469. */
  25470. particleSystem: ParticleSystem;
  25471. /**
  25472. * The world position of the particle in the scene.
  25473. */
  25474. position: Vector3;
  25475. /**
  25476. * The world direction of the particle in the scene.
  25477. */
  25478. direction: Vector3;
  25479. /**
  25480. * The color of the particle.
  25481. */
  25482. color: Color4;
  25483. /**
  25484. * The color change of the particle per step.
  25485. */
  25486. colorStep: Color4;
  25487. /**
  25488. * Defines how long will the life of the particle be.
  25489. */
  25490. lifeTime: number;
  25491. /**
  25492. * The current age of the particle.
  25493. */
  25494. age: number;
  25495. /**
  25496. * The current size of the particle.
  25497. */
  25498. size: number;
  25499. /**
  25500. * The current scale of the particle.
  25501. */
  25502. scale: Vector2;
  25503. /**
  25504. * The current angle of the particle.
  25505. */
  25506. angle: number;
  25507. /**
  25508. * Defines how fast is the angle changing.
  25509. */
  25510. angularSpeed: number;
  25511. /**
  25512. * Defines the cell index used by the particle to be rendered from a sprite.
  25513. */
  25514. cellIndex: number;
  25515. /** @hidden */
  25516. _initialDirection: Nullable<Vector3>;
  25517. /** @hidden */
  25518. _initialStartSpriteCellID: number;
  25519. _initialEndSpriteCellID: number;
  25520. /** @hidden */
  25521. _currentColorGradient: Nullable<ColorGradient>;
  25522. /** @hidden */
  25523. _currentColor1: Color4;
  25524. /** @hidden */
  25525. _currentColor2: Color4;
  25526. /** @hidden */
  25527. _currentSizeGradient: Nullable<FactorGradient>;
  25528. /** @hidden */
  25529. _currentSize1: number;
  25530. /** @hidden */
  25531. _currentSize2: number;
  25532. /** @hidden */
  25533. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25534. /** @hidden */
  25535. _currentAngularSpeed1: number;
  25536. /** @hidden */
  25537. _currentAngularSpeed2: number;
  25538. /** @hidden */
  25539. _currentVelocityGradient: Nullable<FactorGradient>;
  25540. /** @hidden */
  25541. _currentVelocity1: number;
  25542. /** @hidden */
  25543. _currentVelocity2: number;
  25544. /** @hidden */
  25545. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  25546. /** @hidden */
  25547. _currentLimitVelocity1: number;
  25548. /** @hidden */
  25549. _currentLimitVelocity2: number;
  25550. /**
  25551. * Creates a new instance Particle
  25552. * @param particleSystem the particle system the particle belongs to
  25553. */
  25554. constructor(
  25555. /**
  25556. * particleSystem the particle system the particle belongs to.
  25557. */
  25558. particleSystem: ParticleSystem);
  25559. private updateCellInfoFromSystem;
  25560. /**
  25561. * Defines how the sprite cell index is updated for the particle
  25562. */
  25563. updateCellIndex(): void;
  25564. /**
  25565. * Copy the properties of particle to another one.
  25566. * @param other the particle to copy the information to.
  25567. */
  25568. copyTo(other: Particle): void;
  25569. }
  25570. }
  25571. declare module BABYLON {
  25572. /**
  25573. * This class is made for on one-liner static method to help creating particle system set.
  25574. */
  25575. class ParticleHelper {
  25576. /**
  25577. * Gets or sets base Assets URL
  25578. */
  25579. static BaseAssetsUrl: string;
  25580. /**
  25581. * Create a default particle system that you can tweak
  25582. * @param emitter defines the emitter to use
  25583. * @param capacity defines the system capacity (default is 500 particles)
  25584. * @param scene defines the hosting scene
  25585. * @returns the new Particle system
  25586. */
  25587. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene): ParticleSystem;
  25588. /**
  25589. * This is the main static method (one-liner) of this helper to create different particle systems
  25590. * @param type This string represents the type to the particle system to create
  25591. * @param scene The scene where the particle system should live
  25592. * @param gpu If the system will use gpu
  25593. * @returns the ParticleSystemSet created
  25594. */
  25595. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25596. /**
  25597. * Static function used to export a particle system to a ParticleSystemSet variable.
  25598. * Please note that the emitter shape is not exported
  25599. * @param system defines the particle systems to export
  25600. */
  25601. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25602. }
  25603. }
  25604. declare module BABYLON {
  25605. /**
  25606. * This represents a particle system in Babylon.
  25607. * 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.
  25608. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25609. * @example https://doc.babylonjs.com/babylon101/particles
  25610. */
  25611. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25612. /**
  25613. * This function can be defined to provide custom update for active particles.
  25614. * This function will be called instead of regular update (age, position, color, etc.).
  25615. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25616. */
  25617. updateFunction: (particles: Particle[]) => void;
  25618. private _emitterWorldMatrix;
  25619. /**
  25620. * This function can be defined to specify initial direction for every new particle.
  25621. * It by default use the emitterType defined function
  25622. */
  25623. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25624. /**
  25625. * This function can be defined to specify initial position for every new particle.
  25626. * It by default use the emitterType defined function
  25627. */
  25628. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25629. /**
  25630. * An event triggered when the system is disposed
  25631. */
  25632. onDisposeObservable: Observable<ParticleSystem>;
  25633. private _onDisposeObserver;
  25634. /**
  25635. * Sets a callback that will be triggered when the system is disposed
  25636. */
  25637. onDispose: () => void;
  25638. /**
  25639. * Get hosting scene
  25640. * @returns the scene
  25641. */
  25642. getScene(): Scene;
  25643. private _particles;
  25644. private _epsilon;
  25645. private _capacity;
  25646. private _stockParticles;
  25647. private _newPartsExcess;
  25648. private _vertexData;
  25649. private _vertexBuffer;
  25650. private _vertexBuffers;
  25651. private _spriteBuffer;
  25652. private _indexBuffer;
  25653. private _effect;
  25654. private _customEffect;
  25655. private _cachedDefines;
  25656. private _scaledColorStep;
  25657. private _colorDiff;
  25658. private _scaledDirection;
  25659. private _scaledGravity;
  25660. private _currentRenderId;
  25661. private _alive;
  25662. private _useInstancing;
  25663. private _started;
  25664. private _stopped;
  25665. private _actualFrame;
  25666. private _scaledUpdateSpeed;
  25667. private _vertexBufferSize;
  25668. /**
  25669. * 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.
  25670. */
  25671. subEmitters: ParticleSystem[];
  25672. /**
  25673. * The current active Sub-systems, this property is used by the root particle system only.
  25674. */
  25675. activeSubSystems: Array<ParticleSystem>;
  25676. private _rootParticleSystem;
  25677. /**
  25678. * Gets the current list of active particles
  25679. */
  25680. readonly particles: Particle[];
  25681. /**
  25682. * Returns the string "ParticleSystem"
  25683. * @returns a string containing the class name
  25684. */
  25685. getClassName(): string;
  25686. /**
  25687. * Instantiates a particle system.
  25688. * 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.
  25689. * @param name The name of the particle system
  25690. * @param capacity The max number of particles alive at the same time
  25691. * @param scene The scene the particle system belongs to
  25692. * @param customEffect a custom effect used to change the way particles are rendered by default
  25693. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25694. * @param epsilon Offset used to render the particles
  25695. */
  25696. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25697. private _addFactorGradient;
  25698. private _removeFactorGradient;
  25699. /**
  25700. * Adds a new life time gradient
  25701. * @param gradient defines the gradient to use (between 0 and 1)
  25702. * @param factor defines the life time factor to affect to the specified gradient
  25703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25704. * @returns the current particle system
  25705. */
  25706. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25707. /**
  25708. * Remove a specific life time gradient
  25709. * @param gradient defines the gradient to remove
  25710. * @returns the current particle system
  25711. */
  25712. removeLifeTimeGradient(gradient: number): IParticleSystem;
  25713. /**
  25714. * Adds a new size gradient
  25715. * @param gradient defines the gradient to use (between 0 and 1)
  25716. * @param factor defines the size factor to affect to the specified gradient
  25717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25718. * @returns the current particle system
  25719. */
  25720. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25721. /**
  25722. * Remove a specific size gradient
  25723. * @param gradient defines the gradient to remove
  25724. * @returns the current particle system
  25725. */
  25726. removeSizeGradient(gradient: number): IParticleSystem;
  25727. /**
  25728. * Adds a new angular speed gradient
  25729. * @param gradient defines the gradient to use (between 0 and 1)
  25730. * @param factor defines the angular speed to affect to the specified gradient
  25731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25732. * @returns the current particle system
  25733. */
  25734. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25735. /**
  25736. * Remove a specific angular speed gradient
  25737. * @param gradient defines the gradient to remove
  25738. * @returns the current particle system
  25739. */
  25740. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25741. /**
  25742. * Adds a new velocity gradient
  25743. * @param gradient defines the gradient to use (between 0 and 1)
  25744. * @param factor defines the velocity to affect to the specified gradient
  25745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25746. * @returns the current particle system
  25747. */
  25748. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25749. /**
  25750. * Remove a specific velocity gradient
  25751. * @param gradient defines the gradient to remove
  25752. * @returns the current particle system
  25753. */
  25754. removeVelocityGradient(gradient: number): IParticleSystem;
  25755. /**
  25756. * Adds a new limit velocity gradient
  25757. * @param gradient defines the gradient to use (between 0 and 1)
  25758. * @param factor defines the limit velocity value to affect to the specified gradient
  25759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25760. * @returns the current particle system
  25761. */
  25762. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25763. /**
  25764. * Remove a specific limit velocity gradient
  25765. * @param gradient defines the gradient to remove
  25766. * @returns the current particle system
  25767. */
  25768. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25769. /**
  25770. * Adds a new color gradient
  25771. * @param gradient defines the gradient to use (between 0 and 1)
  25772. * @param color defines the color to affect to the specified gradient
  25773. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25774. */
  25775. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  25776. /**
  25777. * Remove a specific color gradient
  25778. * @param gradient defines the gradient to remove
  25779. */
  25780. removeColorGradient(gradient: number): IParticleSystem;
  25781. private _fetchR;
  25782. protected _reset(): void;
  25783. private _resetEffect;
  25784. private _createVertexBuffers;
  25785. private _createIndexBuffer;
  25786. /**
  25787. * Gets the maximum number of particles active at the same time.
  25788. * @returns The max number of active particles.
  25789. */
  25790. getCapacity(): number;
  25791. /**
  25792. * Gets whether there are still active particles in the system.
  25793. * @returns True if it is alive, otherwise false.
  25794. */
  25795. isAlive(): boolean;
  25796. /**
  25797. * Gets whether the system has been started.
  25798. * @returns True if it has been started, otherwise false.
  25799. */
  25800. isStarted(): boolean;
  25801. /**
  25802. * Starts the particle system and begins to emit
  25803. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25804. */
  25805. start(delay?: number): void;
  25806. /**
  25807. * Stops the particle system.
  25808. * @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.
  25809. */
  25810. stop(stopSubEmitters?: boolean): void;
  25811. /**
  25812. * Remove all active particles
  25813. */
  25814. reset(): void;
  25815. /**
  25816. * @hidden (for internal use only)
  25817. */
  25818. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25819. /**
  25820. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25821. * Its lifetime will start back at 0.
  25822. */
  25823. recycleParticle: (particle: Particle) => void;
  25824. private _stopSubEmitters;
  25825. private _createParticle;
  25826. private _removeFromRoot;
  25827. private _emitFromParticle;
  25828. private _update;
  25829. /** @hidden */
  25830. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25831. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25832. private _getEffect;
  25833. /**
  25834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25835. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25836. */
  25837. animate(preWarmOnly?: boolean): void;
  25838. private _appendParticleVertices;
  25839. /**
  25840. * Rebuilds the particle system.
  25841. */
  25842. rebuild(): void;
  25843. /**
  25844. * Is this system ready to be used/rendered
  25845. * @return true if the system is ready
  25846. */
  25847. isReady(): boolean;
  25848. /**
  25849. * Renders the particle system in its current state.
  25850. * @returns the current number of particles
  25851. */
  25852. render(): number;
  25853. /**
  25854. * Disposes the particle system and free the associated resources
  25855. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25856. */
  25857. dispose(disposeTexture?: boolean): void;
  25858. /**
  25859. * Clones the particle system.
  25860. * @param name The name of the cloned object
  25861. * @param newEmitter The new emitter to use
  25862. * @returns the cloned particle system
  25863. */
  25864. clone(name: string, newEmitter: any): ParticleSystem;
  25865. /**
  25866. * Serializes the particle system to a JSON object.
  25867. * @returns the JSON object
  25868. */
  25869. serialize(): any;
  25870. /** @hidden */
  25871. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  25872. /** @hidden */
  25873. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  25874. /**
  25875. * Parses a JSON object to create a particle system.
  25876. * @param parsedParticleSystem The JSON object to parse
  25877. * @param scene The scene to create the particle system in
  25878. * @param rootUrl The root url to use to load external dependencies like texture
  25879. * @returns the Parsed particle system
  25880. */
  25881. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25882. }
  25883. }
  25884. declare module BABYLON {
  25885. interface Engine {
  25886. /**
  25887. * Create an effect to use with particle systems.
  25888. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  25889. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  25890. * @param uniformsNames defines a list of attribute names
  25891. * @param samplers defines an array of string used to represent textures
  25892. * @param defines defines the string containing the defines to use to compile the shaders
  25893. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  25894. * @param onCompiled defines a function to call when the effect creation is successful
  25895. * @param onError defines a function to call when the effect creation has failed
  25896. * @returns the new Effect
  25897. */
  25898. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  25899. }
  25900. }
  25901. declare module BABYLON {
  25902. /**
  25903. * Represents a set of particle systems working together to create a specific effect
  25904. */
  25905. class ParticleSystemSet implements IDisposable {
  25906. private _emitterCreationOptions;
  25907. private _emitterNode;
  25908. /**
  25909. * Gets the particle system list
  25910. */
  25911. systems: IParticleSystem[];
  25912. /**
  25913. * Gets the emitter node used with this set
  25914. */
  25915. readonly emitterNode: Nullable<TransformNode>;
  25916. /**
  25917. * Creates a new emitter mesh as a sphere
  25918. * @param options defines the options used to create the sphere
  25919. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  25920. * @param scene defines the hosting scene
  25921. */
  25922. setEmitterAsSphere(options: {
  25923. diameter: number;
  25924. segments: number;
  25925. color: Color3;
  25926. }, renderingGroupId: number, scene: Scene): void;
  25927. /**
  25928. * Starts all particle systems of the set
  25929. * @param emitter defines an optional mesh to use as emitter for the particle systems
  25930. */
  25931. start(emitter?: AbstractMesh): void;
  25932. /**
  25933. * Release all associated resources
  25934. */
  25935. dispose(): void;
  25936. /**
  25937. * Serialize the set into a JSON compatible object
  25938. * @returns a JSON compatible representation of the set
  25939. */
  25940. serialize(): any;
  25941. /**
  25942. * Parse a new ParticleSystemSet from a serialized source
  25943. * @param data defines a JSON compatible representation of the set
  25944. * @param scene defines the hosting scene
  25945. * @param gpu defines if we want GPU particles or CPU particles
  25946. * @returns a new ParticleSystemSet
  25947. */
  25948. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  25949. }
  25950. }
  25951. declare module BABYLON {
  25952. /**
  25953. * Represents one particle of a solid particle system.
  25954. */
  25955. class SolidParticle {
  25956. /**
  25957. * particle global index
  25958. */
  25959. idx: number;
  25960. /**
  25961. * The color of the particle
  25962. */
  25963. color: Nullable<Color4>;
  25964. /**
  25965. * The world space position of the particle.
  25966. */
  25967. position: Vector3;
  25968. /**
  25969. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25970. */
  25971. rotation: Vector3;
  25972. /**
  25973. * The world space rotation quaternion of the particle.
  25974. */
  25975. rotationQuaternion: Nullable<Quaternion>;
  25976. /**
  25977. * The scaling of the particle.
  25978. */
  25979. scaling: Vector3;
  25980. /**
  25981. * The uvs of the particle.
  25982. */
  25983. uvs: Vector4;
  25984. /**
  25985. * The current speed of the particle.
  25986. */
  25987. velocity: Vector3;
  25988. /**
  25989. * The pivot point in the particle local space.
  25990. */
  25991. pivot: Vector3;
  25992. /**
  25993. * Must the particle be translated from its pivot point in its local space ?
  25994. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25995. * Default : false
  25996. */
  25997. translateFromPivot: boolean;
  25998. /**
  25999. * Is the particle active or not ?
  26000. */
  26001. alive: boolean;
  26002. /**
  26003. * Is the particle visible or not ?
  26004. */
  26005. isVisible: boolean;
  26006. /**
  26007. * Index of this particle in the global "positions" array (Internal use)
  26008. * @hidden
  26009. */
  26010. _pos: number;
  26011. /**
  26012. * @hidden Index of this particle in the global "indices" array (Internal use)
  26013. */
  26014. _ind: number;
  26015. /**
  26016. * @hidden ModelShape of this particle (Internal use)
  26017. */
  26018. _model: ModelShape;
  26019. /**
  26020. * ModelShape id of this particle
  26021. */
  26022. shapeId: number;
  26023. /**
  26024. * Index of the particle in its shape id (Internal use)
  26025. */
  26026. idxInShape: number;
  26027. /**
  26028. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26029. */
  26030. _modelBoundingInfo: BoundingInfo;
  26031. /**
  26032. * @hidden Particle BoundingInfo object (Internal use)
  26033. */
  26034. _boundingInfo: BoundingInfo;
  26035. /**
  26036. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26037. */
  26038. _sps: SolidParticleSystem;
  26039. /**
  26040. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26041. */
  26042. _stillInvisible: boolean;
  26043. /**
  26044. * @hidden Last computed particle rotation matrix
  26045. */
  26046. _rotationMatrix: number[];
  26047. /**
  26048. * Parent particle Id, if any.
  26049. * Default null.
  26050. */
  26051. parentId: Nullable<number>;
  26052. /**
  26053. * @hidden Internal global position in the SPS.
  26054. */
  26055. _globalPosition: Vector3;
  26056. /**
  26057. * Creates a Solid Particle object.
  26058. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26059. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26060. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26061. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26062. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26063. * @param shapeId (integer) is the model shape identifier in the SPS.
  26064. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26065. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26066. */
  26067. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26068. /**
  26069. * Legacy support, changed scale to scaling
  26070. */
  26071. /**
  26072. * Legacy support, changed scale to scaling
  26073. */
  26074. scale: Vector3;
  26075. /**
  26076. * Legacy support, changed quaternion to rotationQuaternion
  26077. */
  26078. /**
  26079. * Legacy support, changed quaternion to rotationQuaternion
  26080. */
  26081. quaternion: Nullable<Quaternion>;
  26082. /**
  26083. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26084. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26085. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26086. * @returns true if it intersects
  26087. */
  26088. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26089. }
  26090. /**
  26091. * Represents the shape of the model used by one particle of a solid particle system.
  26092. * SPS internal tool, don't use it manually.
  26093. */
  26094. class ModelShape {
  26095. /**
  26096. * The shape id
  26097. * @hidden
  26098. */
  26099. shapeID: number;
  26100. /**
  26101. * flat array of model positions (internal use)
  26102. * @hidden
  26103. */
  26104. _shape: Vector3[];
  26105. /**
  26106. * flat array of model UVs (internal use)
  26107. * @hidden
  26108. */
  26109. _shapeUV: number[];
  26110. /**
  26111. * length of the shape in the model indices array (internal use)
  26112. * @hidden
  26113. */
  26114. _indicesLength: number;
  26115. /**
  26116. * Custom position function (internal use)
  26117. * @hidden
  26118. */
  26119. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26120. /**
  26121. * Custom vertex function (internal use)
  26122. * @hidden
  26123. */
  26124. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26125. /**
  26126. * 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.
  26127. * SPS internal tool, don't use it manually.
  26128. * @hidden
  26129. */
  26130. 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>);
  26131. }
  26132. /**
  26133. * Represents a Depth Sorted Particle in the solid particle system.
  26134. */
  26135. class DepthSortedParticle {
  26136. /**
  26137. * Index of the particle in the "indices" array
  26138. */
  26139. ind: number;
  26140. /**
  26141. * Length of the particle shape in the "indices" array
  26142. */
  26143. indicesLength: number;
  26144. /**
  26145. * Squared distance from the particle to the camera
  26146. */
  26147. sqDistance: number;
  26148. }
  26149. }
  26150. declare module BABYLON {
  26151. /**
  26152. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26153. *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.
  26154. * The SPS is also a particle system. It provides some methods to manage the particles.
  26155. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26156. *
  26157. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26158. */
  26159. class SolidParticleSystem implements IDisposable {
  26160. /**
  26161. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26162. * Example : var p = SPS.particles[i];
  26163. */
  26164. particles: SolidParticle[];
  26165. /**
  26166. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26167. */
  26168. nbParticles: number;
  26169. /**
  26170. * If the particles must ever face the camera (default false). Useful for planar particles.
  26171. */
  26172. billboard: boolean;
  26173. /**
  26174. * Recompute normals when adding a shape
  26175. */
  26176. recomputeNormals: boolean;
  26177. /**
  26178. * This a counter ofr your own usage. It's not set by any SPS functions.
  26179. */
  26180. counter: number;
  26181. /**
  26182. * The SPS name. This name is also given to the underlying mesh.
  26183. */
  26184. name: string;
  26185. /**
  26186. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26187. */
  26188. mesh: Mesh;
  26189. /**
  26190. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26191. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26192. */
  26193. vars: any;
  26194. /**
  26195. * This array is populated when the SPS is set as 'pickable'.
  26196. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26197. * Each element of this array is an object `{idx: int, faceId: int}`.
  26198. * `idx` is the picked particle index in the `SPS.particles` array
  26199. * `faceId` is the picked face index counted within this particle.
  26200. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26201. */
  26202. pickedParticles: {
  26203. idx: number;
  26204. faceId: number;
  26205. }[];
  26206. /**
  26207. * This array is populated when `enableDepthSort` is set to true.
  26208. * Each element of this array is an instance of the class DepthSortedParticle.
  26209. */
  26210. depthSortedParticles: DepthSortedParticle[];
  26211. /**
  26212. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26213. * @hidden
  26214. */
  26215. _bSphereOnly: boolean;
  26216. /**
  26217. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26218. * @hidden
  26219. */
  26220. _bSphereRadiusFactor: number;
  26221. private _scene;
  26222. private _positions;
  26223. private _indices;
  26224. private _normals;
  26225. private _colors;
  26226. private _uvs;
  26227. private _indices32;
  26228. private _positions32;
  26229. private _normals32;
  26230. private _fixedNormal32;
  26231. private _colors32;
  26232. private _uvs32;
  26233. private _index;
  26234. private _updatable;
  26235. private _pickable;
  26236. private _isVisibilityBoxLocked;
  26237. private _alwaysVisible;
  26238. private _depthSort;
  26239. private _shapeCounter;
  26240. private _copy;
  26241. private _shape;
  26242. private _shapeUV;
  26243. private _color;
  26244. private _computeParticleColor;
  26245. private _computeParticleTexture;
  26246. private _computeParticleRotation;
  26247. private _computeParticleVertex;
  26248. private _computeBoundingBox;
  26249. private _depthSortParticles;
  26250. private _cam_axisZ;
  26251. private _cam_axisY;
  26252. private _cam_axisX;
  26253. private _axisZ;
  26254. private _camera;
  26255. private _particle;
  26256. private _camDir;
  26257. private _camInvertedPosition;
  26258. private _rotMatrix;
  26259. private _invertMatrix;
  26260. private _rotated;
  26261. private _quaternion;
  26262. private _vertex;
  26263. private _normal;
  26264. private _yaw;
  26265. private _pitch;
  26266. private _roll;
  26267. private _halfroll;
  26268. private _halfpitch;
  26269. private _halfyaw;
  26270. private _sinRoll;
  26271. private _cosRoll;
  26272. private _sinPitch;
  26273. private _cosPitch;
  26274. private _sinYaw;
  26275. private _cosYaw;
  26276. private _mustUnrotateFixedNormals;
  26277. private _minimum;
  26278. private _maximum;
  26279. private _minBbox;
  26280. private _maxBbox;
  26281. private _particlesIntersect;
  26282. private _depthSortFunction;
  26283. private _needs32Bits;
  26284. private _pivotBackTranslation;
  26285. private _scaledPivot;
  26286. private _particleHasParent;
  26287. private _parent;
  26288. /**
  26289. * Creates a SPS (Solid Particle System) object.
  26290. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26291. * @param scene (Scene) is the scene in which the SPS is added.
  26292. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26293. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26294. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26295. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26296. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26297. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26298. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26299. */
  26300. constructor(name: string, scene: Scene, options?: {
  26301. updatable?: boolean;
  26302. isPickable?: boolean;
  26303. enableDepthSort?: boolean;
  26304. particleIntersection?: boolean;
  26305. boundingSphereOnly?: boolean;
  26306. bSphereRadiusFactor?: number;
  26307. });
  26308. /**
  26309. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26310. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26311. * @returns the created mesh
  26312. */
  26313. buildMesh(): Mesh;
  26314. /**
  26315. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26316. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26317. * Thus the particles generated from `digest()` have their property `position` set yet.
  26318. * @param mesh ( Mesh ) is the mesh to be digested
  26319. * @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
  26320. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26321. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26322. * @returns the current SPS
  26323. */
  26324. digest(mesh: Mesh, options?: {
  26325. facetNb?: number;
  26326. number?: number;
  26327. delta?: number;
  26328. }): SolidParticleSystem;
  26329. private _unrotateFixedNormals;
  26330. private _resetCopy;
  26331. private _meshBuilder;
  26332. private _posToShape;
  26333. private _uvsToShapeUV;
  26334. private _addParticle;
  26335. /**
  26336. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26337. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26338. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26339. * @param nb (positive integer) the number of particles to be created from this model
  26340. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26341. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26342. * @returns the number of shapes in the system
  26343. */
  26344. addShape(mesh: Mesh, nb: number, options?: {
  26345. positionFunction?: any;
  26346. vertexFunction?: any;
  26347. }): number;
  26348. private _rebuildParticle;
  26349. /**
  26350. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26351. * @returns the SPS.
  26352. */
  26353. rebuildMesh(): SolidParticleSystem;
  26354. /**
  26355. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26356. * This method calls `updateParticle()` for each particle of the SPS.
  26357. * For an animated SPS, it is usually called within the render loop.
  26358. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26359. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26360. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26361. * @returns the SPS.
  26362. */
  26363. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26364. private _quaternionRotationYPR;
  26365. private _quaternionToRotationMatrix;
  26366. /**
  26367. * Disposes the SPS.
  26368. */
  26369. dispose(): void;
  26370. /**
  26371. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26372. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26373. * @returns the SPS.
  26374. */
  26375. refreshVisibleSize(): SolidParticleSystem;
  26376. /**
  26377. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26378. * @param size the size (float) of the visibility box
  26379. * note : this doesn't lock the SPS mesh bounding box.
  26380. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26381. */
  26382. setVisibilityBox(size: number): void;
  26383. /**
  26384. * Gets whether the SPS as always visible or not
  26385. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26386. */
  26387. /**
  26388. * Sets the SPS as always visible or not
  26389. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26390. */
  26391. isAlwaysVisible: boolean;
  26392. /**
  26393. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26394. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26395. */
  26396. /**
  26397. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26398. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26399. */
  26400. isVisibilityBoxLocked: boolean;
  26401. /**
  26402. * Tells to `setParticles()` to compute the particle rotations or not.
  26403. * Default value : true. The SPS is faster when it's set to false.
  26404. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26405. */
  26406. /**
  26407. * Gets if `setParticles()` computes the particle rotations or not.
  26408. * Default value : true. The SPS is faster when it's set to false.
  26409. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26410. */
  26411. computeParticleRotation: boolean;
  26412. /**
  26413. * Tells to `setParticles()` to compute the particle colors or not.
  26414. * Default value : true. The SPS is faster when it's set to false.
  26415. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26416. */
  26417. /**
  26418. * Gets if `setParticles()` computes the particle colors or not.
  26419. * Default value : true. The SPS is faster when it's set to false.
  26420. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26421. */
  26422. computeParticleColor: boolean;
  26423. /**
  26424. * Gets if `setParticles()` computes the particle textures or not.
  26425. * Default value : true. The SPS is faster when it's set to false.
  26426. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26427. */
  26428. computeParticleTexture: boolean;
  26429. /**
  26430. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26431. * Default value : false. The SPS is faster when it's set to false.
  26432. * Note : the particle custom vertex positions aren't stored values.
  26433. */
  26434. /**
  26435. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26436. * Default value : false. The SPS is faster when it's set to false.
  26437. * Note : the particle custom vertex positions aren't stored values.
  26438. */
  26439. computeParticleVertex: boolean;
  26440. /**
  26441. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26442. */
  26443. /**
  26444. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26445. */
  26446. computeBoundingBox: boolean;
  26447. /**
  26448. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26449. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26450. * Default : `true`
  26451. */
  26452. /**
  26453. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26454. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26455. * Default : `true`
  26456. */
  26457. depthSortParticles: boolean;
  26458. /**
  26459. * This function does nothing. It may be overwritten to set all the particle first values.
  26460. * The SPS doesn't call this function, you may have to call it by your own.
  26461. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26462. */
  26463. initParticles(): void;
  26464. /**
  26465. * This function does nothing. It may be overwritten to recycle a particle.
  26466. * The SPS doesn't call this function, you may have to call it by your own.
  26467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26468. * @param particle The particle to recycle
  26469. * @returns the recycled particle
  26470. */
  26471. recycleParticle(particle: SolidParticle): SolidParticle;
  26472. /**
  26473. * Updates a particle : this function should be overwritten by the user.
  26474. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26476. * @example : just set a particle position or velocity and recycle conditions
  26477. * @param particle The particle to update
  26478. * @returns the updated particle
  26479. */
  26480. updateParticle(particle: SolidParticle): SolidParticle;
  26481. /**
  26482. * Updates a vertex of a particle : it can be overwritten by the user.
  26483. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26484. * @param particle the current particle
  26485. * @param vertex the current index of the current particle
  26486. * @param pt the index of the current vertex in the particle shape
  26487. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26488. * @example : just set a vertex particle position
  26489. * @returns the updated vertex
  26490. */
  26491. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26492. /**
  26493. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26494. * This does nothing and may be overwritten by the user.
  26495. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26496. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26497. * @param update the boolean update value actually passed to setParticles()
  26498. */
  26499. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26500. /**
  26501. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26502. * This will be passed three parameters.
  26503. * This does nothing and may be overwritten by the user.
  26504. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26505. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26506. * @param update the boolean update value actually passed to setParticles()
  26507. */
  26508. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26509. }
  26510. }
  26511. declare module BABYLON {
  26512. interface PhysicsImpostorJoint {
  26513. mainImpostor: PhysicsImpostor;
  26514. connectedImpostor: PhysicsImpostor;
  26515. joint: PhysicsJoint;
  26516. }
  26517. class PhysicsEngine {
  26518. private _physicsPlugin;
  26519. gravity: Vector3;
  26520. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  26521. setGravity(gravity: Vector3): void;
  26522. /**
  26523. * Set the time step of the physics engine.
  26524. * default is 1/60.
  26525. * To slow it down, enter 1/600 for example.
  26526. * To speed it up, 1/30
  26527. * @param {number} newTimeStep the new timestep to apply to this world.
  26528. */
  26529. setTimeStep(newTimeStep?: number): void;
  26530. /**
  26531. * Get the time step of the physics engine.
  26532. */
  26533. getTimeStep(): number;
  26534. dispose(): void;
  26535. getPhysicsPluginName(): string;
  26536. static Epsilon: number;
  26537. private _impostors;
  26538. private _joints;
  26539. /**
  26540. * Adding a new impostor for the impostor tracking.
  26541. * This will be done by the impostor itself.
  26542. * @param {PhysicsImpostor} impostor the impostor to add
  26543. */
  26544. addImpostor(impostor: PhysicsImpostor): void;
  26545. /**
  26546. * Remove an impostor from the engine.
  26547. * This impostor and its mesh will not longer be updated by the physics engine.
  26548. * @param {PhysicsImpostor} impostor the impostor to remove
  26549. */
  26550. removeImpostor(impostor: PhysicsImpostor): void;
  26551. /**
  26552. * Add a joint to the physics engine
  26553. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  26554. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  26555. * @param {PhysicsJoint} the joint that will connect both impostors.
  26556. */
  26557. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26558. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26559. /**
  26560. * Called by the scene. no need to call it.
  26561. * @hidden
  26562. */
  26563. _step(delta: number): void;
  26564. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26565. getImpostors(): Array<PhysicsImpostor>;
  26566. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26567. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26568. }
  26569. interface IPhysicsEnginePlugin {
  26570. world: any;
  26571. name: string;
  26572. setGravity(gravity: Vector3): void;
  26573. setTimeStep(timeStep: number): void;
  26574. getTimeStep(): number;
  26575. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26576. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26577. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26579. removePhysicsBody(impostor: PhysicsImpostor): void;
  26580. generateJoint(joint: PhysicsImpostorJoint): void;
  26581. removeJoint(joint: PhysicsImpostorJoint): void;
  26582. isSupported(): boolean;
  26583. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26584. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26585. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26586. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26587. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26588. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26589. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26590. getBodyMass(impostor: PhysicsImpostor): number;
  26591. getBodyFriction(impostor: PhysicsImpostor): number;
  26592. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26593. getBodyRestitution(impostor: PhysicsImpostor): number;
  26594. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26595. sleepBody(impostor: PhysicsImpostor): void;
  26596. wakeUpBody(impostor: PhysicsImpostor): void;
  26597. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26598. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26599. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26600. getRadius(impostor: PhysicsImpostor): number;
  26601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26602. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26603. dispose(): void;
  26604. }
  26605. }
  26606. declare module BABYLON {
  26607. class PhysicsHelper {
  26608. private _scene;
  26609. private _physicsEngine;
  26610. constructor(scene: Scene);
  26611. /**
  26612. * @param {Vector3} origin the origin of the explosion
  26613. * @param {number} radius the explosion radius
  26614. * @param {number} strength the explosion strength
  26615. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26616. */
  26617. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26618. /**
  26619. * @param {Vector3} origin the origin of the explosion
  26620. * @param {number} radius the explosion radius
  26621. * @param {number} strength the explosion strength
  26622. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26623. */
  26624. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26625. /**
  26626. * @param {Vector3} origin the origin of the explosion
  26627. * @param {number} radius the explosion radius
  26628. * @param {number} strength the explosion strength
  26629. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26630. */
  26631. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  26632. /**
  26633. * @param {Vector3} origin the origin of the updraft
  26634. * @param {number} radius the radius of the updraft
  26635. * @param {number} strength the strength of the updraft
  26636. * @param {number} height the height of the updraft
  26637. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  26638. */
  26639. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  26640. /**
  26641. * @param {Vector3} origin the of the vortex
  26642. * @param {number} radius the radius of the vortex
  26643. * @param {number} strength the strength of the vortex
  26644. * @param {number} height the height of the vortex
  26645. */
  26646. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  26647. }
  26648. /***** Radial explosion *****/
  26649. class PhysicsRadialExplosionEvent {
  26650. private _scene;
  26651. private _sphere;
  26652. private _sphereOptions;
  26653. private _rays;
  26654. private _dataFetched;
  26655. constructor(scene: Scene);
  26656. /**
  26657. * Returns the data related to the radial explosion event (sphere & rays).
  26658. * @returns {PhysicsRadialExplosionEventData}
  26659. */
  26660. getData(): PhysicsRadialExplosionEventData;
  26661. /**
  26662. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26663. * @param impostor
  26664. * @param {Vector3} origin the origin of the explosion
  26665. * @param {number} radius the explosion radius
  26666. * @param {number} strength the explosion strength
  26667. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26668. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26669. */
  26670. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26671. /**
  26672. * Disposes the sphere.
  26673. * @param {bolean} force
  26674. */
  26675. dispose(force?: boolean): void;
  26676. /*** Helpers ***/
  26677. private _prepareSphere;
  26678. private _intersectsWithSphere;
  26679. }
  26680. /***** Gravitational Field *****/
  26681. class PhysicsGravitationalFieldEvent {
  26682. private _physicsHelper;
  26683. private _scene;
  26684. private _origin;
  26685. private _radius;
  26686. private _strength;
  26687. private _falloff;
  26688. private _tickCallback;
  26689. private _sphere;
  26690. private _dataFetched;
  26691. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26692. /**
  26693. * Returns the data related to the gravitational field event (sphere).
  26694. * @returns {PhysicsGravitationalFieldEventData}
  26695. */
  26696. getData(): PhysicsGravitationalFieldEventData;
  26697. /**
  26698. * Enables the gravitational field.
  26699. */
  26700. enable(): void;
  26701. /**
  26702. * Disables the gravitational field.
  26703. */
  26704. disable(): void;
  26705. /**
  26706. * Disposes the sphere.
  26707. * @param {bolean} force
  26708. */
  26709. dispose(force?: boolean): void;
  26710. private _tick;
  26711. }
  26712. /***** Updraft *****/
  26713. class PhysicsUpdraftEvent {
  26714. private _scene;
  26715. private _origin;
  26716. private _radius;
  26717. private _strength;
  26718. private _height;
  26719. private _updraftMode;
  26720. private _physicsEngine;
  26721. private _originTop;
  26722. private _originDirection;
  26723. private _tickCallback;
  26724. private _cylinder;
  26725. private _cylinderPosition;
  26726. private _dataFetched;
  26727. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26728. /**
  26729. * Returns the data related to the updraft event (cylinder).
  26730. * @returns {PhysicsUpdraftEventData}
  26731. */
  26732. getData(): PhysicsUpdraftEventData;
  26733. /**
  26734. * Enables the updraft.
  26735. */
  26736. enable(): void;
  26737. /**
  26738. * Disables the cortex.
  26739. */
  26740. disable(): void;
  26741. /**
  26742. * Disposes the sphere.
  26743. * @param {bolean} force
  26744. */
  26745. dispose(force?: boolean): void;
  26746. private getImpostorForceAndContactPoint;
  26747. private _tick;
  26748. /*** Helpers ***/
  26749. private _prepareCylinder;
  26750. private _intersectsWithCylinder;
  26751. }
  26752. /***** Vortex *****/
  26753. class PhysicsVortexEvent {
  26754. private _scene;
  26755. private _origin;
  26756. private _radius;
  26757. private _strength;
  26758. private _height;
  26759. private _physicsEngine;
  26760. private _originTop;
  26761. private _centripetalForceThreshold;
  26762. private _updraftMultiplier;
  26763. private _tickCallback;
  26764. private _cylinder;
  26765. private _cylinderPosition;
  26766. private _dataFetched;
  26767. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26768. /**
  26769. * Returns the data related to the vortex event (cylinder).
  26770. * @returns {PhysicsVortexEventData}
  26771. */
  26772. getData(): PhysicsVortexEventData;
  26773. /**
  26774. * Enables the vortex.
  26775. */
  26776. enable(): void;
  26777. /**
  26778. * Disables the cortex.
  26779. */
  26780. disable(): void;
  26781. /**
  26782. * Disposes the sphere.
  26783. * @param {bolean} force
  26784. */
  26785. dispose(force?: boolean): void;
  26786. private getImpostorForceAndContactPoint;
  26787. private _tick;
  26788. /*** Helpers ***/
  26789. private _prepareCylinder;
  26790. private _intersectsWithCylinder;
  26791. }
  26792. /***** Enums *****/
  26793. /**
  26794. * The strenght of the force in correspondence to the distance of the affected object
  26795. */
  26796. enum PhysicsRadialImpulseFalloff {
  26797. /** Defines that impulse is constant in strength across it's whole radius */
  26798. Constant = 0,
  26799. /** DEfines that impulse gets weaker if it's further from the origin */
  26800. Linear = 1
  26801. }
  26802. /**
  26803. * The strenght of the force in correspondence to the distance of the affected object
  26804. */
  26805. enum PhysicsUpdraftMode {
  26806. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26807. Center = 0,
  26808. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  26809. Perpendicular = 1
  26810. }
  26811. /***** Data interfaces *****/
  26812. interface PhysicsForceAndContactPoint {
  26813. force: Vector3;
  26814. contactPoint: Vector3;
  26815. }
  26816. interface PhysicsRadialExplosionEventData {
  26817. sphere: Mesh;
  26818. rays: Array<Ray>;
  26819. }
  26820. interface PhysicsGravitationalFieldEventData {
  26821. sphere: Mesh;
  26822. }
  26823. interface PhysicsUpdraftEventData {
  26824. cylinder: Mesh;
  26825. }
  26826. interface PhysicsVortexEventData {
  26827. cylinder: Mesh;
  26828. }
  26829. }
  26830. declare module BABYLON {
  26831. interface PhysicsImpostorParameters {
  26832. mass: number;
  26833. friction?: number;
  26834. restitution?: number;
  26835. nativeOptions?: any;
  26836. ignoreParent?: boolean;
  26837. disableBidirectionalTransformation?: boolean;
  26838. }
  26839. interface IPhysicsEnabledObject {
  26840. position: Vector3;
  26841. rotationQuaternion: Nullable<Quaternion>;
  26842. scaling: Vector3;
  26843. rotation?: Vector3;
  26844. parent?: any;
  26845. getBoundingInfo(): BoundingInfo;
  26846. computeWorldMatrix(force: boolean): Matrix;
  26847. getWorldMatrix?(): Matrix;
  26848. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26849. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26850. getIndices?(): Nullable<IndicesArray>;
  26851. getScene?(): Scene;
  26852. getAbsolutePosition(): Vector3;
  26853. getAbsolutePivotPoint(): Vector3;
  26854. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26855. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26856. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26857. getClassName(): string;
  26858. }
  26859. class PhysicsImpostor {
  26860. object: IPhysicsEnabledObject;
  26861. type: number;
  26862. private _options;
  26863. private _scene?;
  26864. static DEFAULT_OBJECT_SIZE: Vector3;
  26865. static IDENTITY_QUATERNION: Quaternion;
  26866. private _physicsEngine;
  26867. private _physicsBody;
  26868. private _bodyUpdateRequired;
  26869. private _onBeforePhysicsStepCallbacks;
  26870. private _onAfterPhysicsStepCallbacks;
  26871. private _onPhysicsCollideCallbacks;
  26872. private _deltaPosition;
  26873. private _deltaRotation;
  26874. private _deltaRotationConjugated;
  26875. private _parent;
  26876. private _isDisposed;
  26877. private static _tmpVecs;
  26878. private static _tmpQuat;
  26879. readonly isDisposed: boolean;
  26880. mass: number;
  26881. friction: number;
  26882. restitution: number;
  26883. uniqueId: number;
  26884. private _joints;
  26885. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26886. /**
  26887. * This function will completly initialize this impostor.
  26888. * It will create a new body - but only if this mesh has no parent.
  26889. * If it has, this impostor will not be used other than to define the impostor
  26890. * of the child mesh.
  26891. * @hidden
  26892. */
  26893. _init(): void;
  26894. private _getPhysicsParent;
  26895. /**
  26896. * Should a new body be generated.
  26897. */
  26898. isBodyInitRequired(): boolean;
  26899. setScalingUpdated(updated: boolean): void;
  26900. /**
  26901. * Force a regeneration of this or the parent's impostor's body.
  26902. * Use under cautious - This will remove all joints already implemented.
  26903. */
  26904. forceUpdate(): void;
  26905. /**
  26906. * Gets the body that holds this impostor. Either its own, or its parent.
  26907. */
  26908. /**
  26909. * Set the physics body. Used mainly by the physics engine/plugin
  26910. */
  26911. physicsBody: any;
  26912. parent: Nullable<PhysicsImpostor>;
  26913. resetUpdateFlags(): void;
  26914. getObjectExtendSize(): Vector3;
  26915. getObjectCenter(): Vector3;
  26916. /**
  26917. * Get a specific parametes from the options parameter.
  26918. */
  26919. getParam(paramName: string): any;
  26920. /**
  26921. * Sets a specific parameter in the options given to the physics plugin
  26922. */
  26923. setParam(paramName: string, value: number): void;
  26924. /**
  26925. * Specifically change the body's mass option. Won't recreate the physics body object
  26926. */
  26927. setMass(mass: number): void;
  26928. getLinearVelocity(): Nullable<Vector3>;
  26929. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26930. getAngularVelocity(): Nullable<Vector3>;
  26931. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26932. /**
  26933. * Execute a function with the physics plugin native code.
  26934. * Provide a function the will have two variables - the world object and the physics body object.
  26935. */
  26936. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26937. /**
  26938. * Register a function that will be executed before the physics world is stepping forward.
  26939. */
  26940. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26941. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26942. /**
  26943. * Register a function that will be executed after the physics step
  26944. */
  26945. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26946. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26947. /**
  26948. * register a function that will be executed when this impostor collides against a different body.
  26949. */
  26950. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26951. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26952. private _tmpQuat;
  26953. private _tmpQuat2;
  26954. getParentsRotation(): Quaternion;
  26955. /**
  26956. * this function is executed by the physics engine.
  26957. */
  26958. beforeStep: () => void;
  26959. /**
  26960. * this function is executed by the physics engine.
  26961. */
  26962. afterStep: () => void;
  26963. /**
  26964. * Legacy collision detection event support
  26965. */
  26966. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26967. onCollide: (e: {
  26968. body: any;
  26969. }) => void;
  26970. /**
  26971. * Apply a force
  26972. */
  26973. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26974. /**
  26975. * Apply an impulse
  26976. */
  26977. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26978. /**
  26979. * A help function to create a joint.
  26980. */
  26981. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26982. /**
  26983. * Add a joint to this impostor with a different impostor.
  26984. */
  26985. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26986. /**
  26987. * Will keep this body still, in a sleep mode.
  26988. */
  26989. sleep(): PhysicsImpostor;
  26990. /**
  26991. * Wake the body up.
  26992. */
  26993. wakeUp(): PhysicsImpostor;
  26994. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26995. dispose(): void;
  26996. setDeltaPosition(position: Vector3): void;
  26997. setDeltaRotation(rotation: Quaternion): void;
  26998. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26999. getRadius(): number;
  27000. /**
  27001. * Sync a bone with this impostor
  27002. * @param bone The bone to sync to the impostor.
  27003. * @param boneMesh The mesh that the bone is influencing.
  27004. * @param jointPivot The pivot of the joint / bone in local space.
  27005. * @param distToJoint Optional distance from the impostor to the joint.
  27006. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27007. */
  27008. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27009. /**
  27010. * Sync impostor to a bone
  27011. * @param bone The bone that the impostor will be synced to.
  27012. * @param boneMesh The mesh that the bone is influencing.
  27013. * @param jointPivot The pivot of the joint / bone in local space.
  27014. * @param distToJoint Optional distance from the impostor to the joint.
  27015. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27016. * @param boneAxis Optional vector3 axis the bone is aligned with
  27017. */
  27018. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27019. static NoImpostor: number;
  27020. static SphereImpostor: number;
  27021. static BoxImpostor: number;
  27022. static PlaneImpostor: number;
  27023. static MeshImpostor: number;
  27024. static CylinderImpostor: number;
  27025. static ParticleImpostor: number;
  27026. static HeightmapImpostor: number;
  27027. }
  27028. }
  27029. declare module BABYLON {
  27030. interface PhysicsJointData {
  27031. mainPivot?: Vector3;
  27032. connectedPivot?: Vector3;
  27033. mainAxis?: Vector3;
  27034. connectedAxis?: Vector3;
  27035. collision?: boolean;
  27036. nativeParams?: any;
  27037. }
  27038. /**
  27039. * This is a holder class for the physics joint created by the physics plugin.
  27040. * It holds a set of functions to control the underlying joint.
  27041. */
  27042. class PhysicsJoint {
  27043. type: number;
  27044. jointData: PhysicsJointData;
  27045. private _physicsJoint;
  27046. protected _physicsPlugin: IPhysicsEnginePlugin;
  27047. constructor(type: number, jointData: PhysicsJointData);
  27048. physicsJoint: any;
  27049. physicsPlugin: IPhysicsEnginePlugin;
  27050. /**
  27051. * Execute a function that is physics-plugin specific.
  27052. * @param {Function} func the function that will be executed.
  27053. * It accepts two parameters: the physics world and the physics joint.
  27054. */
  27055. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27056. static DistanceJoint: number;
  27057. static HingeJoint: number;
  27058. static BallAndSocketJoint: number;
  27059. static WheelJoint: number;
  27060. static SliderJoint: number;
  27061. static PrismaticJoint: number;
  27062. static UniversalJoint: number;
  27063. static Hinge2Joint: number;
  27064. static PointToPointJoint: number;
  27065. static SpringJoint: number;
  27066. static LockJoint: number;
  27067. }
  27068. /**
  27069. * A class representing a physics distance joint.
  27070. */
  27071. class DistanceJoint extends PhysicsJoint {
  27072. constructor(jointData: DistanceJointData);
  27073. /**
  27074. * Update the predefined distance.
  27075. */
  27076. updateDistance(maxDistance: number, minDistance?: number): void;
  27077. }
  27078. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27079. constructor(type: number, jointData: PhysicsJointData);
  27080. /**
  27081. * Set the motor values.
  27082. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27083. * @param {number} force the force to apply
  27084. * @param {number} maxForce max force for this motor.
  27085. */
  27086. setMotor(force?: number, maxForce?: number): void;
  27087. /**
  27088. * Set the motor's limits.
  27089. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27090. */
  27091. setLimit(upperLimit: number, lowerLimit?: number): void;
  27092. }
  27093. /**
  27094. * This class represents a single hinge physics joint
  27095. */
  27096. class HingeJoint extends MotorEnabledJoint {
  27097. constructor(jointData: PhysicsJointData);
  27098. /**
  27099. * Set the motor values.
  27100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27101. * @param {number} force the force to apply
  27102. * @param {number} maxForce max force for this motor.
  27103. */
  27104. setMotor(force?: number, maxForce?: number): void;
  27105. /**
  27106. * Set the motor's limits.
  27107. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27108. */
  27109. setLimit(upperLimit: number, lowerLimit?: number): void;
  27110. }
  27111. /**
  27112. * This class represents a dual hinge physics joint (same as wheel joint)
  27113. */
  27114. class Hinge2Joint extends MotorEnabledJoint {
  27115. constructor(jointData: PhysicsJointData);
  27116. /**
  27117. * Set the motor values.
  27118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27119. * @param {number} force the force to apply
  27120. * @param {number} maxForce max force for this motor.
  27121. * @param {motorIndex} the motor's index, 0 or 1.
  27122. */
  27123. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27124. /**
  27125. * Set the motor limits.
  27126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27127. * @param {number} upperLimit the upper limit
  27128. * @param {number} lowerLimit lower limit
  27129. * @param {motorIndex} the motor's index, 0 or 1.
  27130. */
  27131. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27132. }
  27133. interface IMotorEnabledJoint {
  27134. physicsJoint: any;
  27135. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27136. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27137. }
  27138. interface DistanceJointData extends PhysicsJointData {
  27139. maxDistance: number;
  27140. }
  27141. interface SpringJointData extends PhysicsJointData {
  27142. length: number;
  27143. stiffness: number;
  27144. damping: number;
  27145. }
  27146. }
  27147. declare module BABYLON {
  27148. /**
  27149. * Class used to generate realtime reflection / refraction cube textures
  27150. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  27151. */
  27152. class ReflectionProbe {
  27153. /** defines the name of the probe */
  27154. name: string;
  27155. private _scene;
  27156. private _renderTargetTexture;
  27157. private _projectionMatrix;
  27158. private _viewMatrix;
  27159. private _target;
  27160. private _add;
  27161. private _attachedMesh;
  27162. private _invertYAxis;
  27163. /** Gets or sets probe position (center of the cube map) */
  27164. position: Vector3;
  27165. /**
  27166. * Creates a new reflection probe
  27167. * @param name defines the name of the probe
  27168. * @param size defines the texture resolution (for each face)
  27169. * @param scene defines the hosting scene
  27170. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  27171. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  27172. */
  27173. constructor(
  27174. /** defines the name of the probe */
  27175. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  27176. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  27177. samples: number;
  27178. /** Gets or sets the refresh rate to use (on every frame by default) */
  27179. refreshRate: number;
  27180. /**
  27181. * Gets the hosting scene
  27182. * @returns a Scene
  27183. */
  27184. getScene(): Scene;
  27185. /** Gets the internal CubeTexture used to render to */
  27186. readonly cubeTexture: RenderTargetTexture;
  27187. /** Gets the list of meshes to render */
  27188. readonly renderList: Nullable<AbstractMesh[]>;
  27189. /**
  27190. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  27191. * @param mesh defines the mesh to attach to
  27192. */
  27193. attachToMesh(mesh: AbstractMesh): void;
  27194. /**
  27195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  27196. * @param renderingGroupId The rendering group id corresponding to its index
  27197. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27198. */
  27199. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27200. /**
  27201. * Clean all associated resources
  27202. */
  27203. dispose(): void;
  27204. }
  27205. }
  27206. declare module BABYLON {
  27207. /**
  27208. * Postprocess used to generate anaglyphic rendering
  27209. */
  27210. class AnaglyphPostProcess extends PostProcess {
  27211. private _passedProcess;
  27212. /**
  27213. * Creates a new AnaglyphPostProcess
  27214. * @param name defines postprocess name
  27215. * @param options defines creation options or target ratio scale
  27216. * @param rigCameras defines cameras using this postprocess
  27217. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27218. * @param engine defines hosting engine
  27219. * @param reusable defines if the postprocess will be reused multiple times per frame
  27220. */
  27221. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27222. }
  27223. }
  27224. declare module BABYLON {
  27225. class BlackAndWhitePostProcess extends PostProcess {
  27226. degree: number;
  27227. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27228. }
  27229. }
  27230. declare module BABYLON {
  27231. /**
  27232. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27233. */
  27234. class BloomEffect extends PostProcessRenderEffect {
  27235. private bloomScale;
  27236. /**
  27237. * @hidden Internal
  27238. */
  27239. _effects: Array<PostProcess>;
  27240. /**
  27241. * @hidden Internal
  27242. */
  27243. _downscale: ExtractHighlightsPostProcess;
  27244. private _blurX;
  27245. private _blurY;
  27246. private _merge;
  27247. /**
  27248. * The luminance threshold to find bright areas of the image to bloom.
  27249. */
  27250. threshold: number;
  27251. /**
  27252. * The strength of the bloom.
  27253. */
  27254. weight: number;
  27255. /**
  27256. * Specifies the size of the bloom blur kernel, relative to the final output size
  27257. */
  27258. kernel: number;
  27259. /**
  27260. * Creates a new instance of @see BloomEffect
  27261. * @param scene The scene the effect belongs to.
  27262. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27263. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27264. * @param bloomWeight The the strength of bloom.
  27265. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27266. * @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)
  27267. */
  27268. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27269. /**
  27270. * Disposes each of the internal effects for a given camera.
  27271. * @param camera The camera to dispose the effect on.
  27272. */
  27273. disposeEffects(camera: Camera): void;
  27274. /**
  27275. * @hidden Internal
  27276. */
  27277. _updateEffects(): void;
  27278. /**
  27279. * Internal
  27280. * @returns if all the contained post processes are ready.
  27281. * @hidden
  27282. */
  27283. _isReady(): boolean;
  27284. }
  27285. }
  27286. declare module BABYLON {
  27287. /**
  27288. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27289. */
  27290. class BloomMergePostProcess extends PostProcess {
  27291. /** Weight of the bloom to be added to the original input. */
  27292. weight: number;
  27293. /**
  27294. * Creates a new instance of @see BloomMergePostProcess
  27295. * @param name The name of the effect.
  27296. * @param originalFromInput Post process which's input will be used for the merge.
  27297. * @param blurred Blurred highlights post process which's output will be used.
  27298. * @param weight Weight of the bloom to be added to the original input.
  27299. * @param options The required width/height ratio to downsize to before computing the render pass.
  27300. * @param camera The camera to apply the render pass to.
  27301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27302. * @param engine The engine which the post process will be applied. (default: current engine)
  27303. * @param reusable If the post process can be reused on the same frame. (default: false)
  27304. * @param textureType Type of textures used when performing the post process. (default: 0)
  27305. * @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)
  27306. */
  27307. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27308. /** Weight of the bloom to be added to the original input. */
  27309. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27310. }
  27311. }
  27312. declare module BABYLON {
  27313. /**
  27314. * The Blur Post Process which blurs an image based on a kernel and direction.
  27315. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27316. */
  27317. class BlurPostProcess extends PostProcess {
  27318. /** The direction in which to blur the image. */
  27319. direction: Vector2;
  27320. private blockCompilation;
  27321. protected _kernel: number;
  27322. protected _idealKernel: number;
  27323. protected _packedFloat: boolean;
  27324. private _staticDefines;
  27325. /**
  27326. * Sets the length in pixels of the blur sample region
  27327. */
  27328. /**
  27329. * Gets the length in pixels of the blur sample region
  27330. */
  27331. kernel: number;
  27332. /**
  27333. * Sets wether or not the blur needs to unpack/repack floats
  27334. */
  27335. /**
  27336. * Gets wether or not the blur is unpacking/repacking floats
  27337. */
  27338. packedFloat: boolean;
  27339. /**
  27340. * Creates a new instance BlurPostProcess
  27341. * @param name The name of the effect.
  27342. * @param direction The direction in which to blur the image.
  27343. * @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.
  27344. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27345. * @param camera The camera to apply the render pass to.
  27346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27347. * @param engine The engine which the post process will be applied. (default: current engine)
  27348. * @param reusable If the post process can be reused on the same frame. (default: false)
  27349. * @param textureType Type of textures used when performing the post process. (default: 0)
  27350. * @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)
  27351. */
  27352. constructor(name: string,
  27353. /** The direction in which to blur the image. */
  27354. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27355. /**
  27356. * Updates the effect with the current post process compile time values and recompiles the shader.
  27357. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27358. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27359. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27360. * @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
  27361. * @param onCompiled Called when the shader has been compiled.
  27362. * @param onError Called if there is an error when compiling a shader.
  27363. */
  27364. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27365. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27366. /**
  27367. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27368. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27369. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27370. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27371. * The gaps between physical kernels are compensated for in the weighting of the samples
  27372. * @param idealKernel Ideal blur kernel.
  27373. * @return Nearest best kernel.
  27374. */
  27375. protected _nearestBestKernel(idealKernel: number): number;
  27376. /**
  27377. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27378. * @param x The point on the Gaussian distribution to sample.
  27379. * @return the value of the Gaussian function at x.
  27380. */
  27381. protected _gaussianWeight(x: number): number;
  27382. /**
  27383. * Generates a string that can be used as a floating point number in GLSL.
  27384. * @param x Value to print.
  27385. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27386. * @return GLSL float string.
  27387. */
  27388. protected _glslFloat(x: number, decimalFigures?: number): string;
  27389. }
  27390. }
  27391. declare module BABYLON {
  27392. /**
  27393. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27394. */
  27395. class ChromaticAberrationPostProcess extends PostProcess {
  27396. /**
  27397. * The amount of seperation of rgb channels (default: 30)
  27398. */
  27399. aberrationAmount: number;
  27400. /**
  27401. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27402. */
  27403. radialIntensity: number;
  27404. /**
  27405. * 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))
  27406. */
  27407. direction: Vector2;
  27408. /**
  27409. * 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))
  27410. */
  27411. centerPosition: Vector2;
  27412. /**
  27413. * Creates a new instance ChromaticAberrationPostProcess
  27414. * @param name The name of the effect.
  27415. * @param screenWidth The width of the screen to apply the effect on.
  27416. * @param screenHeight The height of the screen to apply the effect on.
  27417. * @param options The required width/height ratio to downsize to before computing the render pass.
  27418. * @param camera The camera to apply the render pass to.
  27419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27420. * @param engine The engine which the post process will be applied. (default: current engine)
  27421. * @param reusable If the post process can be reused on the same frame. (default: false)
  27422. * @param textureType Type of textures used when performing the post process. (default: 0)
  27423. * @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)
  27424. */
  27425. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27426. }
  27427. }
  27428. declare module BABYLON {
  27429. /**
  27430. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27431. */
  27432. class CircleOfConfusionPostProcess extends PostProcess {
  27433. /**
  27434. * 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.
  27435. */
  27436. lensSize: number;
  27437. /**
  27438. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27439. */
  27440. fStop: number;
  27441. /**
  27442. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27443. */
  27444. focusDistance: number;
  27445. /**
  27446. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27447. */
  27448. focalLength: number;
  27449. private _depthTexture;
  27450. /**
  27451. * Creates a new instance CircleOfConfusionPostProcess
  27452. * @param name The name of the effect.
  27453. * @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.
  27454. * @param options The required width/height ratio to downsize to before computing the render pass.
  27455. * @param camera The camera to apply the render pass to.
  27456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27457. * @param engine The engine which the post process will be applied. (default: current engine)
  27458. * @param reusable If the post process can be reused on the same frame. (default: false)
  27459. * @param textureType Type of textures used when performing the post process. (default: 0)
  27460. * @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)
  27461. */
  27462. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27463. /**
  27464. * 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.
  27465. */
  27466. depthTexture: RenderTargetTexture;
  27467. }
  27468. }
  27469. declare module BABYLON {
  27470. class ColorCorrectionPostProcess extends PostProcess {
  27471. private _colorTableTexture;
  27472. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27473. }
  27474. }
  27475. declare module BABYLON {
  27476. /**
  27477. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27478. * input texture to perform effects such as edge detection or sharpening
  27479. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27480. */
  27481. class ConvolutionPostProcess extends PostProcess {
  27482. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27483. kernel: number[];
  27484. /**
  27485. * Creates a new instance ConvolutionPostProcess
  27486. * @param name The name of the effect.
  27487. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27488. * @param options The required width/height ratio to downsize to before computing the render pass.
  27489. * @param camera The camera to apply the render pass to.
  27490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27491. * @param engine The engine which the post process will be applied. (default: current engine)
  27492. * @param reusable If the post process can be reused on the same frame. (default: false)
  27493. * @param textureType Type of textures used when performing the post process. (default: 0)
  27494. */
  27495. constructor(name: string,
  27496. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27497. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27498. /**
  27499. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27500. */
  27501. static EdgeDetect0Kernel: number[];
  27502. /**
  27503. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27504. */
  27505. static EdgeDetect1Kernel: number[];
  27506. /**
  27507. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27508. */
  27509. static EdgeDetect2Kernel: number[];
  27510. /**
  27511. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27512. */
  27513. static SharpenKernel: number[];
  27514. /**
  27515. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27516. */
  27517. static EmbossKernel: number[];
  27518. /**
  27519. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27520. */
  27521. static GaussianKernel: number[];
  27522. }
  27523. }
  27524. declare module BABYLON {
  27525. /**
  27526. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27527. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27528. * based on samples that have a large difference in distance than the center pixel.
  27529. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27530. */
  27531. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27532. direction: Vector2;
  27533. /**
  27534. * Creates a new instance CircleOfConfusionPostProcess
  27535. * @param name The name of the effect.
  27536. * @param scene The scene the effect belongs to.
  27537. * @param direction The direction the blur should be applied.
  27538. * @param kernel The size of the kernel used to blur.
  27539. * @param options The required width/height ratio to downsize to before computing the render pass.
  27540. * @param camera The camera to apply the render pass to.
  27541. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27542. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27544. * @param engine The engine which the post process will be applied. (default: current engine)
  27545. * @param reusable If the post process can be reused on the same frame. (default: false)
  27546. * @param textureType Type of textures used when performing the post process. (default: 0)
  27547. * @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)
  27548. */
  27549. 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);
  27550. }
  27551. }
  27552. declare module BABYLON {
  27553. /**
  27554. * Specifies the level of max blur that should be applied when using the depth of field effect
  27555. */
  27556. enum DepthOfFieldEffectBlurLevel {
  27557. /**
  27558. * Subtle blur
  27559. */
  27560. Low = 0,
  27561. /**
  27562. * Medium blur
  27563. */
  27564. Medium = 1,
  27565. /**
  27566. * Large blur
  27567. */
  27568. High = 2
  27569. }
  27570. /**
  27571. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27572. */
  27573. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27574. private _circleOfConfusion;
  27575. /**
  27576. * @hidden Internal, blurs from high to low
  27577. */
  27578. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27579. private _depthOfFieldBlurY;
  27580. private _dofMerge;
  27581. /**
  27582. * @hidden Internal post processes in depth of field effect
  27583. */
  27584. _effects: Array<PostProcess>;
  27585. /**
  27586. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27587. */
  27588. focalLength: number;
  27589. /**
  27590. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27591. */
  27592. fStop: number;
  27593. /**
  27594. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27595. */
  27596. focusDistance: number;
  27597. /**
  27598. * 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.
  27599. */
  27600. lensSize: number;
  27601. /**
  27602. * Creates a new instance DepthOfFieldEffect
  27603. * @param scene The scene the effect belongs to.
  27604. * @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.
  27605. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27606. * @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)
  27607. */
  27608. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27609. /**
  27610. * 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.
  27611. */
  27612. depthTexture: RenderTargetTexture;
  27613. /**
  27614. * Disposes each of the internal effects for a given camera.
  27615. * @param camera The camera to dispose the effect on.
  27616. */
  27617. disposeEffects(camera: Camera): void;
  27618. /**
  27619. * @hidden Internal
  27620. */
  27621. _updateEffects(): void;
  27622. /**
  27623. * Internal
  27624. * @returns if all the contained post processes are ready.
  27625. * @hidden
  27626. */
  27627. _isReady(): boolean;
  27628. }
  27629. }
  27630. declare module BABYLON {
  27631. /**
  27632. * Options to be set when merging outputs from the default pipeline.
  27633. */
  27634. class DepthOfFieldMergePostProcessOptions {
  27635. /**
  27636. * The original image to merge on top of
  27637. */
  27638. originalFromInput: PostProcess;
  27639. /**
  27640. * Parameters to perform the merge of the depth of field effect
  27641. */
  27642. depthOfField?: {
  27643. circleOfConfusion: PostProcess;
  27644. blurSteps: Array<PostProcess>;
  27645. };
  27646. /**
  27647. * Parameters to perform the merge of bloom effect
  27648. */
  27649. bloom?: {
  27650. blurred: PostProcess;
  27651. weight: number;
  27652. };
  27653. }
  27654. /**
  27655. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27656. */
  27657. class DepthOfFieldMergePostProcess extends PostProcess {
  27658. private blurSteps;
  27659. /**
  27660. * Creates a new instance of DepthOfFieldMergePostProcess
  27661. * @param name The name of the effect.
  27662. * @param originalFromInput Post process which's input will be used for the merge.
  27663. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27664. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27665. * @param options The required width/height ratio to downsize to before computing the render pass.
  27666. * @param camera The camera to apply the render pass to.
  27667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27668. * @param engine The engine which the post process will be applied. (default: current engine)
  27669. * @param reusable If the post process can be reused on the same frame. (default: false)
  27670. * @param textureType Type of textures used when performing the post process. (default: 0)
  27671. * @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)
  27672. */
  27673. 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);
  27674. /**
  27675. * Updates the effect with the current post process compile time values and recompiles the shader.
  27676. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27677. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27678. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27679. * @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
  27680. * @param onCompiled Called when the shader has been compiled.
  27681. * @param onError Called if there is an error when compiling a shader.
  27682. */
  27683. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27684. }
  27685. }
  27686. declare module BABYLON {
  27687. class DisplayPassPostProcess extends PostProcess {
  27688. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27689. }
  27690. }
  27691. declare module BABYLON {
  27692. /**
  27693. * 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.
  27694. */
  27695. class ExtractHighlightsPostProcess extends PostProcess {
  27696. /**
  27697. * The luminance threshold, pixels below this value will be set to black.
  27698. */
  27699. threshold: number;
  27700. /** @hidden */
  27701. _exposure: number;
  27702. /**
  27703. * Post process which has the input texture to be used when performing highlight extraction
  27704. * @hidden
  27705. */
  27706. _inputPostProcess: Nullable<PostProcess>;
  27707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27708. }
  27709. }
  27710. declare module BABYLON {
  27711. class FilterPostProcess extends PostProcess {
  27712. kernelMatrix: Matrix;
  27713. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27714. }
  27715. }
  27716. declare module BABYLON {
  27717. class FxaaPostProcess extends PostProcess {
  27718. texelWidth: number;
  27719. texelHeight: number;
  27720. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27721. private _getDefines;
  27722. }
  27723. }
  27724. declare module BABYLON {
  27725. /**
  27726. * The GrainPostProcess adds noise to the image at mid luminance levels
  27727. */
  27728. class GrainPostProcess extends PostProcess {
  27729. /**
  27730. * The intensity of the grain added (default: 30)
  27731. */
  27732. intensity: number;
  27733. /**
  27734. * If the grain should be randomized on every frame
  27735. */
  27736. animated: boolean;
  27737. /**
  27738. * Creates a new instance of @see GrainPostProcess
  27739. * @param name The name of the effect.
  27740. * @param options The required width/height ratio to downsize to before computing the render pass.
  27741. * @param camera The camera to apply the render pass to.
  27742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27743. * @param engine The engine which the post process will be applied. (default: current engine)
  27744. * @param reusable If the post process can be reused on the same frame. (default: false)
  27745. * @param textureType Type of textures used when performing the post process. (default: 0)
  27746. * @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)
  27747. */
  27748. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27749. }
  27750. }
  27751. declare module BABYLON {
  27752. class HighlightsPostProcess extends PostProcess {
  27753. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27754. }
  27755. }
  27756. declare module BABYLON {
  27757. class ImageProcessingPostProcess extends PostProcess {
  27758. /**
  27759. * Default configuration related to image processing available in the PBR Material.
  27760. */
  27761. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27762. /**
  27763. * Gets the image processing configuration used either in this material.
  27764. */
  27765. /**
  27766. * Sets the Default image processing configuration used either in the this material.
  27767. *
  27768. * If sets to null, the scene one is in use.
  27769. */
  27770. imageProcessingConfiguration: ImageProcessingConfiguration;
  27771. /**
  27772. * Keep track of the image processing observer to allow dispose and replace.
  27773. */
  27774. private _imageProcessingObserver;
  27775. /**
  27776. * Attaches a new image processing configuration to the PBR Material.
  27777. * @param configuration
  27778. */
  27779. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27780. /**
  27781. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27782. */
  27783. /**
  27784. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27785. */
  27786. colorCurves: Nullable<ColorCurves>;
  27787. /**
  27788. * Gets wether the color curves effect is enabled.
  27789. */
  27790. /**
  27791. * Sets wether the color curves effect is enabled.
  27792. */
  27793. colorCurvesEnabled: boolean;
  27794. /**
  27795. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27796. */
  27797. /**
  27798. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27799. */
  27800. colorGradingTexture: Nullable<BaseTexture>;
  27801. /**
  27802. * Gets wether the color grading effect is enabled.
  27803. */
  27804. /**
  27805. * Gets wether the color grading effect is enabled.
  27806. */
  27807. colorGradingEnabled: boolean;
  27808. /**
  27809. * Gets exposure used in the effect.
  27810. */
  27811. /**
  27812. * Sets exposure used in the effect.
  27813. */
  27814. exposure: number;
  27815. /**
  27816. * Gets wether tonemapping is enabled or not.
  27817. */
  27818. /**
  27819. * Sets wether tonemapping is enabled or not
  27820. */
  27821. toneMappingEnabled: boolean;
  27822. /**
  27823. * Gets contrast used in the effect.
  27824. */
  27825. /**
  27826. * Sets contrast used in the effect.
  27827. */
  27828. contrast: number;
  27829. /**
  27830. * Gets Vignette stretch size.
  27831. */
  27832. /**
  27833. * Sets Vignette stretch size.
  27834. */
  27835. vignetteStretch: number;
  27836. /**
  27837. * Gets Vignette centre X Offset.
  27838. */
  27839. /**
  27840. * Sets Vignette centre X Offset.
  27841. */
  27842. vignetteCentreX: number;
  27843. /**
  27844. * Gets Vignette centre Y Offset.
  27845. */
  27846. /**
  27847. * Sets Vignette centre Y Offset.
  27848. */
  27849. vignetteCentreY: number;
  27850. /**
  27851. * Gets Vignette weight or intensity of the vignette effect.
  27852. */
  27853. /**
  27854. * Sets Vignette weight or intensity of the vignette effect.
  27855. */
  27856. vignetteWeight: number;
  27857. /**
  27858. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27859. * if vignetteEnabled is set to true.
  27860. */
  27861. /**
  27862. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27863. * if vignetteEnabled is set to true.
  27864. */
  27865. vignetteColor: Color4;
  27866. /**
  27867. * Gets Camera field of view used by the Vignette effect.
  27868. */
  27869. /**
  27870. * Sets Camera field of view used by the Vignette effect.
  27871. */
  27872. vignetteCameraFov: number;
  27873. /**
  27874. * Gets the vignette blend mode allowing different kind of effect.
  27875. */
  27876. /**
  27877. * Sets the vignette blend mode allowing different kind of effect.
  27878. */
  27879. vignetteBlendMode: number;
  27880. /**
  27881. * Gets wether the vignette effect is enabled.
  27882. */
  27883. /**
  27884. * Sets wether the vignette effect is enabled.
  27885. */
  27886. vignetteEnabled: boolean;
  27887. private _fromLinearSpace;
  27888. /**
  27889. * Gets wether the input of the processing is in Gamma or Linear Space.
  27890. */
  27891. /**
  27892. * Sets wether the input of the processing is in Gamma or Linear Space.
  27893. */
  27894. fromLinearSpace: boolean;
  27895. /**
  27896. * Defines cache preventing GC.
  27897. */
  27898. private _defines;
  27899. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27900. getClassName(): string;
  27901. protected _updateParameters(): void;
  27902. dispose(camera?: Camera): void;
  27903. }
  27904. }
  27905. declare module BABYLON {
  27906. class PassPostProcess extends PostProcess {
  27907. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27908. }
  27909. }
  27910. declare module BABYLON {
  27911. type PostProcessOptions = {
  27912. width: number;
  27913. height: number;
  27914. };
  27915. /**
  27916. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27917. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27918. */
  27919. class PostProcess {
  27920. /** Name of the PostProcess. */
  27921. name: string;
  27922. /**
  27923. * Width of the texture to apply the post process on
  27924. */
  27925. width: number;
  27926. /**
  27927. * Height of the texture to apply the post process on
  27928. */
  27929. height: number;
  27930. /**
  27931. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27932. * @hidden
  27933. */
  27934. _outputTexture: Nullable<InternalTexture>;
  27935. /**
  27936. * Sampling mode used by the shader
  27937. * See https://doc.babylonjs.com/classes/3.1/texture
  27938. */
  27939. renderTargetSamplingMode: number;
  27940. /**
  27941. * Clear color to use when screen clearing
  27942. */
  27943. clearColor: Color4;
  27944. /**
  27945. * If the buffer needs to be cleared before applying the post process. (default: true)
  27946. * Should be set to false if shader will overwrite all previous pixels.
  27947. */
  27948. autoClear: boolean;
  27949. /**
  27950. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27951. */
  27952. alphaMode: number;
  27953. /**
  27954. * Sets the setAlphaBlendConstants of the babylon engine
  27955. */
  27956. alphaConstants: Color4;
  27957. /**
  27958. * Animations to be used for the post processing
  27959. */
  27960. animations: Animation[];
  27961. /**
  27962. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27963. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27964. */
  27965. enablePixelPerfectMode: boolean;
  27966. /**
  27967. * Force the postprocess to be applied without taking in account viewport
  27968. */
  27969. forceFullscreenViewport: boolean;
  27970. /**
  27971. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27972. *
  27973. * | Value | Type | Description |
  27974. * | ----- | ----------------------------------- | ----------- |
  27975. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27976. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27977. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27978. *
  27979. */
  27980. scaleMode: number;
  27981. /**
  27982. * Force textures to be a power of two (default: false)
  27983. */
  27984. alwaysForcePOT: boolean;
  27985. private _samples;
  27986. /**
  27987. * Number of sample textures (default: 1)
  27988. */
  27989. samples: number;
  27990. /**
  27991. * Modify the scale of the post process to be the same as the viewport (default: false)
  27992. */
  27993. adaptScaleToCurrentViewport: boolean;
  27994. private _camera;
  27995. private _scene;
  27996. private _engine;
  27997. private _options;
  27998. private _reusable;
  27999. private _textureType;
  28000. /**
  28001. * Smart array of input and output textures for the post process.
  28002. * @hidden
  28003. */
  28004. _textures: SmartArray<InternalTexture>;
  28005. /**
  28006. * The index in _textures that corresponds to the output texture.
  28007. * @hidden
  28008. */
  28009. _currentRenderTextureInd: number;
  28010. private _effect;
  28011. private _samplers;
  28012. private _fragmentUrl;
  28013. private _vertexUrl;
  28014. private _parameters;
  28015. private _scaleRatio;
  28016. protected _indexParameters: any;
  28017. private _shareOutputWithPostProcess;
  28018. private _texelSize;
  28019. private _forcedOutputTexture;
  28020. /**
  28021. * An event triggered when the postprocess is activated.
  28022. */
  28023. onActivateObservable: Observable<Camera>;
  28024. private _onActivateObserver;
  28025. /**
  28026. * A function that is added to the onActivateObservable
  28027. */
  28028. onActivate: Nullable<(camera: Camera) => void>;
  28029. /**
  28030. * An event triggered when the postprocess changes its size.
  28031. */
  28032. onSizeChangedObservable: Observable<PostProcess>;
  28033. private _onSizeChangedObserver;
  28034. /**
  28035. * A function that is added to the onSizeChangedObservable
  28036. */
  28037. onSizeChanged: (postProcess: PostProcess) => void;
  28038. /**
  28039. * An event triggered when the postprocess applies its effect.
  28040. */
  28041. onApplyObservable: Observable<Effect>;
  28042. private _onApplyObserver;
  28043. /**
  28044. * A function that is added to the onApplyObservable
  28045. */
  28046. onApply: (effect: Effect) => void;
  28047. /**
  28048. * An event triggered before rendering the postprocess
  28049. */
  28050. onBeforeRenderObservable: Observable<Effect>;
  28051. private _onBeforeRenderObserver;
  28052. /**
  28053. * A function that is added to the onBeforeRenderObservable
  28054. */
  28055. onBeforeRender: (effect: Effect) => void;
  28056. /**
  28057. * An event triggered after rendering the postprocess
  28058. */
  28059. onAfterRenderObservable: Observable<Effect>;
  28060. private _onAfterRenderObserver;
  28061. /**
  28062. * A function that is added to the onAfterRenderObservable
  28063. */
  28064. onAfterRender: (efect: Effect) => void;
  28065. /**
  28066. * 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
  28067. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28068. */
  28069. inputTexture: InternalTexture;
  28070. /**
  28071. * Gets the camera which post process is applied to.
  28072. * @returns The camera the post process is applied to.
  28073. */
  28074. getCamera(): Camera;
  28075. /**
  28076. * Gets the texel size of the postprocess.
  28077. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28078. */
  28079. readonly texelSize: Vector2;
  28080. /**
  28081. * Creates a new instance PostProcess
  28082. * @param name The name of the PostProcess.
  28083. * @param fragmentUrl The url of the fragment shader to be used.
  28084. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28085. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28086. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28087. * @param camera The camera to apply the render pass to.
  28088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28089. * @param engine The engine which the post process will be applied. (default: current engine)
  28090. * @param reusable If the post process can be reused on the same frame. (default: false)
  28091. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28092. * @param textureType Type of textures used when performing the post process. (default: 0)
  28093. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28094. * @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
  28095. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28096. */
  28097. constructor(
  28098. /** Name of the PostProcess. */
  28099. 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);
  28100. /**
  28101. * Gets the engine which this post process belongs to.
  28102. * @returns The engine the post process was enabled with.
  28103. */
  28104. getEngine(): Engine;
  28105. /**
  28106. * The effect that is created when initializing the post process.
  28107. * @returns The created effect corrisponding the the postprocess.
  28108. */
  28109. getEffect(): Effect;
  28110. /**
  28111. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28112. * @param postProcess The post process to share the output with.
  28113. * @returns This post process.
  28114. */
  28115. shareOutputWith(postProcess: PostProcess): PostProcess;
  28116. /**
  28117. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28118. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28119. */
  28120. useOwnOutput(): void;
  28121. /**
  28122. * Updates the effect with the current post process compile time values and recompiles the shader.
  28123. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28124. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28125. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28126. * @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
  28127. * @param onCompiled Called when the shader has been compiled.
  28128. * @param onError Called if there is an error when compiling a shader.
  28129. */
  28130. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28131. /**
  28132. * The post process is reusable if it can be used multiple times within one frame.
  28133. * @returns If the post process is reusable
  28134. */
  28135. isReusable(): boolean;
  28136. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28137. markTextureDirty(): void;
  28138. /**
  28139. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28140. * 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.
  28141. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28142. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28143. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28144. * @returns The target texture that was bound to be written to.
  28145. */
  28146. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28147. /**
  28148. * If the post process is supported.
  28149. */
  28150. readonly isSupported: boolean;
  28151. /**
  28152. * The aspect ratio of the output texture.
  28153. */
  28154. readonly aspectRatio: number;
  28155. /**
  28156. * Get a value indicating if the post-process is ready to be used
  28157. * @returns true if the post-process is ready (shader is compiled)
  28158. */
  28159. isReady(): boolean;
  28160. /**
  28161. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28162. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28163. */
  28164. apply(): Nullable<Effect>;
  28165. private _disposeTextures;
  28166. /**
  28167. * Disposes the post process.
  28168. * @param camera The camera to dispose the post process on.
  28169. */
  28170. dispose(camera?: Camera): void;
  28171. }
  28172. }
  28173. declare module BABYLON {
  28174. /**
  28175. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28176. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28177. */
  28178. class PostProcessManager {
  28179. private _scene;
  28180. private _indexBuffer;
  28181. private _vertexBuffers;
  28182. /**
  28183. * Creates a new instance PostProcess
  28184. * @param scene The scene that the post process is associated with.
  28185. */
  28186. constructor(scene: Scene);
  28187. private _prepareBuffers;
  28188. private _buildIndexBuffer;
  28189. /**
  28190. * Rebuilds the vertex buffers of the manager.
  28191. * @hidden
  28192. */
  28193. _rebuild(): void;
  28194. /**
  28195. * Prepares a frame to be run through a post process.
  28196. * @param sourceTexture The input texture to the post procesess. (default: null)
  28197. * @param postProcesses An array of post processes to be run. (default: null)
  28198. * @returns True if the post processes were able to be run.
  28199. * @hidden
  28200. */
  28201. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28202. /**
  28203. * Manually render a set of post processes to a texture.
  28204. * @param postProcesses An array of post processes to be run.
  28205. * @param targetTexture The target texture to render to.
  28206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28207. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28208. * @param lodLevel defines which lod of the texture to render to
  28209. */
  28210. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28211. /**
  28212. * Finalize the result of the output of the postprocesses.
  28213. * @param doNotPresent If true the result will not be displayed to the screen.
  28214. * @param targetTexture The target texture to render to.
  28215. * @param faceIndex The index of the face to bind the target texture to.
  28216. * @param postProcesses The array of post processes to render.
  28217. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28218. * @hidden
  28219. */
  28220. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28221. /**
  28222. * Disposes of the post process manager.
  28223. */
  28224. dispose(): void;
  28225. }
  28226. }
  28227. declare module BABYLON {
  28228. class RefractionPostProcess extends PostProcess {
  28229. color: Color3;
  28230. depth: number;
  28231. colorLevel: number;
  28232. private _refTexture;
  28233. private _ownRefractionTexture;
  28234. /**
  28235. * Gets or sets the refraction texture
  28236. * Please note that you are responsible for disposing the texture if you set it manually
  28237. */
  28238. refractionTexture: Texture;
  28239. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28240. dispose(camera: Camera): void;
  28241. }
  28242. }
  28243. declare module BABYLON {
  28244. /**
  28245. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28246. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28247. */
  28248. class SharpenPostProcess extends PostProcess {
  28249. /**
  28250. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28251. */
  28252. colorAmount: number;
  28253. /**
  28254. * How much sharpness should be applied (default: 0.3)
  28255. */
  28256. edgeAmount: number;
  28257. /**
  28258. * Creates a new instance ConvolutionPostProcess
  28259. * @param name The name of the effect.
  28260. * @param options The required width/height ratio to downsize to before computing the render pass.
  28261. * @param camera The camera to apply the render pass to.
  28262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28263. * @param engine The engine which the post process will be applied. (default: current engine)
  28264. * @param reusable If the post process can be reused on the same frame. (default: false)
  28265. * @param textureType Type of textures used when performing the post process. (default: 0)
  28266. * @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)
  28267. */
  28268. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28269. }
  28270. }
  28271. declare module BABYLON {
  28272. class StereoscopicInterlacePostProcess extends PostProcess {
  28273. private _stepSize;
  28274. private _passedProcess;
  28275. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28276. }
  28277. }
  28278. declare module BABYLON {
  28279. /** Defines operator used for tonemapping */
  28280. enum TonemappingOperator {
  28281. /** Hable */
  28282. Hable = 0,
  28283. /** Reinhard */
  28284. Reinhard = 1,
  28285. /** HejiDawson */
  28286. HejiDawson = 2,
  28287. /** Photographic */
  28288. Photographic = 3
  28289. }
  28290. /**
  28291. * Defines a post process to apply tone mapping
  28292. */
  28293. class TonemapPostProcess extends PostProcess {
  28294. private _operator;
  28295. /** Defines the required exposure adjustement */
  28296. exposureAdjustment: number;
  28297. /**
  28298. * Creates a new TonemapPostProcess
  28299. * @param name defines the name of the postprocess
  28300. * @param _operator defines the operator to use
  28301. * @param exposureAdjustment defines the required exposure adjustement
  28302. * @param camera defines the camera to use (can be null)
  28303. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28304. * @param engine defines the hosting engine (can be ignore if camera is set)
  28305. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28306. */
  28307. constructor(name: string, _operator: TonemappingOperator,
  28308. /** Defines the required exposure adjustement */
  28309. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28310. }
  28311. }
  28312. declare module BABYLON {
  28313. class VolumetricLightScatteringPostProcess extends PostProcess {
  28314. private _volumetricLightScatteringPass;
  28315. private _volumetricLightScatteringRTT;
  28316. private _viewPort;
  28317. private _screenCoordinates;
  28318. private _cachedDefines;
  28319. /**
  28320. * If not undefined, the mesh position is computed from the attached node position
  28321. */
  28322. attachedNode: {
  28323. position: Vector3;
  28324. };
  28325. /**
  28326. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28327. */
  28328. customMeshPosition: Vector3;
  28329. /**
  28330. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28331. */
  28332. useCustomMeshPosition: boolean;
  28333. /**
  28334. * If the post-process should inverse the light scattering direction
  28335. */
  28336. invert: boolean;
  28337. /**
  28338. * The internal mesh used by the post-process
  28339. */
  28340. mesh: Mesh;
  28341. useDiffuseColor: boolean;
  28342. /**
  28343. * Array containing the excluded meshes not rendered in the internal pass
  28344. */
  28345. excludedMeshes: AbstractMesh[];
  28346. /**
  28347. * Controls the overall intensity of the post-process
  28348. */
  28349. exposure: number;
  28350. /**
  28351. * Dissipates each sample's contribution in range [0, 1]
  28352. */
  28353. decay: number;
  28354. /**
  28355. * Controls the overall intensity of each sample
  28356. */
  28357. weight: number;
  28358. /**
  28359. * Controls the density of each sample
  28360. */
  28361. density: number;
  28362. /**
  28363. * @constructor
  28364. * @param {string} name - The post-process name
  28365. * @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)
  28366. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28367. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28368. * @param {number} samples - The post-process quality, default 100
  28369. * @param {number} samplingMode - The post-process filtering mode
  28370. * @param {BABYLON.Engine} engine - The babylon engine
  28371. * @param {boolean} reusable - If the post-process is reusable
  28372. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28373. */
  28374. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28375. getClassName(): string;
  28376. private _isReady;
  28377. /**
  28378. * Sets the new light position for light scattering effect
  28379. * @param {BABYLON.Vector3} The new custom light position
  28380. */
  28381. setCustomMeshPosition(position: Vector3): void;
  28382. /**
  28383. * Returns the light position for light scattering effect
  28384. * @return {BABYLON.Vector3} The custom light position
  28385. */
  28386. getCustomMeshPosition(): Vector3;
  28387. /**
  28388. * Disposes the internal assets and detaches the post-process from the camera
  28389. */
  28390. dispose(camera: Camera): void;
  28391. /**
  28392. * Returns the render target texture used by the post-process
  28393. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28394. */
  28395. getPass(): RenderTargetTexture;
  28396. private _meshExcluded;
  28397. private _createPass;
  28398. private _updateMeshScreenCoordinates;
  28399. /**
  28400. * Creates a default mesh for the Volumeric Light Scattering post-process
  28401. * @param {string} The mesh name
  28402. * @param {BABYLON.Scene} The scene where to create the mesh
  28403. * @return {BABYLON.Mesh} the default mesh
  28404. */
  28405. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28406. }
  28407. }
  28408. declare module BABYLON {
  28409. class VRDistortionCorrectionPostProcess extends PostProcess {
  28410. private _isRightEye;
  28411. private _distortionFactors;
  28412. private _postProcessScaleFactor;
  28413. private _lensCenterOffset;
  28414. private _scaleIn;
  28415. private _scaleFactor;
  28416. private _lensCenter;
  28417. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28418. }
  28419. }
  28420. declare module BABYLON {
  28421. interface Scene {
  28422. /** @hidden (Backing field) */
  28423. _boundingBoxRenderer: BoundingBoxRenderer;
  28424. /** @hidden (Backing field) */
  28425. _forceShowBoundingBoxes: boolean;
  28426. /**
  28427. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28428. */
  28429. forceShowBoundingBoxes: boolean;
  28430. /**
  28431. * Gets the bounding box renderer associated with the scene
  28432. * @returns a BoundingBoxRenderer
  28433. */
  28434. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28435. }
  28436. interface AbstractMesh {
  28437. /** @hidden (Backing field) */
  28438. _showBoundingBox: boolean;
  28439. /**
  28440. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28441. */
  28442. showBoundingBox: boolean;
  28443. }
  28444. class BoundingBoxRenderer implements ISceneComponent {
  28445. /**
  28446. * The component name helpfull to identify the component in the list of scene components.
  28447. */
  28448. readonly name: string;
  28449. /**
  28450. * The scene the component belongs to.
  28451. */
  28452. scene: Scene;
  28453. frontColor: Color3;
  28454. backColor: Color3;
  28455. showBackLines: boolean;
  28456. renderList: SmartArray<BoundingBox>;
  28457. private _colorShader;
  28458. private _vertexBuffers;
  28459. private _indexBuffer;
  28460. constructor(scene: Scene);
  28461. /**
  28462. * Registers the component in a given scene
  28463. */
  28464. register(): void;
  28465. private _evaluateSubMesh;
  28466. private _activeMesh;
  28467. private _prepareRessources;
  28468. private _createIndexBuffer;
  28469. /**
  28470. * Rebuilds the elements related to this component in case of
  28471. * context lost for instance.
  28472. */
  28473. rebuild(): void;
  28474. reset(): void;
  28475. render(): void;
  28476. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28477. dispose(): void;
  28478. }
  28479. }
  28480. declare module BABYLON {
  28481. /**
  28482. * This represents a depth renderer in Babylon.
  28483. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28484. */
  28485. class DepthRenderer {
  28486. private _scene;
  28487. private _depthMap;
  28488. private _effect;
  28489. private _cachedDefines;
  28490. private _camera;
  28491. /**
  28492. * Instantiates a depth renderer
  28493. * @param scene The scene the renderer belongs to
  28494. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28495. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28496. */
  28497. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28498. /**
  28499. * Creates the depth rendering effect and checks if the effect is ready.
  28500. * @param subMesh The submesh to be used to render the depth map of
  28501. * @param useInstances If multiple world instances should be used
  28502. * @returns if the depth renderer is ready to render the depth map
  28503. */
  28504. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28505. /**
  28506. * Gets the texture which the depth map will be written to.
  28507. * @returns The depth map texture
  28508. */
  28509. getDepthMap(): RenderTargetTexture;
  28510. /**
  28511. * Disposes of the depth renderer.
  28512. */
  28513. dispose(): void;
  28514. }
  28515. }
  28516. declare module BABYLON {
  28517. interface Scene {
  28518. /** @hidden (Backing field) */
  28519. _depthRenderer: {
  28520. [id: string]: DepthRenderer;
  28521. };
  28522. /**
  28523. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  28524. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  28525. * @returns the created depth renderer
  28526. */
  28527. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  28528. /**
  28529. * Disables a depth renderer for a given camera
  28530. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  28531. */
  28532. disableDepthRenderer(camera?: Nullable<Camera>): void;
  28533. }
  28534. /**
  28535. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  28536. * in several rendering techniques.
  28537. */
  28538. class DepthRendererSceneComponent implements ISceneComponent {
  28539. /**
  28540. * The component name helpfull to identify the component in the list of scene components.
  28541. */
  28542. readonly name: string;
  28543. /**
  28544. * The scene the component belongs to.
  28545. */
  28546. scene: Scene;
  28547. /**
  28548. * Creates a new instance of the component for the given scene
  28549. * @param scene Defines the scene to register the component in
  28550. */
  28551. constructor(scene: Scene);
  28552. /**
  28553. * Registers the component in a given scene
  28554. */
  28555. register(): void;
  28556. /**
  28557. * Rebuilds the elements related to this component in case of
  28558. * context lost for instance.
  28559. */
  28560. rebuild(): void;
  28561. /**
  28562. * Disposes the component and the associated ressources
  28563. */
  28564. dispose(): void;
  28565. private _gatherRenderTargets;
  28566. }
  28567. }
  28568. declare module BABYLON {
  28569. /**
  28570. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28571. */
  28572. class EdgesRenderer {
  28573. edgesWidthScalerForOrthographic: number;
  28574. edgesWidthScalerForPerspective: number;
  28575. protected _source: AbstractMesh;
  28576. protected _linesPositions: number[];
  28577. protected _linesNormals: number[];
  28578. protected _linesIndices: number[];
  28579. protected _epsilon: number;
  28580. protected _indicesCount: number;
  28581. protected _lineShader: ShaderMaterial;
  28582. protected _ib: WebGLBuffer;
  28583. protected _buffers: {
  28584. [key: string]: Nullable<VertexBuffer>;
  28585. };
  28586. protected _checkVerticesInsteadOfIndices: boolean;
  28587. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28588. isEnabled: boolean;
  28589. /**
  28590. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28591. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28592. * @param source Mesh used to create edges
  28593. * @param epsilon sum of angles in adjacency to check for edge
  28594. * @param checkVerticesInsteadOfIndices
  28595. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28596. */
  28597. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  28598. protected _prepareRessources(): void;
  28599. /** @hidden */
  28600. _rebuild(): void;
  28601. /**
  28602. * Releases the required resources for the edges renderer
  28603. */
  28604. dispose(): void;
  28605. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28606. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28607. /**
  28608. * Checks if the pair of p0 and p1 is en edge
  28609. * @param faceIndex
  28610. * @param edge
  28611. * @param faceNormals
  28612. * @param p0
  28613. * @param p1
  28614. * @private
  28615. */
  28616. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28617. /**
  28618. * Generates lines edges from adjacencjes
  28619. * @private
  28620. */
  28621. _generateEdgesLines(): void;
  28622. render(): void;
  28623. }
  28624. }
  28625. declare module BABYLON {
  28626. /**
  28627. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28628. */
  28629. class GeometryBufferRenderer {
  28630. private _scene;
  28631. private _multiRenderTarget;
  28632. private _ratio;
  28633. private _enablePosition;
  28634. protected _effect: Effect;
  28635. protected _cachedDefines: string;
  28636. /**
  28637. * Set the render list (meshes to be rendered) used in the G buffer.
  28638. */
  28639. renderList: Mesh[];
  28640. /**
  28641. * Gets wether or not G buffer are supported by the running hardware.
  28642. * This requires draw buffer supports
  28643. */
  28644. readonly isSupported: boolean;
  28645. /**
  28646. * Gets wether or not position are enabled for the G buffer.
  28647. */
  28648. /**
  28649. * Sets wether or not position are enabled for the G buffer.
  28650. */
  28651. enablePosition: boolean;
  28652. /**
  28653. * Gets the scene associated with the buffer.
  28654. */
  28655. readonly scene: Scene;
  28656. /**
  28657. * Gets the ratio used by the buffer during its creation.
  28658. * How big is the buffer related to the main canvas.
  28659. */
  28660. readonly ratio: number;
  28661. /**
  28662. * Creates a new G Buffer for the scene
  28663. * @param scene The scene the buffer belongs to
  28664. * @param ratio How big is the buffer related to the main canvas.
  28665. */
  28666. constructor(scene: Scene, ratio?: number);
  28667. /**
  28668. * Checks wether everything is ready to render a submesh to the G buffer.
  28669. * @param subMesh the submesh to check readiness for
  28670. * @param useInstances is the mesh drawn using instance or not
  28671. * @returns true if ready otherwise false
  28672. */
  28673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28674. /**
  28675. * Gets the current underlying G Buffer.
  28676. * @returns the buffer
  28677. */
  28678. getGBuffer(): MultiRenderTarget;
  28679. /**
  28680. * Gets the number of samples used to render the buffer (anti aliasing).
  28681. */
  28682. /**
  28683. * Sets the number of samples used to render the buffer (anti aliasing).
  28684. */
  28685. samples: number;
  28686. /**
  28687. * Disposes the renderer and frees up associated resources.
  28688. */
  28689. dispose(): void;
  28690. protected _createRenderTargets(): void;
  28691. }
  28692. }
  28693. declare module BABYLON {
  28694. interface Scene {
  28695. /** @hidden (Backing field) */
  28696. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28697. /**
  28698. * Gets or Sets the current geometry buffer associated to the scene.
  28699. */
  28700. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28701. /**
  28702. * Enables a GeometryBufferRender and associates it with the scene
  28703. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  28704. * @returns the GeometryBufferRenderer
  28705. */
  28706. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  28707. /**
  28708. * Disables the GeometryBufferRender associated with the scene
  28709. */
  28710. disableGeometryBufferRenderer(): void;
  28711. }
  28712. /**
  28713. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  28714. * in several rendering techniques.
  28715. */
  28716. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  28717. /**
  28718. * The component name helpfull to identify the component in the list of scene components.
  28719. */
  28720. readonly name: string;
  28721. /**
  28722. * The scene the component belongs to.
  28723. */
  28724. scene: Scene;
  28725. /**
  28726. * Creates a new instance of the component for the given scene
  28727. * @param scene Defines the scene to register the component in
  28728. */
  28729. constructor(scene: Scene);
  28730. /**
  28731. * Registers the component in a given scene
  28732. */
  28733. register(): void;
  28734. /**
  28735. * Rebuilds the elements related to this component in case of
  28736. * context lost for instance.
  28737. */
  28738. rebuild(): void;
  28739. /**
  28740. * Disposes the component and the associated ressources
  28741. */
  28742. dispose(): void;
  28743. private _gatherRenderTargets;
  28744. }
  28745. }
  28746. declare module BABYLON {
  28747. /**
  28748. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28749. */
  28750. class LineEdgesRenderer extends EdgesRenderer {
  28751. /**
  28752. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28753. * @param source LineMesh used to generate edges
  28754. * @param epsilon not important (specified angle for edge detection)
  28755. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28756. */
  28757. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28758. /**
  28759. * Always create the edge since its a line so only important things are p0 and p1
  28760. * @param faceIndex not important for LineMesh
  28761. * @param edge not important for LineMesh
  28762. * @param faceNormals not important for LineMesh
  28763. * @param p0 beginnig of line
  28764. * @param p1 end of line
  28765. */
  28766. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28767. /**
  28768. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28769. */
  28770. _generateEdgesLines(): void;
  28771. }
  28772. }
  28773. declare module BABYLON {
  28774. class OutlineRenderer {
  28775. private _scene;
  28776. private _effect;
  28777. private _cachedDefines;
  28778. zOffset: number;
  28779. constructor(scene: Scene);
  28780. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  28781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28782. }
  28783. }
  28784. declare module BABYLON {
  28785. class RenderingGroup {
  28786. index: number;
  28787. private _scene;
  28788. private _opaqueSubMeshes;
  28789. private _transparentSubMeshes;
  28790. private _alphaTestSubMeshes;
  28791. private _depthOnlySubMeshes;
  28792. private _particleSystems;
  28793. private _spriteManagers;
  28794. private _opaqueSortCompareFn;
  28795. private _alphaTestSortCompareFn;
  28796. private _transparentSortCompareFn;
  28797. private _renderOpaque;
  28798. private _renderAlphaTest;
  28799. private _renderTransparent;
  28800. private _edgesRenderers;
  28801. onBeforeTransparentRendering: () => void;
  28802. /**
  28803. * Set the opaque sort comparison function.
  28804. * If null the sub meshes will be render in the order they were created
  28805. */
  28806. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28807. /**
  28808. * Set the alpha test sort comparison function.
  28809. * If null the sub meshes will be render in the order they were created
  28810. */
  28811. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28812. /**
  28813. * Set the transparent sort comparison function.
  28814. * If null the sub meshes will be render in the order they were created
  28815. */
  28816. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28817. /**
  28818. * Creates a new rendering group.
  28819. * @param index The rendering group index
  28820. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28821. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28822. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28823. */
  28824. 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>);
  28825. /**
  28826. * Render all the sub meshes contained in the group.
  28827. * @param customRenderFunction Used to override the default render behaviour of the group.
  28828. * @returns true if rendered some submeshes.
  28829. */
  28830. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28831. /**
  28832. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28833. * @param subMeshes The submeshes to render
  28834. */
  28835. private renderOpaqueSorted;
  28836. /**
  28837. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28838. * @param subMeshes The submeshes to render
  28839. */
  28840. private renderAlphaTestSorted;
  28841. /**
  28842. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28843. * @param subMeshes The submeshes to render
  28844. */
  28845. private renderTransparentSorted;
  28846. /**
  28847. * Renders the submeshes in a specified order.
  28848. * @param subMeshes The submeshes to sort before render
  28849. * @param sortCompareFn The comparison function use to sort
  28850. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28851. * @param transparent Specifies to activate blending if true
  28852. */
  28853. private static renderSorted;
  28854. /**
  28855. * Renders the submeshes in the order they were dispatched (no sort applied).
  28856. * @param subMeshes The submeshes to render
  28857. */
  28858. private static renderUnsorted;
  28859. /**
  28860. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28861. * are rendered back to front if in the same alpha index.
  28862. *
  28863. * @param a The first submesh
  28864. * @param b The second submesh
  28865. * @returns The result of the comparison
  28866. */
  28867. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28868. /**
  28869. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28870. * are rendered back to front.
  28871. *
  28872. * @param a The first submesh
  28873. * @param b The second submesh
  28874. * @returns The result of the comparison
  28875. */
  28876. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28877. /**
  28878. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28879. * are rendered front to back (prevent overdraw).
  28880. *
  28881. * @param a The first submesh
  28882. * @param b The second submesh
  28883. * @returns The result of the comparison
  28884. */
  28885. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28886. /**
  28887. * Resets the different lists of submeshes to prepare a new frame.
  28888. */
  28889. prepare(): void;
  28890. dispose(): void;
  28891. /**
  28892. * Inserts the submesh in its correct queue depending on its material.
  28893. * @param subMesh The submesh to dispatch
  28894. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28895. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28896. */
  28897. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28898. dispatchSprites(spriteManager: SpriteManager): void;
  28899. dispatchParticles(particleSystem: IParticleSystem): void;
  28900. private _renderParticles;
  28901. private _renderSprites;
  28902. }
  28903. }
  28904. declare module BABYLON {
  28905. /**
  28906. * Interface describing the different options available in the rendering manager
  28907. * regarding Auto Clear between groups.
  28908. */
  28909. interface IRenderingManagerAutoClearSetup {
  28910. /**
  28911. * Defines whether or not autoclear is enable.
  28912. */
  28913. autoClear: boolean;
  28914. /**
  28915. * Defines whether or not to autoclear the depth buffer.
  28916. */
  28917. depth: boolean;
  28918. /**
  28919. * Defines whether or not to autoclear the stencil buffer.
  28920. */
  28921. stencil: boolean;
  28922. }
  28923. class RenderingManager {
  28924. /**
  28925. * The max id used for rendering groups (not included)
  28926. */
  28927. static MAX_RENDERINGGROUPS: number;
  28928. /**
  28929. * The min id used for rendering groups (included)
  28930. */
  28931. static MIN_RENDERINGGROUPS: number;
  28932. /**
  28933. * Used to globally prevent autoclearing scenes.
  28934. */
  28935. static AUTOCLEAR: boolean;
  28936. /**
  28937. * @hidden
  28938. */
  28939. _useSceneAutoClearSetup: boolean;
  28940. private _scene;
  28941. private _renderingGroups;
  28942. private _depthStencilBufferAlreadyCleaned;
  28943. private _autoClearDepthStencil;
  28944. private _customOpaqueSortCompareFn;
  28945. private _customAlphaTestSortCompareFn;
  28946. private _customTransparentSortCompareFn;
  28947. private _renderingGroupInfo;
  28948. constructor(scene: Scene);
  28949. private _clearDepthStencilBuffer;
  28950. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28951. reset(): void;
  28952. dispose(): void;
  28953. /**
  28954. * Clear the info related to rendering groups preventing retention points during dispose.
  28955. */
  28956. freeRenderingGroups(): void;
  28957. private _prepareRenderingGroup;
  28958. dispatchSprites(spriteManager: SpriteManager): void;
  28959. dispatchParticles(particleSystem: IParticleSystem): void;
  28960. /**
  28961. * @param subMesh The submesh to dispatch
  28962. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28963. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28964. */
  28965. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28966. /**
  28967. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28968. * This allowed control for front to back rendering or reversly depending of the special needs.
  28969. *
  28970. * @param renderingGroupId The rendering group id corresponding to its index
  28971. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28972. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28973. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28974. */
  28975. 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;
  28976. /**
  28977. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28978. *
  28979. * @param renderingGroupId The rendering group id corresponding to its index
  28980. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28981. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28982. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28983. */
  28984. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28985. /**
  28986. * Gets the current auto clear configuration for one rendering group of the rendering
  28987. * manager.
  28988. * @param index the rendering group index to get the information for
  28989. * @returns The auto clear setup for the requested rendering group
  28990. */
  28991. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28992. }
  28993. }
  28994. declare module BABYLON {
  28995. /**
  28996. * Renders a layer on top of an existing scene
  28997. */
  28998. class UtilityLayerRenderer implements IDisposable {
  28999. /** the original scene that will be rendered on top of */
  29000. originalScene: Scene;
  29001. private _pointerCaptures;
  29002. private _lastPointerEvents;
  29003. private static _DefaultUtilityLayer;
  29004. private static _DefaultKeepDepthUtilityLayer;
  29005. /**
  29006. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  29007. */
  29008. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29009. /**
  29010. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  29011. */
  29012. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29013. /**
  29014. * The scene that is rendered on top of the original scene
  29015. */
  29016. utilityLayerScene: Scene;
  29017. /**
  29018. * If the utility layer should automatically be rendered on top of existing scene
  29019. */
  29020. shouldRender: boolean;
  29021. /**
  29022. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29023. */
  29024. onlyCheckPointerDownEvents: boolean;
  29025. /**
  29026. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29027. */
  29028. processAllEvents: boolean;
  29029. /**
  29030. * Observable raised when the pointer move from the utility layer scene to the main scene
  29031. */
  29032. onPointerOutObservable: Observable<number>;
  29033. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29034. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29035. private _afterRenderObserver;
  29036. private _sceneDisposeObserver;
  29037. private _originalPointerObserver;
  29038. /**
  29039. * Instantiates a UtilityLayerRenderer
  29040. * @param originalScene the original scene that will be rendered on top of
  29041. */
  29042. constructor(
  29043. /** the original scene that will be rendered on top of */
  29044. originalScene: Scene);
  29045. private _notifyObservers;
  29046. /**
  29047. * Renders the utility layers scene on top of the original scene
  29048. */
  29049. render(): void;
  29050. /**
  29051. * Disposes of the renderer
  29052. */
  29053. dispose(): void;
  29054. private _updateCamera;
  29055. }
  29056. }
  29057. declare module BABYLON {
  29058. class Sprite {
  29059. name: string;
  29060. position: Vector3;
  29061. color: Color4;
  29062. width: number;
  29063. height: number;
  29064. angle: number;
  29065. cellIndex: number;
  29066. invertU: number;
  29067. invertV: number;
  29068. disposeWhenFinishedAnimating: boolean;
  29069. animations: Animation[];
  29070. isPickable: boolean;
  29071. actionManager: ActionManager;
  29072. private _animationStarted;
  29073. private _loopAnimation;
  29074. private _fromIndex;
  29075. private _toIndex;
  29076. private _delay;
  29077. private _direction;
  29078. private _manager;
  29079. private _time;
  29080. private _onAnimationEnd;
  29081. /**
  29082. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  29083. */
  29084. isVisible: boolean;
  29085. size: number;
  29086. constructor(name: string, manager: SpriteManager);
  29087. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29088. stopAnimation(): void;
  29089. /** @hidden */
  29090. _animate(deltaTime: number): void;
  29091. dispose(): void;
  29092. }
  29093. }
  29094. declare module BABYLON {
  29095. class SpriteManager {
  29096. name: string;
  29097. sprites: Sprite[];
  29098. renderingGroupId: number;
  29099. layerMask: number;
  29100. fogEnabled: boolean;
  29101. isPickable: boolean;
  29102. cellWidth: number;
  29103. cellHeight: number;
  29104. /**
  29105. * An event triggered when the manager is disposed.
  29106. */
  29107. onDisposeObservable: Observable<SpriteManager>;
  29108. private _onDisposeObserver;
  29109. onDispose: () => void;
  29110. private _capacity;
  29111. private _spriteTexture;
  29112. private _epsilon;
  29113. private _scene;
  29114. private _vertexData;
  29115. private _buffer;
  29116. private _vertexBuffers;
  29117. private _indexBuffer;
  29118. private _effectBase;
  29119. private _effectFog;
  29120. texture: Texture;
  29121. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29122. private _appendSpriteVertex;
  29123. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29124. render(): void;
  29125. dispose(): void;
  29126. }
  29127. }
  29128. declare module BABYLON {
  29129. /**
  29130. * @hidden
  29131. **/
  29132. class _AlphaState {
  29133. private _isAlphaBlendDirty;
  29134. private _isBlendFunctionParametersDirty;
  29135. private _isBlendEquationParametersDirty;
  29136. private _isBlendConstantsDirty;
  29137. private _alphaBlend;
  29138. private _blendFunctionParameters;
  29139. private _blendEquationParameters;
  29140. private _blendConstants;
  29141. /**
  29142. * Initializes the state.
  29143. */
  29144. constructor();
  29145. readonly isDirty: boolean;
  29146. alphaBlend: boolean;
  29147. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29148. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29149. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29150. reset(): void;
  29151. apply(gl: WebGLRenderingContext): void;
  29152. }
  29153. }
  29154. declare module BABYLON {
  29155. /**
  29156. * @hidden
  29157. **/
  29158. class _DepthCullingState {
  29159. private _isDepthTestDirty;
  29160. private _isDepthMaskDirty;
  29161. private _isDepthFuncDirty;
  29162. private _isCullFaceDirty;
  29163. private _isCullDirty;
  29164. private _isZOffsetDirty;
  29165. private _isFrontFaceDirty;
  29166. private _depthTest;
  29167. private _depthMask;
  29168. private _depthFunc;
  29169. private _cull;
  29170. private _cullFace;
  29171. private _zOffset;
  29172. private _frontFace;
  29173. /**
  29174. * Initializes the state.
  29175. */
  29176. constructor();
  29177. readonly isDirty: boolean;
  29178. zOffset: number;
  29179. cullFace: Nullable<number>;
  29180. cull: Nullable<boolean>;
  29181. depthFunc: Nullable<number>;
  29182. depthMask: boolean;
  29183. depthTest: boolean;
  29184. frontFace: Nullable<number>;
  29185. reset(): void;
  29186. apply(gl: WebGLRenderingContext): void;
  29187. }
  29188. }
  29189. declare module BABYLON {
  29190. /**
  29191. * @hidden
  29192. **/
  29193. class _StencilState {
  29194. private _isStencilTestDirty;
  29195. private _isStencilMaskDirty;
  29196. private _isStencilFuncDirty;
  29197. private _isStencilOpDirty;
  29198. private _stencilTest;
  29199. private _stencilMask;
  29200. private _stencilFunc;
  29201. private _stencilFuncRef;
  29202. private _stencilFuncMask;
  29203. private _stencilOpStencilFail;
  29204. private _stencilOpDepthFail;
  29205. private _stencilOpStencilDepthPass;
  29206. readonly isDirty: boolean;
  29207. stencilFunc: number;
  29208. stencilFuncRef: number;
  29209. stencilFuncMask: number;
  29210. stencilOpStencilFail: number;
  29211. stencilOpDepthFail: number;
  29212. stencilOpStencilDepthPass: number;
  29213. stencilMask: number;
  29214. stencilTest: boolean;
  29215. constructor();
  29216. reset(): void;
  29217. apply(gl: WebGLRenderingContext): void;
  29218. }
  29219. }
  29220. declare module BABYLON {
  29221. /**
  29222. * Class used to evalaute queries containing `and` and `or` operators
  29223. */
  29224. class AndOrNotEvaluator {
  29225. /**
  29226. * Evaluate a query
  29227. * @param query defines the query to evaluate
  29228. * @param evaluateCallback defines the callback used to filter result
  29229. * @returns true if the query matches
  29230. */
  29231. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29232. private static _HandleParenthesisContent;
  29233. private static _SimplifyNegation;
  29234. }
  29235. }
  29236. declare module BABYLON {
  29237. /**
  29238. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29239. */
  29240. enum AssetTaskState {
  29241. /**
  29242. * Initialization
  29243. */
  29244. INIT = 0,
  29245. /**
  29246. * Running
  29247. */
  29248. RUNNING = 1,
  29249. /**
  29250. * Done
  29251. */
  29252. DONE = 2,
  29253. /**
  29254. * Error
  29255. */
  29256. ERROR = 3
  29257. }
  29258. /**
  29259. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29260. */
  29261. abstract class AbstractAssetTask {
  29262. /**
  29263. * Task name
  29264. */ name: string;
  29265. /**
  29266. * Callback called when the task is successful
  29267. */
  29268. onSuccess: (task: any) => void;
  29269. /**
  29270. * Callback called when the task is not successful
  29271. */
  29272. onError: (task: any, message?: string, exception?: any) => void;
  29273. /**
  29274. * Creates a new {BABYLON.AssetsManager}
  29275. * @param name defines the name of the task
  29276. */
  29277. constructor(
  29278. /**
  29279. * Task name
  29280. */ name: string);
  29281. private _isCompleted;
  29282. private _taskState;
  29283. private _errorObject;
  29284. /**
  29285. * Get if the task is completed
  29286. */
  29287. readonly isCompleted: boolean;
  29288. /**
  29289. * Gets the current state of the task
  29290. */
  29291. readonly taskState: AssetTaskState;
  29292. /**
  29293. * Gets the current error object (if task is in error)
  29294. */
  29295. readonly errorObject: {
  29296. message?: string;
  29297. exception?: any;
  29298. };
  29299. /**
  29300. * Internal only
  29301. * @hidden
  29302. */
  29303. _setErrorObject(message?: string, exception?: any): void;
  29304. /**
  29305. * Execute the current task
  29306. * @param scene defines the scene where you want your assets to be loaded
  29307. * @param onSuccess is a callback called when the task is successfully executed
  29308. * @param onError is a callback called if an error occurs
  29309. */
  29310. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29311. /**
  29312. * Execute the current task
  29313. * @param scene defines the scene where you want your assets to be loaded
  29314. * @param onSuccess is a callback called when the task is successfully executed
  29315. * @param onError is a callback called if an error occurs
  29316. */
  29317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29318. /**
  29319. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  29320. * This can be used with failed tasks that have the reason for failure fixed.
  29321. */
  29322. reset(): void;
  29323. private onErrorCallback;
  29324. private onDoneCallback;
  29325. }
  29326. /**
  29327. * Define the interface used by progress events raised during assets loading
  29328. */
  29329. interface IAssetsProgressEvent {
  29330. /**
  29331. * Defines the number of remaining tasks to process
  29332. */
  29333. remainingCount: number;
  29334. /**
  29335. * Defines the total number of tasks
  29336. */
  29337. totalCount: number;
  29338. /**
  29339. * Defines the task that was just processed
  29340. */
  29341. task: AbstractAssetTask;
  29342. }
  29343. /**
  29344. * Class used to share progress information about assets loading
  29345. */
  29346. class AssetsProgressEvent implements IAssetsProgressEvent {
  29347. /**
  29348. * Defines the number of remaining tasks to process
  29349. */
  29350. remainingCount: number;
  29351. /**
  29352. * Defines the total number of tasks
  29353. */
  29354. totalCount: number;
  29355. /**
  29356. * Defines the task that was just processed
  29357. */
  29358. task: AbstractAssetTask;
  29359. /**
  29360. * Creates a {BABYLON.AssetsProgressEvent}
  29361. * @param remainingCount defines the number of remaining tasks to process
  29362. * @param totalCount defines the total number of tasks
  29363. * @param task defines the task that was just processed
  29364. */
  29365. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  29366. }
  29367. /**
  29368. * Define a task used by {BABYLON.AssetsManager} to load meshes
  29369. */
  29370. class MeshAssetTask extends AbstractAssetTask {
  29371. /**
  29372. * Defines the name of the task
  29373. */
  29374. name: string;
  29375. /**
  29376. * Defines the list of mesh's names you want to load
  29377. */
  29378. meshesNames: any;
  29379. /**
  29380. * Defines the root url to use as a base to load your meshes and associated resources
  29381. */
  29382. rootUrl: string;
  29383. /**
  29384. * Defines the filename of the scene to load from
  29385. */
  29386. sceneFilename: string;
  29387. /**
  29388. * Gets the list of loaded meshes
  29389. */
  29390. loadedMeshes: Array<AbstractMesh>;
  29391. /**
  29392. * Gets the list of loaded particle systems
  29393. */
  29394. loadedParticleSystems: Array<IParticleSystem>;
  29395. /**
  29396. * Gets the list of loaded skeletons
  29397. */
  29398. loadedSkeletons: Array<Skeleton>;
  29399. /**
  29400. * Callback called when the task is successful
  29401. */
  29402. onSuccess: (task: MeshAssetTask) => void;
  29403. /**
  29404. * Callback called when the task is successful
  29405. */
  29406. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  29407. /**
  29408. * Creates a new {BABYLON.MeshAssetTask}
  29409. * @param name defines the name of the task
  29410. * @param meshesNames defines the list of mesh's names you want to load
  29411. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  29412. * @param sceneFilename defines the filename of the scene to load from
  29413. */
  29414. constructor(
  29415. /**
  29416. * Defines the name of the task
  29417. */
  29418. name: string,
  29419. /**
  29420. * Defines the list of mesh's names you want to load
  29421. */
  29422. meshesNames: any,
  29423. /**
  29424. * Defines the root url to use as a base to load your meshes and associated resources
  29425. */
  29426. rootUrl: string,
  29427. /**
  29428. * Defines the filename of the scene to load from
  29429. */
  29430. sceneFilename: string);
  29431. /**
  29432. * Execute the current task
  29433. * @param scene defines the scene where you want your assets to be loaded
  29434. * @param onSuccess is a callback called when the task is successfully executed
  29435. * @param onError is a callback called if an error occurs
  29436. */
  29437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29438. }
  29439. /**
  29440. * Define a task used by {BABYLON.AssetsManager} to load text content
  29441. */
  29442. class TextFileAssetTask extends AbstractAssetTask {
  29443. /**
  29444. * Defines the name of the task
  29445. */
  29446. name: string;
  29447. /**
  29448. * Defines the location of the file to load
  29449. */
  29450. url: string;
  29451. /**
  29452. * Gets the loaded text string
  29453. */
  29454. text: string;
  29455. /**
  29456. * Callback called when the task is successful
  29457. */
  29458. onSuccess: (task: TextFileAssetTask) => void;
  29459. /**
  29460. * Callback called when the task is successful
  29461. */
  29462. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  29463. /**
  29464. * Creates a new TextFileAssetTask object
  29465. * @param name defines the name of the task
  29466. * @param url defines the location of the file to load
  29467. */
  29468. constructor(
  29469. /**
  29470. * Defines the name of the task
  29471. */
  29472. name: string,
  29473. /**
  29474. * Defines the location of the file to load
  29475. */
  29476. url: string);
  29477. /**
  29478. * Execute the current task
  29479. * @param scene defines the scene where you want your assets to be loaded
  29480. * @param onSuccess is a callback called when the task is successfully executed
  29481. * @param onError is a callback called if an error occurs
  29482. */
  29483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29484. }
  29485. /**
  29486. * Define a task used by {BABYLON.AssetsManager} to load binary data
  29487. */
  29488. class BinaryFileAssetTask extends AbstractAssetTask {
  29489. /**
  29490. * Defines the name of the task
  29491. */
  29492. name: string;
  29493. /**
  29494. * Defines the location of the file to load
  29495. */
  29496. url: string;
  29497. /**
  29498. * Gets the lodaded data (as an array buffer)
  29499. */
  29500. data: ArrayBuffer;
  29501. /**
  29502. * Callback called when the task is successful
  29503. */
  29504. onSuccess: (task: BinaryFileAssetTask) => void;
  29505. /**
  29506. * Callback called when the task is successful
  29507. */
  29508. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  29509. /**
  29510. * Creates a new BinaryFileAssetTask object
  29511. * @param name defines the name of the new task
  29512. * @param url defines the location of the file to load
  29513. */
  29514. constructor(
  29515. /**
  29516. * Defines the name of the task
  29517. */
  29518. name: string,
  29519. /**
  29520. * Defines the location of the file to load
  29521. */
  29522. url: string);
  29523. /**
  29524. * Execute the current task
  29525. * @param scene defines the scene where you want your assets to be loaded
  29526. * @param onSuccess is a callback called when the task is successfully executed
  29527. * @param onError is a callback called if an error occurs
  29528. */
  29529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29530. }
  29531. /**
  29532. * Define a task used by {BABYLON.AssetsManager} to load images
  29533. */
  29534. class ImageAssetTask extends AbstractAssetTask {
  29535. /**
  29536. * Defines the name of the task
  29537. */
  29538. name: string;
  29539. /**
  29540. * Defines the location of the image to load
  29541. */
  29542. url: string;
  29543. /**
  29544. * Gets the loaded images
  29545. */
  29546. image: HTMLImageElement;
  29547. /**
  29548. * Callback called when the task is successful
  29549. */
  29550. onSuccess: (task: ImageAssetTask) => void;
  29551. /**
  29552. * Callback called when the task is successful
  29553. */
  29554. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  29555. /**
  29556. * Creates a new ImageAssetTask
  29557. * @param name defines the name of the task
  29558. * @param url defines the location of the image to load
  29559. */
  29560. constructor(
  29561. /**
  29562. * Defines the name of the task
  29563. */
  29564. name: string,
  29565. /**
  29566. * Defines the location of the image to load
  29567. */
  29568. url: string);
  29569. /**
  29570. * Execute the current task
  29571. * @param scene defines the scene where you want your assets to be loaded
  29572. * @param onSuccess is a callback called when the task is successfully executed
  29573. * @param onError is a callback called if an error occurs
  29574. */
  29575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29576. }
  29577. /**
  29578. * Defines the interface used by texture loading tasks
  29579. */
  29580. interface ITextureAssetTask<TEX extends BaseTexture> {
  29581. /**
  29582. * Gets the loaded texture
  29583. */
  29584. texture: TEX;
  29585. }
  29586. /**
  29587. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  29588. */
  29589. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  29590. /**
  29591. * Defines the name of the task
  29592. */
  29593. name: string;
  29594. /**
  29595. * Defines the location of the file to load
  29596. */
  29597. url: string;
  29598. /**
  29599. * Defines if mipmap should not be generated (default is false)
  29600. */
  29601. noMipmap?: boolean | undefined;
  29602. /**
  29603. * Defines if texture must be inverted on Y axis (default is false)
  29604. */
  29605. invertY?: boolean | undefined;
  29606. /**
  29607. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29608. */
  29609. samplingMode: number;
  29610. /**
  29611. * Gets the loaded texture
  29612. */
  29613. texture: Texture;
  29614. /**
  29615. * Callback called when the task is successful
  29616. */
  29617. onSuccess: (task: TextureAssetTask) => void;
  29618. /**
  29619. * Callback called when the task is successful
  29620. */
  29621. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  29622. /**
  29623. * Creates a new TextureAssetTask object
  29624. * @param name defines the name of the task
  29625. * @param url defines the location of the file to load
  29626. * @param noMipmap defines if mipmap should not be generated (default is false)
  29627. * @param invertY defines if texture must be inverted on Y axis (default is false)
  29628. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29629. */
  29630. constructor(
  29631. /**
  29632. * Defines the name of the task
  29633. */
  29634. name: string,
  29635. /**
  29636. * Defines the location of the file to load
  29637. */
  29638. url: string,
  29639. /**
  29640. * Defines if mipmap should not be generated (default is false)
  29641. */
  29642. noMipmap?: boolean | undefined,
  29643. /**
  29644. * Defines if texture must be inverted on Y axis (default is false)
  29645. */
  29646. invertY?: boolean | undefined,
  29647. /**
  29648. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29649. */
  29650. samplingMode?: number);
  29651. /**
  29652. * Execute the current task
  29653. * @param scene defines the scene where you want your assets to be loaded
  29654. * @param onSuccess is a callback called when the task is successfully executed
  29655. * @param onError is a callback called if an error occurs
  29656. */
  29657. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29658. }
  29659. /**
  29660. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  29661. */
  29662. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  29663. /**
  29664. * Defines the name of the task
  29665. */
  29666. name: string;
  29667. /**
  29668. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29669. */
  29670. url: string;
  29671. /**
  29672. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29673. */
  29674. extensions?: string[] | undefined;
  29675. /**
  29676. * Defines if mipmaps should not be generated (default is false)
  29677. */
  29678. noMipmap?: boolean | undefined;
  29679. /**
  29680. * Defines the explicit list of files (undefined by default)
  29681. */
  29682. files?: string[] | undefined;
  29683. /**
  29684. * Gets the loaded texture
  29685. */
  29686. texture: CubeTexture;
  29687. /**
  29688. * Callback called when the task is successful
  29689. */
  29690. onSuccess: (task: CubeTextureAssetTask) => void;
  29691. /**
  29692. * Callback called when the task is successful
  29693. */
  29694. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  29695. /**
  29696. * Creates a new CubeTextureAssetTask
  29697. * @param name defines the name of the task
  29698. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29699. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29700. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29701. * @param files defines the explicit list of files (undefined by default)
  29702. */
  29703. constructor(
  29704. /**
  29705. * Defines the name of the task
  29706. */
  29707. name: string,
  29708. /**
  29709. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29710. */
  29711. url: string,
  29712. /**
  29713. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29714. */
  29715. extensions?: string[] | undefined,
  29716. /**
  29717. * Defines if mipmaps should not be generated (default is false)
  29718. */
  29719. noMipmap?: boolean | undefined,
  29720. /**
  29721. * Defines the explicit list of files (undefined by default)
  29722. */
  29723. files?: string[] | undefined);
  29724. /**
  29725. * Execute the current task
  29726. * @param scene defines the scene where you want your assets to be loaded
  29727. * @param onSuccess is a callback called when the task is successfully executed
  29728. * @param onError is a callback called if an error occurs
  29729. */
  29730. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29731. }
  29732. /**
  29733. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  29734. */
  29735. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  29736. /**
  29737. * Defines the name of the task
  29738. */
  29739. name: string;
  29740. /**
  29741. * Defines the location of the file to load
  29742. */
  29743. url: string;
  29744. /**
  29745. * Defines the desired size (the more it increases the longer the generation will be)
  29746. */
  29747. size: number;
  29748. /**
  29749. * Defines if mipmaps should not be generated (default is false)
  29750. */
  29751. noMipmap: boolean;
  29752. /**
  29753. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29754. */
  29755. generateHarmonics: boolean;
  29756. /**
  29757. * 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)
  29758. */
  29759. gammaSpace: boolean;
  29760. /**
  29761. * Internal Use Only
  29762. */
  29763. reserved: boolean;
  29764. /**
  29765. * Gets the loaded texture
  29766. */
  29767. texture: HDRCubeTexture;
  29768. /**
  29769. * Callback called when the task is successful
  29770. */
  29771. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  29772. /**
  29773. * Callback called when the task is successful
  29774. */
  29775. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  29776. /**
  29777. * Creates a new HDRCubeTextureAssetTask object
  29778. * @param name defines the name of the task
  29779. * @param url defines the location of the file to load
  29780. * @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.
  29781. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29782. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29783. * @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)
  29784. * @param reserved Internal use only
  29785. */
  29786. constructor(
  29787. /**
  29788. * Defines the name of the task
  29789. */
  29790. name: string,
  29791. /**
  29792. * Defines the location of the file to load
  29793. */
  29794. url: string,
  29795. /**
  29796. * Defines the desired size (the more it increases the longer the generation will be)
  29797. */
  29798. size: number,
  29799. /**
  29800. * Defines if mipmaps should not be generated (default is false)
  29801. */
  29802. noMipmap?: boolean,
  29803. /**
  29804. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29805. */
  29806. generateHarmonics?: boolean,
  29807. /**
  29808. * 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)
  29809. */
  29810. gammaSpace?: boolean,
  29811. /**
  29812. * Internal Use Only
  29813. */
  29814. reserved?: boolean);
  29815. /**
  29816. * Execute the current task
  29817. * @param scene defines the scene where you want your assets to be loaded
  29818. * @param onSuccess is a callback called when the task is successfully executed
  29819. * @param onError is a callback called if an error occurs
  29820. */
  29821. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29822. }
  29823. /**
  29824. * This class can be used to easily import assets into a scene
  29825. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  29826. */
  29827. class AssetsManager {
  29828. private _scene;
  29829. private _isLoading;
  29830. protected _tasks: AbstractAssetTask[];
  29831. protected _waitingTasksCount: number;
  29832. protected _totalTasksCount: number;
  29833. /**
  29834. * Callback called when all tasks are processed
  29835. */
  29836. onFinish: (tasks: AbstractAssetTask[]) => void;
  29837. /**
  29838. * Callback called when a task is successful
  29839. */
  29840. onTaskSuccess: (task: AbstractAssetTask) => void;
  29841. /**
  29842. * Callback called when a task had an error
  29843. */
  29844. onTaskError: (task: AbstractAssetTask) => void;
  29845. /**
  29846. * Callback called when a task is done (whatever the result is)
  29847. */
  29848. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  29849. /**
  29850. * Observable called when all tasks are processed
  29851. */
  29852. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  29853. /**
  29854. * Observable called when a task had an error
  29855. */
  29856. onTaskErrorObservable: Observable<AbstractAssetTask>;
  29857. /**
  29858. * Observable called when a task is successful
  29859. */
  29860. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  29861. /**
  29862. * Observable called when a task is done (whatever the result is)
  29863. */
  29864. onProgressObservable: Observable<IAssetsProgressEvent>;
  29865. /**
  29866. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  29867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29868. */
  29869. useDefaultLoadingScreen: boolean;
  29870. /**
  29871. * Creates a new AssetsManager
  29872. * @param scene defines the scene to work on
  29873. */
  29874. constructor(scene: Scene);
  29875. /**
  29876. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  29877. * @param taskName defines the name of the new task
  29878. * @param meshesNames defines the name of meshes to load
  29879. * @param rootUrl defines the root url to use to locate files
  29880. * @param sceneFilename defines the filename of the scene file
  29881. * @returns a new {BABYLON.MeshAssetTask} object
  29882. */
  29883. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  29884. /**
  29885. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  29886. * @param taskName defines the name of the new task
  29887. * @param url defines the url of the file to load
  29888. * @returns a new {BABYLON.TextFileAssetTask} object
  29889. */
  29890. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  29891. /**
  29892. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  29893. * @param taskName defines the name of the new task
  29894. * @param url defines the url of the file to load
  29895. * @returns a new {BABYLON.BinaryFileAssetTask} object
  29896. */
  29897. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  29898. /**
  29899. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  29900. * @param taskName defines the name of the new task
  29901. * @param url defines the url of the file to load
  29902. * @returns a new {BABYLON.ImageAssetTask} object
  29903. */
  29904. addImageTask(taskName: string, url: string): ImageAssetTask;
  29905. /**
  29906. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  29907. * @param taskName defines the name of the new task
  29908. * @param url defines the url of the file to load
  29909. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29910. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  29911. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29912. * @returns a new {BABYLON.TextureAssetTask} object
  29913. */
  29914. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29915. /**
  29916. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29917. * @param taskName defines the name of the new task
  29918. * @param url defines the url of the file to load
  29919. * @param extensions defines the extension to use to load the cube map (can be null)
  29920. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29921. * @param files defines the list of files to load (can be null)
  29922. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29923. */
  29924. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29925. /**
  29926. *
  29927. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29928. * @param taskName defines the name of the new task
  29929. * @param url defines the url of the file to load
  29930. * @param size defines the size you want for the cubemap (can be null)
  29931. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29932. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29933. * @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)
  29934. * @param reserved Internal use only
  29935. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29936. */
  29937. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29938. /**
  29939. * Remove a task from the assets manager.
  29940. * @param task the task to remove
  29941. */
  29942. removeTask(task: AbstractAssetTask): void;
  29943. private _decreaseWaitingTasksCount;
  29944. private _runTask;
  29945. /**
  29946. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29947. * @return the current instance of the {BABYLON.AssetsManager}
  29948. */
  29949. reset(): AssetsManager;
  29950. /**
  29951. * Start the loading process
  29952. * @return the current instance of the {BABYLON.AssetsManager}
  29953. */
  29954. load(): AssetsManager;
  29955. }
  29956. }
  29957. declare module BABYLON {
  29958. /**
  29959. * Class used to enable access to IndexedDB
  29960. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29961. */
  29962. class Database {
  29963. private callbackManifestChecked;
  29964. private currentSceneUrl;
  29965. private db;
  29966. private _enableSceneOffline;
  29967. private _enableTexturesOffline;
  29968. private manifestVersionFound;
  29969. private mustUpdateRessources;
  29970. private hasReachedQuota;
  29971. private isSupported;
  29972. private idbFactory;
  29973. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29974. static IsUASupportingBlobStorage: boolean;
  29975. /** Gets a boolean indicating if Database storate is enabled */
  29976. static IDBStorageEnabled: boolean;
  29977. /**
  29978. * Gets a boolean indicating if scene must be saved in the database
  29979. */
  29980. readonly enableSceneOffline: boolean;
  29981. /**
  29982. * Gets a boolean indicating if textures must be saved in the database
  29983. */
  29984. readonly enableTexturesOffline: boolean;
  29985. /**
  29986. * Creates a new Database
  29987. * @param urlToScene defines the url to load the scene
  29988. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29989. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29990. */
  29991. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29992. private static _ParseURL;
  29993. private static _ReturnFullUrlLocation;
  29994. private _checkManifestFile;
  29995. /**
  29996. * Open the database and make it available
  29997. * @param successCallback defines the callback to call on success
  29998. * @param errorCallback defines the callback to call on error
  29999. */
  30000. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30001. /**
  30002. * Loads an image from the database
  30003. * @param url defines the url to load from
  30004. * @param image defines the target DOM image
  30005. */
  30006. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30007. private _loadImageFromDBAsync;
  30008. private _saveImageIntoDBAsync;
  30009. private _checkVersionFromDB;
  30010. private _loadVersionFromDBAsync;
  30011. private _saveVersionIntoDBAsync;
  30012. /**
  30013. * Loads a file from database
  30014. * @param url defines the URL to load from
  30015. * @param sceneLoaded defines a callback to call on success
  30016. * @param progressCallBack defines a callback to call when progress changed
  30017. * @param errorCallback defines a callback to call on error
  30018. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30019. */
  30020. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30021. private _loadFileFromDBAsync;
  30022. private _saveFileIntoDBAsync;
  30023. }
  30024. }
  30025. declare module BABYLON {
  30026. interface DDSInfo {
  30027. width: number;
  30028. height: number;
  30029. mipmapCount: number;
  30030. isFourCC: boolean;
  30031. isRGB: boolean;
  30032. isLuminance: boolean;
  30033. isCube: boolean;
  30034. isCompressed: boolean;
  30035. dxgiFormat: number;
  30036. textureType: number;
  30037. /** Sphericle polynomial created for the dds texture */
  30038. sphericalPolynomial?: SphericalPolynomial;
  30039. }
  30040. class DDSTools {
  30041. static StoreLODInAlphaChannel: boolean;
  30042. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30043. private static _FloatView;
  30044. private static _Int32View;
  30045. private static _ToHalfFloat;
  30046. private static _FromHalfFloat;
  30047. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30048. private static _GetHalfFloatRGBAArrayBuffer;
  30049. private static _GetFloatRGBAArrayBuffer;
  30050. private static _GetFloatAsUIntRGBAArrayBuffer;
  30051. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30052. private static _GetRGBAArrayBuffer;
  30053. private static _ExtractLongWordOrder;
  30054. private static _GetRGBArrayBuffer;
  30055. private static _GetLuminanceArrayBuffer;
  30056. /**
  30057. * Uploads DDS Levels to a Babylon Texture
  30058. * @hidden
  30059. */
  30060. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30061. }
  30062. }
  30063. declare module BABYLON {
  30064. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30065. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30066. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30067. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30068. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30069. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30070. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30071. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30072. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30073. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30074. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30075. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30076. /**
  30077. * Decorator used to define property that can be serialized as reference to a camera
  30078. * @param sourceName defines the name of the property to decorate
  30079. */
  30080. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30081. class SerializationHelper {
  30082. static Serialize<T>(entity: T, serializationObject?: any): any;
  30083. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30084. static Clone<T>(creationFunction: () => T, source: T): T;
  30085. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30086. }
  30087. }
  30088. declare module BABYLON {
  30089. /**
  30090. * Wrapper class for promise with external resolve and reject.
  30091. */
  30092. class Deferred<T> {
  30093. /**
  30094. * The promise associated with this deferred object.
  30095. */
  30096. readonly promise: Promise<T>;
  30097. private _resolve;
  30098. private _reject;
  30099. /**
  30100. * The resolve method of the promise associated with this deferred object.
  30101. */
  30102. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30103. /**
  30104. * The reject method of the promise associated with this deferred object.
  30105. */
  30106. readonly reject: (reason?: any) => void;
  30107. /**
  30108. * Constructor for this deferred object.
  30109. */
  30110. constructor();
  30111. }
  30112. }
  30113. declare module BABYLON {
  30114. /**
  30115. * Raw texture data and descriptor sufficient for WebGL texture upload
  30116. */
  30117. interface EnvironmentTextureInfo {
  30118. /**
  30119. * Version of the environment map
  30120. */
  30121. version: number;
  30122. /**
  30123. * Width of image
  30124. */
  30125. width: number;
  30126. /**
  30127. * Irradiance information stored in the file.
  30128. */
  30129. irradiance: any;
  30130. /**
  30131. * Specular information stored in the file.
  30132. */
  30133. specular: any;
  30134. }
  30135. /**
  30136. * Sets of helpers addressing the serialization and deserialization of environment texture
  30137. * stored in a BabylonJS env file.
  30138. * Those files are usually stored as .env files.
  30139. */
  30140. class EnvironmentTextureTools {
  30141. /**
  30142. * Magic number identifying the env file.
  30143. */
  30144. private static _MagicBytes;
  30145. /**
  30146. * Gets the environment info from an env file.
  30147. * @param data The array buffer containing the .env bytes.
  30148. * @returns the environment file info (the json header) if successfully parsed.
  30149. */
  30150. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30151. /**
  30152. * Creates an environment texture from a loaded cube texture.
  30153. * @param texture defines the cube texture to convert in env file
  30154. * @return a promise containing the environment data if succesfull.
  30155. */
  30156. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30157. /**
  30158. * Creates a JSON representation of the spherical data.
  30159. * @param texture defines the texture containing the polynomials
  30160. * @return the JSON representation of the spherical info
  30161. */
  30162. private static _CreateEnvTextureIrradiance;
  30163. /**
  30164. * Uploads the texture info contained in the env file to the GPU.
  30165. * @param texture defines the internal texture to upload to
  30166. * @param arrayBuffer defines the buffer cotaining the data to load
  30167. * @param info defines the texture info retrieved through the GetEnvInfo method
  30168. * @returns a promise
  30169. */
  30170. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30171. /**
  30172. * Uploads the levels of image data to the GPU.
  30173. * @param texture defines the internal texture to upload to
  30174. * @param imageData defines the array buffer views of image data [mipmap][face]
  30175. * @returns a promise
  30176. */
  30177. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30178. /**
  30179. * Uploads spherical polynomials information to the texture.
  30180. * @param texture defines the texture we are trying to upload the information to
  30181. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30182. */
  30183. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30184. }
  30185. }
  30186. declare module BABYLON {
  30187. class FilesInput {
  30188. static FilesToLoad: {
  30189. [key: string]: File;
  30190. };
  30191. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30192. private _engine;
  30193. private _currentScene;
  30194. private _sceneLoadedCallback;
  30195. private _progressCallback;
  30196. private _additionalRenderLoopLogicCallback;
  30197. private _textureLoadingCallback;
  30198. private _startingProcessingFilesCallback;
  30199. private _onReloadCallback;
  30200. private _errorCallback;
  30201. private _elementToMonitor;
  30202. private _sceneFileToLoad;
  30203. private _filesToLoad;
  30204. 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);
  30205. private _dragEnterHandler;
  30206. private _dragOverHandler;
  30207. private _dropHandler;
  30208. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30209. dispose(): void;
  30210. private renderFunction;
  30211. private drag;
  30212. private drop;
  30213. private _traverseFolder;
  30214. private _processFiles;
  30215. loadFiles(event: any): void;
  30216. private _processReload;
  30217. reload(): void;
  30218. }
  30219. }
  30220. declare module BABYLON {
  30221. /**
  30222. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30223. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30224. */
  30225. class KhronosTextureContainer {
  30226. arrayBuffer: any;
  30227. static HEADER_LEN: number;
  30228. static COMPRESSED_2D: number;
  30229. static COMPRESSED_3D: number;
  30230. static TEX_2D: number;
  30231. static TEX_3D: number;
  30232. glType: number;
  30233. glTypeSize: number;
  30234. glFormat: number;
  30235. glInternalFormat: number;
  30236. glBaseInternalFormat: number;
  30237. pixelWidth: number;
  30238. pixelHeight: number;
  30239. pixelDepth: number;
  30240. numberOfArrayElements: number;
  30241. numberOfFaces: number;
  30242. numberOfMipmapLevels: number;
  30243. bytesOfKeyValueData: number;
  30244. loadType: number;
  30245. /**
  30246. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  30247. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  30248. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  30249. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  30250. */
  30251. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  30252. switchEndainness(val: number): number;
  30253. /**
  30254. * Uploads KTX content to a Babylon Texture.
  30255. * It is assumed that the texture has already been created & is currently bound
  30256. * @hidden
  30257. */
  30258. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  30259. private _upload2DCompressedLevels;
  30260. }
  30261. }
  30262. declare module BABYLON {
  30263. /**
  30264. * A class serves as a medium between the observable and its observers
  30265. */
  30266. class EventState {
  30267. /**
  30268. * Create a new EventState
  30269. * @param mask defines the mask associated with this state
  30270. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30271. * @param target defines the original target of the state
  30272. * @param currentTarget defines the current target of the state
  30273. */
  30274. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  30275. /**
  30276. * Initialize the current event state
  30277. * @param mask defines the mask associated with this state
  30278. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30279. * @param target defines the original target of the state
  30280. * @param currentTarget defines the current target of the state
  30281. * @returns the current event state
  30282. */
  30283. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  30284. /**
  30285. * An Observer can set this property to true to prevent subsequent observers of being notified
  30286. */
  30287. skipNextObservers: boolean;
  30288. /**
  30289. * Get the mask value that were used to trigger the event corresponding to this EventState object
  30290. */
  30291. mask: number;
  30292. /**
  30293. * The object that originally notified the event
  30294. */
  30295. target?: any;
  30296. /**
  30297. * The current object in the bubbling phase
  30298. */
  30299. currentTarget?: any;
  30300. /**
  30301. * This will be populated with the return value of the last function that was executed.
  30302. * If it is the first function in the callback chain it will be the event data.
  30303. */
  30304. lastReturnValue?: any;
  30305. }
  30306. /**
  30307. * Represent an Observer registered to a given Observable object.
  30308. */
  30309. class Observer<T> {
  30310. /**
  30311. * Defines the callback to call when the observer is notified
  30312. */
  30313. callback: (eventData: T, eventState: EventState) => void;
  30314. /**
  30315. * Defines the mask of the observer (used to filter notifications)
  30316. */
  30317. mask: number;
  30318. /**
  30319. * Defines the current scope used to restore the JS context
  30320. */
  30321. scope: any;
  30322. /** @hidden */
  30323. _willBeUnregistered: boolean;
  30324. /**
  30325. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  30326. */
  30327. unregisterOnNextCall: boolean;
  30328. /**
  30329. * Creates a new observer
  30330. * @param callback defines the callback to call when the observer is notified
  30331. * @param mask defines the mask of the observer (used to filter notifications)
  30332. * @param scope defines the current scope used to restore the JS context
  30333. */
  30334. constructor(
  30335. /**
  30336. * Defines the callback to call when the observer is notified
  30337. */
  30338. callback: (eventData: T, eventState: EventState) => void,
  30339. /**
  30340. * Defines the mask of the observer (used to filter notifications)
  30341. */
  30342. mask: number,
  30343. /**
  30344. * Defines the current scope used to restore the JS context
  30345. */
  30346. scope?: any);
  30347. }
  30348. /**
  30349. * Represent a list of observers registered to multiple Observables object.
  30350. */
  30351. class MultiObserver<T> {
  30352. private _observers;
  30353. private _observables;
  30354. /**
  30355. * Release associated resources
  30356. */
  30357. dispose(): void;
  30358. /**
  30359. * Raise a callback when one of the observable will notify
  30360. * @param observables defines a list of observables to watch
  30361. * @param callback defines the callback to call on notification
  30362. * @param mask defines the mask used to filter notifications
  30363. * @param scope defines the current scope used to restore the JS context
  30364. * @returns the new MultiObserver
  30365. */
  30366. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  30367. }
  30368. /**
  30369. * The Observable class is a simple implementation of the Observable pattern.
  30370. *
  30371. * 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.
  30372. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  30373. * 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).
  30374. * 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.
  30375. */
  30376. class Observable<T> {
  30377. private _observers;
  30378. private _eventState;
  30379. private _onObserverAdded;
  30380. /**
  30381. * Creates a new observable
  30382. * @param onObserverAdded defines a callback to call when a new observer is added
  30383. */
  30384. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  30385. /**
  30386. * Create a new Observer with the specified callback
  30387. * @param callback the callback that will be executed for that Observer
  30388. * @param mask the mask used to filter observers
  30389. * @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.
  30390. * @param scope optional scope for the callback to be called from
  30391. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  30392. * @returns the new observer created for the callback
  30393. */
  30394. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  30395. /**
  30396. * Create a new Observer with the specified callback and unregisters after the next notification
  30397. * @param callback the callback that will be executed for that Observer
  30398. * @returns the new observer created for the callback
  30399. */
  30400. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  30401. /**
  30402. * Remove an Observer from the Observable object
  30403. * @param observer the instance of the Observer to remove
  30404. * @returns false if it doesn't belong to this Observable
  30405. */
  30406. remove(observer: Nullable<Observer<T>>): boolean;
  30407. /**
  30408. * Remove a callback from the Observable object
  30409. * @param callback the callback to remove
  30410. * @param scope optional scope. If used only the callbacks with this scope will be removed
  30411. * @returns false if it doesn't belong to this Observable
  30412. */
  30413. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  30414. private _deferUnregister;
  30415. private _remove;
  30416. /**
  30417. * Notify all Observers by calling their respective callback with the given data
  30418. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  30419. * @param eventData defines the data to send to all observers
  30420. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  30421. * @param target defines the original target of the state
  30422. * @param currentTarget defines the current target of the state
  30423. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  30424. */
  30425. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  30426. /**
  30427. * Calling this will execute each callback, expecting it to be a promise or return a value.
  30428. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  30429. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  30430. * and it is crucial that all callbacks will be executed.
  30431. * The order of the callbacks is kept, callbacks are not executed parallel.
  30432. *
  30433. * @param eventData The data to be sent to each callback
  30434. * @param mask is used to filter observers defaults to -1
  30435. * @param target defines the callback target (see EventState)
  30436. * @param currentTarget defines he current object in the bubbling phase
  30437. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  30438. */
  30439. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  30440. /**
  30441. * Notify a specific observer
  30442. * @param observer defines the observer to notify
  30443. * @param eventData defines the data to be sent to each callback
  30444. * @param mask is used to filter observers defaults to -1
  30445. */
  30446. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  30447. /**
  30448. * Gets a boolean indicating if the observable has at least one observer
  30449. * @returns true is the Observable has at least one Observer registered
  30450. */
  30451. hasObservers(): boolean;
  30452. /**
  30453. * Clear the list of observers
  30454. */
  30455. clear(): void;
  30456. /**
  30457. * Clone the current observable
  30458. * @returns a new observable
  30459. */
  30460. clone(): Observable<T>;
  30461. /**
  30462. * Does this observable handles observer registered with a given mask
  30463. * @param mask defines the mask to be tested
  30464. * @return whether or not one observer registered with the given mask is handeled
  30465. **/
  30466. hasSpecificMask(mask?: number): boolean;
  30467. }
  30468. }
  30469. declare module BABYLON {
  30470. /**
  30471. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30472. */
  30473. class PerformanceMonitor {
  30474. private _enabled;
  30475. private _rollingFrameTime;
  30476. private _lastFrameTimeMs;
  30477. /**
  30478. * constructor
  30479. * @param frameSampleSize The number of samples required to saturate the sliding window
  30480. */
  30481. constructor(frameSampleSize?: number);
  30482. /**
  30483. * Samples current frame
  30484. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30485. */
  30486. sampleFrame(timeMs?: number): void;
  30487. /**
  30488. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30489. * @return Average frame time in milliseconds
  30490. */
  30491. readonly averageFrameTime: number;
  30492. /**
  30493. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30494. * @return Frame time variance in milliseconds squared
  30495. */
  30496. readonly averageFrameTimeVariance: number;
  30497. /**
  30498. * Returns the frame time of the most recent frame
  30499. * @return Frame time in milliseconds
  30500. */
  30501. readonly instantaneousFrameTime: number;
  30502. /**
  30503. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30504. * @return Framerate in frames per second
  30505. */
  30506. readonly averageFPS: number;
  30507. /**
  30508. * Returns the average framerate in frames per second using the most recent frame time
  30509. * @return Framerate in frames per second
  30510. */
  30511. readonly instantaneousFPS: number;
  30512. /**
  30513. * Returns true if enough samples have been taken to completely fill the sliding window
  30514. * @return true if saturated
  30515. */
  30516. readonly isSaturated: boolean;
  30517. /**
  30518. * Enables contributions to the sliding window sample set
  30519. */
  30520. enable(): void;
  30521. /**
  30522. * Disables contributions to the sliding window sample set
  30523. * Samples will not be interpolated over the disabled period
  30524. */
  30525. disable(): void;
  30526. /**
  30527. * Returns true if sampling is enabled
  30528. * @return true if enabled
  30529. */
  30530. readonly isEnabled: boolean;
  30531. /**
  30532. * Resets performance monitor
  30533. */
  30534. reset(): void;
  30535. }
  30536. /**
  30537. * RollingAverage
  30538. *
  30539. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30540. */
  30541. class RollingAverage {
  30542. /**
  30543. * Current average
  30544. */
  30545. average: number;
  30546. /**
  30547. * Current variance
  30548. */
  30549. variance: number;
  30550. protected _samples: Array<number>;
  30551. protected _sampleCount: number;
  30552. protected _pos: number;
  30553. protected _m2: number;
  30554. /**
  30555. * constructor
  30556. * @param length The number of samples required to saturate the sliding window
  30557. */
  30558. constructor(length: number);
  30559. /**
  30560. * Adds a sample to the sample set
  30561. * @param v The sample value
  30562. */
  30563. add(v: number): void;
  30564. /**
  30565. * Returns previously added values or null if outside of history or outside the sliding window domain
  30566. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30567. * @return Value previously recorded with add() or null if outside of range
  30568. */
  30569. history(i: number): number;
  30570. /**
  30571. * Returns true if enough samples have been taken to completely fill the sliding window
  30572. * @return true if sample-set saturated
  30573. */
  30574. isSaturated(): boolean;
  30575. /**
  30576. * Resets the rolling average (equivalent to 0 samples taken so far)
  30577. */
  30578. reset(): void;
  30579. /**
  30580. * Wraps a value around the sample range boundaries
  30581. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30582. * @return Wrapped position in sample range
  30583. */
  30584. protected _wrapPosition(i: number): number;
  30585. }
  30586. }
  30587. declare module BABYLON {
  30588. /**
  30589. * Helper class that provides a small promise polyfill
  30590. */
  30591. class PromisePolyfill {
  30592. /**
  30593. * Static function used to check if the polyfill is required
  30594. * If this is the case then the function will inject the polyfill to window.Promise
  30595. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30596. */
  30597. static Apply(force?: boolean): void;
  30598. }
  30599. }
  30600. declare module BABYLON {
  30601. /**
  30602. * Defines the root class used to create scene optimization to use with SceneOptimizer
  30603. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30604. */
  30605. class SceneOptimization {
  30606. /**
  30607. * Defines the priority of this optimization (0 by default which means first in the list)
  30608. */
  30609. priority: number;
  30610. /**
  30611. * Gets a string describing the action executed by the current optimization
  30612. * @returns description string
  30613. */
  30614. getDescription(): string;
  30615. /**
  30616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30617. * @param scene defines the current scene where to apply this optimization
  30618. * @param optimizer defines the current optimizer
  30619. * @returns true if everything that can be done was applied
  30620. */
  30621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30622. /**
  30623. * Creates the SceneOptimization object
  30624. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30625. * @param desc defines the description associated with the optimization
  30626. */
  30627. constructor(
  30628. /**
  30629. * Defines the priority of this optimization (0 by default which means first in the list)
  30630. */
  30631. priority?: number);
  30632. }
  30633. /**
  30634. * Defines an optimization used to reduce the size of render target textures
  30635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30636. */
  30637. class TextureOptimization extends SceneOptimization {
  30638. /**
  30639. * Defines the priority of this optimization (0 by default which means first in the list)
  30640. */
  30641. priority: number;
  30642. /**
  30643. * 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
  30644. */
  30645. maximumSize: number;
  30646. /**
  30647. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30648. */
  30649. step: number;
  30650. /**
  30651. * Gets a string describing the action executed by the current optimization
  30652. * @returns description string
  30653. */
  30654. getDescription(): string;
  30655. /**
  30656. * Creates the TextureOptimization object
  30657. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30658. * @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
  30659. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30660. */
  30661. constructor(
  30662. /**
  30663. * Defines the priority of this optimization (0 by default which means first in the list)
  30664. */
  30665. priority?: number,
  30666. /**
  30667. * 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
  30668. */
  30669. maximumSize?: number,
  30670. /**
  30671. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30672. */
  30673. step?: number);
  30674. /**
  30675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30676. * @param scene defines the current scene where to apply this optimization
  30677. * @param optimizer defines the current optimizer
  30678. * @returns true if everything that can be done was applied
  30679. */
  30680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30681. }
  30682. /**
  30683. * Defines an optimization used to increase or decrease the rendering resolution
  30684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30685. */
  30686. class HardwareScalingOptimization extends SceneOptimization {
  30687. /**
  30688. * Defines the priority of this optimization (0 by default which means first in the list)
  30689. */
  30690. priority: number;
  30691. /**
  30692. * Defines the maximum scale to use (2 by default)
  30693. */
  30694. maximumScale: number;
  30695. /**
  30696. * Defines the step to use between two passes (0.5 by default)
  30697. */
  30698. step: number;
  30699. private _currentScale;
  30700. private _directionOffset;
  30701. /**
  30702. * Gets a string describing the action executed by the current optimization
  30703. * @return description string
  30704. */
  30705. getDescription(): string;
  30706. /**
  30707. * Creates the HardwareScalingOptimization object
  30708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30709. * @param maximumScale defines the maximum scale to use (2 by default)
  30710. * @param step defines the step to use between two passes (0.5 by default)
  30711. */
  30712. constructor(
  30713. /**
  30714. * Defines the priority of this optimization (0 by default which means first in the list)
  30715. */
  30716. priority?: number,
  30717. /**
  30718. * Defines the maximum scale to use (2 by default)
  30719. */
  30720. maximumScale?: number,
  30721. /**
  30722. * Defines the step to use between two passes (0.5 by default)
  30723. */
  30724. step?: number);
  30725. /**
  30726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30727. * @param scene defines the current scene where to apply this optimization
  30728. * @param optimizer defines the current optimizer
  30729. * @returns true if everything that can be done was applied
  30730. */
  30731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30732. }
  30733. /**
  30734. * Defines an optimization used to remove shadows
  30735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30736. */
  30737. class ShadowsOptimization extends SceneOptimization {
  30738. /**
  30739. * Gets a string describing the action executed by the current optimization
  30740. * @return description string
  30741. */
  30742. getDescription(): string;
  30743. /**
  30744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30745. * @param scene defines the current scene where to apply this optimization
  30746. * @param optimizer defines the current optimizer
  30747. * @returns true if everything that can be done was applied
  30748. */
  30749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30750. }
  30751. /**
  30752. * Defines an optimization used to turn post-processes off
  30753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30754. */
  30755. class PostProcessesOptimization extends SceneOptimization {
  30756. /**
  30757. * Gets a string describing the action executed by the current optimization
  30758. * @return description string
  30759. */
  30760. getDescription(): string;
  30761. /**
  30762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30763. * @param scene defines the current scene where to apply this optimization
  30764. * @param optimizer defines the current optimizer
  30765. * @returns true if everything that can be done was applied
  30766. */
  30767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30768. }
  30769. /**
  30770. * Defines an optimization used to turn lens flares off
  30771. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30772. */
  30773. class LensFlaresOptimization extends SceneOptimization {
  30774. /**
  30775. * Gets a string describing the action executed by the current optimization
  30776. * @return description string
  30777. */
  30778. getDescription(): string;
  30779. /**
  30780. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30781. * @param scene defines the current scene where to apply this optimization
  30782. * @param optimizer defines the current optimizer
  30783. * @returns true if everything that can be done was applied
  30784. */
  30785. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30786. }
  30787. /**
  30788. * Defines an optimization based on user defined callback.
  30789. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30790. */
  30791. class CustomOptimization extends SceneOptimization {
  30792. /**
  30793. * Callback called to apply the custom optimization.
  30794. */
  30795. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  30796. /**
  30797. * Callback called to get custom description
  30798. */
  30799. onGetDescription: () => string;
  30800. /**
  30801. * Gets a string describing the action executed by the current optimization
  30802. * @returns description string
  30803. */
  30804. getDescription(): string;
  30805. /**
  30806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30807. * @param scene defines the current scene where to apply this optimization
  30808. * @param optimizer defines the current optimizer
  30809. * @returns true if everything that can be done was applied
  30810. */
  30811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30812. }
  30813. /**
  30814. * Defines an optimization used to turn particles off
  30815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30816. */
  30817. class ParticlesOptimization extends SceneOptimization {
  30818. /**
  30819. * Gets a string describing the action executed by the current optimization
  30820. * @return description string
  30821. */
  30822. getDescription(): string;
  30823. /**
  30824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30825. * @param scene defines the current scene where to apply this optimization
  30826. * @param optimizer defines the current optimizer
  30827. * @returns true if everything that can be done was applied
  30828. */
  30829. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30830. }
  30831. /**
  30832. * Defines an optimization used to turn render targets off
  30833. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30834. */
  30835. class RenderTargetsOptimization extends SceneOptimization {
  30836. /**
  30837. * Gets a string describing the action executed by the current optimization
  30838. * @return description string
  30839. */
  30840. getDescription(): string;
  30841. /**
  30842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30843. * @param scene defines the current scene where to apply this optimization
  30844. * @param optimizer defines the current optimizer
  30845. * @returns true if everything that can be done was applied
  30846. */
  30847. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30848. }
  30849. /**
  30850. * Defines an optimization used to merge meshes with compatible materials
  30851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30852. */
  30853. class MergeMeshesOptimization extends SceneOptimization {
  30854. private static _UpdateSelectionTree;
  30855. /**
  30856. * Gets or sets a boolean which defines if optimization octree has to be updated
  30857. */
  30858. /**
  30859. * Gets or sets a boolean which defines if optimization octree has to be updated
  30860. */
  30861. static UpdateSelectionTree: boolean;
  30862. /**
  30863. * Gets a string describing the action executed by the current optimization
  30864. * @return description string
  30865. */
  30866. getDescription(): string;
  30867. private _canBeMerged;
  30868. /**
  30869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30870. * @param scene defines the current scene where to apply this optimization
  30871. * @param optimizer defines the current optimizer
  30872. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  30873. * @returns true if everything that can be done was applied
  30874. */
  30875. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  30876. }
  30877. /**
  30878. * Defines a list of options used by SceneOptimizer
  30879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30880. */
  30881. class SceneOptimizerOptions {
  30882. /**
  30883. * Defines the target frame rate to reach (60 by default)
  30884. */
  30885. targetFrameRate: number;
  30886. /**
  30887. * Defines the interval between two checkes (2000ms by default)
  30888. */
  30889. trackerDuration: number;
  30890. /**
  30891. * Gets the list of optimizations to apply
  30892. */
  30893. optimizations: SceneOptimization[];
  30894. /**
  30895. * Creates a new list of options used by SceneOptimizer
  30896. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  30897. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  30898. */
  30899. constructor(
  30900. /**
  30901. * Defines the target frame rate to reach (60 by default)
  30902. */
  30903. targetFrameRate?: number,
  30904. /**
  30905. * Defines the interval between two checkes (2000ms by default)
  30906. */
  30907. trackerDuration?: number);
  30908. /**
  30909. * Add a new optimization
  30910. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  30911. * @returns the current SceneOptimizerOptions
  30912. */
  30913. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30914. /**
  30915. * Add a new custom optimization
  30916. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30917. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30918. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30919. * @returns the current SceneOptimizerOptions
  30920. */
  30921. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30922. /**
  30923. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30924. * @param targetFrameRate defines the target frame rate (60 by default)
  30925. * @returns a SceneOptimizerOptions object
  30926. */
  30927. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30928. /**
  30929. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30930. * @param targetFrameRate defines the target frame rate (60 by default)
  30931. * @returns a SceneOptimizerOptions object
  30932. */
  30933. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30934. /**
  30935. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  30936. * @param targetFrameRate defines the target frame rate (60 by default)
  30937. * @returns a SceneOptimizerOptions object
  30938. */
  30939. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30940. }
  30941. /**
  30942. * Class used to run optimizations in order to reach a target frame rate
  30943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30944. */
  30945. class SceneOptimizer implements IDisposable {
  30946. private _isRunning;
  30947. private _options;
  30948. private _scene;
  30949. private _currentPriorityLevel;
  30950. private _targetFrameRate;
  30951. private _trackerDuration;
  30952. private _currentFrameRate;
  30953. private _sceneDisposeObserver;
  30954. private _improvementMode;
  30955. /**
  30956. * Defines an observable called when the optimizer reaches the target frame rate
  30957. */
  30958. onSuccessObservable: Observable<SceneOptimizer>;
  30959. /**
  30960. * Defines an observable called when the optimizer enables an optimization
  30961. */
  30962. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30963. /**
  30964. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30965. */
  30966. onFailureObservable: Observable<SceneOptimizer>;
  30967. /**
  30968. * Gets a boolean indicating if the optimizer is in improvement mode
  30969. */
  30970. readonly isInImprovementMode: boolean;
  30971. /**
  30972. * Gets the current priority level (0 at start)
  30973. */
  30974. readonly currentPriorityLevel: number;
  30975. /**
  30976. * Gets the current frame rate checked by the SceneOptimizer
  30977. */
  30978. readonly currentFrameRate: number;
  30979. /**
  30980. * Gets or sets the current target frame rate (60 by default)
  30981. */
  30982. /**
  30983. * Gets or sets the current target frame rate (60 by default)
  30984. */
  30985. targetFrameRate: number;
  30986. /**
  30987. * Gets or sets the current interval between two checks (every 2000ms by default)
  30988. */
  30989. /**
  30990. * Gets or sets the current interval between two checks (every 2000ms by default)
  30991. */
  30992. trackerDuration: number;
  30993. /**
  30994. * Gets the list of active optimizations
  30995. */
  30996. readonly optimizations: SceneOptimization[];
  30997. /**
  30998. * Creates a new SceneOptimizer
  30999. * @param scene defines the scene to work on
  31000. * @param options defines the options to use with the SceneOptimizer
  31001. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31002. * @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)
  31003. */
  31004. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31005. /**
  31006. * Stops the current optimizer
  31007. */
  31008. stop(): void;
  31009. /**
  31010. * Reset the optimizer to initial step (current priority level = 0)
  31011. */
  31012. reset(): void;
  31013. /**
  31014. * Start the optimizer. By default it will try to reach a specific framerate
  31015. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31016. */
  31017. start(): void;
  31018. private _checkCurrentState;
  31019. /**
  31020. * Release all resources
  31021. */
  31022. dispose(): void;
  31023. /**
  31024. * Helper function to create a SceneOptimizer with one single line of code
  31025. * @param scene defines the scene to work on
  31026. * @param options defines the options to use with the SceneOptimizer
  31027. * @param onSuccess defines a callback to call on success
  31028. * @param onFailure defines a callback to call on failure
  31029. * @returns the new SceneOptimizer object
  31030. */
  31031. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31032. }
  31033. }
  31034. declare module BABYLON {
  31035. class SceneSerializer {
  31036. static ClearCache(): void;
  31037. static Serialize(scene: Scene): any;
  31038. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31039. }
  31040. }
  31041. declare module BABYLON {
  31042. class SmartArray<T> {
  31043. data: Array<T>;
  31044. length: number;
  31045. protected _id: number;
  31046. [index: number]: T;
  31047. constructor(capacity: number);
  31048. push(value: T): void;
  31049. forEach(func: (content: T) => void): void;
  31050. sort(compareFn: (a: T, b: T) => number): void;
  31051. reset(): void;
  31052. dispose(): void;
  31053. concat(array: any): void;
  31054. indexOf(value: T): number;
  31055. contains(value: T): boolean;
  31056. private static _GlobalId;
  31057. }
  31058. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31059. private _duplicateId;
  31060. [index: number]: T;
  31061. push(value: T): void;
  31062. pushNoDuplicate(value: T): boolean;
  31063. reset(): void;
  31064. concatWithNoDuplicate(array: any): void;
  31065. }
  31066. }
  31067. declare module BABYLON {
  31068. /**
  31069. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31070. * The underlying implementation relies on an associative array to ensure the best performances.
  31071. * The value can be anything including 'null' but except 'undefined'
  31072. */
  31073. class StringDictionary<T> {
  31074. /**
  31075. * This will clear this dictionary and copy the content from the 'source' one.
  31076. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31077. * @param source the dictionary to take the content from and copy to this dictionary
  31078. */
  31079. copyFrom(source: StringDictionary<T>): void;
  31080. /**
  31081. * Get a value based from its key
  31082. * @param key the given key to get the matching value from
  31083. * @return the value if found, otherwise undefined is returned
  31084. */
  31085. get(key: string): T | undefined;
  31086. /**
  31087. * Get a value from its key or add it if it doesn't exist.
  31088. * This method will ensure you that a given key/data will be present in the dictionary.
  31089. * @param key the given key to get the matching value from
  31090. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31091. * The factory will only be invoked if there's no data for the given key.
  31092. * @return the value corresponding to the key.
  31093. */
  31094. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31095. /**
  31096. * Get a value from its key if present in the dictionary otherwise add it
  31097. * @param key the key to get the value from
  31098. * @param val if there's no such key/value pair in the dictionary add it with this value
  31099. * @return the value corresponding to the key
  31100. */
  31101. getOrAdd(key: string, val: T): T;
  31102. /**
  31103. * Check if there's a given key in the dictionary
  31104. * @param key the key to check for
  31105. * @return true if the key is present, false otherwise
  31106. */
  31107. contains(key: string): boolean;
  31108. /**
  31109. * Add a new key and its corresponding value
  31110. * @param key the key to add
  31111. * @param value the value corresponding to the key
  31112. * @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
  31113. */
  31114. add(key: string, value: T): boolean;
  31115. set(key: string, value: T): boolean;
  31116. /**
  31117. * Get the element of the given key and remove it from the dictionary
  31118. * @param key
  31119. */
  31120. getAndRemove(key: string): Nullable<T>;
  31121. /**
  31122. * Remove a key/value from the dictionary.
  31123. * @param key the key to remove
  31124. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31125. */
  31126. remove(key: string): boolean;
  31127. /**
  31128. * Clear the whole content of the dictionary
  31129. */
  31130. clear(): void;
  31131. readonly count: number;
  31132. /**
  31133. * Execute a callback on each key/val of the dictionary.
  31134. * Note that you can remove any element in this dictionary in the callback implementation
  31135. * @param callback the callback to execute on a given key/value pair
  31136. */
  31137. forEach(callback: (key: string, val: T) => void): void;
  31138. /**
  31139. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31140. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31141. * Note that you can remove any element in this dictionary in the callback implementation
  31142. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31143. */
  31144. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31145. private _count;
  31146. private _data;
  31147. }
  31148. }
  31149. declare module BABYLON {
  31150. class Tags {
  31151. static EnableFor(obj: any): void;
  31152. static DisableFor(obj: any): void;
  31153. static HasTags(obj: any): boolean;
  31154. static GetTags(obj: any, asString?: boolean): any;
  31155. static AddTagsTo(obj: any, tagsString: string): void;
  31156. static _AddTagTo(obj: any, tag: string): void;
  31157. static RemoveTagsFrom(obj: any, tagsString: string): void;
  31158. static _RemoveTagFrom(obj: any, tag: string): void;
  31159. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  31160. }
  31161. }
  31162. declare module BABYLON {
  31163. class TextureTools {
  31164. /**
  31165. * Uses the GPU to create a copy texture rescaled at a given size
  31166. * @param texture Texture to copy from
  31167. * @param width Desired width
  31168. * @param height Desired height
  31169. * @return Generated texture
  31170. */
  31171. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  31172. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  31173. private static _environmentBRDFBase64Texture;
  31174. }
  31175. }
  31176. declare module BABYLON {
  31177. class TGATools {
  31178. private static _TYPE_INDEXED;
  31179. private static _TYPE_RGB;
  31180. private static _TYPE_GREY;
  31181. private static _TYPE_RLE_INDEXED;
  31182. private static _TYPE_RLE_RGB;
  31183. private static _TYPE_RLE_GREY;
  31184. private static _ORIGIN_MASK;
  31185. private static _ORIGIN_SHIFT;
  31186. private static _ORIGIN_BL;
  31187. private static _ORIGIN_BR;
  31188. private static _ORIGIN_UL;
  31189. private static _ORIGIN_UR;
  31190. static GetTGAHeader(data: Uint8Array): any;
  31191. /**
  31192. * Uploads TGA content to a Babylon Texture
  31193. * @hidden
  31194. */
  31195. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  31196. 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;
  31197. 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;
  31198. 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;
  31199. 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;
  31200. 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;
  31201. 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;
  31202. }
  31203. }
  31204. declare module BABYLON {
  31205. interface IAnimatable {
  31206. animations: Array<Animation>;
  31207. }
  31208. /** Interface used by value gradients (color, factor, ...) */
  31209. interface IValueGradient {
  31210. /**
  31211. * Gets or sets the gradient value (between 0 and 1)
  31212. */
  31213. gradient: number;
  31214. }
  31215. /** Class used to store color gradient */
  31216. class ColorGradient implements IValueGradient {
  31217. /**
  31218. * Gets or sets the gradient value (between 0 and 1)
  31219. */
  31220. gradient: number;
  31221. /**
  31222. * Gets or sets first associated color
  31223. */
  31224. color1: Color4;
  31225. /**
  31226. * Gets or sets second associated color
  31227. */
  31228. color2?: Color4;
  31229. /**
  31230. * Will get a color picked randomly between color1 and color2.
  31231. * If color2 is undefined then color1 will be used
  31232. * @param result defines the target Color4 to store the result in
  31233. */
  31234. getColorToRef(result: Color4): void;
  31235. }
  31236. /** Class used to store factor gradient */
  31237. class FactorGradient implements IValueGradient {
  31238. /**
  31239. * Gets or sets the gradient value (between 0 and 1)
  31240. */
  31241. gradient: number;
  31242. /**
  31243. * Gets or sets first associated factor
  31244. */
  31245. factor1: number;
  31246. /**
  31247. * Gets or sets second associated factor
  31248. */
  31249. factor2?: number;
  31250. /**
  31251. * Will get a number picked randomly between factor1 and factor2.
  31252. * If factor2 is undefined then factor1 will be used
  31253. * @returns the picked number
  31254. */
  31255. getFactor(): number;
  31256. }
  31257. class LoadFileError extends Error {
  31258. request?: XMLHttpRequest | undefined;
  31259. private static _setPrototypeOf;
  31260. constructor(message: string, request?: XMLHttpRequest | undefined);
  31261. }
  31262. class RetryStrategy {
  31263. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31264. }
  31265. interface IFileRequest {
  31266. /**
  31267. * Raised when the request is complete (success or error).
  31268. */
  31269. onCompleteObservable: Observable<IFileRequest>;
  31270. /**
  31271. * Aborts the request for a file.
  31272. */
  31273. abort: () => void;
  31274. }
  31275. class Tools {
  31276. static BaseUrl: string;
  31277. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31278. /**
  31279. * Default behaviour for cors in the application.
  31280. * It can be a string if the expected behavior is identical in the entire app.
  31281. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31282. */
  31283. static CorsBehavior: string | ((url: string | string[]) => string);
  31284. static UseFallbackTexture: boolean;
  31285. /**
  31286. * Use this object to register external classes like custom textures or material
  31287. * to allow the laoders to instantiate them
  31288. */
  31289. static RegisteredExternalClasses: {
  31290. [key: string]: Object;
  31291. };
  31292. static fallbackTexture: string;
  31293. /**
  31294. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31295. * @param u defines the coordinate on X axis
  31296. * @param v defines the coordinate on Y axis
  31297. * @param width defines the width of the source data
  31298. * @param height defines the height of the source data
  31299. * @param pixels defines the source byte array
  31300. * @param color defines the output color
  31301. */
  31302. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31303. /**
  31304. * Interpolates between a and b via alpha
  31305. * @param a The lower value (returned when alpha = 0)
  31306. * @param b The upper value (returned when alpha = 1)
  31307. * @param alpha The interpolation-factor
  31308. * @return The mixed value
  31309. */
  31310. static Mix(a: number, b: number, alpha: number): number;
  31311. static Instantiate(className: string): any;
  31312. /**
  31313. * Provides a slice function that will work even on IE
  31314. * @param data defines the array to slice
  31315. * @param start defines the start of the data (optional)
  31316. * @param end defines the end of the data (optional)
  31317. * @returns the new sliced array
  31318. */
  31319. static Slice<T>(data: T, start?: number, end?: number): T;
  31320. static SetImmediate(action: () => void): void;
  31321. static IsExponentOfTwo(value: number): boolean;
  31322. private static _tmpFloatArray;
  31323. /**
  31324. * Returns the nearest 32-bit single precision float representation of a Number
  31325. * @param value A Number. If the parameter is of a different type, it will get converted
  31326. * to a number or to NaN if it cannot be converted
  31327. * @returns number
  31328. */
  31329. static FloatRound(value: number): number;
  31330. /**
  31331. * Find the next highest power of two.
  31332. * @param x Number to start search from.
  31333. * @return Next highest power of two.
  31334. */
  31335. static CeilingPOT(x: number): number;
  31336. /**
  31337. * Find the next lowest power of two.
  31338. * @param x Number to start search from.
  31339. * @return Next lowest power of two.
  31340. */
  31341. static FloorPOT(x: number): number;
  31342. /**
  31343. * Find the nearest power of two.
  31344. * @param x Number to start search from.
  31345. * @return Next nearest power of two.
  31346. */
  31347. static NearestPOT(x: number): number;
  31348. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31349. static GetFilename(path: string): string;
  31350. /**
  31351. * Extracts the "folder" part of a path (everything before the filename).
  31352. * @param uri The URI to extract the info from
  31353. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31354. * @returns The "folder" part of the path
  31355. */
  31356. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31357. static GetDOMTextContent(element: HTMLElement): string;
  31358. static ToDegrees(angle: number): number;
  31359. static ToRadians(angle: number): number;
  31360. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31361. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31362. minimum: Vector3;
  31363. maximum: Vector3;
  31364. };
  31365. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31366. minimum: Vector3;
  31367. maximum: Vector3;
  31368. };
  31369. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  31370. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  31371. minimum: Vector2;
  31372. maximum: Vector2;
  31373. };
  31374. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31375. static GetPointerPrefix(): string;
  31376. /**
  31377. * @param func - the function to be called
  31378. * @param requester - the object that will request the next frame. Falls back to window.
  31379. */
  31380. static QueueNewFrame(func: () => void, requester?: any): number;
  31381. static RequestFullscreen(element: HTMLElement): void;
  31382. static ExitFullscreen(): void;
  31383. static SetCorsBehavior(url: string | string[], element: {
  31384. crossOrigin: string | null;
  31385. }): void;
  31386. static CleanUrl(url: string): string;
  31387. static PreprocessUrl: (url: string) => string;
  31388. /**
  31389. * Loads an image as an HTMLImageElement.
  31390. * @param input url string, ArrayBuffer, or Blob to load
  31391. * @param onLoad callback called when the image successfully loads
  31392. * @param onError callback called when the image fails to load
  31393. * @param database database for caching
  31394. * @returns the HTMLImageElement of the loaded image
  31395. */
  31396. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  31397. 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;
  31398. /**
  31399. * Load a script (identified by an url). When the url returns, the
  31400. * content of this file is added into a new script element, attached to the DOM (body element)
  31401. */
  31402. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31403. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31404. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31405. static FileAsURL(content: string): string;
  31406. static Format(value: number, decimals?: number): string;
  31407. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31408. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31409. static IsEmpty(obj: any): boolean;
  31410. static RegisterTopRootEvents(events: {
  31411. name: string;
  31412. handler: Nullable<(e: FocusEvent) => any>;
  31413. }[]): void;
  31414. static UnregisterTopRootEvents(events: {
  31415. name: string;
  31416. handler: Nullable<(e: FocusEvent) => any>;
  31417. }[]): void;
  31418. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31419. /**
  31420. * Converts the canvas data to blob.
  31421. * This acts as a polyfill for browsers not supporting the to blob function.
  31422. * @param canvas Defines the canvas to extract the data from
  31423. * @param successCallback Defines the callback triggered once the data are available
  31424. * @param mimeType Defines the mime type of the result
  31425. */
  31426. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31427. /**
  31428. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31429. * @param successCallback Defines the callback triggered once the data are available
  31430. * @param mimeType Defines the mime type of the result
  31431. * @param fileName The filename to download. If present, the result will automatically be downloaded
  31432. */
  31433. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31434. /**
  31435. * Downloads a blob in the browser
  31436. * @param blob defines the blob to download
  31437. * @param fileName defines the name of the downloaded file
  31438. */
  31439. static Download(blob: Blob, fileName: string): void;
  31440. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31441. /**
  31442. * Generates an image screenshot from the specified camera.
  31443. *
  31444. * @param engine The engine to use for rendering
  31445. * @param camera The camera to use for rendering
  31446. * @param size This parameter can be set to a single number or to an object with the
  31447. * following (optional) properties: precision, width, height. If a single number is passed,
  31448. * it will be used for both width and height. If an object is passed, the screenshot size
  31449. * will be derived from the parameters. The precision property is a multiplier allowing
  31450. * rendering at a higher or lower resolution.
  31451. * @param successCallback The callback receives a single parameter which contains the
  31452. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31453. * src parameter of an <img> to display it.
  31454. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31455. * Check your browser for supported MIME types.
  31456. * @param samples Texture samples (default: 1)
  31457. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31458. * @param fileName A name for for the downloaded file.
  31459. * @constructor
  31460. */
  31461. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31462. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  31463. /**
  31464. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31465. * Be aware Math.random() could cause collisions, but:
  31466. * "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"
  31467. */
  31468. static RandomId(): string;
  31469. /**
  31470. * Test if the given uri is a base64 string.
  31471. * @param uri The uri to test
  31472. * @return True if the uri is a base64 string or false otherwise.
  31473. */
  31474. static IsBase64(uri: string): boolean;
  31475. /**
  31476. * Decode the given base64 uri.
  31477. * @param uri The uri to decode
  31478. * @return The decoded base64 data.
  31479. */
  31480. static DecodeBase64(uri: string): ArrayBuffer;
  31481. private static _NoneLogLevel;
  31482. private static _MessageLogLevel;
  31483. private static _WarningLogLevel;
  31484. private static _ErrorLogLevel;
  31485. private static _LogCache;
  31486. static errorsCount: number;
  31487. static OnNewCacheEntry: (entry: string) => void;
  31488. static readonly NoneLogLevel: number;
  31489. static readonly MessageLogLevel: number;
  31490. static readonly WarningLogLevel: number;
  31491. static readonly ErrorLogLevel: number;
  31492. static readonly AllLogLevel: number;
  31493. private static _AddLogEntry;
  31494. private static _FormatMessage;
  31495. private static _LogDisabled;
  31496. private static _LogEnabled;
  31497. private static _WarnDisabled;
  31498. private static _WarnEnabled;
  31499. private static _ErrorDisabled;
  31500. private static _ErrorEnabled;
  31501. static Log: (message: string) => void;
  31502. static Warn: (message: string) => void;
  31503. static Error: (message: string) => void;
  31504. static readonly LogCache: string;
  31505. static ClearLogCache(): void;
  31506. static LogLevels: number;
  31507. /**
  31508. * Check if the loaded document was accessed via `file:`-Protocol.
  31509. * @returns boolean
  31510. */
  31511. static IsFileURL(): boolean;
  31512. static IsWindowObjectExist(): boolean;
  31513. private static _PerformanceNoneLogLevel;
  31514. private static _PerformanceUserMarkLogLevel;
  31515. private static _PerformanceConsoleLogLevel;
  31516. private static _performance;
  31517. static readonly PerformanceNoneLogLevel: number;
  31518. static readonly PerformanceUserMarkLogLevel: number;
  31519. static readonly PerformanceConsoleLogLevel: number;
  31520. static PerformanceLogLevel: number;
  31521. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31522. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31523. static _StartUserMark(counterName: string, condition?: boolean): void;
  31524. static _EndUserMark(counterName: string, condition?: boolean): void;
  31525. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  31526. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  31527. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31528. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31529. static readonly Now: number;
  31530. /**
  31531. * This method will return the name of the class used to create the instance of the given object.
  31532. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31533. * @param object the object to get the class name from
  31534. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  31535. */
  31536. static GetClassName(object: any, isType?: boolean): string;
  31537. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31538. /**
  31539. * This method will return the name of the full name of the class, including its owning module (if any).
  31540. * 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).
  31541. * @param object the object to get the class name from
  31542. * @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.
  31543. */
  31544. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31545. /**
  31546. * 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.
  31547. * @param array
  31548. */
  31549. static arrayOrStringFeeder(array: any): (i: number) => number;
  31550. /**
  31551. * Compute the hashCode of a stream of number
  31552. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  31553. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  31554. * @return the hash code computed
  31555. */
  31556. static hashCodeFromStream(feeder: (index: number) => number): number;
  31557. /**
  31558. * Returns a promise that resolves after the given amount of time.
  31559. * @param delay Number of milliseconds to delay
  31560. * @returns Promise that resolves after the given amount of time
  31561. */
  31562. static DelayAsync(delay: number): Promise<void>;
  31563. /**
  31564. * Gets the current gradient from an array of IValueGradient
  31565. * @param ratio defines the current ratio to get
  31566. * @param gradients defines the array of IValueGradient
  31567. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31568. */
  31569. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31570. }
  31571. /**
  31572. * This class is used to track a performance counter which is number based.
  31573. * The user has access to many properties which give statistics of different nature
  31574. *
  31575. * The implementer can track two kinds of Performance Counter: time and count
  31576. * 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.
  31577. * 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.
  31578. */
  31579. class PerfCounter {
  31580. static Enabled: boolean;
  31581. /**
  31582. * Returns the smallest value ever
  31583. */
  31584. readonly min: number;
  31585. /**
  31586. * Returns the biggest value ever
  31587. */
  31588. readonly max: number;
  31589. /**
  31590. * Returns the average value since the performance counter is running
  31591. */
  31592. readonly average: number;
  31593. /**
  31594. * Returns the average value of the last second the counter was monitored
  31595. */
  31596. readonly lastSecAverage: number;
  31597. /**
  31598. * Returns the current value
  31599. */
  31600. readonly current: number;
  31601. readonly total: number;
  31602. readonly count: number;
  31603. constructor();
  31604. /**
  31605. * Call this method to start monitoring a new frame.
  31606. * 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.
  31607. */
  31608. fetchNewFrame(): void;
  31609. /**
  31610. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31611. * @param newCount the count value to add to the monitored count
  31612. * @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.
  31613. */
  31614. addCount(newCount: number, fetchResult: boolean): void;
  31615. /**
  31616. * Start monitoring this performance counter
  31617. */
  31618. beginMonitoring(): void;
  31619. /**
  31620. * Compute the time lapsed since the previous beginMonitoring() call.
  31621. * @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
  31622. */
  31623. endMonitoring(newFrame?: boolean): void;
  31624. private _fetchResult;
  31625. private _startMonitoringTime;
  31626. private _min;
  31627. private _max;
  31628. private _average;
  31629. private _current;
  31630. private _totalValueCount;
  31631. private _totalAccumulated;
  31632. private _lastSecAverage;
  31633. private _lastSecAccumulated;
  31634. private _lastSecTime;
  31635. private _lastSecValueCount;
  31636. }
  31637. /**
  31638. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31639. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31640. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31641. * @param name The name of the class, case should be preserved
  31642. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31643. */
  31644. function className(name: string, module?: string): (target: Object) => void;
  31645. /**
  31646. * An implementation of a loop for asynchronous functions.
  31647. */
  31648. class AsyncLoop {
  31649. iterations: number;
  31650. private _fn;
  31651. private _successCallback;
  31652. index: number;
  31653. private _done;
  31654. /**
  31655. * Constroctor.
  31656. * @param iterations the number of iterations.
  31657. * @param _fn the function to run each iteration
  31658. * @param _successCallback the callback that will be called upon succesful execution
  31659. * @param offset starting offset.
  31660. */
  31661. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  31662. /**
  31663. * Execute the next iteration. Must be called after the last iteration was finished.
  31664. */
  31665. executeNext(): void;
  31666. /**
  31667. * Break the loop and run the success callback.
  31668. */
  31669. breakLoop(): void;
  31670. /**
  31671. * Helper function
  31672. */
  31673. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  31674. /**
  31675. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31676. * @param iterations total number of iterations
  31677. * @param syncedIterations number of synchronous iterations in each async iteration.
  31678. * @param fn the function to call each iteration.
  31679. * @param callback a success call back that will be called when iterating stops.
  31680. * @param breakFunction a break condition (optional)
  31681. * @param timeout timeout settings for the setTimeout function. default - 0.
  31682. * @constructor
  31683. */
  31684. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  31685. }
  31686. }
  31687. interface HTMLCanvasElement {
  31688. /** Track wether a record is in progress */
  31689. isRecording: boolean;
  31690. /** Capture Stream method defined by some browsers */
  31691. captureStream(fps?: number): MediaStream;
  31692. }
  31693. interface MediaRecorder {
  31694. /** Starts recording */
  31695. start(timeSlice: number): void;
  31696. /** Stops recording */
  31697. stop(): void;
  31698. /** Event raised when an error arised. */
  31699. onerror: (event: ErrorEvent) => void;
  31700. /** Event raised when the recording stops. */
  31701. onstop: (event: Event) => void;
  31702. /** Event raised when a new chunk of data is available and should be tracked. */
  31703. ondataavailable: (event: Event) => void;
  31704. }
  31705. interface MediaRecorderOptions {
  31706. /** The mime type you want to use as the recording container for the new MediaRecorder */
  31707. mimeType?: string;
  31708. /** The chosen bitrate for the audio component of the media. */
  31709. audioBitsPerSecond?: number;
  31710. /** The chosen bitrate for the video component of the media. */
  31711. videoBitsPerSecond?: number;
  31712. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  31713. bitsPerSecond?: number;
  31714. }
  31715. interface MediaRecorderConstructor {
  31716. /**
  31717. * A reference to the prototype.
  31718. */
  31719. readonly prototype: MediaRecorder;
  31720. /**
  31721. * Creates a new MediaRecorder.
  31722. * @param stream Defines the stream to record.
  31723. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  31724. */
  31725. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  31726. }
  31727. /**
  31728. * MediaRecoreder object available in some browsers.
  31729. */
  31730. declare var MediaRecorder: MediaRecorderConstructor;
  31731. declare module BABYLON {
  31732. /**
  31733. * This represents the different options avilable for the video capture.
  31734. */
  31735. interface VideoRecorderOptions {
  31736. /** Defines the mime type of the video */
  31737. mimeType: string;
  31738. /** Defines the video the video should be recorded at */
  31739. fps: number;
  31740. /** Defines the chunk size for the recording data */
  31741. recordChunckSize: number;
  31742. }
  31743. /**
  31744. * This can helps recording videos from BabylonJS.
  31745. * This is based on the available WebRTC functionalities of the browser.
  31746. *
  31747. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  31748. */
  31749. class VideoRecorder {
  31750. private static readonly _defaultOptions;
  31751. /**
  31752. * Returns wehther or not the VideoRecorder is available in your browser.
  31753. * @param engine Defines the Babylon Engine to check the support for
  31754. * @returns true if supported otherwise false
  31755. */
  31756. static IsSupported(engine: Engine): boolean;
  31757. private readonly _options;
  31758. private _canvas;
  31759. private _mediaRecorder;
  31760. private _recordedChunks;
  31761. private _fileName;
  31762. private _resolve;
  31763. private _reject;
  31764. /**
  31765. * True wether a recording is already in progress.
  31766. */
  31767. readonly isRecording: boolean;
  31768. /**
  31769. * Create a new VideoCapture object which can help converting what you see in Babylon to
  31770. * a video file.
  31771. * @param engine Defines the BabylonJS Engine you wish to record
  31772. * @param options Defines options that can be used to customized the capture
  31773. */
  31774. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  31775. /**
  31776. * Stops the current recording before the default capture timeout passed in the startRecording
  31777. * functions.
  31778. */
  31779. stopRecording(): void;
  31780. /**
  31781. * Starts recording the canvas for a max duration specified in parameters.
  31782. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  31783. * @param maxDuration Defines the maximum recording time in seconds.
  31784. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  31785. * @return a promise callback at the end of the recording with the video data in Blob.
  31786. */
  31787. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  31788. /**
  31789. * Releases internal resources used during the recording.
  31790. */
  31791. dispose(): void;
  31792. private _handleDataAvailable;
  31793. private _handleError;
  31794. private _handleStop;
  31795. }
  31796. }
  31797. declare module BABYLON {
  31798. /**
  31799. * Defines the potential axis of a Joystick
  31800. */
  31801. enum JoystickAxis {
  31802. /** X axis */
  31803. X = 0,
  31804. /** Y axis */
  31805. Y = 1,
  31806. /** Z axis */
  31807. Z = 2
  31808. }
  31809. /**
  31810. * Class used to define virtual joystick (used in touch mode)
  31811. */
  31812. class VirtualJoystick {
  31813. /**
  31814. * Gets or sets a boolean indicating that left and right values must be inverted
  31815. */
  31816. reverseLeftRight: boolean;
  31817. /**
  31818. * Gets or sets a boolean indicating that up and down values must be inverted
  31819. */
  31820. reverseUpDown: boolean;
  31821. /**
  31822. * Gets the offset value for the position (ie. the change of the position value)
  31823. */
  31824. deltaPosition: Vector3;
  31825. /**
  31826. * Gets a boolean indicating if the virtual joystick was pressed
  31827. */
  31828. pressed: boolean;
  31829. private static _globalJoystickIndex;
  31830. private static vjCanvas;
  31831. private static vjCanvasContext;
  31832. private static vjCanvasWidth;
  31833. private static vjCanvasHeight;
  31834. private static halfWidth;
  31835. private _action;
  31836. private _axisTargetedByLeftAndRight;
  31837. private _axisTargetedByUpAndDown;
  31838. private _joystickSensibility;
  31839. private _inversedSensibility;
  31840. private _joystickPointerID;
  31841. private _joystickColor;
  31842. private _joystickPointerPos;
  31843. private _joystickPreviousPointerPos;
  31844. private _joystickPointerStartPos;
  31845. private _deltaJoystickVector;
  31846. private _leftJoystick;
  31847. private _touches;
  31848. private _onPointerDownHandlerRef;
  31849. private _onPointerMoveHandlerRef;
  31850. private _onPointerUpHandlerRef;
  31851. private _onResize;
  31852. /**
  31853. * Creates a new virtual joystick
  31854. * @param leftJoystick defines that the joystick is for left hand (false by default)
  31855. */
  31856. constructor(leftJoystick?: boolean);
  31857. /**
  31858. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  31859. * @param newJoystickSensibility defines the new sensibility
  31860. */
  31861. setJoystickSensibility(newJoystickSensibility: number): void;
  31862. private _onPointerDown;
  31863. private _onPointerMove;
  31864. private _onPointerUp;
  31865. /**
  31866. * Change the color of the virtual joystick
  31867. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  31868. */
  31869. setJoystickColor(newColor: string): void;
  31870. /**
  31871. * Defines a callback to call when the joystick is touched
  31872. * @param action defines the callback
  31873. */
  31874. setActionOnTouch(action: () => any): void;
  31875. /**
  31876. * Defines which axis you'd like to control for left & right
  31877. * @param axis defines the axis to use
  31878. */
  31879. setAxisForLeftRight(axis: JoystickAxis): void;
  31880. /**
  31881. * Defines which axis you'd like to control for up & down
  31882. * @param axis defines the axis to use
  31883. */
  31884. setAxisForUpDown(axis: JoystickAxis): void;
  31885. private _drawVirtualJoystick;
  31886. /**
  31887. * Release internal HTML canvas
  31888. */
  31889. releaseCanvas(): void;
  31890. }
  31891. }
  31892. declare module BABYLON {
  31893. /**
  31894. * Helper class to push actions to a pool of workers.
  31895. */
  31896. class WorkerPool implements IDisposable {
  31897. private _workerInfos;
  31898. private _pendingActions;
  31899. /**
  31900. * Constructor
  31901. * @param workers Array of workers to use for actions
  31902. */
  31903. constructor(workers: Array<Worker>);
  31904. /**
  31905. * Terminates all workers and clears any pending actions.
  31906. */
  31907. dispose(): void;
  31908. /**
  31909. * Pushes an action to the worker pool. If all the workers are active, the action will be
  31910. * pended until a worker has completed its action.
  31911. * @param action The action to perform. Call onComplete when the action is complete.
  31912. */
  31913. push(action: (worker: Worker, onComplete: () => void) => void): void;
  31914. private _execute;
  31915. }
  31916. }
  31917. declare module BABYLON {
  31918. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  31919. readonly name: string;
  31920. private _zoomStopsAnimation;
  31921. private _idleRotationSpeed;
  31922. private _idleRotationWaitTime;
  31923. private _idleRotationSpinupTime;
  31924. /**
  31925. * Sets the flag that indicates if user zooming should stop animation.
  31926. */
  31927. /**
  31928. * Gets the flag that indicates if user zooming should stop animation.
  31929. */
  31930. zoomStopsAnimation: boolean;
  31931. /**
  31932. * Sets the default speed at which the camera rotates around the model.
  31933. */
  31934. /**
  31935. * Gets the default speed at which the camera rotates around the model.
  31936. */
  31937. idleRotationSpeed: number;
  31938. /**
  31939. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  31940. */
  31941. /**
  31942. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  31943. */
  31944. idleRotationWaitTime: number;
  31945. /**
  31946. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31947. */
  31948. /**
  31949. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31950. */
  31951. idleRotationSpinupTime: number;
  31952. /**
  31953. * Gets a value indicating if the camera is currently rotating because of this behavior
  31954. */
  31955. readonly rotationInProgress: boolean;
  31956. private _onPrePointerObservableObserver;
  31957. private _onAfterCheckInputsObserver;
  31958. private _attachedCamera;
  31959. private _isPointerDown;
  31960. private _lastFrameTime;
  31961. private _lastInteractionTime;
  31962. private _cameraRotationSpeed;
  31963. init(): void;
  31964. attach(camera: ArcRotateCamera): void;
  31965. detach(): void;
  31966. /**
  31967. * Returns true if user is scrolling.
  31968. * @return true if user is scrolling.
  31969. */
  31970. private _userIsZooming;
  31971. private _lastFrameRadius;
  31972. private _shouldAnimationStopForInteraction;
  31973. /**
  31974. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31975. */
  31976. private _applyUserInteraction;
  31977. private _userIsMoving;
  31978. }
  31979. }
  31980. declare module BABYLON {
  31981. /**
  31982. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  31983. */
  31984. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  31985. readonly name: string;
  31986. /**
  31987. * The easing function used by animations
  31988. */
  31989. static EasingFunction: BackEase;
  31990. /**
  31991. * The easing mode used by animations
  31992. */
  31993. static EasingMode: number;
  31994. /**
  31995. * The duration of the animation, in milliseconds
  31996. */
  31997. transitionDuration: number;
  31998. /**
  31999. * Length of the distance animated by the transition when lower radius is reached
  32000. */
  32001. lowerRadiusTransitionRange: number;
  32002. /**
  32003. * Length of the distance animated by the transition when upper radius is reached
  32004. */
  32005. upperRadiusTransitionRange: number;
  32006. private _autoTransitionRange;
  32007. /**
  32008. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32009. */
  32010. /**
  32011. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32012. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32013. */
  32014. autoTransitionRange: boolean;
  32015. private _attachedCamera;
  32016. private _onAfterCheckInputsObserver;
  32017. private _onMeshTargetChangedObserver;
  32018. init(): void;
  32019. attach(camera: ArcRotateCamera): void;
  32020. detach(): void;
  32021. private _radiusIsAnimating;
  32022. private _radiusBounceTransition;
  32023. private _animatables;
  32024. private _cachedWheelPrecision;
  32025. /**
  32026. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32027. * @param radiusLimit The limit to check against.
  32028. * @return Bool to indicate if at limit.
  32029. */
  32030. private _isRadiusAtLimit;
  32031. /**
  32032. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32033. * @param radiusDelta The delta by which to animate to. Can be negative.
  32034. */
  32035. private _applyBoundRadiusAnimation;
  32036. /**
  32037. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32038. */
  32039. protected _clearAnimationLocks(): void;
  32040. /**
  32041. * Stops and removes all animations that have been applied to the camera
  32042. */
  32043. stopAllAnimations(): void;
  32044. }
  32045. }
  32046. declare module BABYLON {
  32047. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32048. readonly name: string;
  32049. private _mode;
  32050. private _radiusScale;
  32051. private _positionScale;
  32052. private _defaultElevation;
  32053. private _elevationReturnTime;
  32054. private _elevationReturnWaitTime;
  32055. private _zoomStopsAnimation;
  32056. private _framingTime;
  32057. /**
  32058. * The easing function used by animations
  32059. */
  32060. static EasingFunction: ExponentialEase;
  32061. /**
  32062. * The easing mode used by animations
  32063. */
  32064. static EasingMode: number;
  32065. /**
  32066. * Sets the current mode used by the behavior
  32067. */
  32068. /**
  32069. * Gets current mode used by the behavior.
  32070. */
  32071. mode: number;
  32072. /**
  32073. * Sets the scale applied to the radius (1 by default)
  32074. */
  32075. /**
  32076. * Gets the scale applied to the radius
  32077. */
  32078. radiusScale: number;
  32079. /**
  32080. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32081. */
  32082. /**
  32083. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32084. */
  32085. positionScale: number;
  32086. /**
  32087. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32088. * behaviour is triggered, in radians.
  32089. */
  32090. /**
  32091. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32092. * behaviour is triggered, in radians.
  32093. */
  32094. defaultElevation: number;
  32095. /**
  32096. * Sets the time (in milliseconds) taken to return to the default beta position.
  32097. * Negative value indicates camera should not return to default.
  32098. */
  32099. /**
  32100. * Gets the time (in milliseconds) taken to return to the default beta position.
  32101. * Negative value indicates camera should not return to default.
  32102. */
  32103. elevationReturnTime: number;
  32104. /**
  32105. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32106. */
  32107. /**
  32108. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32109. */
  32110. elevationReturnWaitTime: number;
  32111. /**
  32112. * Sets the flag that indicates if user zooming should stop animation.
  32113. */
  32114. /**
  32115. * Gets the flag that indicates if user zooming should stop animation.
  32116. */
  32117. zoomStopsAnimation: boolean;
  32118. /**
  32119. * Sets the transition time when framing the mesh, in milliseconds
  32120. */
  32121. /**
  32122. * Gets the transition time when framing the mesh, in milliseconds
  32123. */
  32124. framingTime: number;
  32125. private _onPrePointerObservableObserver;
  32126. private _onAfterCheckInputsObserver;
  32127. private _onMeshTargetChangedObserver;
  32128. private _attachedCamera;
  32129. private _isPointerDown;
  32130. private _lastInteractionTime;
  32131. init(): void;
  32132. attach(camera: ArcRotateCamera): void;
  32133. detach(): void;
  32134. private _animatables;
  32135. private _betaIsAnimating;
  32136. private _betaTransition;
  32137. private _radiusTransition;
  32138. private _vectorTransition;
  32139. /**
  32140. * Targets the given mesh and updates zoom level accordingly.
  32141. * @param mesh The mesh to target.
  32142. * @param radius Optional. If a cached radius position already exists, overrides default.
  32143. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32144. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32145. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32146. */
  32147. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32148. /**
  32149. * Targets the given mesh with its children and updates zoom level accordingly.
  32150. * @param mesh The mesh to target.
  32151. * @param radius Optional. If a cached radius position already exists, overrides default.
  32152. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32155. */
  32156. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32157. /**
  32158. * Targets the given meshes with their children and updates zoom level accordingly.
  32159. * @param meshes The mesh to target.
  32160. * @param radius Optional. If a cached radius position already exists, overrides default.
  32161. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32164. */
  32165. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32166. /**
  32167. * Targets the given mesh and updates zoom level accordingly.
  32168. * @param mesh The mesh to target.
  32169. * @param radius Optional. If a cached radius position already exists, overrides default.
  32170. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32173. */
  32174. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32175. /**
  32176. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  32177. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  32178. * frustum width.
  32179. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  32180. * to fully enclose the mesh in the viewing frustum.
  32181. */
  32182. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  32183. /**
  32184. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  32185. * is automatically returned to its default position (expected to be above ground plane).
  32186. */
  32187. private _maintainCameraAboveGround;
  32188. /**
  32189. * Returns the frustum slope based on the canvas ratio and camera FOV
  32190. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  32191. */
  32192. private _getFrustumSlope;
  32193. /**
  32194. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  32195. */
  32196. private _clearAnimationLocks;
  32197. /**
  32198. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32199. */
  32200. private _applyUserInteraction;
  32201. /**
  32202. * Stops and removes all animations that have been applied to the camera
  32203. */
  32204. stopAllAnimations(): void;
  32205. /**
  32206. * Gets a value indicating if the user is moving the camera
  32207. */
  32208. readonly isUserIsMoving: boolean;
  32209. /**
  32210. * The camera can move all the way towards the mesh.
  32211. */
  32212. static IgnoreBoundsSizeMode: number;
  32213. /**
  32214. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  32215. */
  32216. static FitFrustumSidesMode: number;
  32217. }
  32218. }
  32219. declare module BABYLON {
  32220. /**
  32221. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  32222. */
  32223. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  32224. private ui;
  32225. /**
  32226. * The name of the behavior
  32227. */
  32228. name: string;
  32229. /**
  32230. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  32231. */
  32232. distanceAwayFromFace: number;
  32233. /**
  32234. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  32235. */
  32236. distanceAwayFromBottomOfFace: number;
  32237. private _faceVectors;
  32238. private _target;
  32239. private _scene;
  32240. private _onRenderObserver;
  32241. private _tmpMatrix;
  32242. private _tmpVector;
  32243. /**
  32244. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  32245. * @param ui The transform node that should be attched to the mesh
  32246. */
  32247. constructor(ui: BABYLON.TransformNode);
  32248. /**
  32249. * Initializes the behavior
  32250. */
  32251. init(): void;
  32252. private _closestFace;
  32253. private _zeroVector;
  32254. private _lookAtTmpMatrix;
  32255. private _lookAtToRef;
  32256. /**
  32257. * Attaches the AttachToBoxBehavior to the passed in mesh
  32258. * @param target The mesh that the specified node will be attached to
  32259. */
  32260. attach(target: BABYLON.Mesh): void;
  32261. /**
  32262. * Detaches the behavior from the mesh
  32263. */
  32264. detach(): void;
  32265. }
  32266. }
  32267. declare module BABYLON {
  32268. /**
  32269. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  32270. */
  32271. class FadeInOutBehavior implements Behavior<Mesh> {
  32272. /**
  32273. * Time in milliseconds to delay before fading in (Default: 0)
  32274. */
  32275. delay: number;
  32276. /**
  32277. * Time in milliseconds for the mesh to fade in (Default: 300)
  32278. */
  32279. fadeInTime: number;
  32280. private _millisecondsPerFrame;
  32281. private _hovered;
  32282. private _hoverValue;
  32283. private _ownerNode;
  32284. /**
  32285. * Instatiates the FadeInOutBehavior
  32286. */
  32287. constructor();
  32288. /**
  32289. * The name of the behavior
  32290. */
  32291. readonly name: string;
  32292. /**
  32293. * Initializes the behavior
  32294. */
  32295. init(): void;
  32296. /**
  32297. * Attaches the fade behavior on the passed in mesh
  32298. * @param ownerNode The mesh that will be faded in/out once attached
  32299. */
  32300. attach(ownerNode: Mesh): void;
  32301. /**
  32302. * Detaches the behavior from the mesh
  32303. */
  32304. detach(): void;
  32305. /**
  32306. * Triggers the mesh to begin fading in or out
  32307. * @param value if the object should fade in or out (true to fade in)
  32308. */
  32309. fadeIn(value: boolean): void;
  32310. private _update;
  32311. private _setAllVisibility;
  32312. }
  32313. }
  32314. declare module BABYLON {
  32315. /**
  32316. * A behavior that when attached to a mesh will allow the mesh to be scaled
  32317. */
  32318. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  32319. private _dragBehaviorA;
  32320. private _dragBehaviorB;
  32321. private _startDistance;
  32322. private _initialScale;
  32323. private _targetScale;
  32324. private _ownerNode;
  32325. private _sceneRenderObserver;
  32326. constructor();
  32327. /**
  32328. * The name of the behavior
  32329. */
  32330. readonly name: string;
  32331. /**
  32332. * Initializes the behavior
  32333. */
  32334. init(): void;
  32335. private _getCurrentDistance;
  32336. /**
  32337. * Attaches the scale behavior the passed in mesh
  32338. * @param ownerNode The mesh that will be scaled around once attached
  32339. */
  32340. attach(ownerNode: Mesh): void;
  32341. /**
  32342. * Detaches the behavior from the mesh
  32343. */
  32344. detach(): void;
  32345. }
  32346. }
  32347. declare module BABYLON {
  32348. /**
  32349. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  32350. */
  32351. class PointerDragBehavior implements Behavior<Mesh> {
  32352. private _attachedNode;
  32353. private _dragPlane;
  32354. private _scene;
  32355. private _pointerObserver;
  32356. private _beforeRenderObserver;
  32357. private static _planeScene;
  32358. /**
  32359. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  32360. */
  32361. maxDragAngle: number;
  32362. /**
  32363. * @hidden
  32364. */
  32365. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  32366. /**
  32367. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32368. */
  32369. currentDraggingPointerID: number;
  32370. /**
  32371. * The last position where the pointer hit the drag plane in world space
  32372. */
  32373. lastDragPosition: Vector3;
  32374. /**
  32375. * If the behavior is currently in a dragging state
  32376. */
  32377. dragging: boolean;
  32378. /**
  32379. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32380. */
  32381. dragDeltaRatio: number;
  32382. /**
  32383. * If the drag plane orientation should be updated during the dragging (Default: true)
  32384. */
  32385. updateDragPlane: boolean;
  32386. private _debugMode;
  32387. private _moving;
  32388. /**
  32389. * Fires each time the attached mesh is dragged with the pointer
  32390. * * delta between last drag position and current drag position in world space
  32391. * * dragDistance along the drag axis
  32392. * * dragPlaneNormal normal of the current drag plane used during the drag
  32393. * * dragPlanePoint in world space where the drag intersects the drag plane
  32394. */
  32395. onDragObservable: Observable<{
  32396. delta: Vector3;
  32397. dragPlanePoint: Vector3;
  32398. dragPlaneNormal: Vector3;
  32399. dragDistance: number;
  32400. pointerId: number;
  32401. }>;
  32402. /**
  32403. * Fires each time a drag begins (eg. mouse down on mesh)
  32404. */
  32405. onDragStartObservable: Observable<{
  32406. dragPlanePoint: Vector3;
  32407. pointerId: number;
  32408. }>;
  32409. /**
  32410. * Fires each time a drag ends (eg. mouse release after drag)
  32411. */
  32412. onDragEndObservable: Observable<{
  32413. dragPlanePoint: Vector3;
  32414. pointerId: number;
  32415. }>;
  32416. /**
  32417. * If the attached mesh should be moved when dragged
  32418. */
  32419. moveAttached: boolean;
  32420. /**
  32421. * If the drag behavior will react to drag events (Default: true)
  32422. */
  32423. enabled: boolean;
  32424. /**
  32425. * If camera controls should be detached during the drag
  32426. */
  32427. detachCameraControls: boolean;
  32428. /**
  32429. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32430. */
  32431. useObjectOrienationForDragging: boolean;
  32432. private _options;
  32433. /**
  32434. * Creates a pointer drag behavior that can be attached to a mesh
  32435. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  32436. */
  32437. constructor(options?: {
  32438. dragAxis?: Vector3;
  32439. dragPlaneNormal?: Vector3;
  32440. });
  32441. /**
  32442. * The name of the behavior
  32443. */
  32444. readonly name: string;
  32445. /**
  32446. * Initializes the behavior
  32447. */
  32448. init(): void;
  32449. private _tmpVector;
  32450. private _alternatePickedPoint;
  32451. private _worldDragAxis;
  32452. private _targetPosition;
  32453. private _attachedElement;
  32454. /**
  32455. * Attaches the drag behavior the passed in mesh
  32456. * @param ownerNode The mesh that will be dragged around once attached
  32457. */
  32458. attach(ownerNode: Mesh): void;
  32459. releaseDrag(): void;
  32460. private _startDragRay;
  32461. private _lastPointerRay;
  32462. /**
  32463. * Simulates the start of a pointer drag event on the behavior
  32464. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  32465. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  32466. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  32467. */
  32468. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  32469. private _startDrag;
  32470. private _dragDelta;
  32471. private _moveDrag;
  32472. private _pickWithRayOnDragPlane;
  32473. private _pointA;
  32474. private _pointB;
  32475. private _pointC;
  32476. private _lineA;
  32477. private _lineB;
  32478. private _localAxis;
  32479. private _lookAt;
  32480. private _updateDragPlanePosition;
  32481. /**
  32482. * Detaches the behavior from the mesh
  32483. */
  32484. detach(): void;
  32485. }
  32486. }
  32487. declare module BABYLON {
  32488. /**
  32489. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  32490. */
  32491. class SixDofDragBehavior implements Behavior<Mesh> {
  32492. private static _virtualScene;
  32493. private _ownerNode;
  32494. private _sceneRenderObserver;
  32495. private _scene;
  32496. private _targetPosition;
  32497. private _virtualOriginMesh;
  32498. private _virtualDragMesh;
  32499. private _pointerObserver;
  32500. private _moving;
  32501. private _startingOrientation;
  32502. /**
  32503. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  32504. */
  32505. private zDragFactor;
  32506. /**
  32507. * If the behavior is currently in a dragging state
  32508. */
  32509. dragging: boolean;
  32510. /**
  32511. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32512. */
  32513. dragDeltaRatio: number;
  32514. /**
  32515. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32516. */
  32517. currentDraggingPointerID: number;
  32518. /**
  32519. * If camera controls should be detached during the drag
  32520. */
  32521. detachCameraControls: boolean;
  32522. constructor();
  32523. /**
  32524. * The name of the behavior
  32525. */
  32526. readonly name: string;
  32527. /**
  32528. * Initializes the behavior
  32529. */
  32530. init(): void;
  32531. /**
  32532. * Attaches the scale behavior the passed in mesh
  32533. * @param ownerNode The mesh that will be scaled around once attached
  32534. */
  32535. attach(ownerNode: Mesh): void;
  32536. /**
  32537. * Detaches the behavior from the mesh
  32538. */
  32539. detach(): void;
  32540. }
  32541. }
  32542. declare module BABYLON {
  32543. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  32544. camera: ArcRotateCamera;
  32545. gamepad: Nullable<Gamepad>;
  32546. private _onGamepadConnectedObserver;
  32547. private _onGamepadDisconnectedObserver;
  32548. gamepadRotationSensibility: number;
  32549. gamepadMoveSensibility: number;
  32550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32551. detachControl(element: Nullable<HTMLElement>): void;
  32552. checkInputs(): void;
  32553. getClassName(): string;
  32554. getSimpleName(): string;
  32555. }
  32556. }
  32557. declare module BABYLON {
  32558. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  32559. camera: ArcRotateCamera;
  32560. private _keys;
  32561. keysUp: number[];
  32562. keysDown: number[];
  32563. keysLeft: number[];
  32564. keysRight: number[];
  32565. keysReset: number[];
  32566. panningSensibility: number;
  32567. zoomingSensibility: number;
  32568. useAltToZoom: boolean;
  32569. private _ctrlPressed;
  32570. private _altPressed;
  32571. private _onCanvasBlurObserver;
  32572. private _onKeyboardObserver;
  32573. private _engine;
  32574. private _scene;
  32575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32576. detachControl(element: Nullable<HTMLElement>): void;
  32577. checkInputs(): void;
  32578. getClassName(): string;
  32579. getSimpleName(): string;
  32580. }
  32581. }
  32582. declare module BABYLON {
  32583. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  32584. camera: ArcRotateCamera;
  32585. private _wheel;
  32586. private _observer;
  32587. wheelPrecision: number;
  32588. /**
  32589. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  32590. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  32591. */
  32592. wheelDeltaPercentage: number;
  32593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32594. detachControl(element: Nullable<HTMLElement>): void;
  32595. getClassName(): string;
  32596. getSimpleName(): string;
  32597. }
  32598. }
  32599. declare module BABYLON {
  32600. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  32601. camera: ArcRotateCamera;
  32602. buttons: number[];
  32603. angularSensibilityX: number;
  32604. angularSensibilityY: number;
  32605. pinchPrecision: number;
  32606. /**
  32607. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  32608. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  32609. */
  32610. pinchDeltaPercentage: number;
  32611. panningSensibility: number;
  32612. multiTouchPanning: boolean;
  32613. multiTouchPanAndZoom: boolean;
  32614. private _isPanClick;
  32615. pinchInwards: boolean;
  32616. private _pointerInput;
  32617. private _observer;
  32618. private _onMouseMove;
  32619. private _onGestureStart;
  32620. private _onGesture;
  32621. private _MSGestureHandler;
  32622. private _onLostFocus;
  32623. private _onContextMenu;
  32624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32625. detachControl(element: Nullable<HTMLElement>): void;
  32626. getClassName(): string;
  32627. getSimpleName(): string;
  32628. }
  32629. }
  32630. declare module BABYLON {
  32631. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  32632. camera: ArcRotateCamera;
  32633. alphaCorrection: number;
  32634. betaCorrection: number;
  32635. gammaCorrection: number;
  32636. private _alpha;
  32637. private _gamma;
  32638. private _dirty;
  32639. private _deviceOrientationHandler;
  32640. constructor();
  32641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32642. /** @hidden */
  32643. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  32644. checkInputs(): void;
  32645. detachControl(element: Nullable<HTMLElement>): void;
  32646. getClassName(): string;
  32647. getSimpleName(): string;
  32648. }
  32649. }
  32650. declare module BABYLON {
  32651. /**
  32652. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  32653. * Screen rotation is taken into account.
  32654. */
  32655. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  32656. private _camera;
  32657. private _screenOrientationAngle;
  32658. private _constantTranform;
  32659. private _screenQuaternion;
  32660. private _alpha;
  32661. private _beta;
  32662. private _gamma;
  32663. constructor();
  32664. camera: FreeCamera;
  32665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32666. private _orientationChanged;
  32667. private _deviceOrientation;
  32668. detachControl(element: Nullable<HTMLElement>): void;
  32669. checkInputs(): void;
  32670. getClassName(): string;
  32671. getSimpleName(): string;
  32672. }
  32673. }
  32674. declare module BABYLON {
  32675. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  32676. camera: FreeCamera;
  32677. gamepad: Nullable<Gamepad>;
  32678. private _onGamepadConnectedObserver;
  32679. private _onGamepadDisconnectedObserver;
  32680. gamepadAngularSensibility: number;
  32681. gamepadMoveSensibility: number;
  32682. private _cameraTransform;
  32683. private _deltaTransform;
  32684. private _vector3;
  32685. private _vector2;
  32686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32687. detachControl(element: Nullable<HTMLElement>): void;
  32688. checkInputs(): void;
  32689. getClassName(): string;
  32690. getSimpleName(): string;
  32691. }
  32692. }
  32693. declare module BABYLON {
  32694. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  32695. camera: FreeCamera;
  32696. private _keys;
  32697. private _onCanvasBlurObserver;
  32698. private _onKeyboardObserver;
  32699. private _engine;
  32700. private _scene;
  32701. keysUp: number[];
  32702. keysDown: number[];
  32703. keysLeft: number[];
  32704. keysRight: number[];
  32705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32706. detachControl(element: Nullable<HTMLElement>): void;
  32707. checkInputs(): void;
  32708. getClassName(): string;
  32709. /** @hidden */
  32710. _onLostFocus(e: FocusEvent): void;
  32711. getSimpleName(): string;
  32712. }
  32713. }
  32714. declare module BABYLON {
  32715. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  32716. touchEnabled: boolean;
  32717. camera: FreeCamera;
  32718. buttons: number[];
  32719. angularSensibility: number;
  32720. private _pointerInput;
  32721. private _onMouseMove;
  32722. private _observer;
  32723. private previousPosition;
  32724. constructor(touchEnabled?: boolean);
  32725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32726. detachControl(element: Nullable<HTMLElement>): void;
  32727. getClassName(): string;
  32728. getSimpleName(): string;
  32729. }
  32730. }
  32731. declare module BABYLON {
  32732. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  32733. camera: FreeCamera;
  32734. private _offsetX;
  32735. private _offsetY;
  32736. private _pointerPressed;
  32737. private _pointerInput;
  32738. private _observer;
  32739. private _onLostFocus;
  32740. touchAngularSensibility: number;
  32741. touchMoveSensibility: number;
  32742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32743. detachControl(element: Nullable<HTMLElement>): void;
  32744. checkInputs(): void;
  32745. getClassName(): string;
  32746. getSimpleName(): string;
  32747. }
  32748. }
  32749. declare module BABYLON {
  32750. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  32751. camera: FreeCamera;
  32752. private _leftjoystick;
  32753. private _rightjoystick;
  32754. getLeftJoystick(): VirtualJoystick;
  32755. getRightJoystick(): VirtualJoystick;
  32756. checkInputs(): void;
  32757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32758. detachControl(element: Nullable<HTMLElement>): void;
  32759. getClassName(): string;
  32760. getSimpleName(): string;
  32761. }
  32762. }
  32763. declare module BABYLON {
  32764. /**
  32765. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  32766. */
  32767. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  32768. /**
  32769. * Creates a new AnaglyphArcRotateCamera
  32770. * @param name defines camera name
  32771. * @param alpha defines alpha angle (in radians)
  32772. * @param beta defines beta angle (in radians)
  32773. * @param radius defines radius
  32774. * @param target defines camera target
  32775. * @param interaxialDistance defines distance between each color axis
  32776. * @param scene defines the hosting scene
  32777. */
  32778. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  32779. /**
  32780. * Gets camera class name
  32781. * @returns AnaglyphArcRotateCamera
  32782. */
  32783. getClassName(): string;
  32784. }
  32785. }
  32786. declare module BABYLON {
  32787. /**
  32788. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  32789. */
  32790. class AnaglyphFreeCamera extends FreeCamera {
  32791. /**
  32792. * Creates a new AnaglyphFreeCamera
  32793. * @param name defines camera name
  32794. * @param position defines initial position
  32795. * @param interaxialDistance defines distance between each color axis
  32796. * @param scene defines the hosting scene
  32797. */
  32798. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32799. /**
  32800. * Gets camera class name
  32801. * @returns AnaglyphFreeCamera
  32802. */
  32803. getClassName(): string;
  32804. }
  32805. }
  32806. declare module BABYLON {
  32807. /**
  32808. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  32809. */
  32810. class AnaglyphGamepadCamera extends GamepadCamera {
  32811. /**
  32812. * Creates a new AnaglyphGamepadCamera
  32813. * @param name defines camera name
  32814. * @param position defines initial position
  32815. * @param interaxialDistance defines distance between each color axis
  32816. * @param scene defines the hosting scene
  32817. */
  32818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32819. /**
  32820. * Gets camera class name
  32821. * @returns AnaglyphGamepadCamera
  32822. */
  32823. getClassName(): string;
  32824. }
  32825. }
  32826. declare module BABYLON {
  32827. /**
  32828. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  32829. */
  32830. class AnaglyphUniversalCamera extends UniversalCamera {
  32831. /**
  32832. * Creates a new AnaglyphUniversalCamera
  32833. * @param name defines camera name
  32834. * @param position defines initial position
  32835. * @param interaxialDistance defines distance between each color axis
  32836. * @param scene defines the hosting scene
  32837. */
  32838. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32839. /**
  32840. * Gets camera class name
  32841. * @returns AnaglyphUniversalCamera
  32842. */
  32843. getClassName(): string;
  32844. }
  32845. }
  32846. declare module BABYLON {
  32847. /**
  32848. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  32849. */
  32850. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  32851. /**
  32852. * Creates a new StereoscopicArcRotateCamera
  32853. * @param name defines camera name
  32854. * @param alpha defines alpha angle (in radians)
  32855. * @param beta defines beta angle (in radians)
  32856. * @param radius defines radius
  32857. * @param target defines camera target
  32858. * @param interaxialDistance defines distance between each color axis
  32859. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32860. * @param scene defines the hosting scene
  32861. */
  32862. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32863. /**
  32864. * Gets camera class name
  32865. * @returns StereoscopicArcRotateCamera
  32866. */
  32867. getClassName(): string;
  32868. }
  32869. }
  32870. declare module BABYLON {
  32871. /**
  32872. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  32873. */
  32874. class StereoscopicFreeCamera extends FreeCamera {
  32875. /**
  32876. * Creates a new StereoscopicFreeCamera
  32877. * @param name defines camera name
  32878. * @param position defines initial position
  32879. * @param interaxialDistance defines distance between each color axis
  32880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32881. * @param scene defines the hosting scene
  32882. */
  32883. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32884. /**
  32885. * Gets camera class name
  32886. * @returns StereoscopicFreeCamera
  32887. */
  32888. getClassName(): string;
  32889. }
  32890. }
  32891. declare module BABYLON {
  32892. /**
  32893. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  32894. */
  32895. class StereoscopicGamepadCamera extends GamepadCamera {
  32896. /**
  32897. * Creates a new StereoscopicGamepadCamera
  32898. * @param name defines camera name
  32899. * @param position defines initial position
  32900. * @param interaxialDistance defines distance between each color axis
  32901. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32902. * @param scene defines the hosting scene
  32903. */
  32904. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32905. /**
  32906. * Gets camera class name
  32907. * @returns StereoscopicGamepadCamera
  32908. */
  32909. getClassName(): string;
  32910. }
  32911. }
  32912. declare module BABYLON {
  32913. /**
  32914. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  32915. */
  32916. class StereoscopicUniversalCamera extends UniversalCamera {
  32917. /**
  32918. * Creates a new StereoscopicUniversalCamera
  32919. * @param name defines camera name
  32920. * @param position defines initial position
  32921. * @param interaxialDistance defines distance between each color axis
  32922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32923. * @param scene defines the hosting scene
  32924. */
  32925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32926. /**
  32927. * Gets camera class name
  32928. * @returns StereoscopicUniversalCamera
  32929. */
  32930. getClassName(): string;
  32931. }
  32932. }
  32933. declare module BABYLON {
  32934. class VRCameraMetrics {
  32935. hResolution: number;
  32936. vResolution: number;
  32937. hScreenSize: number;
  32938. vScreenSize: number;
  32939. vScreenCenter: number;
  32940. eyeToScreenDistance: number;
  32941. lensSeparationDistance: number;
  32942. interpupillaryDistance: number;
  32943. distortionK: number[];
  32944. chromaAbCorrection: number[];
  32945. postProcessScaleFactor: number;
  32946. lensCenterOffset: number;
  32947. compensateDistortion: boolean;
  32948. readonly aspectRatio: number;
  32949. readonly aspectRatioFov: number;
  32950. readonly leftHMatrix: Matrix;
  32951. readonly rightHMatrix: Matrix;
  32952. readonly leftPreViewMatrix: Matrix;
  32953. readonly rightPreViewMatrix: Matrix;
  32954. static GetDefault(): VRCameraMetrics;
  32955. }
  32956. }
  32957. declare module BABYLON {
  32958. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  32959. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32960. getClassName(): string;
  32961. }
  32962. }
  32963. declare module BABYLON {
  32964. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  32965. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32966. getClassName(): string;
  32967. }
  32968. }
  32969. declare module BABYLON {
  32970. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  32971. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32972. getClassName(): string;
  32973. }
  32974. }
  32975. declare module BABYLON {
  32976. /**
  32977. * Options to modify the vr teleportation behavior.
  32978. */
  32979. interface VRTeleportationOptions {
  32980. /**
  32981. * The name of the mesh which should be used as the teleportation floor. (default: null)
  32982. */
  32983. floorMeshName?: string;
  32984. /**
  32985. * A list of meshes to be used as the teleportation floor. (default: empty)
  32986. */
  32987. floorMeshes?: Mesh[];
  32988. }
  32989. /**
  32990. * Options to modify the vr experience helper's behavior.
  32991. */
  32992. interface VRExperienceHelperOptions extends WebVROptions {
  32993. /**
  32994. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  32995. */
  32996. createDeviceOrientationCamera?: boolean;
  32997. /**
  32998. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  32999. */
  33000. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  33001. /**
  33002. * Uses the main button on the controller to toggle the laser casted. (default: true)
  33003. */
  33004. laserToggle?: boolean;
  33005. /**
  33006. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  33007. */
  33008. floorMeshes?: Mesh[];
  33009. }
  33010. /**
  33011. * Helps to quickly add VR support to an existing scene.
  33012. * See http://doc.babylonjs.com/how_to/webvr_helper
  33013. */
  33014. class VRExperienceHelper {
  33015. /** Options to modify the vr experience helper's behavior. */
  33016. webVROptions: VRExperienceHelperOptions;
  33017. private _scene;
  33018. private _position;
  33019. private _btnVR;
  33020. private _btnVRDisplayed;
  33021. private _webVRsupported;
  33022. private _webVRready;
  33023. private _webVRrequesting;
  33024. private _webVRpresenting;
  33025. private _hasEnteredVR;
  33026. private _fullscreenVRpresenting;
  33027. private _canvas;
  33028. private _webVRCamera;
  33029. private _vrDeviceOrientationCamera;
  33030. private _deviceOrientationCamera;
  33031. private _existingCamera;
  33032. private _onKeyDown;
  33033. private _onVrDisplayPresentChange;
  33034. private _onVRDisplayChanged;
  33035. private _onVRRequestPresentStart;
  33036. private _onVRRequestPresentComplete;
  33037. /**
  33038. * Observable raised when entering VR.
  33039. */
  33040. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33041. /**
  33042. * Observable raised when exiting VR.
  33043. */
  33044. onExitingVRObservable: Observable<VRExperienceHelper>;
  33045. /**
  33046. * Observable raised when controller mesh is loaded.
  33047. */
  33048. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33049. /** Return this.onEnteringVRObservable
  33050. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33051. */
  33052. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33053. /** Return this.onExitingVRObservable
  33054. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33055. */
  33056. readonly onExitingVR: Observable<VRExperienceHelper>;
  33057. /** Return this.onControllerMeshLoadedObservable
  33058. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33059. */
  33060. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33061. private _rayLength;
  33062. private _useCustomVRButton;
  33063. private _teleportationRequested;
  33064. private _teleportActive;
  33065. private _floorMeshName;
  33066. private _floorMeshesCollection;
  33067. private _rotationAllowed;
  33068. private _teleportBackwardsVector;
  33069. private _teleportationTarget;
  33070. private _isDefaultTeleportationTarget;
  33071. private _postProcessMove;
  33072. private _teleportationFillColor;
  33073. private _teleportationBorderColor;
  33074. private _rotationAngle;
  33075. private _haloCenter;
  33076. private _cameraGazer;
  33077. private _padSensibilityUp;
  33078. private _padSensibilityDown;
  33079. private _leftController;
  33080. private _rightController;
  33081. /**
  33082. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  33083. */
  33084. onNewMeshSelected: Observable<AbstractMesh>;
  33085. /**
  33086. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  33087. */
  33088. onNewMeshPicked: Observable<PickingInfo>;
  33089. private _circleEase;
  33090. /**
  33091. * Observable raised before camera teleportation
  33092. */
  33093. onBeforeCameraTeleport: Observable<Vector3>;
  33094. /**
  33095. * Observable raised after camera teleportation
  33096. */
  33097. onAfterCameraTeleport: Observable<Vector3>;
  33098. /**
  33099. * Observable raised when current selected mesh gets unselected
  33100. */
  33101. onSelectedMeshUnselected: Observable<AbstractMesh>;
  33102. private _raySelectionPredicate;
  33103. /**
  33104. * To be optionaly changed by user to define custom ray selection
  33105. */
  33106. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  33107. /**
  33108. * To be optionaly changed by user to define custom selection logic (after ray selection)
  33109. */
  33110. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  33111. /**
  33112. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  33113. */
  33114. teleportationEnabled: boolean;
  33115. private _defaultHeight;
  33116. private _teleportationInitialized;
  33117. private _interactionsEnabled;
  33118. private _interactionsRequested;
  33119. private _displayGaze;
  33120. private _displayLaserPointer;
  33121. /**
  33122. * The mesh used to display where the user is going to teleport.
  33123. */
  33124. /**
  33125. * Sets the mesh to be used to display where the user is going to teleport.
  33126. */
  33127. teleportationTarget: Mesh;
  33128. /**
  33129. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  33130. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  33131. * See http://doc.babylonjs.com/resources/baking_transformations
  33132. */
  33133. gazeTrackerMesh: Mesh;
  33134. /**
  33135. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  33136. */
  33137. updateGazeTrackerScale: boolean;
  33138. /**
  33139. * The gaze tracking mesh corresponding to the left controller
  33140. */
  33141. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  33142. /**
  33143. * The gaze tracking mesh corresponding to the right controller
  33144. */
  33145. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  33146. /**
  33147. * If the ray of the gaze should be displayed.
  33148. */
  33149. /**
  33150. * Sets if the ray of the gaze should be displayed.
  33151. */
  33152. displayGaze: boolean;
  33153. /**
  33154. * If the ray of the LaserPointer should be displayed.
  33155. */
  33156. /**
  33157. * Sets if the ray of the LaserPointer should be displayed.
  33158. */
  33159. displayLaserPointer: boolean;
  33160. /**
  33161. * The deviceOrientationCamera used as the camera when not in VR.
  33162. */
  33163. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  33164. /**
  33165. * Based on the current WebVR support, returns the current VR camera used.
  33166. */
  33167. readonly currentVRCamera: Nullable<Camera>;
  33168. /**
  33169. * The webVRCamera which is used when in VR.
  33170. */
  33171. readonly webVRCamera: WebVRFreeCamera;
  33172. /**
  33173. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  33174. */
  33175. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  33176. private readonly _teleportationRequestInitiated;
  33177. /**
  33178. * Instantiates a VRExperienceHelper.
  33179. * Helps to quickly add VR support to an existing scene.
  33180. * @param scene The scene the VRExperienceHelper belongs to.
  33181. * @param webVROptions Options to modify the vr experience helper's behavior.
  33182. */
  33183. constructor(scene: Scene,
  33184. /** Options to modify the vr experience helper's behavior. */
  33185. webVROptions?: VRExperienceHelperOptions);
  33186. private _onDefaultMeshLoaded;
  33187. private _onResize;
  33188. private _onFullscreenChange;
  33189. /**
  33190. * Gets a value indicating if we are currently in VR mode.
  33191. */
  33192. readonly isInVRMode: boolean;
  33193. private onVrDisplayPresentChange;
  33194. private onVRDisplayChanged;
  33195. private moveButtonToBottomRight;
  33196. private displayVRButton;
  33197. private updateButtonVisibility;
  33198. /**
  33199. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  33200. * Otherwise, will use the fullscreen API.
  33201. */
  33202. enterVR(): void;
  33203. /**
  33204. * Attempt to exit VR, or fullscreen.
  33205. */
  33206. exitVR(): void;
  33207. /**
  33208. * The position of the vr experience helper.
  33209. */
  33210. /**
  33211. * Sets the position of the vr experience helper.
  33212. */
  33213. position: Vector3;
  33214. /**
  33215. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  33216. */
  33217. enableInteractions(): void;
  33218. private readonly _noControllerIsActive;
  33219. private beforeRender;
  33220. private _isTeleportationFloor;
  33221. /**
  33222. * Adds a floor mesh to be used for teleportation.
  33223. * @param floorMesh the mesh to be used for teleportation.
  33224. */
  33225. addFloorMesh(floorMesh: Mesh): void;
  33226. /**
  33227. * Removes a floor mesh from being used for teleportation.
  33228. * @param floorMesh the mesh to be removed.
  33229. */
  33230. removeFloorMesh(floorMesh: Mesh): void;
  33231. /**
  33232. * Enables interactions and teleportation using the VR controllers and gaze.
  33233. * @param vrTeleportationOptions options to modify teleportation behavior.
  33234. */
  33235. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  33236. private _onNewGamepadConnected;
  33237. private _tryEnableInteractionOnController;
  33238. private _onNewGamepadDisconnected;
  33239. private _enableInteractionOnController;
  33240. private _checkTeleportWithRay;
  33241. private _checkRotate;
  33242. private _checkTeleportBackwards;
  33243. private _enableTeleportationOnController;
  33244. private _createTeleportationCircles;
  33245. private _displayTeleportationTarget;
  33246. private _hideTeleportationTarget;
  33247. private _rotateCamera;
  33248. private _moveTeleportationSelectorTo;
  33249. private _workingVector;
  33250. private _workingQuaternion;
  33251. private _workingMatrix;
  33252. private _teleportCamera;
  33253. private _convertNormalToDirectionOfRay;
  33254. private _castRayAndSelectObject;
  33255. private _notifySelectedMeshUnselected;
  33256. /**
  33257. * Sets the color of the laser ray from the vr controllers.
  33258. * @param color new color for the ray.
  33259. */
  33260. changeLaserColor(color: Color3): void;
  33261. /**
  33262. * Sets the color of the ray from the vr headsets gaze.
  33263. * @param color new color for the ray.
  33264. */
  33265. changeGazeColor(color: Color3): void;
  33266. /**
  33267. * Exits VR and disposes of the vr experience helper
  33268. */
  33269. dispose(): void;
  33270. /**
  33271. * Gets the name of the VRExperienceHelper class
  33272. * @returns "VRExperienceHelper"
  33273. */
  33274. getClassName(): string;
  33275. }
  33276. }
  33277. declare module BABYLON {
  33278. /**
  33279. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  33280. * IMPORTANT!! The data is right-hand data.
  33281. * @export
  33282. * @interface DevicePose
  33283. */
  33284. interface DevicePose {
  33285. /**
  33286. * The position of the device, values in array are [x,y,z].
  33287. */
  33288. readonly position: Nullable<Float32Array>;
  33289. /**
  33290. * The linearVelocity of the device, values in array are [x,y,z].
  33291. */
  33292. readonly linearVelocity: Nullable<Float32Array>;
  33293. /**
  33294. * The linearAcceleration of the device, values in array are [x,y,z].
  33295. */
  33296. readonly linearAcceleration: Nullable<Float32Array>;
  33297. /**
  33298. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  33299. */
  33300. readonly orientation: Nullable<Float32Array>;
  33301. /**
  33302. * The angularVelocity of the device, values in array are [x,y,z].
  33303. */
  33304. readonly angularVelocity: Nullable<Float32Array>;
  33305. /**
  33306. * The angularAcceleration of the device, values in array are [x,y,z].
  33307. */
  33308. readonly angularAcceleration: Nullable<Float32Array>;
  33309. }
  33310. /**
  33311. * Interface representing a pose controlled object in Babylon.
  33312. * A pose controlled object has both regular pose values as well as pose values
  33313. * from an external device such as a VR head mounted display
  33314. */
  33315. interface PoseControlled {
  33316. /**
  33317. * The position of the object in babylon space.
  33318. */
  33319. position: Vector3;
  33320. /**
  33321. * The rotation quaternion of the object in babylon space.
  33322. */
  33323. rotationQuaternion: Quaternion;
  33324. /**
  33325. * The position of the device in babylon space.
  33326. */
  33327. devicePosition?: Vector3;
  33328. /**
  33329. * The rotation quaternion of the device in babylon space.
  33330. */
  33331. deviceRotationQuaternion: Quaternion;
  33332. /**
  33333. * The raw pose coming from the device.
  33334. */
  33335. rawPose: Nullable<DevicePose>;
  33336. /**
  33337. * The scale of the device to be used when translating from device space to babylon space.
  33338. */
  33339. deviceScaleFactor: number;
  33340. /**
  33341. * Updates the poseControlled values based on the input device pose.
  33342. * @param poseData the pose data to update the object with
  33343. */
  33344. updateFromDevice(poseData: DevicePose): void;
  33345. }
  33346. /**
  33347. * Set of options to customize the webVRCamera
  33348. */
  33349. interface WebVROptions {
  33350. /**
  33351. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  33352. */
  33353. trackPosition?: boolean;
  33354. /**
  33355. * Sets the scale of the vrDevice in babylon space. (default: 1)
  33356. */
  33357. positionScale?: number;
  33358. /**
  33359. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  33360. */
  33361. displayName?: string;
  33362. /**
  33363. * Should the native controller meshes be initialized. (default: true)
  33364. */
  33365. controllerMeshes?: boolean;
  33366. /**
  33367. * Creating a default HemiLight only on controllers. (default: true)
  33368. */
  33369. defaultLightingOnControllers?: boolean;
  33370. /**
  33371. * If you don't want to use the default VR button of the helper. (default: false)
  33372. */
  33373. useCustomVRButton?: boolean;
  33374. /**
  33375. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  33376. */
  33377. customVRButton?: HTMLButtonElement;
  33378. /**
  33379. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  33380. */
  33381. rayLength?: number;
  33382. /**
  33383. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  33384. */
  33385. defaultHeight?: number;
  33386. }
  33387. /**
  33388. * This represents a WebVR camera.
  33389. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  33390. * @example http://doc.babylonjs.com/how_to/webvr_camera
  33391. */
  33392. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  33393. private webVROptions;
  33394. /**
  33395. * @hidden
  33396. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  33397. */
  33398. _vrDevice: any;
  33399. /**
  33400. * The rawPose of the vrDevice.
  33401. */
  33402. rawPose: Nullable<DevicePose>;
  33403. private _onVREnabled;
  33404. private _specsVersion;
  33405. private _attached;
  33406. private _frameData;
  33407. protected _descendants: Array<Node>;
  33408. private _deviceRoomPosition;
  33409. /** @hidden */
  33410. _deviceRoomRotationQuaternion: Quaternion;
  33411. private _standingMatrix;
  33412. /**
  33413. * Represents device position in babylon space.
  33414. */
  33415. devicePosition: Vector3;
  33416. /**
  33417. * Represents device rotation in babylon space.
  33418. */
  33419. deviceRotationQuaternion: Quaternion;
  33420. /**
  33421. * The scale of the device to be used when translating from device space to babylon space.
  33422. */
  33423. deviceScaleFactor: number;
  33424. private _deviceToWorld;
  33425. private _worldToDevice;
  33426. /**
  33427. * References to the webVR controllers for the vrDevice.
  33428. */
  33429. controllers: Array<WebVRController>;
  33430. /**
  33431. * Emits an event when a controller is attached.
  33432. */
  33433. onControllersAttachedObservable: Observable<WebVRController[]>;
  33434. /**
  33435. * Emits an event when a controller's mesh has been loaded;
  33436. */
  33437. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33438. /**
  33439. * Emits an event when the HMD's pose has been updated.
  33440. */
  33441. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33442. private _poseSet;
  33443. /**
  33444. * If the rig cameras be used as parent instead of this camera.
  33445. */
  33446. rigParenting: boolean;
  33447. private _lightOnControllers;
  33448. private _defaultHeight?;
  33449. /**
  33450. * Instantiates a WebVRFreeCamera.
  33451. * @param name The name of the WebVRFreeCamera
  33452. * @param position The starting anchor position for the camera
  33453. * @param scene The scene the camera belongs to
  33454. * @param webVROptions a set of customizable options for the webVRCamera
  33455. */
  33456. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  33457. /**
  33458. * Gets the device distance from the ground in meters.
  33459. * @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.
  33460. */
  33461. deviceDistanceToRoomGround(): number;
  33462. /**
  33463. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33464. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  33465. */
  33466. useStandingMatrix(callback?: (bool: boolean) => void): void;
  33467. /**
  33468. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33469. * @returns A promise with a boolean set to if the standing matrix is supported.
  33470. */
  33471. useStandingMatrixAsync(): Promise<boolean>;
  33472. /**
  33473. * Disposes the camera
  33474. */
  33475. dispose(): void;
  33476. /**
  33477. * Gets a vrController by name.
  33478. * @param name The name of the controller to retreive
  33479. * @returns the controller matching the name specified or null if not found
  33480. */
  33481. getControllerByName(name: string): Nullable<WebVRController>;
  33482. private _leftController;
  33483. /**
  33484. * The controller corrisponding to the users left hand.
  33485. */
  33486. readonly leftController: Nullable<WebVRController>;
  33487. private _rightController;
  33488. /**
  33489. * The controller corrisponding to the users right hand.
  33490. */
  33491. readonly rightController: Nullable<WebVRController>;
  33492. /**
  33493. * Casts a ray forward from the vrCamera's gaze.
  33494. * @param length Length of the ray (default: 100)
  33495. * @returns the ray corrisponding to the gaze
  33496. */
  33497. getForwardRay(length?: number): Ray;
  33498. /**
  33499. * @hidden
  33500. * Updates the camera based on device's frame data
  33501. */
  33502. _checkInputs(): void;
  33503. /**
  33504. * Updates the poseControlled values based on the input device pose.
  33505. * @param poseData Pose coming from the device
  33506. */
  33507. updateFromDevice(poseData: DevicePose): void;
  33508. private _htmlElementAttached;
  33509. private _detachIfAttached;
  33510. /**
  33511. * WebVR's attach control will start broadcasting frames to the device.
  33512. * Note that in certain browsers (chrome for example) this function must be called
  33513. * within a user-interaction callback. Example:
  33514. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  33515. *
  33516. * @param element html element to attach the vrDevice to
  33517. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  33518. */
  33519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33520. /**
  33521. * Detaches the camera from the html element and disables VR
  33522. *
  33523. * @param element html element to detach from
  33524. */
  33525. detachControl(element: HTMLElement): void;
  33526. /**
  33527. * @returns the name of this class
  33528. */
  33529. getClassName(): string;
  33530. /**
  33531. * Calls resetPose on the vrDisplay
  33532. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  33533. */
  33534. resetToCurrentRotation(): void;
  33535. /**
  33536. * @hidden
  33537. * Updates the rig cameras (left and right eye)
  33538. */
  33539. _updateRigCameras(): void;
  33540. private _workingVector;
  33541. private _oneVector;
  33542. private _workingMatrix;
  33543. private updateCacheCalled;
  33544. /**
  33545. * @hidden
  33546. * Updates the cached values of the camera
  33547. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  33548. */
  33549. _updateCache(ignoreParentClass?: boolean): void;
  33550. /**
  33551. * Updates the current device position and rotation in the babylon world
  33552. */
  33553. update(): void;
  33554. /**
  33555. * @hidden
  33556. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  33557. * @returns an identity matrix
  33558. */
  33559. _getViewMatrix(): Matrix;
  33560. /**
  33561. * This function is called by the two RIG cameras.
  33562. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  33563. */
  33564. protected _getWebVRViewMatrix(): Matrix;
  33565. protected _getWebVRProjectionMatrix(): Matrix;
  33566. private _onGamepadConnectedObserver;
  33567. private _onGamepadDisconnectedObserver;
  33568. /**
  33569. * Initializes the controllers and their meshes
  33570. */
  33571. initControllers(): void;
  33572. }
  33573. }
  33574. declare module BABYLON {
  33575. interface IOctreeContainer<T> {
  33576. blocks: Array<OctreeBlock<T>>;
  33577. }
  33578. class Octree<T> {
  33579. maxDepth: number;
  33580. blocks: Array<OctreeBlock<T>>;
  33581. dynamicContent: T[];
  33582. private _maxBlockCapacity;
  33583. private _selectionContent;
  33584. private _creationFunc;
  33585. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  33586. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  33587. addMesh(entry: T): void;
  33588. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  33589. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  33590. intersectsRay(ray: Ray): SmartArray<T>;
  33591. 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;
  33592. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  33593. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  33594. }
  33595. }
  33596. declare module BABYLON {
  33597. class OctreeBlock<T> {
  33598. entries: T[];
  33599. blocks: Array<OctreeBlock<T>>;
  33600. private _depth;
  33601. private _maxDepth;
  33602. private _capacity;
  33603. private _minPoint;
  33604. private _maxPoint;
  33605. private _boundingVectors;
  33606. private _creationFunc;
  33607. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  33608. readonly capacity: number;
  33609. readonly minPoint: Vector3;
  33610. readonly maxPoint: Vector3;
  33611. addEntry(entry: T): void;
  33612. addEntries(entries: T[]): void;
  33613. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33614. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33615. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  33616. createInnerBlocks(): void;
  33617. }
  33618. }
  33619. declare module BABYLON {
  33620. interface Engine {
  33621. /**
  33622. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  33623. * @return the new query
  33624. */
  33625. createQuery(): WebGLQuery;
  33626. /**
  33627. * Delete and release a webGL query
  33628. * @param query defines the query to delete
  33629. * @return the current engine
  33630. */
  33631. deleteQuery(query: WebGLQuery): Engine;
  33632. /**
  33633. * Check if a given query has resolved and got its value
  33634. * @param query defines the query to check
  33635. * @returns true if the query got its value
  33636. */
  33637. isQueryResultAvailable(query: WebGLQuery): boolean;
  33638. /**
  33639. * Gets the value of a given query
  33640. * @param query defines the query to check
  33641. * @returns the value of the query
  33642. */
  33643. getQueryResult(query: WebGLQuery): number;
  33644. /**
  33645. * Initiates an occlusion query
  33646. * @param algorithmType defines the algorithm to use
  33647. * @param query defines the query to use
  33648. * @returns the current engine
  33649. * @see http://doc.babylonjs.com/features/occlusionquery
  33650. */
  33651. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  33652. /**
  33653. * Ends an occlusion query
  33654. * @see http://doc.babylonjs.com/features/occlusionquery
  33655. * @param algorithmType defines the algorithm to use
  33656. * @returns the current engine
  33657. */
  33658. endOcclusionQuery(algorithmType: number): Engine;
  33659. /**
  33660. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  33661. * Please note that only one query can be issued at a time
  33662. * @returns a time token used to track the time span
  33663. */
  33664. startTimeQuery(): Nullable<_TimeToken>;
  33665. /**
  33666. * Ends a time query
  33667. * @param token defines the token used to measure the time span
  33668. * @returns the time spent (in ns)
  33669. */
  33670. endTimeQuery(token: _TimeToken): int;
  33671. /** @hidden */
  33672. _currentNonTimestampToken: Nullable<_TimeToken>;
  33673. /** @hidden */
  33674. _createTimeQuery(): WebGLQuery;
  33675. /** @hidden */
  33676. _deleteTimeQuery(query: WebGLQuery): void;
  33677. /** @hidden */
  33678. _getGlAlgorithmType(algorithmType: number): number;
  33679. /** @hidden */
  33680. _getTimeQueryResult(query: WebGLQuery): any;
  33681. /** @hidden */
  33682. _getTimeQueryAvailability(query: WebGLQuery): any;
  33683. }
  33684. }
  33685. declare module BABYLON {
  33686. interface Engine {
  33687. /**
  33688. * Creates a webGL transform feedback object
  33689. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  33690. * @returns the webGL transform feedback object
  33691. */
  33692. createTransformFeedback(): WebGLTransformFeedback;
  33693. /**
  33694. * Delete a webGL transform feedback object
  33695. * @param value defines the webGL transform feedback object to delete
  33696. */
  33697. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  33698. /**
  33699. * Bind a webGL transform feedback object to the webgl context
  33700. * @param value defines the webGL transform feedback object to bind
  33701. */
  33702. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  33703. /**
  33704. * Begins a transform feedback operation
  33705. * @param usePoints defines if points or triangles must be used
  33706. */
  33707. beginTransformFeedback(usePoints: boolean): void;
  33708. /**
  33709. * Ends a transform feedback operation
  33710. */
  33711. endTransformFeedback(): void;
  33712. /**
  33713. * Specify the varyings to use with transform feedback
  33714. * @param program defines the associated webGL program
  33715. * @param value defines the list of strings representing the varying names
  33716. */
  33717. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  33718. /**
  33719. * Bind a webGL buffer for a transform feedback operation
  33720. * @param value defines the webGL buffer to bind
  33721. */
  33722. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  33723. }
  33724. }
  33725. declare module BABYLON {
  33726. /**
  33727. * Google Daydream controller
  33728. */
  33729. class DaydreamController extends WebVRController {
  33730. /**
  33731. * Base Url for the controller model.
  33732. */
  33733. static MODEL_BASE_URL: string;
  33734. /**
  33735. * File name for the controller model.
  33736. */
  33737. static MODEL_FILENAME: string;
  33738. /**
  33739. * Gamepad Id prefix used to identify Daydream Controller.
  33740. */
  33741. static readonly GAMEPAD_ID_PREFIX: string;
  33742. /**
  33743. * Creates a new DaydreamController from a gamepad
  33744. * @param vrGamepad the gamepad that the controller should be created from
  33745. */
  33746. constructor(vrGamepad: any);
  33747. /**
  33748. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33749. * @param scene scene in which to add meshes
  33750. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33751. */
  33752. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33753. /**
  33754. * Called once for each button that changed state since the last frame
  33755. * @param buttonIdx Which button index changed
  33756. * @param state New state of the button
  33757. * @param changes Which properties on the state changed since last frame
  33758. */
  33759. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33760. }
  33761. }
  33762. declare module BABYLON {
  33763. /**
  33764. * Gear VR Controller
  33765. */
  33766. class GearVRController extends WebVRController {
  33767. /**
  33768. * Base Url for the controller model.
  33769. */
  33770. static MODEL_BASE_URL: string;
  33771. /**
  33772. * File name for the controller model.
  33773. */
  33774. static MODEL_FILENAME: string;
  33775. private _maxRotationDistFromHeadset;
  33776. private _draggedRoomRotation;
  33777. private _tmpVector;
  33778. /**
  33779. * Gamepad Id prefix used to identify this controller.
  33780. */
  33781. static readonly GAMEPAD_ID_PREFIX: string;
  33782. private readonly _buttonIndexToObservableNameMap;
  33783. /**
  33784. * Creates a new GearVRController from a gamepad
  33785. * @param vrGamepad the gamepad that the controller should be created from
  33786. */
  33787. constructor(vrGamepad: any);
  33788. /**
  33789. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33790. * @param poseData raw pose fromthe device
  33791. */
  33792. updateFromDevice(poseData: DevicePose): void;
  33793. /**
  33794. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33795. * @param scene scene in which to add meshes
  33796. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33797. */
  33798. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33799. /**
  33800. * Called once for each button that changed state since the last frame
  33801. * @param buttonIdx Which button index changed
  33802. * @param state New state of the button
  33803. * @param changes Which properties on the state changed since last frame
  33804. */
  33805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33806. }
  33807. }
  33808. declare module BABYLON {
  33809. /**
  33810. * Generic Controller
  33811. */
  33812. class GenericController extends WebVRController {
  33813. /**
  33814. * Base Url for the controller model.
  33815. */
  33816. static readonly MODEL_BASE_URL: string;
  33817. /**
  33818. * File name for the controller model.
  33819. */
  33820. static readonly MODEL_FILENAME: string;
  33821. /**
  33822. * Creates a new GenericController from a gamepad
  33823. * @param vrGamepad the gamepad that the controller should be created from
  33824. */
  33825. constructor(vrGamepad: any);
  33826. /**
  33827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33828. * @param scene scene in which to add meshes
  33829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33830. */
  33831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33832. /**
  33833. * Called once for each button that changed state since the last frame
  33834. * @param buttonIdx Which button index changed
  33835. * @param state New state of the button
  33836. * @param changes Which properties on the state changed since last frame
  33837. */
  33838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33839. }
  33840. }
  33841. declare module BABYLON {
  33842. /**
  33843. * Oculus Touch Controller
  33844. */
  33845. class OculusTouchController extends WebVRController {
  33846. /**
  33847. * Base Url for the controller model.
  33848. */
  33849. static MODEL_BASE_URL: string;
  33850. /**
  33851. * File name for the left controller model.
  33852. */
  33853. static MODEL_LEFT_FILENAME: string;
  33854. /**
  33855. * File name for the right controller model.
  33856. */
  33857. static MODEL_RIGHT_FILENAME: string;
  33858. /**
  33859. * Fired when the secondary trigger on this controller is modified
  33860. */
  33861. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33862. /**
  33863. * Fired when the thumb rest on this controller is modified
  33864. */
  33865. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  33866. /**
  33867. * Creates a new OculusTouchController from a gamepad
  33868. * @param vrGamepad the gamepad that the controller should be created from
  33869. */
  33870. constructor(vrGamepad: any);
  33871. /**
  33872. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33873. * @param scene scene in which to add meshes
  33874. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33875. */
  33876. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33877. /**
  33878. * Fired when the A button on this controller is modified
  33879. */
  33880. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33881. /**
  33882. * Fired when the B button on this controller is modified
  33883. */
  33884. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33885. /**
  33886. * Fired when the X button on this controller is modified
  33887. */
  33888. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33889. /**
  33890. * Fired when the Y button on this controller is modified
  33891. */
  33892. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33893. /**
  33894. * Called once for each button that changed state since the last frame
  33895. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  33896. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  33897. * 2) secondary trigger (same)
  33898. * 3) A (right) X (left), touch, pressed = value
  33899. * 4) B / Y
  33900. * 5) thumb rest
  33901. * @param buttonIdx Which button index changed
  33902. * @param state New state of the button
  33903. * @param changes Which properties on the state changed since last frame
  33904. */
  33905. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Defines the types of pose enabled controllers that are supported
  33911. */
  33912. enum PoseEnabledControllerType {
  33913. /**
  33914. * HTC Vive
  33915. */
  33916. VIVE = 0,
  33917. /**
  33918. * Oculus Rift
  33919. */
  33920. OCULUS = 1,
  33921. /**
  33922. * Windows mixed reality
  33923. */
  33924. WINDOWS = 2,
  33925. /**
  33926. * Samsung gear VR
  33927. */
  33928. GEAR_VR = 3,
  33929. /**
  33930. * Google Daydream
  33931. */
  33932. DAYDREAM = 4,
  33933. /**
  33934. * Generic
  33935. */
  33936. GENERIC = 5
  33937. }
  33938. /**
  33939. * Defines the MutableGamepadButton interface for the state of a gamepad button
  33940. */
  33941. interface MutableGamepadButton {
  33942. /**
  33943. * Value of the button/trigger
  33944. */
  33945. value: number;
  33946. /**
  33947. * If the button/trigger is currently touched
  33948. */
  33949. touched: boolean;
  33950. /**
  33951. * If the button/trigger is currently pressed
  33952. */
  33953. pressed: boolean;
  33954. }
  33955. /**
  33956. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  33957. * @hidden
  33958. */
  33959. interface ExtendedGamepadButton extends GamepadButton {
  33960. /**
  33961. * If the button/trigger is currently pressed
  33962. */
  33963. readonly pressed: boolean;
  33964. /**
  33965. * If the button/trigger is currently touched
  33966. */
  33967. readonly touched: boolean;
  33968. /**
  33969. * Value of the button/trigger
  33970. */
  33971. readonly value: number;
  33972. }
  33973. /**
  33974. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33975. */
  33976. class PoseEnabledControllerHelper {
  33977. /**
  33978. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33979. * @param vrGamepad the gamepad to initialized
  33980. * @returns a vr controller of the type the gamepad identified as
  33981. */
  33982. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  33983. }
  33984. /**
  33985. * Defines the PoseEnabledController object that contains state of a vr capable controller
  33986. */
  33987. class PoseEnabledController extends Gamepad implements PoseControlled {
  33988. private _deviceRoomPosition;
  33989. private _deviceRoomRotationQuaternion;
  33990. /**
  33991. * The device position in babylon space
  33992. */
  33993. devicePosition: Vector3;
  33994. /**
  33995. * The device rotation in babylon space
  33996. */
  33997. deviceRotationQuaternion: Quaternion;
  33998. /**
  33999. * The scale factor of the device in babylon space
  34000. */
  34001. deviceScaleFactor: number;
  34002. /**
  34003. * (Likely devicePosition should be used instead) The device position in its room space
  34004. */
  34005. position: Vector3;
  34006. /**
  34007. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  34008. */
  34009. rotationQuaternion: Quaternion;
  34010. /**
  34011. * The type of controller (Eg. Windows mixed reality)
  34012. */
  34013. controllerType: PoseEnabledControllerType;
  34014. protected _calculatedPosition: Vector3;
  34015. private _calculatedRotation;
  34016. /**
  34017. * The raw pose from the device
  34018. */
  34019. rawPose: DevicePose;
  34020. /**
  34021. * Internal, the mesh attached to the controller
  34022. * @hidden
  34023. */
  34024. _mesh: Nullable<AbstractMesh>;
  34025. private _poseControlledCamera;
  34026. private _leftHandSystemQuaternion;
  34027. /**
  34028. * Internal, matrix used to convert room space to babylon space
  34029. * @hidden
  34030. */
  34031. _deviceToWorld: Matrix;
  34032. /**
  34033. * Node to be used when casting a ray from the controller
  34034. * @hidden
  34035. */
  34036. _pointingPoseNode: Nullable<AbstractMesh>;
  34037. /**
  34038. * Name of the child mesh that can be used to cast a ray from the controller
  34039. */
  34040. static readonly POINTING_POSE: string;
  34041. /**
  34042. * Creates a new PoseEnabledController from a gamepad
  34043. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34044. */
  34045. constructor(browserGamepad: any);
  34046. private _workingMatrix;
  34047. /**
  34048. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34049. */
  34050. update(): void;
  34051. /**
  34052. * Updates only the pose device and mesh without doing any button event checking
  34053. */
  34054. protected _updatePoseAndMesh(): void;
  34055. /**
  34056. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34057. * @param poseData raw pose fromthe device
  34058. */
  34059. updateFromDevice(poseData: DevicePose): void;
  34060. /**
  34061. * @hidden
  34062. */
  34063. _meshAttachedObservable: Observable<AbstractMesh>;
  34064. /**
  34065. * Attaches a mesh to the controller
  34066. * @param mesh the mesh to be attached
  34067. */
  34068. attachToMesh(mesh: AbstractMesh): void;
  34069. /**
  34070. * Attaches the controllers mesh to a camera
  34071. * @param camera the camera the mesh should be attached to
  34072. */
  34073. attachToPoseControlledCamera(camera: TargetCamera): void;
  34074. /**
  34075. * Disposes of the controller
  34076. */
  34077. dispose(): void;
  34078. /**
  34079. * The mesh that is attached to the controller
  34080. */
  34081. readonly mesh: Nullable<AbstractMesh>;
  34082. /**
  34083. * Gets the ray of the controller in the direction the controller is pointing
  34084. * @param length the length the resulting ray should be
  34085. * @returns a ray in the direction the controller is pointing
  34086. */
  34087. getForwardRay(length?: number): Ray;
  34088. }
  34089. }
  34090. declare module BABYLON {
  34091. /**
  34092. * Vive Controller
  34093. */
  34094. class ViveController extends WebVRController {
  34095. /**
  34096. * Base Url for the controller model.
  34097. */
  34098. static MODEL_BASE_URL: string;
  34099. /**
  34100. * File name for the controller model.
  34101. */
  34102. static MODEL_FILENAME: string;
  34103. /**
  34104. * Creates a new ViveController from a gamepad
  34105. * @param vrGamepad the gamepad that the controller should be created from
  34106. */
  34107. constructor(vrGamepad: any);
  34108. /**
  34109. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34110. * @param scene scene in which to add meshes
  34111. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34112. */
  34113. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34114. /**
  34115. * Fired when the left button on this controller is modified
  34116. */
  34117. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34118. /**
  34119. * Fired when the right button on this controller is modified
  34120. */
  34121. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34122. /**
  34123. * Fired when the menu button on this controller is modified
  34124. */
  34125. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34126. /**
  34127. * Called once for each button that changed state since the last frame
  34128. * Vive mapping:
  34129. * 0: touchpad
  34130. * 1: trigger
  34131. * 2: left AND right buttons
  34132. * 3: menu button
  34133. * @param buttonIdx Which button index changed
  34134. * @param state New state of the button
  34135. * @param changes Which properties on the state changed since last frame
  34136. */
  34137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34138. }
  34139. }
  34140. declare module BABYLON {
  34141. /**
  34142. * Defines the WebVRController object that represents controllers tracked in 3D space
  34143. */
  34144. abstract class WebVRController extends PoseEnabledController {
  34145. /**
  34146. * Internal, the default controller model for the controller
  34147. */
  34148. protected _defaultModel: AbstractMesh;
  34149. /**
  34150. * Fired when the trigger state has changed
  34151. */
  34152. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34153. /**
  34154. * Fired when the main button state has changed
  34155. */
  34156. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34157. /**
  34158. * Fired when the secondary button state has changed
  34159. */
  34160. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34161. /**
  34162. * Fired when the pad state has changed
  34163. */
  34164. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  34165. /**
  34166. * Fired when controllers stick values have changed
  34167. */
  34168. onPadValuesChangedObservable: Observable<StickValues>;
  34169. /**
  34170. * Array of button availible on the controller
  34171. */
  34172. protected _buttons: Array<MutableGamepadButton>;
  34173. private _onButtonStateChange;
  34174. /**
  34175. * Fired when a controller button's state has changed
  34176. * @param callback the callback containing the button that was modified
  34177. */
  34178. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  34179. /**
  34180. * X and Y axis corrisponding to the controllers joystick
  34181. */
  34182. pad: StickValues;
  34183. /**
  34184. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  34185. */
  34186. hand: string;
  34187. /**
  34188. * The default controller model for the controller
  34189. */
  34190. readonly defaultModel: AbstractMesh;
  34191. /**
  34192. * Creates a new WebVRController from a gamepad
  34193. * @param vrGamepad the gamepad that the WebVRController should be created from
  34194. */
  34195. constructor(vrGamepad: any);
  34196. /**
  34197. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34198. */
  34199. update(): void;
  34200. /**
  34201. * Function to be called when a button is modified
  34202. */
  34203. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34204. /**
  34205. * Loads a mesh and attaches it to the controller
  34206. * @param scene the scene the mesh should be added to
  34207. * @param meshLoaded callback for when the mesh has been loaded
  34208. */
  34209. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34210. private _setButtonValue;
  34211. private _changes;
  34212. private _checkChanges;
  34213. /**
  34214. * Disposes of th webVRCOntroller
  34215. */
  34216. dispose(): void;
  34217. }
  34218. }
  34219. declare module BABYLON {
  34220. /**
  34221. * Defines the WindowsMotionController object that the state of the windows motion controller
  34222. */
  34223. class WindowsMotionController extends WebVRController {
  34224. /**
  34225. * The base url used to load the left and right controller models
  34226. */
  34227. static MODEL_BASE_URL: string;
  34228. /**
  34229. * The name of the left controller model file
  34230. */
  34231. static MODEL_LEFT_FILENAME: string;
  34232. /**
  34233. * The name of the right controller model file
  34234. */
  34235. static MODEL_RIGHT_FILENAME: string;
  34236. /**
  34237. * The controller name prefix for this controller type
  34238. */
  34239. static readonly GAMEPAD_ID_PREFIX: string;
  34240. /**
  34241. * The controller id pattern for this controller type
  34242. */
  34243. private static readonly GAMEPAD_ID_PATTERN;
  34244. private _loadedMeshInfo;
  34245. private readonly _mapping;
  34246. /**
  34247. * Fired when the trackpad on this controller is clicked
  34248. */
  34249. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  34250. /**
  34251. * Fired when the trackpad on this controller is modified
  34252. */
  34253. onTrackpadValuesChangedObservable: Observable<StickValues>;
  34254. /**
  34255. * The current x and y values of this controller's trackpad
  34256. */
  34257. trackpad: StickValues;
  34258. /**
  34259. * Creates a new WindowsMotionController from a gamepad
  34260. * @param vrGamepad the gamepad that the controller should be created from
  34261. */
  34262. constructor(vrGamepad: any);
  34263. /**
  34264. * Fired when the trigger on this controller is modified
  34265. */
  34266. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34267. /**
  34268. * Fired when the menu button on this controller is modified
  34269. */
  34270. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34271. /**
  34272. * Fired when the grip button on this controller is modified
  34273. */
  34274. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34275. /**
  34276. * Fired when the thumbstick button on this controller is modified
  34277. */
  34278. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34279. /**
  34280. * Fired when the touchpad button on this controller is modified
  34281. */
  34282. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34283. /**
  34284. * Fired when the touchpad values on this controller are modified
  34285. */
  34286. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  34287. private _updateTrackpad;
  34288. /**
  34289. * Called once per frame by the engine.
  34290. */
  34291. update(): void;
  34292. /**
  34293. * Called once for each button that changed state since the last frame
  34294. * @param buttonIdx Which button index changed
  34295. * @param state New state of the button
  34296. * @param changes Which properties on the state changed since last frame
  34297. */
  34298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34299. /**
  34300. * Moves the buttons on the controller mesh based on their current state
  34301. * @param buttonName the name of the button to move
  34302. * @param buttonValue the value of the button which determines the buttons new position
  34303. */
  34304. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  34305. /**
  34306. * Moves the axis on the controller mesh based on its current state
  34307. * @param axis the index of the axis
  34308. * @param axisValue the value of the axis which determines the meshes new position
  34309. * @hidden
  34310. */
  34311. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  34312. /**
  34313. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34314. * @param scene scene in which to add meshes
  34315. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34316. */
  34317. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  34318. /**
  34319. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  34320. * can be transformed by button presses and axes values, based on this._mapping.
  34321. *
  34322. * @param scene scene in which the meshes exist
  34323. * @param meshes list of meshes that make up the controller model to process
  34324. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  34325. */
  34326. private processModel;
  34327. private createMeshInfo;
  34328. /**
  34329. * Gets the ray of the controller in the direction the controller is pointing
  34330. * @param length the length the resulting ray should be
  34331. * @returns a ray in the direction the controller is pointing
  34332. */
  34333. getForwardRay(length?: number): Ray;
  34334. /**
  34335. * Disposes of the controller
  34336. */
  34337. dispose(): void;
  34338. }
  34339. }
  34340. declare module BABYLON {
  34341. /**
  34342. * Interface to implement to create a shadow generator compatible with BJS.
  34343. */
  34344. interface IShadowGenerator {
  34345. /**
  34346. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34347. * @returns The render target texture if present otherwise, null
  34348. */
  34349. getShadowMap(): Nullable<RenderTargetTexture>;
  34350. /**
  34351. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34352. * @returns The render target texture if the shadow map is present otherwise, null
  34353. */
  34354. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34355. /**
  34356. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34357. * @param subMesh The submesh we want to render in the shadow map
  34358. * @param useInstances Defines wether will draw in the map using instances
  34359. * @returns true if ready otherwise, false
  34360. */
  34361. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34362. /**
  34363. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34364. * @param defines Defines of the material we want to update
  34365. * @param lightIndex Index of the light in the enabled light list of the material
  34366. */
  34367. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34368. /**
  34369. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34370. * defined in the generator but impacting the effect).
  34371. * It implies the unifroms available on the materials are the standard BJS ones.
  34372. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34373. * @param effect The effect we are binfing the information for
  34374. */
  34375. bindShadowLight(lightIndex: string, effect: Effect): void;
  34376. /**
  34377. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34378. * (eq to shadow prjection matrix * light transform matrix)
  34379. * @returns The transform matrix used to create the shadow map
  34380. */
  34381. getTransformMatrix(): Matrix;
  34382. /**
  34383. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34384. * Cube and 2D textures for instance.
  34385. */
  34386. recreateShadowMap(): void;
  34387. /**
  34388. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34389. * @param onCompiled Callback triggered at the and of the effects compilation
  34390. * @param options Sets of optional options forcing the compilation with different modes
  34391. */
  34392. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34393. useInstances: boolean;
  34394. }>): void;
  34395. /**
  34396. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34397. * @param options Sets of optional options forcing the compilation with different modes
  34398. * @returns A promise that resolves when the compilation completes
  34399. */
  34400. forceCompilationAsync(options?: Partial<{
  34401. useInstances: boolean;
  34402. }>): Promise<void>;
  34403. /**
  34404. * Serializes the shadow generator setup to a json object.
  34405. * @returns The serialized JSON object
  34406. */
  34407. serialize(): any;
  34408. /**
  34409. * Disposes the Shadow map and related Textures and effects.
  34410. */
  34411. dispose(): void;
  34412. }
  34413. /**
  34414. * Default implementation IShadowGenerator.
  34415. * This is the main object responsible of generating shadows in the framework.
  34416. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34417. */
  34418. class ShadowGenerator implements IShadowGenerator {
  34419. /**
  34420. * Shadow generator mode None: no filtering applied.
  34421. */
  34422. static readonly FILTER_NONE: number;
  34423. /**
  34424. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34426. */
  34427. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34428. /**
  34429. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34430. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34431. */
  34432. static readonly FILTER_POISSONSAMPLING: number;
  34433. /**
  34434. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34436. */
  34437. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34438. /**
  34439. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34440. * edge artifacts on steep falloff.
  34441. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34442. */
  34443. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34444. /**
  34445. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34446. * edge artifacts on steep falloff.
  34447. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34448. */
  34449. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34450. /**
  34451. * Shadow generator mode PCF: Percentage Closer Filtering
  34452. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34453. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34454. */
  34455. static readonly FILTER_PCF: number;
  34456. /**
  34457. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34458. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34459. * Contact Hardening
  34460. */
  34461. static readonly FILTER_PCSS: number;
  34462. /**
  34463. * Reserved for PCF and PCSS
  34464. * Highest Quality.
  34465. *
  34466. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34467. *
  34468. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34469. */
  34470. static readonly QUALITY_HIGH: number;
  34471. /**
  34472. * Reserved for PCF and PCSS
  34473. * Good tradeoff for quality/perf cross devices
  34474. *
  34475. * Execute PCF on a 3*3 kernel.
  34476. *
  34477. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34478. */
  34479. static readonly QUALITY_MEDIUM: number;
  34480. /**
  34481. * Reserved for PCF and PCSS
  34482. * The lowest quality but the fastest.
  34483. *
  34484. * Execute PCF on a 1*1 kernel.
  34485. *
  34486. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34487. */
  34488. static readonly QUALITY_LOW: number;
  34489. private _bias;
  34490. /**
  34491. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34492. */
  34493. /**
  34494. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34495. */
  34496. bias: number;
  34497. private _normalBias;
  34498. /**
  34499. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34500. */
  34501. /**
  34502. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34503. */
  34504. normalBias: number;
  34505. private _blurBoxOffset;
  34506. /**
  34507. * Gets the blur box offset: offset applied during the blur pass.
  34508. * Only usefull if useKernelBlur = false
  34509. */
  34510. /**
  34511. * Sets the blur box offset: offset applied during the blur pass.
  34512. * Only usefull if useKernelBlur = false
  34513. */
  34514. blurBoxOffset: number;
  34515. private _blurScale;
  34516. /**
  34517. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  34518. * 2 means half of the size.
  34519. */
  34520. /**
  34521. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  34522. * 2 means half of the size.
  34523. */
  34524. blurScale: number;
  34525. private _blurKernel;
  34526. /**
  34527. * Gets the blur kernel: kernel size of the blur pass.
  34528. * Only usefull if useKernelBlur = true
  34529. */
  34530. /**
  34531. * Sets the blur kernel: kernel size of the blur pass.
  34532. * Only usefull if useKernelBlur = true
  34533. */
  34534. blurKernel: number;
  34535. private _useKernelBlur;
  34536. /**
  34537. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  34538. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34539. */
  34540. /**
  34541. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  34542. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34543. */
  34544. useKernelBlur: boolean;
  34545. private _depthScale;
  34546. /**
  34547. * Gets the depth scale used in ESM mode.
  34548. */
  34549. /**
  34550. * Sets the depth scale used in ESM mode.
  34551. * This can override the scale stored on the light.
  34552. */
  34553. depthScale: number;
  34554. private _filter;
  34555. /**
  34556. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  34557. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34558. */
  34559. /**
  34560. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  34561. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34562. */
  34563. filter: number;
  34564. /**
  34565. * Gets if the current filter is set to Poisson Sampling.
  34566. */
  34567. /**
  34568. * Sets the current filter to Poisson Sampling.
  34569. */
  34570. usePoissonSampling: boolean;
  34571. /**
  34572. * Gets if the current filter is set to VSM.
  34573. * DEPRECATED. Should use useExponentialShadowMap instead.
  34574. */
  34575. /**
  34576. * Sets the current filter is to VSM.
  34577. * DEPRECATED. Should use useExponentialShadowMap instead.
  34578. */
  34579. useVarianceShadowMap: boolean;
  34580. /**
  34581. * Gets if the current filter is set to blurred VSM.
  34582. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34583. */
  34584. /**
  34585. * Sets the current filter is to blurred VSM.
  34586. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34587. */
  34588. useBlurVarianceShadowMap: boolean;
  34589. /**
  34590. * Gets if the current filter is set to ESM.
  34591. */
  34592. /**
  34593. * Sets the current filter is to ESM.
  34594. */
  34595. useExponentialShadowMap: boolean;
  34596. /**
  34597. * Gets if the current filter is set to filtered ESM.
  34598. */
  34599. /**
  34600. * Gets if the current filter is set to filtered ESM.
  34601. */
  34602. useBlurExponentialShadowMap: boolean;
  34603. /**
  34604. * Gets if the current filter is set to "close ESM" (using the inverse of the
  34605. * exponential to prevent steep falloff artifacts).
  34606. */
  34607. /**
  34608. * Sets the current filter to "close ESM" (using the inverse of the
  34609. * exponential to prevent steep falloff artifacts).
  34610. */
  34611. useCloseExponentialShadowMap: boolean;
  34612. /**
  34613. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  34614. * exponential to prevent steep falloff artifacts).
  34615. */
  34616. /**
  34617. * Sets the current filter to filtered "close ESM" (using the inverse of the
  34618. * exponential to prevent steep falloff artifacts).
  34619. */
  34620. useBlurCloseExponentialShadowMap: boolean;
  34621. /**
  34622. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  34623. */
  34624. /**
  34625. * Sets the current filter to "PCF" (percentage closer filtering).
  34626. */
  34627. usePercentageCloserFiltering: boolean;
  34628. private _filteringQuality;
  34629. /**
  34630. * Gets the PCF or PCSS Quality.
  34631. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34632. */
  34633. /**
  34634. * Sets the PCF or PCSS Quality.
  34635. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34636. */
  34637. filteringQuality: number;
  34638. /**
  34639. * Gets if the current filter is set to "PCSS" (contact hardening).
  34640. */
  34641. /**
  34642. * Sets the current filter to "PCSS" (contact hardening).
  34643. */
  34644. useContactHardeningShadow: boolean;
  34645. private _contactHardeningLightSizeUVRatio;
  34646. /**
  34647. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34648. * Using a ratio helps keeping shape stability independently of the map size.
  34649. *
  34650. * It does not account for the light projection as it was having too much
  34651. * instability during the light setup or during light position changes.
  34652. *
  34653. * Only valid if useContactHardeningShadow is true.
  34654. */
  34655. /**
  34656. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34657. * Using a ratio helps keeping shape stability independently of the map size.
  34658. *
  34659. * It does not account for the light projection as it was having too much
  34660. * instability during the light setup or during light position changes.
  34661. *
  34662. * Only valid if useContactHardeningShadow is true.
  34663. */
  34664. contactHardeningLightSizeUVRatio: number;
  34665. private _darkness;
  34666. /**
  34667. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34668. * 0 means strongest and 1 would means no shadow.
  34669. * @returns the darkness.
  34670. */
  34671. getDarkness(): number;
  34672. /**
  34673. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34674. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34675. * @returns the shadow generator allowing fluent coding.
  34676. */
  34677. setDarkness(darkness: number): ShadowGenerator;
  34678. private _transparencyShadow;
  34679. /**
  34680. * Sets the ability to have transparent shadow (boolean).
  34681. * @param transparent True if transparent else False
  34682. * @returns the shadow generator allowing fluent coding
  34683. */
  34684. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  34685. private _shadowMap;
  34686. private _shadowMap2;
  34687. /**
  34688. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34689. * @returns The render target texture if present otherwise, null
  34690. */
  34691. getShadowMap(): Nullable<RenderTargetTexture>;
  34692. /**
  34693. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34694. * @returns The render target texture if the shadow map is present otherwise, null
  34695. */
  34696. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34697. /**
  34698. * Helper function to add a mesh and its descendants to the list of shadow casters.
  34699. * @param mesh Mesh to add
  34700. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  34701. * @returns the Shadow Generator itself
  34702. */
  34703. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34704. /**
  34705. * Helper function to remove a mesh and its descendants from the list of shadow casters
  34706. * @param mesh Mesh to remove
  34707. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  34708. * @returns the Shadow Generator itself
  34709. */
  34710. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34711. /**
  34712. * Controls the extent to which the shadows fade out at the edge of the frustum
  34713. * Used only by directionals and spots
  34714. */
  34715. frustumEdgeFalloff: number;
  34716. private _light;
  34717. /**
  34718. * Returns the associated light object.
  34719. * @returns the light generating the shadow
  34720. */
  34721. getLight(): IShadowLight;
  34722. /**
  34723. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  34724. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  34725. * It might on the other hand introduce peter panning.
  34726. */
  34727. forceBackFacesOnly: boolean;
  34728. private _scene;
  34729. private _lightDirection;
  34730. private _effect;
  34731. private _viewMatrix;
  34732. private _projectionMatrix;
  34733. private _transformMatrix;
  34734. private _cachedPosition;
  34735. private _cachedDirection;
  34736. private _cachedDefines;
  34737. private _currentRenderID;
  34738. private _boxBlurPostprocess;
  34739. private _kernelBlurXPostprocess;
  34740. private _kernelBlurYPostprocess;
  34741. private _blurPostProcesses;
  34742. private _mapSize;
  34743. private _currentFaceIndex;
  34744. private _currentFaceIndexCache;
  34745. private _textureType;
  34746. private _defaultTextureMatrix;
  34747. /**
  34748. * Creates a ShadowGenerator object.
  34749. * A ShadowGenerator is the required tool to use the shadows.
  34750. * Each light casting shadows needs to use its own ShadowGenerator.
  34751. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  34752. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  34753. * @param light The light object generating the shadows.
  34754. * @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.
  34755. */
  34756. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  34757. private _initializeGenerator;
  34758. private _initializeShadowMap;
  34759. private _initializeBlurRTTAndPostProcesses;
  34760. private _renderForShadowMap;
  34761. private _renderSubMeshForShadowMap;
  34762. private _applyFilterValues;
  34763. /**
  34764. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34765. * @param onCompiled Callback triggered at the and of the effects compilation
  34766. * @param options Sets of optional options forcing the compilation with different modes
  34767. */
  34768. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34769. useInstances: boolean;
  34770. }>): void;
  34771. /**
  34772. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34773. * @param options Sets of optional options forcing the compilation with different modes
  34774. * @returns A promise that resolves when the compilation completes
  34775. */
  34776. forceCompilationAsync(options?: Partial<{
  34777. useInstances: boolean;
  34778. }>): Promise<void>;
  34779. /**
  34780. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34781. * @param subMesh The submesh we want to render in the shadow map
  34782. * @param useInstances Defines wether will draw in the map using instances
  34783. * @returns true if ready otherwise, false
  34784. */
  34785. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34786. /**
  34787. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34788. * @param defines Defines of the material we want to update
  34789. * @param lightIndex Index of the light in the enabled light list of the material
  34790. */
  34791. prepareDefines(defines: any, lightIndex: number): void;
  34792. /**
  34793. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34794. * defined in the generator but impacting the effect).
  34795. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34796. * @param effect The effect we are binfing the information for
  34797. */
  34798. bindShadowLight(lightIndex: string, effect: Effect): void;
  34799. /**
  34800. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34801. * (eq to shadow prjection matrix * light transform matrix)
  34802. * @returns The transform matrix used to create the shadow map
  34803. */
  34804. getTransformMatrix(): Matrix;
  34805. /**
  34806. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34807. * Cube and 2D textures for instance.
  34808. */
  34809. recreateShadowMap(): void;
  34810. private _disposeBlurPostProcesses;
  34811. private _disposeRTTandPostProcesses;
  34812. /**
  34813. * Disposes the ShadowGenerator.
  34814. * Returns nothing.
  34815. */
  34816. dispose(): void;
  34817. /**
  34818. * Serializes the shadow generator setup to a json object.
  34819. * @returns The serialized JSON object
  34820. */
  34821. serialize(): any;
  34822. /**
  34823. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  34824. * @param parsedShadowGenerator The JSON object to parse
  34825. * @param scene The scene to create the shadow map for
  34826. * @returns The parsed shadow generator
  34827. */
  34828. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  34829. }
  34830. }
  34831. declare module BABYLON {
  34832. }
  34833. declare module BABYLON {
  34834. /**
  34835. * Background material used to create an efficient environement around your scene.
  34836. */
  34837. class BackgroundMaterial extends PushMaterial {
  34838. /**
  34839. * Standard reflectance value at parallel view angle.
  34840. */
  34841. static StandardReflectance0: number;
  34842. /**
  34843. * Standard reflectance value at grazing angle.
  34844. */
  34845. static StandardReflectance90: number;
  34846. protected _primaryColor: Color3;
  34847. /**
  34848. * Key light Color (multiply against the environement texture)
  34849. */
  34850. primaryColor: Color3;
  34851. protected __perceptualColor: Nullable<Color3>;
  34852. /**
  34853. * Experimental Internal Use Only.
  34854. *
  34855. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  34856. * This acts as a helper to set the primary color to a more "human friendly" value.
  34857. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  34858. * output color as close as possible from the chosen value.
  34859. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  34860. * part of lighting setup.)
  34861. */
  34862. _perceptualColor: Nullable<Color3>;
  34863. protected _primaryColorShadowLevel: float;
  34864. /**
  34865. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  34866. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  34867. */
  34868. primaryColorShadowLevel: float;
  34869. protected _primaryColorHighlightLevel: float;
  34870. /**
  34871. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  34872. * The primary color is used at the level chosen to define what the white area would look.
  34873. */
  34874. primaryColorHighlightLevel: float;
  34875. protected _reflectionTexture: Nullable<BaseTexture>;
  34876. /**
  34877. * Reflection Texture used in the material.
  34878. * Should be author in a specific way for the best result (refer to the documentation).
  34879. */
  34880. reflectionTexture: Nullable<BaseTexture>;
  34881. protected _reflectionBlur: float;
  34882. /**
  34883. * Reflection Texture level of blur.
  34884. *
  34885. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  34886. * texture twice.
  34887. */
  34888. reflectionBlur: float;
  34889. protected _diffuseTexture: Nullable<BaseTexture>;
  34890. /**
  34891. * Diffuse Texture used in the material.
  34892. * Should be author in a specific way for the best result (refer to the documentation).
  34893. */
  34894. diffuseTexture: Nullable<BaseTexture>;
  34895. protected _shadowLights: Nullable<IShadowLight[]>;
  34896. /**
  34897. * Specify the list of lights casting shadow on the material.
  34898. * All scene shadow lights will be included if null.
  34899. */
  34900. shadowLights: Nullable<IShadowLight[]>;
  34901. protected _shadowLevel: float;
  34902. /**
  34903. * Helps adjusting the shadow to a softer level if required.
  34904. * 0 means black shadows and 1 means no shadows.
  34905. */
  34906. shadowLevel: float;
  34907. protected _sceneCenter: Vector3;
  34908. /**
  34909. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  34910. * It is usually zero but might be interesting to modify according to your setup.
  34911. */
  34912. sceneCenter: Vector3;
  34913. protected _opacityFresnel: boolean;
  34914. /**
  34915. * This helps specifying that the material is falling off to the sky box at grazing angle.
  34916. * This helps ensuring a nice transition when the camera goes under the ground.
  34917. */
  34918. opacityFresnel: boolean;
  34919. protected _reflectionFresnel: boolean;
  34920. /**
  34921. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  34922. * This helps adding a mirror texture on the ground.
  34923. */
  34924. reflectionFresnel: boolean;
  34925. protected _reflectionFalloffDistance: number;
  34926. /**
  34927. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  34928. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  34929. */
  34930. reflectionFalloffDistance: number;
  34931. protected _reflectionAmount: number;
  34932. /**
  34933. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  34934. */
  34935. reflectionAmount: number;
  34936. protected _reflectionReflectance0: number;
  34937. /**
  34938. * This specifies the weight of the reflection at grazing angle.
  34939. */
  34940. reflectionReflectance0: number;
  34941. protected _reflectionReflectance90: number;
  34942. /**
  34943. * This specifies the weight of the reflection at a perpendicular point of view.
  34944. */
  34945. reflectionReflectance90: number;
  34946. /**
  34947. * Sets the reflection reflectance fresnel values according to the default standard
  34948. * empirically know to work well :-)
  34949. */
  34950. reflectionStandardFresnelWeight: number;
  34951. protected _useRGBColor: boolean;
  34952. /**
  34953. * Helps to directly use the maps channels instead of their level.
  34954. */
  34955. useRGBColor: boolean;
  34956. protected _enableNoise: boolean;
  34957. /**
  34958. * This helps reducing the banding effect that could occur on the background.
  34959. */
  34960. enableNoise: boolean;
  34961. /**
  34962. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  34963. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  34964. * Recommended to be keep at 1.0 except for special cases.
  34965. */
  34966. fovMultiplier: number;
  34967. private _fovMultiplier;
  34968. /**
  34969. * Enable the FOV adjustment feature controlled by fovMultiplier.
  34970. */
  34971. useEquirectangularFOV: boolean;
  34972. private _maxSimultaneousLights;
  34973. /**
  34974. * Number of Simultaneous lights allowed on the material.
  34975. */
  34976. maxSimultaneousLights: int;
  34977. /**
  34978. * Default configuration related to image processing available in the Background Material.
  34979. */
  34980. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34981. /**
  34982. * Keep track of the image processing observer to allow dispose and replace.
  34983. */
  34984. private _imageProcessingObserver;
  34985. /**
  34986. * Attaches a new image processing configuration to the PBR Material.
  34987. * @param configuration (if null the scene configuration will be use)
  34988. */
  34989. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34990. /**
  34991. * Gets the image processing configuration used either in this material.
  34992. */
  34993. /**
  34994. * Sets the Default image processing configuration used either in the this material.
  34995. *
  34996. * If sets to null, the scene one is in use.
  34997. */
  34998. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  34999. /**
  35000. * Gets wether the color curves effect is enabled.
  35001. */
  35002. /**
  35003. * Sets wether the color curves effect is enabled.
  35004. */
  35005. cameraColorCurvesEnabled: boolean;
  35006. /**
  35007. * Gets wether the color grading effect is enabled.
  35008. */
  35009. /**
  35010. * Gets wether the color grading effect is enabled.
  35011. */
  35012. cameraColorGradingEnabled: boolean;
  35013. /**
  35014. * Gets wether tonemapping is enabled or not.
  35015. */
  35016. /**
  35017. * Sets wether tonemapping is enabled or not
  35018. */
  35019. cameraToneMappingEnabled: boolean;
  35020. /**
  35021. * The camera exposure used on this material.
  35022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35023. * This corresponds to a photographic exposure.
  35024. */
  35025. /**
  35026. * The camera exposure used on this material.
  35027. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35028. * This corresponds to a photographic exposure.
  35029. */
  35030. cameraExposure: float;
  35031. /**
  35032. * Gets The camera contrast used on this material.
  35033. */
  35034. /**
  35035. * Sets The camera contrast used on this material.
  35036. */
  35037. cameraContrast: float;
  35038. /**
  35039. * Gets the Color Grading 2D Lookup Texture.
  35040. */
  35041. /**
  35042. * Sets the Color Grading 2D Lookup Texture.
  35043. */
  35044. cameraColorGradingTexture: Nullable<BaseTexture>;
  35045. /**
  35046. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35047. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35048. * 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;
  35049. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35050. */
  35051. /**
  35052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35054. * 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;
  35055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35056. */
  35057. cameraColorCurves: Nullable<ColorCurves>;
  35058. /**
  35059. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  35060. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  35061. */
  35062. switchToBGR: boolean;
  35063. private _renderTargets;
  35064. private _reflectionControls;
  35065. private _white;
  35066. private _primaryShadowColor;
  35067. private _primaryHighlightColor;
  35068. /**
  35069. * Instantiates a Background Material in the given scene
  35070. * @param name The friendly name of the material
  35071. * @param scene The scene to add the material to
  35072. */
  35073. constructor(name: string, scene: Scene);
  35074. /**
  35075. * The entire material has been created in order to prevent overdraw.
  35076. * @returns false
  35077. */
  35078. needAlphaTesting(): boolean;
  35079. /**
  35080. * The entire material has been created in order to prevent overdraw.
  35081. * @returns true if blending is enable
  35082. */
  35083. needAlphaBlending(): boolean;
  35084. /**
  35085. * Checks wether the material is ready to be rendered for a given mesh.
  35086. * @param mesh The mesh to render
  35087. * @param subMesh The submesh to check against
  35088. * @param useInstances Specify wether or not the material is used with instances
  35089. * @returns true if all the dependencies are ready (Textures, Effects...)
  35090. */
  35091. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35092. /**
  35093. * Compute the primary color according to the chosen perceptual color.
  35094. */
  35095. private _computePrimaryColorFromPerceptualColor;
  35096. /**
  35097. * Compute the highlights and shadow colors according to their chosen levels.
  35098. */
  35099. private _computePrimaryColors;
  35100. /**
  35101. * Build the uniform buffer used in the material.
  35102. */
  35103. buildUniformLayout(): void;
  35104. /**
  35105. * Unbind the material.
  35106. */
  35107. unbind(): void;
  35108. /**
  35109. * Bind only the world matrix to the material.
  35110. * @param world The world matrix to bind.
  35111. */
  35112. bindOnlyWorldMatrix(world: Matrix): void;
  35113. /**
  35114. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  35115. * @param world The world matrix to bind.
  35116. * @param subMesh The submesh to bind for.
  35117. */
  35118. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35119. /**
  35120. * Dispose the material.
  35121. * @param forceDisposeEffect Force disposal of the associated effect.
  35122. * @param forceDisposeTextures Force disposal of the associated textures.
  35123. */
  35124. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35125. /**
  35126. * Clones the material.
  35127. * @param name The cloned name.
  35128. * @returns The cloned material.
  35129. */
  35130. clone(name: string): BackgroundMaterial;
  35131. /**
  35132. * Serializes the current material to its JSON representation.
  35133. * @returns The JSON representation.
  35134. */
  35135. serialize(): any;
  35136. /**
  35137. * Gets the class name of the material
  35138. * @returns "BackgroundMaterial"
  35139. */
  35140. getClassName(): string;
  35141. /**
  35142. * Parse a JSON input to create back a background material.
  35143. * @param source The JSON data to parse
  35144. * @param scene The scene to create the parsed material in
  35145. * @param rootUrl The root url of the assets the material depends upon
  35146. * @returns the instantiated BackgroundMaterial.
  35147. */
  35148. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  35149. }
  35150. }
  35151. declare module BABYLON {
  35152. /**
  35153. * The Physically based material base class of BJS.
  35154. *
  35155. * This offers the main features of a standard PBR material.
  35156. * For more information, please refer to the documentation :
  35157. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35158. */
  35159. abstract class PBRBaseMaterial extends PushMaterial {
  35160. /**
  35161. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  35162. */
  35163. static readonly LIGHTFALLOFF_PHYSICAL: number;
  35164. /**
  35165. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  35166. * to enhance interoperability with other engines.
  35167. */
  35168. static readonly LIGHTFALLOFF_GLTF: number;
  35169. /**
  35170. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  35171. * to enhance interoperability with other materials.
  35172. */
  35173. static readonly LIGHTFALLOFF_STANDARD: number;
  35174. /**
  35175. * Intensity of the direct lights e.g. the four lights available in your scene.
  35176. * This impacts both the direct diffuse and specular highlights.
  35177. */
  35178. protected _directIntensity: number;
  35179. /**
  35180. * Intensity of the emissive part of the material.
  35181. * This helps controlling the emissive effect without modifying the emissive color.
  35182. */
  35183. protected _emissiveIntensity: number;
  35184. /**
  35185. * Intensity of the environment e.g. how much the environment will light the object
  35186. * either through harmonics for rough material or through the refelction for shiny ones.
  35187. */
  35188. protected _environmentIntensity: number;
  35189. /**
  35190. * This is a special control allowing the reduction of the specular highlights coming from the
  35191. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35192. */
  35193. protected _specularIntensity: number;
  35194. /**
  35195. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  35196. */
  35197. private _lightingInfos;
  35198. /**
  35199. * Debug Control allowing disabling the bump map on this material.
  35200. */
  35201. protected _disableBumpMap: boolean;
  35202. /**
  35203. * AKA Diffuse Texture in standard nomenclature.
  35204. */
  35205. protected _albedoTexture: BaseTexture;
  35206. /**
  35207. * AKA Occlusion Texture in other nomenclature.
  35208. */
  35209. protected _ambientTexture: BaseTexture;
  35210. /**
  35211. * AKA Occlusion Texture Intensity in other nomenclature.
  35212. */
  35213. protected _ambientTextureStrength: number;
  35214. /**
  35215. * Defines how much the AO map is occluding the analytical lights (point spot...).
  35216. * 1 means it completely occludes it
  35217. * 0 mean it has no impact
  35218. */
  35219. protected _ambientTextureImpactOnAnalyticalLights: number;
  35220. /**
  35221. * Stores the alpha values in a texture.
  35222. */
  35223. protected _opacityTexture: BaseTexture;
  35224. /**
  35225. * Stores the reflection values in a texture.
  35226. */
  35227. protected _reflectionTexture: BaseTexture;
  35228. /**
  35229. * Stores the refraction values in a texture.
  35230. */
  35231. protected _refractionTexture: BaseTexture;
  35232. /**
  35233. * Stores the emissive values in a texture.
  35234. */
  35235. protected _emissiveTexture: BaseTexture;
  35236. /**
  35237. * AKA Specular texture in other nomenclature.
  35238. */
  35239. protected _reflectivityTexture: BaseTexture;
  35240. /**
  35241. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35242. */
  35243. protected _metallicTexture: BaseTexture;
  35244. /**
  35245. * Specifies the metallic scalar of the metallic/roughness workflow.
  35246. * Can also be used to scale the metalness values of the metallic texture.
  35247. */
  35248. protected _metallic: Nullable<number>;
  35249. /**
  35250. * Specifies the roughness scalar of the metallic/roughness workflow.
  35251. * Can also be used to scale the roughness values of the metallic texture.
  35252. */
  35253. protected _roughness: Nullable<number>;
  35254. /**
  35255. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35256. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35257. */
  35258. protected _microSurfaceTexture: BaseTexture;
  35259. /**
  35260. * Stores surface normal data used to displace a mesh in a texture.
  35261. */
  35262. protected _bumpTexture: BaseTexture;
  35263. /**
  35264. * Stores the pre-calculated light information of a mesh in a texture.
  35265. */
  35266. protected _lightmapTexture: BaseTexture;
  35267. /**
  35268. * The color of a material in ambient lighting.
  35269. */
  35270. protected _ambientColor: Color3;
  35271. /**
  35272. * AKA Diffuse Color in other nomenclature.
  35273. */
  35274. protected _albedoColor: Color3;
  35275. /**
  35276. * AKA Specular Color in other nomenclature.
  35277. */
  35278. protected _reflectivityColor: Color3;
  35279. /**
  35280. * The color applied when light is reflected from a material.
  35281. */
  35282. protected _reflectionColor: Color3;
  35283. /**
  35284. * The color applied when light is emitted from a material.
  35285. */
  35286. protected _emissiveColor: Color3;
  35287. /**
  35288. * AKA Glossiness in other nomenclature.
  35289. */
  35290. protected _microSurface: number;
  35291. /**
  35292. * source material index of refraction (IOR)' / 'destination material IOR.
  35293. */
  35294. protected _indexOfRefraction: number;
  35295. /**
  35296. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35297. */
  35298. protected _invertRefractionY: boolean;
  35299. /**
  35300. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35301. * Materials half opaque for instance using refraction could benefit from this control.
  35302. */
  35303. protected _linkRefractionWithTransparency: boolean;
  35304. /**
  35305. * Specifies that the material will use the light map as a show map.
  35306. */
  35307. protected _useLightmapAsShadowmap: boolean;
  35308. /**
  35309. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35310. * makes the reflect vector face the model (under horizon).
  35311. */
  35312. protected _useHorizonOcclusion: boolean;
  35313. /**
  35314. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35315. * too much the area relying on ambient texture to define their ambient occlusion.
  35316. */
  35317. protected _useRadianceOcclusion: boolean;
  35318. /**
  35319. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35320. */
  35321. protected _useAlphaFromAlbedoTexture: boolean;
  35322. /**
  35323. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35324. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35325. */
  35326. protected _useSpecularOverAlpha: boolean;
  35327. /**
  35328. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35329. */
  35330. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35331. /**
  35332. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35333. */
  35334. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  35335. /**
  35336. * Specifies if the metallic texture contains the roughness information in its green channel.
  35337. */
  35338. protected _useRoughnessFromMetallicTextureGreen: boolean;
  35339. /**
  35340. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35341. */
  35342. protected _useMetallnessFromMetallicTextureBlue: boolean;
  35343. /**
  35344. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35345. */
  35346. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  35347. /**
  35348. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35349. */
  35350. protected _useAmbientInGrayScale: boolean;
  35351. /**
  35352. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35353. * The material will try to infer what glossiness each pixel should be.
  35354. */
  35355. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  35356. /**
  35357. * Defines the falloff type used in this material.
  35358. * It by default is Physical.
  35359. */
  35360. protected _lightFalloff: number;
  35361. /**
  35362. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35363. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35364. */
  35365. protected _useRadianceOverAlpha: boolean;
  35366. /**
  35367. * Allows using an object space normal map (instead of tangent space).
  35368. */
  35369. protected _useObjectSpaceNormalMap: boolean;
  35370. /**
  35371. * Allows using the bump map in parallax mode.
  35372. */
  35373. protected _useParallax: boolean;
  35374. /**
  35375. * Allows using the bump map in parallax occlusion mode.
  35376. */
  35377. protected _useParallaxOcclusion: boolean;
  35378. /**
  35379. * Controls the scale bias of the parallax mode.
  35380. */
  35381. protected _parallaxScaleBias: number;
  35382. /**
  35383. * If sets to true, disables all the lights affecting the material.
  35384. */
  35385. protected _disableLighting: boolean;
  35386. /**
  35387. * Number of Simultaneous lights allowed on the material.
  35388. */
  35389. protected _maxSimultaneousLights: number;
  35390. /**
  35391. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  35392. */
  35393. protected _invertNormalMapX: boolean;
  35394. /**
  35395. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  35396. */
  35397. protected _invertNormalMapY: boolean;
  35398. /**
  35399. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35400. */
  35401. protected _twoSidedLighting: boolean;
  35402. /**
  35403. * Defines the alpha limits in alpha test mode.
  35404. */
  35405. protected _alphaCutOff: number;
  35406. /**
  35407. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35408. */
  35409. protected _forceAlphaTest: boolean;
  35410. /**
  35411. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35412. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35413. */
  35414. protected _useAlphaFresnel: boolean;
  35415. /**
  35416. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35417. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35418. */
  35419. protected _useLinearAlphaFresnel: boolean;
  35420. /**
  35421. * The transparency mode of the material.
  35422. */
  35423. protected _transparencyMode: Nullable<number>;
  35424. /**
  35425. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  35426. * from cos thetav and roughness:
  35427. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  35428. */
  35429. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  35430. /**
  35431. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35432. */
  35433. protected _forceIrradianceInFragment: boolean;
  35434. /**
  35435. * Force normal to face away from face.
  35436. */
  35437. protected _forceNormalForward: boolean;
  35438. /**
  35439. * Enables specular anti aliasing in the PBR shader.
  35440. * It will both interacts on the Geometry for analytical and IBL lighting.
  35441. * It also prefilter the roughness map based on the bump values.
  35442. */
  35443. protected _enableSpecularAntiAliasing: boolean;
  35444. /**
  35445. * Default configuration related to image processing available in the PBR Material.
  35446. */
  35447. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35448. /**
  35449. * Keep track of the image processing observer to allow dispose and replace.
  35450. */
  35451. private _imageProcessingObserver;
  35452. /**
  35453. * Attaches a new image processing configuration to the PBR Material.
  35454. * @param configuration
  35455. */
  35456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35457. /**
  35458. * Stores the available render targets.
  35459. */
  35460. private _renderTargets;
  35461. /**
  35462. * Sets the global ambient color for the material used in lighting calculations.
  35463. */
  35464. private _globalAmbientColor;
  35465. /**
  35466. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  35467. */
  35468. private _useLogarithmicDepth;
  35469. /**
  35470. * If set to true, no lighting calculations will be applied.
  35471. */
  35472. private _unlit;
  35473. /**
  35474. * Instantiates a new PBRMaterial instance.
  35475. *
  35476. * @param name The material name
  35477. * @param scene The scene the material will be use in.
  35478. */
  35479. constructor(name: string, scene: Scene);
  35480. /**
  35481. * Gets the name of the material class.
  35482. */
  35483. getClassName(): string;
  35484. /**
  35485. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35486. */
  35487. /**
  35488. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35489. */
  35490. useLogarithmicDepth: boolean;
  35491. /**
  35492. * Gets the current transparency mode.
  35493. */
  35494. /**
  35495. * Sets the transparency mode of the material.
  35496. *
  35497. * | Value | Type | Description |
  35498. * | ----- | ----------------------------------- | ----------- |
  35499. * | 0 | OPAQUE | |
  35500. * | 1 | ALPHATEST | |
  35501. * | 2 | ALPHABLEND | |
  35502. * | 3 | ALPHATESTANDBLEND | |
  35503. *
  35504. */
  35505. transparencyMode: Nullable<number>;
  35506. /**
  35507. * Returns true if alpha blending should be disabled.
  35508. */
  35509. private readonly _disableAlphaBlending;
  35510. /**
  35511. * Specifies whether or not this material should be rendered in alpha blend mode.
  35512. */
  35513. needAlphaBlending(): boolean;
  35514. /**
  35515. * Specifies if the mesh will require alpha blending.
  35516. * @param mesh - BJS mesh.
  35517. */
  35518. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  35519. /**
  35520. * Specifies whether or not this material should be rendered in alpha test mode.
  35521. */
  35522. needAlphaTesting(): boolean;
  35523. /**
  35524. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  35525. */
  35526. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  35527. /**
  35528. * Gets the texture used for the alpha test.
  35529. */
  35530. getAlphaTestTexture(): BaseTexture;
  35531. /**
  35532. * Stores the reflectivity values based on metallic roughness workflow.
  35533. */
  35534. private static _scaledReflectivity;
  35535. /**
  35536. * Specifies that the submesh is ready to be used.
  35537. * @param mesh - BJS mesh.
  35538. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  35539. * @param useInstances - Specifies that instances should be used.
  35540. * @returns - boolean indicating that the submesh is ready or not.
  35541. */
  35542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35543. /**
  35544. * Specifies if the material uses metallic roughness workflow.
  35545. * @returns boolean specifiying if the material uses metallic roughness workflow.
  35546. */
  35547. isMetallicWorkflow(): boolean;
  35548. private _prepareEffect;
  35549. private _prepareDefines;
  35550. /**
  35551. * Force shader compilation
  35552. */
  35553. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  35554. clipPlane: boolean;
  35555. }>): void;
  35556. /**
  35557. * Initializes the uniform buffer layout for the shader.
  35558. */
  35559. buildUniformLayout(): void;
  35560. /**
  35561. * Unbinds the textures.
  35562. */
  35563. unbind(): void;
  35564. /**
  35565. * Binds the submesh data.
  35566. * @param world - The world matrix.
  35567. * @param mesh - The BJS mesh.
  35568. * @param subMesh - A submesh of the BJS mesh.
  35569. */
  35570. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35571. /**
  35572. * Returns the animatable textures.
  35573. * @returns - Array of animatable textures.
  35574. */
  35575. getAnimatables(): IAnimatable[];
  35576. /**
  35577. * Returns the texture used for reflections.
  35578. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  35579. */
  35580. private _getReflectionTexture;
  35581. /**
  35582. * Returns the texture used for refraction or null if none is used.
  35583. * @returns - Refection texture if present. If no refraction texture and refraction
  35584. * is linked with transparency, returns environment texture. Otherwise, returns null.
  35585. */
  35586. private _getRefractionTexture;
  35587. /**
  35588. * Disposes the resources of the material.
  35589. * @param forceDisposeEffect - Forces the disposal of effects.
  35590. * @param forceDisposeTextures - Forces the disposal of all textures.
  35591. */
  35592. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. /**
  35597. * The Physically based simple base material of BJS.
  35598. *
  35599. * This enables better naming and convention enforcements on top of the pbrMaterial.
  35600. * It is used as the base class for both the specGloss and metalRough conventions.
  35601. */
  35602. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  35603. /**
  35604. * Number of Simultaneous lights allowed on the material.
  35605. */
  35606. maxSimultaneousLights: number;
  35607. /**
  35608. * If sets to true, disables all the lights affecting the material.
  35609. */
  35610. disableLighting: boolean;
  35611. /**
  35612. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  35613. */
  35614. environmentTexture: BaseTexture;
  35615. /**
  35616. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35617. */
  35618. invertNormalMapX: boolean;
  35619. /**
  35620. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35621. */
  35622. invertNormalMapY: boolean;
  35623. /**
  35624. * Normal map used in the model.
  35625. */
  35626. normalTexture: BaseTexture;
  35627. /**
  35628. * Emissivie color used to self-illuminate the model.
  35629. */
  35630. emissiveColor: Color3;
  35631. /**
  35632. * Emissivie texture used to self-illuminate the model.
  35633. */
  35634. emissiveTexture: BaseTexture;
  35635. /**
  35636. * Occlusion Channel Strenght.
  35637. */
  35638. occlusionStrength: number;
  35639. /**
  35640. * Occlusion Texture of the material (adding extra occlusion effects).
  35641. */
  35642. occlusionTexture: BaseTexture;
  35643. /**
  35644. * Defines the alpha limits in alpha test mode.
  35645. */
  35646. alphaCutOff: number;
  35647. /**
  35648. * Gets the current double sided mode.
  35649. */
  35650. /**
  35651. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35652. */
  35653. doubleSided: boolean;
  35654. lightmapTexture: BaseTexture;
  35655. useLightmapAsShadowmap: boolean;
  35656. /**
  35657. * Return the active textures of the material.
  35658. */
  35659. getActiveTextures(): BaseTexture[];
  35660. hasTexture(texture: BaseTexture): boolean;
  35661. /**
  35662. * Instantiates a new PBRMaterial instance.
  35663. *
  35664. * @param name The material name
  35665. * @param scene The scene the material will be use in.
  35666. */
  35667. constructor(name: string, scene: Scene);
  35668. getClassName(): string;
  35669. }
  35670. }
  35671. declare module BABYLON {
  35672. /**
  35673. * The Physically based material of BJS.
  35674. *
  35675. * This offers the main features of a standard PBR material.
  35676. * For more information, please refer to the documentation :
  35677. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35678. */
  35679. class PBRMaterial extends PBRBaseMaterial {
  35680. /**
  35681. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  35682. */
  35683. static readonly PBRMATERIAL_OPAQUE: number;
  35684. /**
  35685. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  35686. */
  35687. static readonly PBRMATERIAL_ALPHATEST: number;
  35688. /**
  35689. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35690. */
  35691. static readonly PBRMATERIAL_ALPHABLEND: number;
  35692. /**
  35693. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35694. * They are also discarded below the alpha cutoff threshold to improve performances.
  35695. */
  35696. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  35697. /**
  35698. * Defines the default value of how much AO map is occluding the analytical lights
  35699. * (point spot...).
  35700. */
  35701. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  35702. /**
  35703. * Intensity of the direct lights e.g. the four lights available in your scene.
  35704. * This impacts both the direct diffuse and specular highlights.
  35705. */
  35706. directIntensity: number;
  35707. /**
  35708. * Intensity of the emissive part of the material.
  35709. * This helps controlling the emissive effect without modifying the emissive color.
  35710. */
  35711. emissiveIntensity: number;
  35712. /**
  35713. * Intensity of the environment e.g. how much the environment will light the object
  35714. * either through harmonics for rough material or through the refelction for shiny ones.
  35715. */
  35716. environmentIntensity: number;
  35717. /**
  35718. * This is a special control allowing the reduction of the specular highlights coming from the
  35719. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35720. */
  35721. specularIntensity: number;
  35722. /**
  35723. * Debug Control allowing disabling the bump map on this material.
  35724. */
  35725. disableBumpMap: boolean;
  35726. /**
  35727. * AKA Diffuse Texture in standard nomenclature.
  35728. */
  35729. albedoTexture: BaseTexture;
  35730. /**
  35731. * AKA Occlusion Texture in other nomenclature.
  35732. */
  35733. ambientTexture: BaseTexture;
  35734. /**
  35735. * AKA Occlusion Texture Intensity in other nomenclature.
  35736. */
  35737. ambientTextureStrength: number;
  35738. /**
  35739. * Defines how much the AO map is occluding the analytical lights (point spot...).
  35740. * 1 means it completely occludes it
  35741. * 0 mean it has no impact
  35742. */
  35743. ambientTextureImpactOnAnalyticalLights: number;
  35744. /**
  35745. * Stores the alpha values in a texture.
  35746. */
  35747. opacityTexture: BaseTexture;
  35748. /**
  35749. * Stores the reflection values in a texture.
  35750. */
  35751. reflectionTexture: Nullable<BaseTexture>;
  35752. /**
  35753. * Stores the emissive values in a texture.
  35754. */
  35755. emissiveTexture: BaseTexture;
  35756. /**
  35757. * AKA Specular texture in other nomenclature.
  35758. */
  35759. reflectivityTexture: BaseTexture;
  35760. /**
  35761. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35762. */
  35763. metallicTexture: BaseTexture;
  35764. /**
  35765. * Specifies the metallic scalar of the metallic/roughness workflow.
  35766. * Can also be used to scale the metalness values of the metallic texture.
  35767. */
  35768. metallic: Nullable<number>;
  35769. /**
  35770. * Specifies the roughness scalar of the metallic/roughness workflow.
  35771. * Can also be used to scale the roughness values of the metallic texture.
  35772. */
  35773. roughness: Nullable<number>;
  35774. /**
  35775. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35776. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35777. */
  35778. microSurfaceTexture: BaseTexture;
  35779. /**
  35780. * Stores surface normal data used to displace a mesh in a texture.
  35781. */
  35782. bumpTexture: BaseTexture;
  35783. /**
  35784. * Stores the pre-calculated light information of a mesh in a texture.
  35785. */
  35786. lightmapTexture: BaseTexture;
  35787. /**
  35788. * Stores the refracted light information in a texture.
  35789. */
  35790. refractionTexture: BaseTexture;
  35791. /**
  35792. * The color of a material in ambient lighting.
  35793. */
  35794. ambientColor: Color3;
  35795. /**
  35796. * AKA Diffuse Color in other nomenclature.
  35797. */
  35798. albedoColor: Color3;
  35799. /**
  35800. * AKA Specular Color in other nomenclature.
  35801. */
  35802. reflectivityColor: Color3;
  35803. /**
  35804. * The color reflected from the material.
  35805. */
  35806. reflectionColor: Color3;
  35807. /**
  35808. * The color emitted from the material.
  35809. */
  35810. emissiveColor: Color3;
  35811. /**
  35812. * AKA Glossiness in other nomenclature.
  35813. */
  35814. microSurface: number;
  35815. /**
  35816. * source material index of refraction (IOR)' / 'destination material IOR.
  35817. */
  35818. indexOfRefraction: number;
  35819. /**
  35820. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35821. */
  35822. invertRefractionY: boolean;
  35823. /**
  35824. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35825. * Materials half opaque for instance using refraction could benefit from this control.
  35826. */
  35827. linkRefractionWithTransparency: boolean;
  35828. useLightmapAsShadowmap: boolean;
  35829. /**
  35830. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35831. */
  35832. useAlphaFromAlbedoTexture: boolean;
  35833. /**
  35834. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35835. */
  35836. forceAlphaTest: boolean;
  35837. /**
  35838. * Defines the alpha limits in alpha test mode.
  35839. */
  35840. alphaCutOff: number;
  35841. /**
  35842. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35843. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35844. */
  35845. useSpecularOverAlpha: boolean;
  35846. /**
  35847. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35848. */
  35849. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35850. /**
  35851. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35852. */
  35853. useRoughnessFromMetallicTextureAlpha: boolean;
  35854. /**
  35855. * Specifies if the metallic texture contains the roughness information in its green channel.
  35856. */
  35857. useRoughnessFromMetallicTextureGreen: boolean;
  35858. /**
  35859. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35860. */
  35861. useMetallnessFromMetallicTextureBlue: boolean;
  35862. /**
  35863. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35864. */
  35865. useAmbientOcclusionFromMetallicTextureRed: boolean;
  35866. /**
  35867. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35868. */
  35869. useAmbientInGrayScale: boolean;
  35870. /**
  35871. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35872. * The material will try to infer what glossiness each pixel should be.
  35873. */
  35874. useAutoMicroSurfaceFromReflectivityMap: boolean;
  35875. /**
  35876. * BJS is using an harcoded light falloff based on a manually sets up range.
  35877. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35878. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35879. */
  35880. /**
  35881. * BJS is using an harcoded light falloff based on a manually sets up range.
  35882. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35883. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35884. */
  35885. usePhysicalLightFalloff: boolean;
  35886. /**
  35887. * In order to support the falloff compatibility with gltf, a special mode has been added
  35888. * to reproduce the gltf light falloff.
  35889. */
  35890. /**
  35891. * In order to support the falloff compatibility with gltf, a special mode has been added
  35892. * to reproduce the gltf light falloff.
  35893. */
  35894. useGLTFLightFalloff: boolean;
  35895. /**
  35896. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35897. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35898. */
  35899. useRadianceOverAlpha: boolean;
  35900. /**
  35901. * Allows using an object space normal map (instead of tangent space).
  35902. */
  35903. useObjectSpaceNormalMap: boolean;
  35904. /**
  35905. * Allows using the bump map in parallax mode.
  35906. */
  35907. useParallax: boolean;
  35908. /**
  35909. * Allows using the bump map in parallax occlusion mode.
  35910. */
  35911. useParallaxOcclusion: boolean;
  35912. /**
  35913. * Controls the scale bias of the parallax mode.
  35914. */
  35915. parallaxScaleBias: number;
  35916. /**
  35917. * If sets to true, disables all the lights affecting the material.
  35918. */
  35919. disableLighting: boolean;
  35920. /**
  35921. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35922. */
  35923. forceIrradianceInFragment: boolean;
  35924. /**
  35925. * Number of Simultaneous lights allowed on the material.
  35926. */
  35927. maxSimultaneousLights: number;
  35928. /**
  35929. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35930. */
  35931. invertNormalMapX: boolean;
  35932. /**
  35933. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35934. */
  35935. invertNormalMapY: boolean;
  35936. /**
  35937. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35938. */
  35939. twoSidedLighting: boolean;
  35940. /**
  35941. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35942. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35943. */
  35944. useAlphaFresnel: boolean;
  35945. /**
  35946. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35947. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35948. */
  35949. useLinearAlphaFresnel: boolean;
  35950. /**
  35951. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35952. * And/Or occlude the blended part.
  35953. */
  35954. environmentBRDFTexture: Nullable<BaseTexture>;
  35955. /**
  35956. * Force normal to face away from face.
  35957. */
  35958. forceNormalForward: boolean;
  35959. /**
  35960. * Enables specular anti aliasing in the PBR shader.
  35961. * It will both interacts on the Geometry for analytical and IBL lighting.
  35962. * It also prefilter the roughness map based on the bump values.
  35963. */
  35964. enableSpecularAntiAliasing: boolean;
  35965. /**
  35966. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35967. * makes the reflect vector face the model (under horizon).
  35968. */
  35969. useHorizonOcclusion: boolean;
  35970. /**
  35971. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35972. * too much the area relying on ambient texture to define their ambient occlusion.
  35973. */
  35974. useRadianceOcclusion: boolean;
  35975. /**
  35976. * If set to true, no lighting calculations will be applied.
  35977. */
  35978. unlit: boolean;
  35979. /**
  35980. * Gets the image processing configuration used either in this material.
  35981. */
  35982. /**
  35983. * Sets the Default image processing configuration used either in the this material.
  35984. *
  35985. * If sets to null, the scene one is in use.
  35986. */
  35987. imageProcessingConfiguration: ImageProcessingConfiguration;
  35988. /**
  35989. * Gets wether the color curves effect is enabled.
  35990. */
  35991. /**
  35992. * Sets wether the color curves effect is enabled.
  35993. */
  35994. cameraColorCurvesEnabled: boolean;
  35995. /**
  35996. * Gets wether the color grading effect is enabled.
  35997. */
  35998. /**
  35999. * Gets wether the color grading effect is enabled.
  36000. */
  36001. cameraColorGradingEnabled: boolean;
  36002. /**
  36003. * Gets wether tonemapping is enabled or not.
  36004. */
  36005. /**
  36006. * Sets wether tonemapping is enabled or not
  36007. */
  36008. cameraToneMappingEnabled: boolean;
  36009. /**
  36010. * The camera exposure used on this material.
  36011. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36012. * This corresponds to a photographic exposure.
  36013. */
  36014. /**
  36015. * The camera exposure used on this material.
  36016. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36017. * This corresponds to a photographic exposure.
  36018. */
  36019. cameraExposure: number;
  36020. /**
  36021. * Gets The camera contrast used on this material.
  36022. */
  36023. /**
  36024. * Sets The camera contrast used on this material.
  36025. */
  36026. cameraContrast: number;
  36027. /**
  36028. * Gets the Color Grading 2D Lookup Texture.
  36029. */
  36030. /**
  36031. * Sets the Color Grading 2D Lookup Texture.
  36032. */
  36033. cameraColorGradingTexture: Nullable<BaseTexture>;
  36034. /**
  36035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36037. * 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;
  36038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36039. */
  36040. /**
  36041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36043. * 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;
  36044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36045. */
  36046. cameraColorCurves: Nullable<ColorCurves>;
  36047. /**
  36048. * Instantiates a new PBRMaterial instance.
  36049. *
  36050. * @param name The material name
  36051. * @param scene The scene the material will be use in.
  36052. */
  36053. constructor(name: string, scene: Scene);
  36054. /**
  36055. * Returns the name of this material class.
  36056. */
  36057. getClassName(): string;
  36058. /**
  36059. * Returns an array of the actively used textures.
  36060. * @returns - Array of BaseTextures
  36061. */
  36062. getActiveTextures(): BaseTexture[];
  36063. /**
  36064. * Checks to see if a texture is used in the material.
  36065. * @param texture - Base texture to use.
  36066. * @returns - Boolean specifying if a texture is used in the material.
  36067. */
  36068. hasTexture(texture: BaseTexture): boolean;
  36069. /**
  36070. * Makes a duplicate of the current material.
  36071. * @param name - name to use for the new material.
  36072. */
  36073. clone(name: string): PBRMaterial;
  36074. /**
  36075. * Serializes this PBR Material.
  36076. * @returns - An object with the serialized material.
  36077. */
  36078. serialize(): any;
  36079. /**
  36080. * Parses a PBR Material from a serialized object.
  36081. * @param source - Serialized object.
  36082. * @param scene - BJS scene instance.
  36083. * @param rootUrl - url for the scene object
  36084. * @returns - PBRMaterial
  36085. */
  36086. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  36087. }
  36088. }
  36089. declare module BABYLON {
  36090. /**
  36091. * The PBR material of BJS following the metal roughness convention.
  36092. *
  36093. * This fits to the PBR convention in the GLTF definition:
  36094. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  36095. */
  36096. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  36097. /**
  36098. * The base color has two different interpretations depending on the value of metalness.
  36099. * When the material is a metal, the base color is the specific measured reflectance value
  36100. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  36101. * of the material.
  36102. */
  36103. baseColor: Color3;
  36104. /**
  36105. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  36106. * well as opacity information in the alpha channel.
  36107. */
  36108. baseTexture: BaseTexture;
  36109. /**
  36110. * Specifies the metallic scalar value of the material.
  36111. * Can also be used to scale the metalness values of the metallic texture.
  36112. */
  36113. metallic: number;
  36114. /**
  36115. * Specifies the roughness scalar value of the material.
  36116. * Can also be used to scale the roughness values of the metallic texture.
  36117. */
  36118. roughness: number;
  36119. /**
  36120. * Texture containing both the metallic value in the B channel and the
  36121. * roughness value in the G channel to keep better precision.
  36122. */
  36123. metallicRoughnessTexture: BaseTexture;
  36124. /**
  36125. * Instantiates a new PBRMetalRoughnessMaterial instance.
  36126. *
  36127. * @param name The material name
  36128. * @param scene The scene the material will be use in.
  36129. */
  36130. constructor(name: string, scene: Scene);
  36131. /**
  36132. * Return the currrent class name of the material.
  36133. */
  36134. getClassName(): string;
  36135. /**
  36136. * Return the active textures of the material.
  36137. */
  36138. getActiveTextures(): BaseTexture[];
  36139. /**
  36140. * Checks to see if a texture is used in the material.
  36141. * @param texture - Base texture to use.
  36142. * @returns - Boolean specifying if a texture is used in the material.
  36143. */
  36144. hasTexture(texture: BaseTexture): boolean;
  36145. /**
  36146. * Makes a duplicate of the current material.
  36147. * @param name - name to use for the new material.
  36148. */
  36149. clone(name: string): PBRMetallicRoughnessMaterial;
  36150. /**
  36151. * Serialize the material to a parsable JSON object.
  36152. */
  36153. serialize(): any;
  36154. /**
  36155. * Parses a JSON object correponding to the serialize function.
  36156. */
  36157. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  36158. }
  36159. }
  36160. declare module BABYLON {
  36161. /**
  36162. * The PBR material of BJS following the specular glossiness convention.
  36163. *
  36164. * This fits to the PBR convention in the GLTF definition:
  36165. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  36166. */
  36167. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  36168. /**
  36169. * Specifies the diffuse color of the material.
  36170. */
  36171. diffuseColor: Color3;
  36172. /**
  36173. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  36174. * channel.
  36175. */
  36176. diffuseTexture: BaseTexture;
  36177. /**
  36178. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  36179. */
  36180. specularColor: Color3;
  36181. /**
  36182. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  36183. */
  36184. glossiness: number;
  36185. /**
  36186. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  36187. */
  36188. specularGlossinessTexture: BaseTexture;
  36189. /**
  36190. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  36191. *
  36192. * @param name The material name
  36193. * @param scene The scene the material will be use in.
  36194. */
  36195. constructor(name: string, scene: Scene);
  36196. /**
  36197. * Return the currrent class name of the material.
  36198. */
  36199. getClassName(): string;
  36200. /**
  36201. * Return the active textures of the material.
  36202. */
  36203. getActiveTextures(): BaseTexture[];
  36204. /**
  36205. * Checks to see if a texture is used in the material.
  36206. * @param texture - Base texture to use.
  36207. * @returns - Boolean specifying if a texture is used in the material.
  36208. */
  36209. hasTexture(texture: BaseTexture): boolean;
  36210. /**
  36211. * Makes a duplicate of the current material.
  36212. * @param name - name to use for the new material.
  36213. */
  36214. clone(name: string): PBRSpecularGlossinessMaterial;
  36215. /**
  36216. * Serialize the material to a parsable JSON object.
  36217. */
  36218. serialize(): any;
  36219. /**
  36220. * Parses a JSON object correponding to the serialize function.
  36221. */
  36222. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  36223. }
  36224. }
  36225. declare module BABYLON {
  36226. class BaseTexture {
  36227. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36228. name: string;
  36229. private _hasAlpha;
  36230. hasAlpha: boolean;
  36231. getAlphaFromRGB: boolean;
  36232. level: number;
  36233. coordinatesIndex: number;
  36234. private _coordinatesMode;
  36235. /**
  36236. * How a texture is mapped.
  36237. *
  36238. * | Value | Type | Description |
  36239. * | ----- | ----------------------------------- | ----------- |
  36240. * | 0 | EXPLICIT_MODE | |
  36241. * | 1 | SPHERICAL_MODE | |
  36242. * | 2 | PLANAR_MODE | |
  36243. * | 3 | CUBIC_MODE | |
  36244. * | 4 | PROJECTION_MODE | |
  36245. * | 5 | SKYBOX_MODE | |
  36246. * | 6 | INVCUBIC_MODE | |
  36247. * | 7 | EQUIRECTANGULAR_MODE | |
  36248. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  36249. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  36250. */
  36251. coordinatesMode: number;
  36252. /**
  36253. * | Value | Type | Description |
  36254. * | ----- | ------------------ | ----------- |
  36255. * | 0 | CLAMP_ADDRESSMODE | |
  36256. * | 1 | WRAP_ADDRESSMODE | |
  36257. * | 2 | MIRROR_ADDRESSMODE | |
  36258. */
  36259. wrapU: number;
  36260. /**
  36261. * | Value | Type | Description |
  36262. * | ----- | ------------------ | ----------- |
  36263. * | 0 | CLAMP_ADDRESSMODE | |
  36264. * | 1 | WRAP_ADDRESSMODE | |
  36265. * | 2 | MIRROR_ADDRESSMODE | |
  36266. */
  36267. wrapV: number;
  36268. /**
  36269. * | Value | Type | Description |
  36270. * | ----- | ------------------ | ----------- |
  36271. * | 0 | CLAMP_ADDRESSMODE | |
  36272. * | 1 | WRAP_ADDRESSMODE | |
  36273. * | 2 | MIRROR_ADDRESSMODE | |
  36274. */
  36275. wrapR: number;
  36276. anisotropicFilteringLevel: number;
  36277. isCube: boolean;
  36278. is3D: boolean;
  36279. gammaSpace: boolean;
  36280. /**
  36281. * Gets whether or not the texture contains RGBD data.
  36282. */
  36283. readonly isRGBD: boolean;
  36284. invertZ: boolean;
  36285. lodLevelInAlpha: boolean;
  36286. lodGenerationOffset: number;
  36287. lodGenerationScale: number;
  36288. isRenderTarget: boolean;
  36289. readonly uid: string;
  36290. toString(): string;
  36291. getClassName(): string;
  36292. animations: Animation[];
  36293. /**
  36294. * An event triggered when the texture is disposed.
  36295. */
  36296. onDisposeObservable: Observable<BaseTexture>;
  36297. private _onDisposeObserver;
  36298. onDispose: () => void;
  36299. delayLoadState: number;
  36300. private _scene;
  36301. /** @hidden */
  36302. _texture: Nullable<InternalTexture>;
  36303. private _uid;
  36304. readonly isBlocking: boolean;
  36305. constructor(scene: Nullable<Scene>);
  36306. getScene(): Nullable<Scene>;
  36307. getTextureMatrix(): Matrix;
  36308. getReflectionTextureMatrix(): Matrix;
  36309. getInternalTexture(): Nullable<InternalTexture>;
  36310. isReadyOrNotBlocking(): boolean;
  36311. isReady(): boolean;
  36312. private _cachedSize;
  36313. getSize(): ISize;
  36314. getBaseSize(): ISize;
  36315. scale(ratio: number): void;
  36316. readonly canRescale: boolean;
  36317. /** @hidden */
  36318. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  36319. /** @hidden */
  36320. _rebuild(): void;
  36321. delayLoad(): void;
  36322. clone(): Nullable<BaseTexture>;
  36323. readonly textureType: number;
  36324. readonly textureFormat: number;
  36325. /**
  36326. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  36327. * This will returns an RGBA array buffer containing either in values (0-255) or
  36328. * float values (0-1) depending of the underlying buffer type.
  36329. * @param faceIndex The face of the texture to read (in case of cube texture)
  36330. * @param level The LOD level of the texture to read (in case of Mip Maps)
  36331. * @returns The Array buffer containing the pixels data.
  36332. */
  36333. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  36334. releaseInternalTexture(): void;
  36335. sphericalPolynomial: Nullable<SphericalPolynomial>;
  36336. readonly _lodTextureHigh: Nullable<BaseTexture>;
  36337. readonly _lodTextureMid: Nullable<BaseTexture>;
  36338. readonly _lodTextureLow: Nullable<BaseTexture>;
  36339. dispose(): void;
  36340. serialize(): any;
  36341. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  36342. }
  36343. }
  36344. declare module BABYLON {
  36345. /**
  36346. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  36347. * It can help converting any input color in a desired output one. This can then be used to create effects
  36348. * from sepia, black and white to sixties or futuristic rendering...
  36349. *
  36350. * The only supported format is currently 3dl.
  36351. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  36352. */
  36353. class ColorGradingTexture extends BaseTexture {
  36354. /**
  36355. * The current texture matrix. (will always be identity in color grading texture)
  36356. */
  36357. private _textureMatrix;
  36358. /**
  36359. * The texture URL.
  36360. */
  36361. url: string;
  36362. /**
  36363. * Empty line regex stored for GC.
  36364. */
  36365. private static _noneEmptyLineRegex;
  36366. private _engine;
  36367. /**
  36368. * Instantiates a ColorGradingTexture from the following parameters.
  36369. *
  36370. * @param url The location of the color gradind data (currently only supporting 3dl)
  36371. * @param scene The scene the texture will be used in
  36372. */
  36373. constructor(url: string, scene: Scene);
  36374. /**
  36375. * Returns the texture matrix used in most of the material.
  36376. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  36377. */
  36378. getTextureMatrix(): Matrix;
  36379. /**
  36380. * Occurs when the file being loaded is a .3dl LUT file.
  36381. */
  36382. private load3dlTexture;
  36383. /**
  36384. * Starts the loading process of the texture.
  36385. */
  36386. private loadTexture;
  36387. /**
  36388. * Clones the color gradind texture.
  36389. */
  36390. clone(): ColorGradingTexture;
  36391. /**
  36392. * Called during delayed load for textures.
  36393. */
  36394. delayLoad(): void;
  36395. /**
  36396. * Parses a color grading texture serialized by Babylon.
  36397. * @param parsedTexture The texture information being parsedTexture
  36398. * @param scene The scene to load the texture in
  36399. * @param rootUrl The root url of the data assets to load
  36400. * @return A color gradind texture
  36401. */
  36402. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  36403. /**
  36404. * Serializes the LUT texture to json format.
  36405. */
  36406. serialize(): any;
  36407. }
  36408. }
  36409. declare module BABYLON {
  36410. class CubeTexture extends BaseTexture {
  36411. url: string;
  36412. /**
  36413. * Gets or sets the center of the bounding box associated with the cube texture
  36414. * It must define where the camera used to render the texture was set
  36415. */
  36416. boundingBoxPosition: Vector3;
  36417. private _boundingBoxSize;
  36418. /**
  36419. * Gets or sets the size of the bounding box associated with the cube texture
  36420. * When defined, the cubemap will switch to local mode
  36421. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36422. * @example https://www.babylonjs-playground.com/#RNASML
  36423. */
  36424. boundingBoxSize: Vector3;
  36425. protected _rotationY: number;
  36426. /**
  36427. * Sets texture matrix rotation angle around Y axis in radians.
  36428. */
  36429. /**
  36430. * Gets texture matrix rotation angle around Y axis radians.
  36431. */
  36432. rotationY: number;
  36433. private _noMipmap;
  36434. private _files;
  36435. private _extensions;
  36436. private _textureMatrix;
  36437. private _format;
  36438. private _createPolynomials;
  36439. /** @hidden */
  36440. readonly _prefiltered: boolean;
  36441. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  36442. /**
  36443. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  36444. * @param url defines the url of the prefiltered texture
  36445. * @param scene defines the scene the texture is attached to
  36446. * @param forcedExtension defines the extension of the file if different from the url
  36447. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36448. * @return the prefiltered texture
  36449. */
  36450. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  36451. /**
  36452. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  36453. * as prefiltered data.
  36454. * @param rootUrl defines the url of the texture or the root name of the six images
  36455. * @param scene defines the scene the texture is attached to
  36456. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  36457. * @param noMipmap defines if mipmaps should be created or not
  36458. * @param files defines the six files to load for the different faces
  36459. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  36460. * @param onError defines a callback triggered in case of error during load
  36461. * @param format defines the internal format to use for the texture once loaded
  36462. * @param prefiltered defines whether or not the texture is created from prefiltered data
  36463. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  36464. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36465. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36466. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36467. * @return the cube texture
  36468. */
  36469. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  36470. delayLoad(): void;
  36471. getReflectionTextureMatrix(): Matrix;
  36472. setReflectionTextureMatrix(value: Matrix): void;
  36473. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  36474. clone(): CubeTexture;
  36475. }
  36476. }
  36477. declare module BABYLON {
  36478. /**
  36479. * A class extending {BABYLON.Texture} allowing drawing on a texture
  36480. * @see http://doc.babylonjs.com/how_to/dynamictexture
  36481. */
  36482. class DynamicTexture extends Texture {
  36483. private _generateMipMaps;
  36484. private _canvas;
  36485. private _context;
  36486. private _engine;
  36487. /**
  36488. * Creates a {BABYLON.DynamicTexture}
  36489. * @param name defines the name of the texture
  36490. * @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
  36491. * @param scene defines the scene where you want the texture
  36492. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  36493. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36494. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  36495. */
  36496. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  36497. /**
  36498. * Gets the current state of canRescale
  36499. */
  36500. readonly canRescale: boolean;
  36501. private _recreate;
  36502. /**
  36503. * Scales the texture
  36504. * @param ratio the scale factor to apply to both width and height
  36505. */
  36506. scale(ratio: number): void;
  36507. /**
  36508. * Resizes the texture
  36509. * @param width the new width
  36510. * @param height the new height
  36511. */
  36512. scaleTo(width: number, height: number): void;
  36513. /**
  36514. * Gets the context of the canvas used by the texture
  36515. * @returns the canvas context of the dynamic texture
  36516. */
  36517. getContext(): CanvasRenderingContext2D;
  36518. /**
  36519. * Clears the texture
  36520. */
  36521. clear(): void;
  36522. /**
  36523. * Updates the texture
  36524. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36525. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  36526. */
  36527. update(invertY?: boolean, premulAlpha?: boolean): void;
  36528. /**
  36529. * Draws text onto the texture
  36530. * @param text defines the text to be drawn
  36531. * @param x defines the placement of the text from the left
  36532. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  36533. * @param font defines the font to be used with font-style, font-size, font-name
  36534. * @param color defines the color used for the text
  36535. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  36536. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36537. * @param update defines whether texture is immediately update (default is true)
  36538. */
  36539. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  36540. /**
  36541. * Clones the texture
  36542. * @returns the clone of the texture.
  36543. */
  36544. clone(): DynamicTexture;
  36545. /**
  36546. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  36547. * @returns a serialized dynamic texture object
  36548. */
  36549. serialize(): any;
  36550. /** @hidden */
  36551. _rebuild(): void;
  36552. }
  36553. }
  36554. declare module BABYLON {
  36555. /**
  36556. * This represents a texture coming from an HDR input.
  36557. *
  36558. * The only supported format is currently panorama picture stored in RGBE format.
  36559. * Example of such files can be found on HDRLib: http://hdrlib.com/
  36560. */
  36561. class HDRCubeTexture extends BaseTexture {
  36562. private static _facesMapping;
  36563. private _generateHarmonics;
  36564. private _noMipmap;
  36565. private _textureMatrix;
  36566. private _size;
  36567. private _onLoad;
  36568. private _onError;
  36569. /**
  36570. * The texture URL.
  36571. */
  36572. url: string;
  36573. /**
  36574. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  36575. */
  36576. coordinatesMode: number;
  36577. protected _isBlocking: boolean;
  36578. /**
  36579. * Sets wether or not the texture is blocking during loading.
  36580. */
  36581. /**
  36582. * Gets wether or not the texture is blocking during loading.
  36583. */
  36584. isBlocking: boolean;
  36585. protected _rotationY: number;
  36586. /**
  36587. * Sets texture matrix rotation angle around Y axis in radians.
  36588. */
  36589. /**
  36590. * Gets texture matrix rotation angle around Y axis radians.
  36591. */
  36592. rotationY: number;
  36593. /**
  36594. * Gets or sets the center of the bounding box associated with the cube texture
  36595. * It must define where the camera used to render the texture was set
  36596. */
  36597. boundingBoxPosition: Vector3;
  36598. private _boundingBoxSize;
  36599. /**
  36600. * Gets or sets the size of the bounding box associated with the cube texture
  36601. * When defined, the cubemap will switch to local mode
  36602. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36603. * @example https://www.babylonjs-playground.com/#RNASML
  36604. */
  36605. boundingBoxSize: Vector3;
  36606. /**
  36607. * Instantiates an HDRTexture from the following parameters.
  36608. *
  36609. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  36610. * @param scene The scene the texture will be used in
  36611. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  36612. * @param noMipmap Forces to not generate the mipmap if true
  36613. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  36614. * @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)
  36615. * @param reserved Reserved flag for internal use.
  36616. */
  36617. 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>);
  36618. /**
  36619. * Occurs when the file is raw .hdr file.
  36620. */
  36621. private loadTexture;
  36622. clone(): HDRCubeTexture;
  36623. delayLoad(): void;
  36624. getReflectionTextureMatrix(): Matrix;
  36625. setReflectionTextureMatrix(value: Matrix): void;
  36626. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  36627. serialize(): any;
  36628. }
  36629. }
  36630. declare module BABYLON {
  36631. /**
  36632. * Class used to store data associated with WebGL texture data for the engine
  36633. * This class should not be used directly
  36634. */
  36635. class InternalTexture implements IInternalTextureTracker {
  36636. /**
  36637. * The source of the texture data is unknown
  36638. */
  36639. static DATASOURCE_UNKNOWN: number;
  36640. /**
  36641. * Texture data comes from an URL
  36642. */
  36643. static DATASOURCE_URL: number;
  36644. /**
  36645. * Texture data is only used for temporary storage
  36646. */
  36647. static DATASOURCE_TEMP: number;
  36648. /**
  36649. * Texture data comes from raw data (ArrayBuffer)
  36650. */
  36651. static DATASOURCE_RAW: number;
  36652. /**
  36653. * Texture content is dynamic (video or dynamic texture)
  36654. */
  36655. static DATASOURCE_DYNAMIC: number;
  36656. /**
  36657. * Texture content is generated by rendering to it
  36658. */
  36659. static DATASOURCE_RENDERTARGET: number;
  36660. /**
  36661. * Texture content is part of a multi render target process
  36662. */
  36663. static DATASOURCE_MULTIRENDERTARGET: number;
  36664. /**
  36665. * Texture data comes from a cube data file
  36666. */
  36667. static DATASOURCE_CUBE: number;
  36668. /**
  36669. * Texture data comes from a raw cube data
  36670. */
  36671. static DATASOURCE_CUBERAW: number;
  36672. /**
  36673. * Texture data come from a prefiltered cube data file
  36674. */
  36675. static DATASOURCE_CUBEPREFILTERED: number;
  36676. /**
  36677. * Texture content is raw 3D data
  36678. */
  36679. static DATASOURCE_RAW3D: number;
  36680. /**
  36681. * Texture content is a depth texture
  36682. */
  36683. static DATASOURCE_DEPTHTEXTURE: number;
  36684. /**
  36685. * Texture data comes from a raw cube data encoded with RGBD
  36686. */
  36687. static DATASOURCE_CUBERAW_RGBD: number;
  36688. /**
  36689. * Defines if the texture is ready
  36690. */
  36691. isReady: boolean;
  36692. /**
  36693. * Defines if the texture is a cube texture
  36694. */
  36695. isCube: boolean;
  36696. /**
  36697. * Defines if the texture contains 3D data
  36698. */
  36699. is3D: boolean;
  36700. /**
  36701. * Gets the URL used to load this texture
  36702. */
  36703. url: string;
  36704. /**
  36705. * Gets the sampling mode of the texture
  36706. */
  36707. samplingMode: number;
  36708. /**
  36709. * Gets a boolean indicating if the texture needs mipmaps generation
  36710. */
  36711. generateMipMaps: boolean;
  36712. /**
  36713. * Gets the number of samples used by the texture (WebGL2+ only)
  36714. */
  36715. samples: number;
  36716. /**
  36717. * Gets the type of the texture
  36718. */
  36719. type: number;
  36720. /**
  36721. * Gets the format of the texture
  36722. */
  36723. format: number;
  36724. /**
  36725. * Observable called when the texture is loaded
  36726. */
  36727. onLoadedObservable: Observable<InternalTexture>;
  36728. /**
  36729. * Gets the width of the texture
  36730. */
  36731. width: number;
  36732. /**
  36733. * Gets the height of the texture
  36734. */
  36735. height: number;
  36736. /**
  36737. * Gets the depth of the texture
  36738. */
  36739. depth: number;
  36740. /**
  36741. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36742. */
  36743. baseWidth: number;
  36744. /**
  36745. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36746. */
  36747. baseHeight: number;
  36748. /**
  36749. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36750. */
  36751. baseDepth: number;
  36752. /**
  36753. * Gets a boolean indicating if the texture is inverted on Y axis
  36754. */
  36755. invertY: boolean;
  36756. /**
  36757. * Gets or set the previous tracker in the list
  36758. */
  36759. previous: Nullable<IInternalTextureTracker>;
  36760. /**
  36761. * Gets or set the next tracker in the list
  36762. */
  36763. next: Nullable<IInternalTextureTracker>;
  36764. /** @hidden */
  36765. _initialSlot: number;
  36766. /** @hidden */
  36767. _designatedSlot: number;
  36768. /** @hidden */
  36769. _dataSource: number;
  36770. /** @hidden */
  36771. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36772. /** @hidden */
  36773. _bufferView: Nullable<ArrayBufferView>;
  36774. /** @hidden */
  36775. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36776. /** @hidden */
  36777. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36778. /** @hidden */
  36779. _size: number;
  36780. /** @hidden */
  36781. _extension: string;
  36782. /** @hidden */
  36783. _files: Nullable<string[]>;
  36784. /** @hidden */
  36785. _workingCanvas: HTMLCanvasElement;
  36786. /** @hidden */
  36787. _workingContext: CanvasRenderingContext2D;
  36788. /** @hidden */
  36789. _framebuffer: Nullable<WebGLFramebuffer>;
  36790. /** @hidden */
  36791. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36792. /** @hidden */
  36793. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36794. /** @hidden */
  36795. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36796. /** @hidden */
  36797. _attachments: Nullable<number[]>;
  36798. /** @hidden */
  36799. _cachedCoordinatesMode: Nullable<number>;
  36800. /** @hidden */
  36801. _cachedWrapU: Nullable<number>;
  36802. /** @hidden */
  36803. _cachedWrapV: Nullable<number>;
  36804. /** @hidden */
  36805. _cachedWrapR: Nullable<number>;
  36806. /** @hidden */
  36807. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36808. /** @hidden */
  36809. _isDisabled: boolean;
  36810. /** @hidden */
  36811. _compression: Nullable<string>;
  36812. /** @hidden */
  36813. _generateStencilBuffer: boolean;
  36814. /** @hidden */
  36815. _generateDepthBuffer: boolean;
  36816. /** @hidden */
  36817. _comparisonFunction: number;
  36818. /** @hidden */
  36819. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36820. /** @hidden */
  36821. _lodGenerationScale: number;
  36822. /** @hidden */
  36823. _lodGenerationOffset: number;
  36824. /** @hidden */
  36825. _lodTextureHigh: BaseTexture;
  36826. /** @hidden */
  36827. _lodTextureMid: BaseTexture;
  36828. /** @hidden */
  36829. _lodTextureLow: BaseTexture;
  36830. /** @hidden */
  36831. _isRGBD: boolean;
  36832. /** @hidden */
  36833. _webGLTexture: Nullable<WebGLTexture>;
  36834. /** @hidden */
  36835. _references: number;
  36836. private _engine;
  36837. /**
  36838. * Gets the Engine the texture belongs to.
  36839. * @returns The babylon engine
  36840. */
  36841. getEngine(): Engine;
  36842. /**
  36843. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  36844. */
  36845. readonly dataSource: number;
  36846. /**
  36847. * Creates a new InternalTexture
  36848. * @param engine defines the engine to use
  36849. * @param dataSource defines the type of data that will be used
  36850. */
  36851. constructor(engine: Engine, dataSource: number);
  36852. /**
  36853. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  36854. */
  36855. incrementReferences(): void;
  36856. /**
  36857. * Change the size of the texture (not the size of the content)
  36858. * @param width defines the new width
  36859. * @param height defines the new height
  36860. * @param depth defines the new depth (1 by default)
  36861. */
  36862. updateSize(width: int, height: int, depth?: int): void;
  36863. /** @hidden */
  36864. _rebuild(): void;
  36865. /** @hidden */
  36866. _swapAndDie(target: InternalTexture): void;
  36867. /**
  36868. * Dispose the current allocated resources
  36869. */
  36870. dispose(): void;
  36871. }
  36872. }
  36873. declare module BABYLON {
  36874. /**
  36875. * This represents the required contract to create a new type of texture loader.
  36876. */
  36877. interface IInternalTextureLoader {
  36878. /**
  36879. * Defines wether the loader supports cascade loading the different faces.
  36880. */
  36881. supportCascades: boolean;
  36882. /**
  36883. * This returns if the loader support the current file information.
  36884. * @param extension defines the file extension of the file being loaded
  36885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36886. * @param fallback defines the fallback internal texture if any
  36887. * @param isBase64 defines whether the texture is encoded as a base64
  36888. * @param isBuffer defines whether the texture data are stored as a buffer
  36889. * @returns true if the loader can load the specified file
  36890. */
  36891. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  36892. /**
  36893. * Transform the url before loading if required.
  36894. * @param rootUrl the url of the texture
  36895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36896. * @returns the transformed texture
  36897. */
  36898. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  36899. /**
  36900. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  36901. * @param rootUrl the url of the texture
  36902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36903. * @returns the fallback texture
  36904. */
  36905. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  36906. /**
  36907. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  36908. * @param data contains the texture data
  36909. * @param texture defines the BabylonJS internal texture
  36910. * @param createPolynomials will be true if polynomials have been requested
  36911. * @param onLoad defines the callback to trigger once the texture is ready
  36912. * @param onError defines the callback to trigger in case of error
  36913. */
  36914. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  36915. /**
  36916. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  36917. * @param data contains the texture data
  36918. * @param texture defines the BabylonJS internal texture
  36919. * @param callback defines the method to call once ready to upload
  36920. */
  36921. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. /**
  36926. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  36927. */
  36928. interface IInternalTextureTracker {
  36929. /**
  36930. * Gets or set the previous tracker in the list
  36931. */
  36932. previous: Nullable<IInternalTextureTracker>;
  36933. /**
  36934. * Gets or set the next tracker in the list
  36935. */
  36936. next: Nullable<IInternalTextureTracker>;
  36937. }
  36938. /**
  36939. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  36940. */
  36941. class DummyInternalTextureTracker {
  36942. /**
  36943. * Gets or set the previous tracker in the list
  36944. */
  36945. previous: Nullable<IInternalTextureTracker>;
  36946. /**
  36947. * Gets or set the next tracker in the list
  36948. */
  36949. next: Nullable<IInternalTextureTracker>;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. class MirrorTexture extends RenderTargetTexture {
  36954. private scene;
  36955. mirrorPlane: Plane;
  36956. private _transformMatrix;
  36957. private _mirrorMatrix;
  36958. private _savedViewMatrix;
  36959. private _blurX;
  36960. private _blurY;
  36961. private _adaptiveBlurKernel;
  36962. private _blurKernelX;
  36963. private _blurKernelY;
  36964. private _blurRatio;
  36965. blurRatio: number;
  36966. adaptiveBlurKernel: number;
  36967. blurKernel: number;
  36968. blurKernelX: number;
  36969. blurKernelY: number;
  36970. private _autoComputeBlurKernel;
  36971. protected _onRatioRescale(): void;
  36972. private _updateGammaSpace;
  36973. private _imageProcessingConfigChangeObserver;
  36974. constructor(name: string, size: number | {
  36975. width: number;
  36976. height: number;
  36977. } | {
  36978. ratio: number;
  36979. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  36980. private _preparePostProcesses;
  36981. clone(): MirrorTexture;
  36982. serialize(): any;
  36983. dispose(): void;
  36984. }
  36985. }
  36986. declare module BABYLON {
  36987. interface IMultiRenderTargetOptions {
  36988. generateMipMaps?: boolean;
  36989. types?: number[];
  36990. samplingModes?: number[];
  36991. generateDepthBuffer?: boolean;
  36992. generateStencilBuffer?: boolean;
  36993. generateDepthTexture?: boolean;
  36994. textureCount?: number;
  36995. doNotChangeAspectRatio?: boolean;
  36996. defaultType?: number;
  36997. }
  36998. class MultiRenderTarget extends RenderTargetTexture {
  36999. private _internalTextures;
  37000. private _textures;
  37001. readonly isSupported: boolean;
  37002. private _multiRenderTargetOptions;
  37003. readonly textures: Texture[];
  37004. readonly depthTexture: Texture;
  37005. wrapU: number;
  37006. wrapV: number;
  37007. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  37008. /** @hidden */
  37009. _rebuild(): void;
  37010. private _createInternalTextures;
  37011. private _createTextures;
  37012. samples: number;
  37013. resize(size: any): void;
  37014. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37015. dispose(): void;
  37016. releaseInternalTextures(): void;
  37017. }
  37018. }
  37019. declare module BABYLON {
  37020. /**
  37021. * Raw cube texture where the raw buffers are passed in
  37022. */
  37023. class RawCubeTexture extends CubeTexture {
  37024. /**
  37025. * Creates a cube texture where the raw buffers are passed in.
  37026. * @param scene defines the scene the texture is attached to
  37027. * @param data defines the array of data to use to create each face
  37028. * @param size defines the size of the textures
  37029. * @param format defines the format of the data
  37030. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  37031. * @param generateMipMaps defines if the engine should generate the mip levels
  37032. * @param invertY defines if data must be stored with Y axis inverted
  37033. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  37034. * @param compression defines the compression used (null by default)
  37035. */
  37036. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  37037. /**
  37038. * Updates the raw cube texture.
  37039. * @param data defines the data to store
  37040. * @param format defines the data format
  37041. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  37042. * @param invertY defines if data must be stored with Y axis inverted
  37043. * @param compression defines the compression used (null by default)
  37044. * @param level defines which level of the texture to update
  37045. */
  37046. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  37047. /**
  37048. * Updates a raw cube texture with RGBD encoded data.
  37049. * @param data defines the array of data [mipmap][face] to use to create each face
  37050. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  37051. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37052. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37053. * @returns a promsie that resolves when the operation is complete
  37054. */
  37055. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  37056. /**
  37057. * Clones the raw cube texture.
  37058. * @return a new cube texture
  37059. */
  37060. clone(): CubeTexture;
  37061. /** @hidden */
  37062. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  37063. }
  37064. }
  37065. declare module BABYLON {
  37066. class RawTexture extends Texture {
  37067. format: number;
  37068. private _engine;
  37069. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  37070. update(data: ArrayBufferView): void;
  37071. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37072. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37073. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37074. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37075. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37076. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37077. }
  37078. }
  37079. declare module BABYLON {
  37080. /**
  37081. * Class used to store 3D textures containing user data
  37082. */
  37083. class RawTexture3D extends Texture {
  37084. /** Gets or sets the texture format to use */
  37085. format: number;
  37086. private _engine;
  37087. /**
  37088. * Create a new RawTexture3D
  37089. * @param data defines the data of the texture
  37090. * @param width defines the width of the texture
  37091. * @param height defines the height of the texture
  37092. * @param depth defines the depth of the texture
  37093. * @param format defines the texture format to use
  37094. * @param scene defines the hosting scene
  37095. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  37096. * @param invertY defines if texture must be stored with Y axis inverted
  37097. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37098. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  37099. */
  37100. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  37101. /** Gets or sets the texture format to use */
  37102. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  37103. /**
  37104. * Update the texture with new data
  37105. * @param data defines the data to store in the texture
  37106. */
  37107. update(data: ArrayBufferView): void;
  37108. }
  37109. }
  37110. declare module BABYLON {
  37111. /**
  37112. * Creates a refraction texture used by refraction channel of the standard material.
  37113. * @param name the texture name
  37114. * @param size size of the underlying texture
  37115. * @param scene root scene
  37116. */
  37117. class RefractionTexture extends RenderTargetTexture {
  37118. refractionPlane: Plane;
  37119. depth: number;
  37120. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  37121. clone(): RefractionTexture;
  37122. serialize(): any;
  37123. }
  37124. }
  37125. declare module BABYLON {
  37126. class RenderTargetTexture extends Texture {
  37127. isCube: boolean;
  37128. static _REFRESHRATE_RENDER_ONCE: number;
  37129. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37130. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37131. static readonly REFRESHRATE_RENDER_ONCE: number;
  37132. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37133. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37134. /**
  37135. * Use this predicate to dynamically define the list of mesh you want to render.
  37136. * If set, the renderList property will be overwritten.
  37137. */
  37138. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37139. private _renderList;
  37140. /**
  37141. * Use this list to define the list of mesh you want to render.
  37142. */
  37143. renderList: Nullable<Array<AbstractMesh>>;
  37144. private _hookArray;
  37145. renderParticles: boolean;
  37146. renderSprites: boolean;
  37147. coordinatesMode: number;
  37148. activeCamera: Nullable<Camera>;
  37149. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37150. useCameraPostProcesses: boolean;
  37151. ignoreCameraViewport: boolean;
  37152. private _postProcessManager;
  37153. private _postProcesses;
  37154. private _resizeObserver;
  37155. /**
  37156. * An event triggered when the texture is unbind.
  37157. */
  37158. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37159. /**
  37160. * An event triggered when the texture is unbind.
  37161. */
  37162. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37163. private _onAfterUnbindObserver;
  37164. onAfterUnbind: () => void;
  37165. /**
  37166. * An event triggered before rendering the texture
  37167. */
  37168. onBeforeRenderObservable: Observable<number>;
  37169. private _onBeforeRenderObserver;
  37170. onBeforeRender: (faceIndex: number) => void;
  37171. /**
  37172. * An event triggered after rendering the texture
  37173. */
  37174. onAfterRenderObservable: Observable<number>;
  37175. private _onAfterRenderObserver;
  37176. onAfterRender: (faceIndex: number) => void;
  37177. /**
  37178. * An event triggered after the texture clear
  37179. */
  37180. onClearObservable: Observable<Engine>;
  37181. private _onClearObserver;
  37182. onClear: (Engine: Engine) => void;
  37183. clearColor: Color4;
  37184. protected _size: number | {
  37185. width: number;
  37186. height: number;
  37187. };
  37188. protected _initialSizeParameter: number | {
  37189. width: number;
  37190. height: number;
  37191. } | {
  37192. ratio: number;
  37193. };
  37194. protected _sizeRatio: Nullable<number>;
  37195. /** @hidden */
  37196. _generateMipMaps: boolean;
  37197. protected _renderingManager: RenderingManager;
  37198. /** @hidden */
  37199. _waitingRenderList: string[];
  37200. protected _doNotChangeAspectRatio: boolean;
  37201. protected _currentRefreshId: number;
  37202. protected _refreshRate: number;
  37203. protected _textureMatrix: Matrix;
  37204. protected _samples: number;
  37205. protected _renderTargetOptions: RenderTargetCreationOptions;
  37206. readonly renderTargetOptions: RenderTargetCreationOptions;
  37207. protected _engine: Engine;
  37208. protected _onRatioRescale(): void;
  37209. /**
  37210. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37211. * It must define where the camera used to render the texture is set
  37212. */
  37213. boundingBoxPosition: Vector3;
  37214. private _boundingBoxSize;
  37215. /**
  37216. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37217. * When defined, the cubemap will switch to local mode
  37218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37219. * @example https://www.babylonjs-playground.com/#RNASML
  37220. */
  37221. boundingBoxSize: Vector3;
  37222. /**
  37223. * In case the RTT has been created with a depth texture, get the associated
  37224. * depth texture.
  37225. * Otherwise, return null.
  37226. */
  37227. depthStencilTexture: Nullable<InternalTexture>;
  37228. /**
  37229. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  37230. * or used a shadow, depth texture...
  37231. * @param name The friendly name of the texture
  37232. * @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)
  37233. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37234. * @param generateMipMaps True if mip maps need to be generated after render.
  37235. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37236. * @param type The type of the buffer in the RTT (int, half float, float...)
  37237. * @param isCube True if a cube texture needs to be created
  37238. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37239. * @param generateDepthBuffer True to generate a depth buffer
  37240. * @param generateStencilBuffer True to generate a stencil buffer
  37241. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37242. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37243. */
  37244. constructor(name: string, size: number | {
  37245. width: number;
  37246. height: number;
  37247. } | {
  37248. ratio: number;
  37249. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  37250. /**
  37251. * Creates a depth stencil texture.
  37252. * This is only available in WebGL 2 or with the depth texture extension available.
  37253. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37254. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37255. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37256. */
  37257. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37258. private _processSizeParameter;
  37259. samples: number;
  37260. resetRefreshCounter(): void;
  37261. refreshRate: number;
  37262. addPostProcess(postProcess: PostProcess): void;
  37263. clearPostProcesses(dispose?: boolean): void;
  37264. removePostProcess(postProcess: PostProcess): void;
  37265. /** @hidden */
  37266. _shouldRender(): boolean;
  37267. getRenderSize(): number;
  37268. getRenderWidth(): number;
  37269. getRenderHeight(): number;
  37270. readonly canRescale: boolean;
  37271. scale(ratio: number): void;
  37272. getReflectionTextureMatrix(): Matrix;
  37273. resize(size: number | {
  37274. width: number;
  37275. height: number;
  37276. } | {
  37277. ratio: number;
  37278. }): void;
  37279. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37280. private _bestReflectionRenderTargetDimension;
  37281. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37282. private renderToTarget;
  37283. /**
  37284. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37285. * This allowed control for front to back rendering or reversly depending of the special needs.
  37286. *
  37287. * @param renderingGroupId The rendering group id corresponding to its index
  37288. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37289. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37290. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37291. */
  37292. 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;
  37293. /**
  37294. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37295. *
  37296. * @param renderingGroupId The rendering group id corresponding to its index
  37297. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37298. */
  37299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37300. clone(): RenderTargetTexture;
  37301. serialize(): any;
  37302. disposeFramebufferObjects(): void;
  37303. dispose(): void;
  37304. /** @hidden */
  37305. _rebuild(): void;
  37306. /**
  37307. * Clear the info related to rendering groups preventing retention point in material dispose.
  37308. */
  37309. freeRenderingGroups(): void;
  37310. }
  37311. }
  37312. declare module BABYLON {
  37313. class Texture extends BaseTexture {
  37314. static NEAREST_SAMPLINGMODE: number;
  37315. static NEAREST_NEAREST_MIPLINEAR: number;
  37316. static BILINEAR_SAMPLINGMODE: number;
  37317. static LINEAR_LINEAR_MIPNEAREST: number;
  37318. static TRILINEAR_SAMPLINGMODE: number;
  37319. static LINEAR_LINEAR_MIPLINEAR: number;
  37320. static NEAREST_NEAREST_MIPNEAREST: number;
  37321. static NEAREST_LINEAR_MIPNEAREST: number;
  37322. static NEAREST_LINEAR_MIPLINEAR: number;
  37323. static NEAREST_LINEAR: number;
  37324. static NEAREST_NEAREST: number;
  37325. static LINEAR_NEAREST_MIPNEAREST: number;
  37326. static LINEAR_NEAREST_MIPLINEAR: number;
  37327. static LINEAR_LINEAR: number;
  37328. static LINEAR_NEAREST: number;
  37329. static EXPLICIT_MODE: number;
  37330. static SPHERICAL_MODE: number;
  37331. static PLANAR_MODE: number;
  37332. static CUBIC_MODE: number;
  37333. static PROJECTION_MODE: number;
  37334. static SKYBOX_MODE: number;
  37335. static INVCUBIC_MODE: number;
  37336. static EQUIRECTANGULAR_MODE: number;
  37337. static FIXED_EQUIRECTANGULAR_MODE: number;
  37338. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37339. static readonly CLAMP_ADDRESSMODE: number;
  37340. static readonly WRAP_ADDRESSMODE: number;
  37341. static readonly MIRROR_ADDRESSMODE: number;
  37342. /**
  37343. * 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
  37344. */
  37345. static UseSerializedUrlIfAny: boolean;
  37346. url: Nullable<string>;
  37347. uOffset: number;
  37348. vOffset: number;
  37349. uScale: number;
  37350. vScale: number;
  37351. uAng: number;
  37352. vAng: number;
  37353. wAng: number;
  37354. /**
  37355. * Defines the center of rotation (U)
  37356. */
  37357. uRotationCenter: number;
  37358. /**
  37359. * Defines the center of rotation (V)
  37360. */
  37361. vRotationCenter: number;
  37362. /**
  37363. * Defines the center of rotation (W)
  37364. */
  37365. wRotationCenter: number;
  37366. readonly noMipmap: boolean;
  37367. private _noMipmap;
  37368. /** @hidden */
  37369. _invertY: boolean;
  37370. private _rowGenerationMatrix;
  37371. private _cachedTextureMatrix;
  37372. private _projectionModeMatrix;
  37373. private _t0;
  37374. private _t1;
  37375. private _t2;
  37376. private _cachedUOffset;
  37377. private _cachedVOffset;
  37378. private _cachedUScale;
  37379. private _cachedVScale;
  37380. private _cachedUAng;
  37381. private _cachedVAng;
  37382. private _cachedWAng;
  37383. private _cachedProjectionMatrixId;
  37384. private _cachedCoordinatesMode;
  37385. /** @hidden */
  37386. _samplingMode: number;
  37387. /** @hidden */
  37388. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37389. private _deleteBuffer;
  37390. protected _format: Nullable<number>;
  37391. private _delayedOnLoad;
  37392. private _delayedOnError;
  37393. protected _onLoadObservable: Nullable<Observable<Texture>>;
  37394. protected _isBlocking: boolean;
  37395. isBlocking: boolean;
  37396. readonly samplingMode: number;
  37397. 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);
  37398. /**
  37399. * Update the url (and optional buffer) of this texture if url was null during construction.
  37400. * @param url the url of the texture
  37401. * @param buffer the buffer of the texture (defaults to null)
  37402. */
  37403. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  37404. delayLoad(): void;
  37405. /**
  37406. * Default is Trilinear mode.
  37407. *
  37408. * | Value | Type | Description |
  37409. * | ----- | ------------------ | ----------- |
  37410. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37411. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37412. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37413. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37414. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37415. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37416. * | 7 | NEAREST_LINEAR | |
  37417. * | 8 | NEAREST_NEAREST | |
  37418. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37419. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37420. * | 11 | LINEAR_LINEAR | |
  37421. * | 12 | LINEAR_NEAREST | |
  37422. *
  37423. * > _mag_: magnification filter (close to the viewer)
  37424. * > _min_: minification filter (far from the viewer)
  37425. * > _mip_: filter used between mip map levels
  37426. *
  37427. */
  37428. updateSamplingMode(samplingMode: number): void;
  37429. private _prepareRowForTextureGeneration;
  37430. getTextureMatrix(): Matrix;
  37431. getReflectionTextureMatrix(): Matrix;
  37432. clone(): Texture;
  37433. readonly onLoadObservable: Observable<Texture>;
  37434. serialize(): any;
  37435. getClassName(): string;
  37436. dispose(): void;
  37437. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  37438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  37439. 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;
  37440. }
  37441. }
  37442. declare module BABYLON {
  37443. /**
  37444. * Settings for finer control over video usage
  37445. */
  37446. interface VideoTextureSettings {
  37447. /**
  37448. * Applies `autoplay` to video, if specified
  37449. */
  37450. autoPlay?: boolean;
  37451. /**
  37452. * Applies `loop` to video, if specified
  37453. */
  37454. loop?: boolean;
  37455. /**
  37456. * Automatically updates internal texture from video at every frame in the render loop
  37457. */
  37458. autoUpdateTexture: boolean;
  37459. /**
  37460. * Image src displayed during the video loading or until the user interacts with the video.
  37461. */
  37462. poster?: string;
  37463. }
  37464. class VideoTexture extends Texture {
  37465. /**
  37466. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  37467. */
  37468. readonly autoUpdateTexture: boolean;
  37469. /**
  37470. * The video instance used by the texture internally
  37471. */
  37472. readonly video: HTMLVideoElement;
  37473. private _onUserActionRequestedObservable;
  37474. readonly onUserActionRequestedObservable: Observable<Texture>;
  37475. private _generateMipMaps;
  37476. private _engine;
  37477. private _stillImageCaptured;
  37478. private _poster;
  37479. /**
  37480. * Creates a video texture.
  37481. * Sample : https://doc.babylonjs.com/how_to/video_texture
  37482. * @param {string | null} name optional name, will detect from video source, if not defined
  37483. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  37484. * @param {BABYLON.Scene} scene is obviously the current scene.
  37485. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  37486. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  37487. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  37488. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  37489. */
  37490. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  37491. private _getName;
  37492. private _getVideo;
  37493. private _createInternalTexture;
  37494. private reset;
  37495. /**
  37496. * @hidden Internal method to initiate `update`.
  37497. */
  37498. _rebuild(): void;
  37499. /**
  37500. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  37501. */
  37502. update(): void;
  37503. /**
  37504. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  37505. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  37506. */
  37507. updateTexture(isVisible: boolean): void;
  37508. protected _updateInternalTexture: (e?: Event | undefined) => void;
  37509. /**
  37510. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  37511. * @param url New url.
  37512. */
  37513. updateURL(url: string): void;
  37514. dispose(): void;
  37515. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  37516. minWidth: number;
  37517. maxWidth: number;
  37518. minHeight: number;
  37519. maxHeight: number;
  37520. deviceId: string;
  37521. }): void;
  37522. }
  37523. }
  37524. declare var DracoDecoderModule: any;
  37525. declare var WebAssembly: any;
  37526. declare module BABYLON {
  37527. /**
  37528. * Configuration for Draco compression
  37529. */
  37530. interface IDracoCompressionConfiguration {
  37531. /**
  37532. * Configuration for the decoder.
  37533. */
  37534. decoder?: {
  37535. /**
  37536. * The url to the WebAssembly module.
  37537. */
  37538. wasmUrl?: string;
  37539. /**
  37540. * The url to the WebAssembly binary.
  37541. */
  37542. wasmBinaryUrl?: string;
  37543. /**
  37544. * The url to the fallback JavaScript module.
  37545. */
  37546. fallbackUrl?: string;
  37547. };
  37548. }
  37549. /**
  37550. * Draco compression (https://google.github.io/draco/)
  37551. *
  37552. * This class wraps the Draco module.
  37553. *
  37554. * **Encoder**
  37555. *
  37556. * The encoder is not currently implemented.
  37557. *
  37558. * **Decoder**
  37559. *
  37560. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  37561. *
  37562. * To update the configuration, use the following code:
  37563. * ```javascript
  37564. * BABYLON.DracoCompression.Configuration = {
  37565. * decoder: {
  37566. * wasmUrl: "<url to the WebAssembly library>",
  37567. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  37568. * fallbackUrl: "<url to the fallback JavaScript library>",
  37569. * }
  37570. * };
  37571. * ```
  37572. *
  37573. * 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.
  37574. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  37575. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  37576. *
  37577. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  37578. * ```javascript
  37579. * var dracoCompression = new BABYLON.DracoCompression();
  37580. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  37581. * [BABYLON.VertexBuffer.PositionKind]: 0
  37582. * });
  37583. * ```
  37584. *
  37585. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  37586. */
  37587. class DracoCompression implements IDisposable {
  37588. private static _DecoderModulePromise;
  37589. /**
  37590. * The configuration. Defaults to the following urls:
  37591. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  37592. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  37593. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  37594. */
  37595. static Configuration: IDracoCompressionConfiguration;
  37596. /**
  37597. * Returns true if the decoder is available.
  37598. */
  37599. static readonly DecoderAvailable: boolean;
  37600. /**
  37601. * Constructor
  37602. */
  37603. constructor();
  37604. /**
  37605. * Stop all async operations and release resources.
  37606. */
  37607. dispose(): void;
  37608. /**
  37609. * Decode Draco compressed mesh data to vertex data.
  37610. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  37611. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  37612. * @returns A promise that resolves with the decoded vertex data
  37613. */
  37614. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  37615. [kind: string]: number;
  37616. }): Promise<VertexData>;
  37617. private static _GetDecoderModule;
  37618. private static _LoadScriptAsync;
  37619. private static _LoadFileAsync;
  37620. }
  37621. }
  37622. declare module BABYLON {
  37623. /**
  37624. * Particle emitter emitting particles from the inside of a box.
  37625. * It emits the particles randomly between 2 given directions.
  37626. */
  37627. class BoxParticleEmitter implements IParticleEmitterType {
  37628. /**
  37629. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37630. */
  37631. direction1: Vector3;
  37632. /**
  37633. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37634. */
  37635. direction2: Vector3;
  37636. /**
  37637. * 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.
  37638. */
  37639. minEmitBox: Vector3;
  37640. /**
  37641. * 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.
  37642. */
  37643. maxEmitBox: Vector3;
  37644. /**
  37645. * Creates a new instance BoxParticleEmitter
  37646. */
  37647. constructor();
  37648. /**
  37649. * Called by the particle System when the direction is computed for the created particle.
  37650. * @param worldMatrix is the world matrix of the particle system
  37651. * @param directionToUpdate is the direction vector to update with the result
  37652. * @param particle is the particle we are computed the direction for
  37653. */
  37654. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37655. /**
  37656. * Called by the particle System when the position is computed for the created particle.
  37657. * @param worldMatrix is the world matrix of the particle system
  37658. * @param positionToUpdate is the position vector to update with the result
  37659. * @param particle is the particle we are computed the position for
  37660. */
  37661. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37662. /**
  37663. * Clones the current emitter and returns a copy of it
  37664. * @returns the new emitter
  37665. */
  37666. clone(): BoxParticleEmitter;
  37667. /**
  37668. * Called by the GPUParticleSystem to setup the update shader
  37669. * @param effect defines the update shader
  37670. */
  37671. applyToShader(effect: Effect): void;
  37672. /**
  37673. * Returns a string to use to update the GPU particles update shader
  37674. * @returns a string containng the defines string
  37675. */
  37676. getEffectDefines(): string;
  37677. /**
  37678. * Returns the string "BoxParticleEmitter"
  37679. * @returns a string containing the class name
  37680. */
  37681. getClassName(): string;
  37682. /**
  37683. * Serializes the particle system to a JSON object.
  37684. * @returns the JSON object
  37685. */
  37686. serialize(): any;
  37687. /**
  37688. * Parse properties from a JSON object
  37689. * @param serializationObject defines the JSON object
  37690. */
  37691. parse(serializationObject: any): void;
  37692. }
  37693. }
  37694. declare module BABYLON {
  37695. /**
  37696. * Particle emitter emitting particles from the inside of a cone.
  37697. * It emits the particles alongside the cone volume from the base to the particle.
  37698. * The emission direction might be randomized.
  37699. */
  37700. class ConeParticleEmitter implements IParticleEmitterType {
  37701. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37702. directionRandomizer: number;
  37703. private _radius;
  37704. private _angle;
  37705. private _height;
  37706. /**
  37707. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  37708. */
  37709. radiusRange: number;
  37710. /**
  37711. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  37712. */
  37713. heightRange: number;
  37714. /**
  37715. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  37716. */
  37717. emitFromSpawnPointOnly: boolean;
  37718. /**
  37719. * Gets or sets the radius of the emission cone
  37720. */
  37721. radius: number;
  37722. /**
  37723. * Gets or sets the angle of the emission cone
  37724. */
  37725. angle: number;
  37726. private _buildHeight;
  37727. /**
  37728. * Creates a new instance ConeParticleEmitter
  37729. * @param radius the radius of the emission cone (1 by default)
  37730. * @param angles the cone base angle (PI by default)
  37731. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  37732. */
  37733. constructor(radius?: number, angle?: number,
  37734. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37735. directionRandomizer?: number);
  37736. /**
  37737. * Called by the particle System when the direction is computed for the created particle.
  37738. * @param worldMatrix is the world matrix of the particle system
  37739. * @param directionToUpdate is the direction vector to update with the result
  37740. * @param particle is the particle we are computed the direction for
  37741. */
  37742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37743. /**
  37744. * Called by the particle System when the position is computed for the created particle.
  37745. * @param worldMatrix is the world matrix of the particle system
  37746. * @param positionToUpdate is the position vector to update with the result
  37747. * @param particle is the particle we are computed the position for
  37748. */
  37749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37750. /**
  37751. * Clones the current emitter and returns a copy of it
  37752. * @returns the new emitter
  37753. */
  37754. clone(): ConeParticleEmitter;
  37755. /**
  37756. * Called by the GPUParticleSystem to setup the update shader
  37757. * @param effect defines the update shader
  37758. */
  37759. applyToShader(effect: Effect): void;
  37760. /**
  37761. * Returns a string to use to update the GPU particles update shader
  37762. * @returns a string containng the defines string
  37763. */
  37764. getEffectDefines(): string;
  37765. /**
  37766. * Returns the string "ConeParticleEmitter"
  37767. * @returns a string containing the class name
  37768. */
  37769. getClassName(): string;
  37770. /**
  37771. * Serializes the particle system to a JSON object.
  37772. * @returns the JSON object
  37773. */
  37774. serialize(): any;
  37775. /**
  37776. * Parse properties from a JSON object
  37777. * @param serializationObject defines the JSON object
  37778. */
  37779. parse(serializationObject: any): void;
  37780. }
  37781. }
  37782. declare module BABYLON {
  37783. /**
  37784. * Particle emitter emitting particles from the inside of a hemisphere.
  37785. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  37786. */
  37787. class HemisphericParticleEmitter implements IParticleEmitterType {
  37788. /**
  37789. * The radius of the emission hemisphere.
  37790. */
  37791. radius: number;
  37792. /**
  37793. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37794. */
  37795. radiusRange: number;
  37796. /**
  37797. * How much to randomize the particle direction [0-1].
  37798. */
  37799. directionRandomizer: number;
  37800. /**
  37801. * Creates a new instance HemisphericParticleEmitter
  37802. * @param radius the radius of the emission hemisphere (1 by default)
  37803. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37804. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37805. */
  37806. constructor(
  37807. /**
  37808. * The radius of the emission hemisphere.
  37809. */
  37810. radius?: number,
  37811. /**
  37812. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37813. */
  37814. radiusRange?: number,
  37815. /**
  37816. * How much to randomize the particle direction [0-1].
  37817. */
  37818. directionRandomizer?: number);
  37819. /**
  37820. * Called by the particle System when the direction is computed for the created particle.
  37821. * @param worldMatrix is the world matrix of the particle system
  37822. * @param directionToUpdate is the direction vector to update with the result
  37823. * @param particle is the particle we are computed the direction for
  37824. */
  37825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37826. /**
  37827. * Called by the particle System when the position is computed for the created particle.
  37828. * @param worldMatrix is the world matrix of the particle system
  37829. * @param positionToUpdate is the position vector to update with the result
  37830. * @param particle is the particle we are computed the position for
  37831. */
  37832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37833. /**
  37834. * Clones the current emitter and returns a copy of it
  37835. * @returns the new emitter
  37836. */
  37837. clone(): HemisphericParticleEmitter;
  37838. /**
  37839. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37840. * @param effect defines the update shader
  37841. */
  37842. applyToShader(effect: Effect): void;
  37843. /**
  37844. * Returns a string to use to update the GPU particles update shader
  37845. * @returns a string containng the defines string
  37846. */
  37847. getEffectDefines(): string;
  37848. /**
  37849. * Returns the string "HemisphericParticleEmitter"
  37850. * @returns a string containing the class name
  37851. */
  37852. getClassName(): string;
  37853. /**
  37854. * Serializes the particle system to a JSON object.
  37855. * @returns the JSON object
  37856. */
  37857. serialize(): any;
  37858. /**
  37859. * Parse properties from a JSON object
  37860. * @param serializationObject defines the JSON object
  37861. */
  37862. parse(serializationObject: any): void;
  37863. }
  37864. }
  37865. declare module BABYLON {
  37866. /**
  37867. * Particle emitter represents a volume emitting particles.
  37868. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  37869. */
  37870. interface IParticleEmitterType {
  37871. /**
  37872. * Called by the particle System when the direction is computed for the created particle.
  37873. * @param worldMatrix is the world matrix of the particle system
  37874. * @param directionToUpdate is the direction vector to update with the result
  37875. * @param particle is the particle we are computed the direction for
  37876. */
  37877. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37878. /**
  37879. * Called by the particle System when the position is computed for the created particle.
  37880. * @param worldMatrix is the world matrix of the particle system
  37881. * @param positionToUpdate is the position vector to update with the result
  37882. * @param particle is the particle we are computed the position for
  37883. */
  37884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37885. /**
  37886. * Clones the current emitter and returns a copy of it
  37887. * @returns the new emitter
  37888. */
  37889. clone(): IParticleEmitterType;
  37890. /**
  37891. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37892. * @param effect defines the update shader
  37893. */
  37894. applyToShader(effect: Effect): void;
  37895. /**
  37896. * Returns a string to use to update the GPU particles update shader
  37897. * @returns the effect defines string
  37898. */
  37899. getEffectDefines(): string;
  37900. /**
  37901. * Returns a string representing the class name
  37902. * @returns a string containing the class name
  37903. */
  37904. getClassName(): string;
  37905. /**
  37906. * Serializes the particle system to a JSON object.
  37907. * @returns the JSON object
  37908. */
  37909. serialize(): any;
  37910. /**
  37911. * Parse properties from a JSON object
  37912. * @param serializationObject defines the JSON object
  37913. */
  37914. parse(serializationObject: any): void;
  37915. }
  37916. }
  37917. declare module BABYLON {
  37918. /**
  37919. * Particle emitter emitting particles from a point.
  37920. * It emits the particles randomly between 2 given directions.
  37921. */
  37922. class PointParticleEmitter implements IParticleEmitterType {
  37923. /**
  37924. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37925. */
  37926. direction1: Vector3;
  37927. /**
  37928. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37929. */
  37930. direction2: Vector3;
  37931. /**
  37932. * Creates a new instance PointParticleEmitter
  37933. */
  37934. constructor();
  37935. /**
  37936. * Called by the particle System when the direction is computed for the created particle.
  37937. * @param worldMatrix is the world matrix of the particle system
  37938. * @param directionToUpdate is the direction vector to update with the result
  37939. * @param particle is the particle we are computed the direction for
  37940. */
  37941. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37942. /**
  37943. * Called by the particle System when the position is computed for the created particle.
  37944. * @param worldMatrix is the world matrix of the particle system
  37945. * @param positionToUpdate is the position vector to update with the result
  37946. * @param particle is the particle we are computed the position for
  37947. */
  37948. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37949. /**
  37950. * Clones the current emitter and returns a copy of it
  37951. * @returns the new emitter
  37952. */
  37953. clone(): PointParticleEmitter;
  37954. /**
  37955. * Called by the GPUParticleSystem to setup the update shader
  37956. * @param effect defines the update shader
  37957. */
  37958. applyToShader(effect: Effect): void;
  37959. /**
  37960. * Returns a string to use to update the GPU particles update shader
  37961. * @returns a string containng the defines string
  37962. */
  37963. getEffectDefines(): string;
  37964. /**
  37965. * Returns the string "PointParticleEmitter"
  37966. * @returns a string containing the class name
  37967. */
  37968. getClassName(): string;
  37969. /**
  37970. * Serializes the particle system to a JSON object.
  37971. * @returns the JSON object
  37972. */
  37973. serialize(): any;
  37974. /**
  37975. * Parse properties from a JSON object
  37976. * @param serializationObject defines the JSON object
  37977. */
  37978. parse(serializationObject: any): void;
  37979. }
  37980. }
  37981. declare module BABYLON {
  37982. /**
  37983. * Particle emitter emitting particles from the inside of a sphere.
  37984. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  37985. */
  37986. class SphereParticleEmitter implements IParticleEmitterType {
  37987. /**
  37988. * The radius of the emission sphere.
  37989. */
  37990. radius: number;
  37991. /**
  37992. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37993. */
  37994. radiusRange: number;
  37995. /**
  37996. * How much to randomize the particle direction [0-1].
  37997. */
  37998. directionRandomizer: number;
  37999. /**
  38000. * Creates a new instance SphereParticleEmitter
  38001. * @param radius the radius of the emission sphere (1 by default)
  38002. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38003. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38004. */
  38005. constructor(
  38006. /**
  38007. * The radius of the emission sphere.
  38008. */
  38009. radius?: number,
  38010. /**
  38011. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38012. */
  38013. radiusRange?: number,
  38014. /**
  38015. * How much to randomize the particle direction [0-1].
  38016. */
  38017. directionRandomizer?: number);
  38018. /**
  38019. * Called by the particle System when the direction is computed for the created particle.
  38020. * @param worldMatrix is the world matrix of the particle system
  38021. * @param directionToUpdate is the direction vector to update with the result
  38022. * @param particle is the particle we are computed the direction for
  38023. */
  38024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38025. /**
  38026. * Called by the particle System when the position is computed for the created particle.
  38027. * @param worldMatrix is the world matrix of the particle system
  38028. * @param positionToUpdate is the position vector to update with the result
  38029. * @param particle is the particle we are computed the position for
  38030. */
  38031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38032. /**
  38033. * Clones the current emitter and returns a copy of it
  38034. * @returns the new emitter
  38035. */
  38036. clone(): SphereParticleEmitter;
  38037. /**
  38038. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38039. * @param effect defines the update shader
  38040. */
  38041. applyToShader(effect: Effect): void;
  38042. /**
  38043. * Returns a string to use to update the GPU particles update shader
  38044. * @returns a string containng the defines string
  38045. */
  38046. getEffectDefines(): string;
  38047. /**
  38048. * Returns the string "SphereParticleEmitter"
  38049. * @returns a string containing the class name
  38050. */
  38051. getClassName(): string;
  38052. /**
  38053. * Serializes the particle system to a JSON object.
  38054. * @returns the JSON object
  38055. */
  38056. serialize(): any;
  38057. /**
  38058. * Parse properties from a JSON object
  38059. * @param serializationObject defines the JSON object
  38060. */
  38061. parse(serializationObject: any): void;
  38062. }
  38063. /**
  38064. * Particle emitter emitting particles from the inside of a sphere.
  38065. * It emits the particles randomly between two vectors.
  38066. */
  38067. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  38068. /**
  38069. * The min limit of the emission direction.
  38070. */
  38071. direction1: Vector3;
  38072. /**
  38073. * The max limit of the emission direction.
  38074. */
  38075. direction2: Vector3;
  38076. /**
  38077. * Creates a new instance SphereDirectedParticleEmitter
  38078. * @param radius the radius of the emission sphere (1 by default)
  38079. * @param direction1 the min limit of the emission direction (up vector by default)
  38080. * @param direction2 the max limit of the emission direction (up vector by default)
  38081. */
  38082. constructor(radius?: number,
  38083. /**
  38084. * The min limit of the emission direction.
  38085. */
  38086. direction1?: Vector3,
  38087. /**
  38088. * The max limit of the emission direction.
  38089. */
  38090. direction2?: Vector3);
  38091. /**
  38092. * Called by the particle System when the direction is computed for the created particle.
  38093. * @param worldMatrix is the world matrix of the particle system
  38094. * @param directionToUpdate is the direction vector to update with the result
  38095. * @param particle is the particle we are computed the direction for
  38096. */
  38097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38098. /**
  38099. * Clones the current emitter and returns a copy of it
  38100. * @returns the new emitter
  38101. */
  38102. clone(): SphereDirectedParticleEmitter;
  38103. /**
  38104. * Called by the GPUParticleSystem to setup the update shader
  38105. * @param effect defines the update shader
  38106. */
  38107. applyToShader(effect: Effect): void;
  38108. /**
  38109. * Returns a string to use to update the GPU particles update shader
  38110. * @returns a string containng the defines string
  38111. */
  38112. getEffectDefines(): string;
  38113. /**
  38114. * Returns the string "SphereDirectedParticleEmitter"
  38115. * @returns a string containing the class name
  38116. */
  38117. getClassName(): string;
  38118. /**
  38119. * Serializes the particle system to a JSON object.
  38120. * @returns the JSON object
  38121. */
  38122. serialize(): any;
  38123. /**
  38124. * Parse properties from a JSON object
  38125. * @param serializationObject defines the JSON object
  38126. */
  38127. parse(serializationObject: any): void;
  38128. }
  38129. }
  38130. declare module BABYLON {
  38131. class CannonJSPlugin implements IPhysicsEnginePlugin {
  38132. private _useDeltaForWorldStep;
  38133. world: any;
  38134. name: string;
  38135. private _physicsMaterials;
  38136. private _fixedTimeStep;
  38137. BJSCANNON: any;
  38138. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  38139. setGravity(gravity: Vector3): void;
  38140. setTimeStep(timeStep: number): void;
  38141. getTimeStep(): number;
  38142. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38143. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38144. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38145. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38146. private _processChildMeshes;
  38147. removePhysicsBody(impostor: PhysicsImpostor): void;
  38148. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38149. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38150. private _addMaterial;
  38151. private _checkWithEpsilon;
  38152. private _createShape;
  38153. private _createHeightmap;
  38154. private _minus90X;
  38155. private _plus90X;
  38156. private _tmpPosition;
  38157. private _tmpDeltaPosition;
  38158. private _tmpUnityRotation;
  38159. private _updatePhysicsBodyTransformation;
  38160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38162. isSupported(): boolean;
  38163. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38164. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38165. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38166. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38167. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38168. getBodyMass(impostor: PhysicsImpostor): number;
  38169. getBodyFriction(impostor: PhysicsImpostor): number;
  38170. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38171. getBodyRestitution(impostor: PhysicsImpostor): number;
  38172. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38173. sleepBody(impostor: PhysicsImpostor): void;
  38174. wakeUpBody(impostor: PhysicsImpostor): void;
  38175. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38176. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  38177. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  38178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38179. getRadius(impostor: PhysicsImpostor): number;
  38180. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38181. dispose(): void;
  38182. private _extendNamespace;
  38183. }
  38184. }
  38185. declare module BABYLON {
  38186. class OimoJSPlugin implements IPhysicsEnginePlugin {
  38187. world: any;
  38188. name: string;
  38189. BJSOIMO: any;
  38190. constructor(iterations?: number);
  38191. setGravity(gravity: Vector3): void;
  38192. setTimeStep(timeStep: number): void;
  38193. getTimeStep(): number;
  38194. private _tmpImpostorsArray;
  38195. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38197. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38199. private _tmpPositionVector;
  38200. removePhysicsBody(impostor: PhysicsImpostor): void;
  38201. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38202. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38203. isSupported(): boolean;
  38204. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38205. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38206. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38207. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38208. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38209. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38210. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38211. getBodyMass(impostor: PhysicsImpostor): number;
  38212. getBodyFriction(impostor: PhysicsImpostor): number;
  38213. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38214. getBodyRestitution(impostor: PhysicsImpostor): number;
  38215. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38216. sleepBody(impostor: PhysicsImpostor): void;
  38217. wakeUpBody(impostor: PhysicsImpostor): void;
  38218. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38219. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  38220. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  38221. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38222. getRadius(impostor: PhysicsImpostor): number;
  38223. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38224. dispose(): void;
  38225. }
  38226. }
  38227. declare module BABYLON {
  38228. /**
  38229. * This represents a set of one or more post processes in Babylon.
  38230. * A post process can be used to apply a shader to a texture after it is rendered.
  38231. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38232. */
  38233. class PostProcessRenderEffect {
  38234. private _postProcesses;
  38235. private _getPostProcesses;
  38236. private _singleInstance;
  38237. private _cameras;
  38238. private _indicesForCamera;
  38239. /**
  38240. * Name of the effect
  38241. * @hidden
  38242. */
  38243. _name: string;
  38244. /**
  38245. * Instantiates a post process render effect.
  38246. * A post process can be used to apply a shader to a texture after it is rendered.
  38247. * @param engine The engine the effect is tied to
  38248. * @param name The name of the effect
  38249. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  38250. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  38251. */
  38252. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  38253. /**
  38254. * Checks if all the post processes in the effect are supported.
  38255. */
  38256. readonly isSupported: boolean;
  38257. /**
  38258. * Updates the current state of the effect
  38259. * @hidden
  38260. */
  38261. _update(): void;
  38262. /**
  38263. * Attaches the effect on cameras
  38264. * @param cameras The camera to attach to.
  38265. * @hidden
  38266. */
  38267. _attachCameras(cameras: Camera): void;
  38268. /**
  38269. * Attaches the effect on cameras
  38270. * @param cameras The camera to attach to.
  38271. * @hidden
  38272. */
  38273. _attachCameras(cameras: Camera[]): void;
  38274. /**
  38275. * Detatches the effect on cameras
  38276. * @param cameras The camera to detatch from.
  38277. * @hidden
  38278. */
  38279. _detachCameras(cameras: Camera): void;
  38280. /**
  38281. * Detatches the effect on cameras
  38282. * @param cameras The camera to detatch from.
  38283. * @hidden
  38284. */
  38285. _detachCameras(cameras: Camera[]): void;
  38286. /**
  38287. * Enables the effect on given cameras
  38288. * @param cameras The camera to enable.
  38289. * @hidden
  38290. */
  38291. _enable(cameras: Camera): void;
  38292. /**
  38293. * Enables the effect on given cameras
  38294. * @param cameras The camera to enable.
  38295. * @hidden
  38296. */
  38297. _enable(cameras: Nullable<Camera[]>): void;
  38298. /**
  38299. * Disables the effect on the given cameras
  38300. * @param cameras The camera to disable.
  38301. * @hidden
  38302. */
  38303. _disable(cameras: Camera): void;
  38304. /**
  38305. * Disables the effect on the given cameras
  38306. * @param cameras The camera to disable.
  38307. * @hidden
  38308. */
  38309. _disable(cameras: Nullable<Camera[]>): void;
  38310. /**
  38311. * Gets a list of the post processes contained in the effect.
  38312. * @param camera The camera to get the post processes on.
  38313. * @returns The list of the post processes in the effect.
  38314. */
  38315. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  38316. }
  38317. }
  38318. declare module BABYLON {
  38319. class PostProcessRenderPipeline {
  38320. private engine;
  38321. private _renderEffects;
  38322. private _renderEffectsForIsolatedPass;
  38323. protected _cameras: Camera[];
  38324. /** @hidden */
  38325. _name: string;
  38326. constructor(engine: Engine, name: string);
  38327. getClassName(): string;
  38328. readonly isSupported: boolean;
  38329. addEffect(renderEffect: PostProcessRenderEffect): void;
  38330. /** @hidden */
  38331. _rebuild(): void;
  38332. /** @hidden */
  38333. _enableEffect(renderEffectName: string, cameras: Camera): void;
  38334. /** @hidden */
  38335. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  38336. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38337. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38338. /** @hidden */
  38339. _attachCameras(cameras: Camera, unique: boolean): void;
  38340. /** @hidden */
  38341. _attachCameras(cameras: Camera[], unique: boolean): void;
  38342. /** @hidden */
  38343. _detachCameras(cameras: Camera): void;
  38344. /** @hidden */
  38345. _detachCameras(cameras: Nullable<Camera[]>): void;
  38346. /** @hidden */
  38347. _update(): void;
  38348. /** @hidden */
  38349. _reset(): void;
  38350. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  38351. dispose(): void;
  38352. }
  38353. }
  38354. declare module BABYLON {
  38355. class PostProcessRenderPipelineManager {
  38356. private _renderPipelines;
  38357. constructor();
  38358. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  38359. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  38360. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  38361. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  38362. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  38363. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38364. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38365. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38366. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38367. update(): void;
  38368. /** @hidden */
  38369. _rebuild(): void;
  38370. dispose(): void;
  38371. }
  38372. }
  38373. declare module BABYLON {
  38374. interface Scene {
  38375. /** @hidden (Backing field) */
  38376. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38377. /**
  38378. * Gets the postprocess render pipeline manager
  38379. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38380. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38381. */
  38382. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38383. }
  38384. /**
  38385. * Defines the Render Pipeline scene component responsible to rendering pipelines
  38386. */
  38387. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  38388. /**
  38389. * The component name helpfull to identify the component in the list of scene components.
  38390. */
  38391. readonly name: string;
  38392. /**
  38393. * The scene the component belongs to.
  38394. */
  38395. scene: Scene;
  38396. /**
  38397. * Creates a new instance of the component for the given scene
  38398. * @param scene Defines the scene to register the component in
  38399. */
  38400. constructor(scene: Scene);
  38401. /**
  38402. * Registers the component in a given scene
  38403. */
  38404. register(): void;
  38405. /**
  38406. * Rebuilds the elements related to this component in case of
  38407. * context lost for instance.
  38408. */
  38409. rebuild(): void;
  38410. /**
  38411. * Disposes the component and the associated ressources
  38412. */
  38413. dispose(): void;
  38414. private _gatherRenderTargets;
  38415. private _rebuildGeometry;
  38416. }
  38417. }
  38418. declare module BABYLON {
  38419. /**
  38420. * Helper class dealing with the extraction of spherical polynomial dataArray
  38421. * from a cube map.
  38422. */
  38423. class CubeMapToSphericalPolynomialTools {
  38424. private static FileFaces;
  38425. /**
  38426. * Converts a texture to the according Spherical Polynomial data.
  38427. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38428. *
  38429. * @param texture The texture to extract the information from.
  38430. * @return The Spherical Polynomial data.
  38431. */
  38432. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  38433. /**
  38434. * Converts a cubemap to the according Spherical Polynomial data.
  38435. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38436. *
  38437. * @param cubeInfo The Cube map to extract the information from.
  38438. * @return The Spherical Polynomial data.
  38439. */
  38440. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Header information of HDR texture files.
  38446. */
  38447. interface HDRInfo {
  38448. /**
  38449. * The height of the texture in pixels.
  38450. */
  38451. height: number;
  38452. /**
  38453. * The width of the texture in pixels.
  38454. */
  38455. width: number;
  38456. /**
  38457. * The index of the beginning of the data in the binary file.
  38458. */
  38459. dataPosition: number;
  38460. }
  38461. /**
  38462. * This groups tools to convert HDR texture to native colors array.
  38463. */
  38464. class HDRTools {
  38465. private static Ldexp;
  38466. private static Rgbe2float;
  38467. private static readStringLine;
  38468. /**
  38469. * Reads header information from an RGBE texture stored in a native array.
  38470. * More information on this format are available here:
  38471. * https://en.wikipedia.org/wiki/RGBE_image_format
  38472. *
  38473. * @param uint8array The binary file stored in native array.
  38474. * @return The header information.
  38475. */
  38476. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  38477. /**
  38478. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  38479. * This RGBE texture needs to store the information as a panorama.
  38480. *
  38481. * More information on this format are available here:
  38482. * https://en.wikipedia.org/wiki/RGBE_image_format
  38483. *
  38484. * @param buffer The binary file stored in an array buffer.
  38485. * @param size The expected size of the extracted cubemap.
  38486. * @return The Cube Map information.
  38487. */
  38488. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  38489. /**
  38490. * Returns the pixels data extracted from an RGBE texture.
  38491. * This pixels will be stored left to right up to down in the R G B order in one array.
  38492. *
  38493. * More information on this format are available here:
  38494. * https://en.wikipedia.org/wiki/RGBE_image_format
  38495. *
  38496. * @param uint8array The binary file stored in an array buffer.
  38497. * @param hdrInfo The header information of the file.
  38498. * @return The pixels data in RGB right to left up to down order.
  38499. */
  38500. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  38501. private static RGBE_ReadPixels_RLE;
  38502. }
  38503. }
  38504. declare module BABYLON {
  38505. /**
  38506. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  38507. */
  38508. interface CubeMapInfo {
  38509. /**
  38510. * The pixel array for the front face.
  38511. * This is stored in format, left to right, up to down format.
  38512. */
  38513. front: Nullable<ArrayBufferView>;
  38514. /**
  38515. * The pixel array for the back face.
  38516. * This is stored in format, left to right, up to down format.
  38517. */
  38518. back: Nullable<ArrayBufferView>;
  38519. /**
  38520. * The pixel array for the left face.
  38521. * This is stored in format, left to right, up to down format.
  38522. */
  38523. left: Nullable<ArrayBufferView>;
  38524. /**
  38525. * The pixel array for the right face.
  38526. * This is stored in format, left to right, up to down format.
  38527. */
  38528. right: Nullable<ArrayBufferView>;
  38529. /**
  38530. * The pixel array for the up face.
  38531. * This is stored in format, left to right, up to down format.
  38532. */
  38533. up: Nullable<ArrayBufferView>;
  38534. /**
  38535. * The pixel array for the down face.
  38536. * This is stored in format, left to right, up to down format.
  38537. */
  38538. down: Nullable<ArrayBufferView>;
  38539. /**
  38540. * The size of the cubemap stored.
  38541. *
  38542. * Each faces will be size * size pixels.
  38543. */
  38544. size: number;
  38545. /**
  38546. * The format of the texture.
  38547. *
  38548. * RGBA, RGB.
  38549. */
  38550. format: number;
  38551. /**
  38552. * The type of the texture data.
  38553. *
  38554. * UNSIGNED_INT, FLOAT.
  38555. */
  38556. type: number;
  38557. /**
  38558. * Specifies whether the texture is in gamma space.
  38559. */
  38560. gammaSpace: boolean;
  38561. }
  38562. /**
  38563. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  38564. */
  38565. class PanoramaToCubeMapTools {
  38566. private static FACE_FRONT;
  38567. private static FACE_BACK;
  38568. private static FACE_RIGHT;
  38569. private static FACE_LEFT;
  38570. private static FACE_DOWN;
  38571. private static FACE_UP;
  38572. /**
  38573. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  38574. *
  38575. * @param float32Array The source data.
  38576. * @param inputWidth The width of the input panorama.
  38577. * @param inputhHeight The height of the input panorama.
  38578. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  38579. * @return The cubemap data
  38580. */
  38581. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  38582. private static CreateCubemapTexture;
  38583. private static CalcProjectionSpherical;
  38584. }
  38585. }
  38586. declare module BABYLON {
  38587. class CustomProceduralTexture extends ProceduralTexture {
  38588. private _animate;
  38589. private _time;
  38590. private _config;
  38591. private _texturePath;
  38592. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38593. private loadJson;
  38594. isReady(): boolean;
  38595. render(useCameraPostProcess?: boolean): void;
  38596. updateTextures(): void;
  38597. updateShaderUniforms(): void;
  38598. animate: boolean;
  38599. }
  38600. }
  38601. declare module BABYLON {
  38602. /**
  38603. * Class used to generate noise procedural textures
  38604. */
  38605. class NoiseProceduralTexture extends ProceduralTexture {
  38606. private _time;
  38607. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  38608. brightness: number;
  38609. /** Defines the number of octaves to process */
  38610. octaves: number;
  38611. /** Defines the level of persistence (0.8 by default) */
  38612. persistence: number;
  38613. /** Gets or sets animation speed factor (default is 1) */
  38614. animationSpeedFactor: number;
  38615. /**
  38616. * Creates a new NoiseProceduralTexture
  38617. * @param name defines the name fo the texture
  38618. * @param size defines the size of the texture (default is 256)
  38619. * @param scene defines the hosting scene
  38620. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  38621. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  38622. */
  38623. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38624. private _updateShaderUniforms;
  38625. /** Generate the current state of the procedural texture */
  38626. render(useCameraPostProcess?: boolean): void;
  38627. /**
  38628. * Serializes this noise procedural texture
  38629. * @returns a serialized noise procedural texture object
  38630. */
  38631. serialize(): any;
  38632. /**
  38633. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  38634. * @param parsedTexture defines parsed texture data
  38635. * @param scene defines the current scene
  38636. * @param rootUrl defines the root URL containing noise procedural texture information
  38637. * @returns a parsed NoiseProceduralTexture
  38638. */
  38639. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  38640. }
  38641. }
  38642. declare module BABYLON {
  38643. class ProceduralTexture extends Texture {
  38644. isCube: boolean;
  38645. private _size;
  38646. /** @hidden */
  38647. _generateMipMaps: boolean;
  38648. isEnabled: boolean;
  38649. private _currentRefreshId;
  38650. private _refreshRate;
  38651. onGenerated: () => void;
  38652. private _vertexBuffers;
  38653. private _indexBuffer;
  38654. private _effect;
  38655. private _uniforms;
  38656. private _samplers;
  38657. private _fragment;
  38658. /** @hidden */
  38659. _textures: {
  38660. [key: string]: Texture;
  38661. };
  38662. private _floats;
  38663. private _ints;
  38664. private _floatsArrays;
  38665. private _colors3;
  38666. private _colors4;
  38667. private _vectors2;
  38668. private _vectors3;
  38669. private _matrices;
  38670. private _fallbackTexture;
  38671. private _fallbackTextureUsed;
  38672. private _engine;
  38673. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  38674. private _createIndexBuffer;
  38675. /** @hidden */
  38676. _rebuild(): void;
  38677. reset(): void;
  38678. isReady(): boolean;
  38679. resetRefreshCounter(): void;
  38680. setFragment(fragment: any): void;
  38681. refreshRate: number;
  38682. /** @hidden */
  38683. _shouldRender(): boolean;
  38684. getRenderSize(): number;
  38685. resize(size: number, generateMipMaps: boolean): void;
  38686. private _checkUniform;
  38687. setTexture(name: string, texture: Texture): ProceduralTexture;
  38688. setFloat(name: string, value: number): ProceduralTexture;
  38689. /**
  38690. * Set the value of an uniform to an integer value
  38691. * @param name defines the name of the uniform
  38692. * @param value defines the value to set
  38693. * @returns the current procedural texture
  38694. */
  38695. setInt(name: string, value: number): ProceduralTexture;
  38696. setFloats(name: string, value: number[]): ProceduralTexture;
  38697. setColor3(name: string, value: Color3): ProceduralTexture;
  38698. setColor4(name: string, value: Color4): ProceduralTexture;
  38699. setVector2(name: string, value: Vector2): ProceduralTexture;
  38700. setVector3(name: string, value: Vector3): ProceduralTexture;
  38701. setMatrix(name: string, value: Matrix): ProceduralTexture;
  38702. render(useCameraPostProcess?: boolean): void;
  38703. clone(): ProceduralTexture;
  38704. dispose(): void;
  38705. }
  38706. }
  38707. declare module BABYLON {
  38708. }
  38709. declare module BABYLON {
  38710. }
  38711. declare module BABYLON {
  38712. }
  38713. declare module BABYLON {
  38714. }
  38715. declare module BABYLON {
  38716. /**
  38717. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  38718. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38719. */
  38720. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  38721. private _scene;
  38722. private _camerasToBeAttached;
  38723. /**
  38724. * ID of the sharpen post process,
  38725. */
  38726. private readonly SharpenPostProcessId;
  38727. /**
  38728. * ID of the image processing post process;
  38729. */
  38730. readonly ImageProcessingPostProcessId: string;
  38731. /**
  38732. * ID of the Fast Approximate Anti-Aliasing post process;
  38733. */
  38734. readonly FxaaPostProcessId: string;
  38735. /**
  38736. * ID of the chromatic aberration post process,
  38737. */
  38738. private readonly ChromaticAberrationPostProcessId;
  38739. /**
  38740. * ID of the grain post process
  38741. */
  38742. private readonly GrainPostProcessId;
  38743. /**
  38744. * Sharpen post process which will apply a sharpen convolution to enhance edges
  38745. */
  38746. sharpen: SharpenPostProcess;
  38747. private _sharpenEffect;
  38748. private bloom;
  38749. /**
  38750. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  38751. */
  38752. depthOfField: DepthOfFieldEffect;
  38753. /**
  38754. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  38755. */
  38756. fxaa: FxaaPostProcess;
  38757. /**
  38758. * Image post processing pass used to perform operations such as tone mapping or color grading.
  38759. */
  38760. imageProcessing: ImageProcessingPostProcess;
  38761. /**
  38762. * Chromatic aberration post process which will shift rgb colors in the image
  38763. */
  38764. chromaticAberration: ChromaticAberrationPostProcess;
  38765. private _chromaticAberrationEffect;
  38766. /**
  38767. * Grain post process which add noise to the image
  38768. */
  38769. grain: GrainPostProcess;
  38770. private _grainEffect;
  38771. /**
  38772. * Glow post process which adds a glow to emmisive areas of the image
  38773. */
  38774. private _glowLayer;
  38775. /**
  38776. * Animations which can be used to tweak settings over a period of time
  38777. */
  38778. animations: Animation[];
  38779. private _imageProcessingConfigurationObserver;
  38780. private _sharpenEnabled;
  38781. private _bloomEnabled;
  38782. private _depthOfFieldEnabled;
  38783. private _depthOfFieldBlurLevel;
  38784. private _fxaaEnabled;
  38785. private _imageProcessingEnabled;
  38786. private _defaultPipelineTextureType;
  38787. private _bloomScale;
  38788. private _chromaticAberrationEnabled;
  38789. private _grainEnabled;
  38790. private _buildAllowed;
  38791. /**
  38792. * Enable or disable the sharpen process from the pipeline
  38793. */
  38794. sharpenEnabled: boolean;
  38795. private _resizeObserver;
  38796. private _hardwareScaleLevel;
  38797. private _bloomKernel;
  38798. /**
  38799. * Specifies the size of the bloom blur kernel, relative to the final output size
  38800. */
  38801. bloomKernel: number;
  38802. /**
  38803. * Specifies the weight of the bloom in the final rendering
  38804. */
  38805. private _bloomWeight;
  38806. /**
  38807. * Specifies the luma threshold for the area that will be blurred by the bloom
  38808. */
  38809. private _bloomThreshold;
  38810. private _hdr;
  38811. /**
  38812. * The strength of the bloom.
  38813. */
  38814. bloomWeight: number;
  38815. /**
  38816. * The strength of the bloom.
  38817. */
  38818. bloomThreshold: number;
  38819. /**
  38820. * The scale of the bloom, lower value will provide better performance.
  38821. */
  38822. bloomScale: number;
  38823. /**
  38824. * Enable or disable the bloom from the pipeline
  38825. */
  38826. bloomEnabled: boolean;
  38827. private _rebuildBloom;
  38828. /**
  38829. * If the depth of field is enabled.
  38830. */
  38831. depthOfFieldEnabled: boolean;
  38832. /**
  38833. * Blur level of the depth of field effect. (Higher blur will effect performance)
  38834. */
  38835. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  38836. /**
  38837. * If the anti aliasing is enabled.
  38838. */
  38839. fxaaEnabled: boolean;
  38840. private _samples;
  38841. /**
  38842. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  38843. */
  38844. samples: number;
  38845. /**
  38846. * If image processing is enabled.
  38847. */
  38848. imageProcessingEnabled: boolean;
  38849. /**
  38850. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  38851. */
  38852. glowLayerEnabled: boolean;
  38853. /**
  38854. * Enable or disable the chromaticAberration process from the pipeline
  38855. */
  38856. chromaticAberrationEnabled: boolean;
  38857. /**
  38858. * Enable or disable the grain process from the pipeline
  38859. */
  38860. grainEnabled: boolean;
  38861. /**
  38862. * @constructor
  38863. * @param {string} name - The rendering pipeline name (default: "")
  38864. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  38865. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  38866. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  38867. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  38868. */
  38869. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  38870. /**
  38871. * Force the compilation of the entire pipeline.
  38872. */
  38873. prepare(): void;
  38874. private _hasCleared;
  38875. private _prevPostProcess;
  38876. private _prevPrevPostProcess;
  38877. private _setAutoClearAndTextureSharing;
  38878. private _buildPipeline;
  38879. private _disposePostProcesses;
  38880. /**
  38881. * Adds a camera to the pipeline
  38882. * @param camera the camera to be added
  38883. */
  38884. addCamera(camera: Camera): void;
  38885. /**
  38886. * Removes a camera from the pipeline
  38887. * @param camera the camera to remove
  38888. */
  38889. removeCamera(camera: Camera): void;
  38890. /**
  38891. * Dispose of the pipeline and stop all post processes
  38892. */
  38893. dispose(): void;
  38894. /**
  38895. * Serialize the rendering pipeline (Used when exporting)
  38896. * @returns the serialized object
  38897. */
  38898. serialize(): any;
  38899. /**
  38900. * Parse the serialized pipeline
  38901. * @param source Source pipeline.
  38902. * @param scene The scene to load the pipeline to.
  38903. * @param rootUrl The URL of the serialized pipeline.
  38904. * @returns An instantiated pipeline from the serialized object.
  38905. */
  38906. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  38907. }
  38908. }
  38909. declare module BABYLON {
  38910. class LensRenderingPipeline extends PostProcessRenderPipeline {
  38911. /**
  38912. * The chromatic aberration PostProcess id in the pipeline
  38913. */
  38914. LensChromaticAberrationEffect: string;
  38915. /**
  38916. * The highlights enhancing PostProcess id in the pipeline
  38917. */
  38918. HighlightsEnhancingEffect: string;
  38919. /**
  38920. * The depth-of-field PostProcess id in the pipeline
  38921. */
  38922. LensDepthOfFieldEffect: string;
  38923. private _scene;
  38924. private _depthTexture;
  38925. private _grainTexture;
  38926. private _chromaticAberrationPostProcess;
  38927. private _highlightsPostProcess;
  38928. private _depthOfFieldPostProcess;
  38929. private _edgeBlur;
  38930. private _grainAmount;
  38931. private _chromaticAberration;
  38932. private _distortion;
  38933. private _highlightsGain;
  38934. private _highlightsThreshold;
  38935. private _dofDistance;
  38936. private _dofAperture;
  38937. private _dofDarken;
  38938. private _dofPentagon;
  38939. private _blurNoise;
  38940. /**
  38941. * @constructor
  38942. *
  38943. * Effect parameters are as follow:
  38944. * {
  38945. * chromatic_aberration: number; // from 0 to x (1 for realism)
  38946. * edge_blur: number; // from 0 to x (1 for realism)
  38947. * distortion: number; // from 0 to x (1 for realism)
  38948. * grain_amount: number; // from 0 to 1
  38949. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  38950. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  38951. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  38952. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  38953. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  38954. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  38955. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  38956. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  38957. * }
  38958. * Note: if an effect parameter is unset, effect is disabled
  38959. *
  38960. * @param {string} name - The rendering pipeline name
  38961. * @param {object} parameters - An object containing all parameters (see above)
  38962. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38963. * @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)
  38964. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38965. */
  38966. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  38967. setEdgeBlur(amount: number): void;
  38968. disableEdgeBlur(): void;
  38969. setGrainAmount(amount: number): void;
  38970. disableGrain(): void;
  38971. setChromaticAberration(amount: number): void;
  38972. disableChromaticAberration(): void;
  38973. setEdgeDistortion(amount: number): void;
  38974. disableEdgeDistortion(): void;
  38975. setFocusDistance(amount: number): void;
  38976. disableDepthOfField(): void;
  38977. setAperture(amount: number): void;
  38978. setDarkenOutOfFocus(amount: number): void;
  38979. enablePentagonBokeh(): void;
  38980. disablePentagonBokeh(): void;
  38981. enableNoiseBlur(): void;
  38982. disableNoiseBlur(): void;
  38983. setHighlightsGain(amount: number): void;
  38984. setHighlightsThreshold(amount: number): void;
  38985. disableHighlights(): void;
  38986. /**
  38987. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  38988. */
  38989. dispose(disableDepthRender?: boolean): void;
  38990. private _createChromaticAberrationPostProcess;
  38991. private _createHighlightsPostProcess;
  38992. private _createDepthOfFieldPostProcess;
  38993. private _createGrainTexture;
  38994. }
  38995. }
  38996. declare module BABYLON {
  38997. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  38998. /**
  38999. * The PassPostProcess id in the pipeline that contains the original scene color
  39000. */
  39001. SSAOOriginalSceneColorEffect: string;
  39002. /**
  39003. * The SSAO PostProcess id in the pipeline
  39004. */
  39005. SSAORenderEffect: string;
  39006. /**
  39007. * The horizontal blur PostProcess id in the pipeline
  39008. */
  39009. SSAOBlurHRenderEffect: string;
  39010. /**
  39011. * The vertical blur PostProcess id in the pipeline
  39012. */
  39013. SSAOBlurVRenderEffect: string;
  39014. /**
  39015. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39016. */
  39017. SSAOCombineRenderEffect: string;
  39018. /**
  39019. * The output strength of the SSAO post-process. Default value is 1.0.
  39020. */
  39021. totalStrength: number;
  39022. /**
  39023. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  39024. */
  39025. maxZ: number;
  39026. /**
  39027. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  39028. */
  39029. minZAspect: number;
  39030. private _samples;
  39031. /**
  39032. * Number of samples used for the SSAO calculations. Default value is 8
  39033. */
  39034. samples: number;
  39035. private _textureSamples;
  39036. /**
  39037. * Number of samples to use for antialiasing
  39038. */
  39039. textureSamples: number;
  39040. /**
  39041. * Ratio object used for SSAO ratio and blur ratio
  39042. */
  39043. private _ratio;
  39044. /**
  39045. * Dynamically generated sphere sampler.
  39046. */
  39047. private _sampleSphere;
  39048. /**
  39049. * Blur filter offsets
  39050. */
  39051. private _samplerOffsets;
  39052. /**
  39053. * Are we using bilateral blur ?
  39054. */
  39055. private _expensiveBlur;
  39056. expensiveBlur: boolean;
  39057. /**
  39058. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  39059. */
  39060. radius: number;
  39061. /**
  39062. * The base color of the SSAO post-process
  39063. * The final result is "base + ssao" between [0, 1]
  39064. */
  39065. base: number;
  39066. /**
  39067. * Support test.
  39068. */
  39069. static readonly IsSupported: boolean;
  39070. private _scene;
  39071. private _depthTexture;
  39072. private _normalTexture;
  39073. private _randomTexture;
  39074. private _originalColorPostProcess;
  39075. private _ssaoPostProcess;
  39076. private _blurHPostProcess;
  39077. private _blurVPostProcess;
  39078. private _ssaoCombinePostProcess;
  39079. private _firstUpdate;
  39080. /**
  39081. * @constructor
  39082. * @param {string} name - The rendering pipeline name
  39083. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39084. * @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 }
  39085. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39086. */
  39087. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39088. /**
  39089. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39090. */
  39091. dispose(disableGeometryBufferRenderer?: boolean): void;
  39092. private _createBlurPostProcess;
  39093. /** @hidden */
  39094. _rebuild(): void;
  39095. private _bits;
  39096. private _radicalInverse_VdC;
  39097. private _hammersley;
  39098. private _hemisphereSample_uniform;
  39099. private _generateHemisphere;
  39100. private _createSSAOPostProcess;
  39101. private _createSSAOCombinePostProcess;
  39102. private _createRandomTexture;
  39103. /**
  39104. * Serialize the rendering pipeline (Used when exporting)
  39105. * @returns the serialized object
  39106. */
  39107. serialize(): any;
  39108. /**
  39109. * Parse the serialized pipeline
  39110. * @param source Source pipeline.
  39111. * @param scene The scene to load the pipeline to.
  39112. * @param rootUrl The URL of the serialized pipeline.
  39113. * @returns An instantiated pipeline from the serialized object.
  39114. */
  39115. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  39116. }
  39117. }
  39118. declare module BABYLON {
  39119. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  39120. /**
  39121. * The PassPostProcess id in the pipeline that contains the original scene color
  39122. */
  39123. SSAOOriginalSceneColorEffect: string;
  39124. /**
  39125. * The SSAO PostProcess id in the pipeline
  39126. */
  39127. SSAORenderEffect: string;
  39128. /**
  39129. * The horizontal blur PostProcess id in the pipeline
  39130. */
  39131. SSAOBlurHRenderEffect: string;
  39132. /**
  39133. * The vertical blur PostProcess id in the pipeline
  39134. */
  39135. SSAOBlurVRenderEffect: string;
  39136. /**
  39137. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39138. */
  39139. SSAOCombineRenderEffect: string;
  39140. /**
  39141. * The output strength of the SSAO post-process. Default value is 1.0.
  39142. */
  39143. totalStrength: number;
  39144. /**
  39145. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  39146. */
  39147. radius: number;
  39148. /**
  39149. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  39150. * Must not be equal to fallOff and superior to fallOff.
  39151. * Default value is 0.975
  39152. */
  39153. area: number;
  39154. /**
  39155. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  39156. * Must not be equal to area and inferior to area.
  39157. * Default value is 0.0
  39158. */
  39159. fallOff: number;
  39160. /**
  39161. * The base color of the SSAO post-process
  39162. * The final result is "base + ssao" between [0, 1]
  39163. */
  39164. base: number;
  39165. private _scene;
  39166. private _depthTexture;
  39167. private _randomTexture;
  39168. private _originalColorPostProcess;
  39169. private _ssaoPostProcess;
  39170. private _blurHPostProcess;
  39171. private _blurVPostProcess;
  39172. private _ssaoCombinePostProcess;
  39173. private _firstUpdate;
  39174. /**
  39175. * @constructor
  39176. * @param {string} name - The rendering pipeline name
  39177. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39178. * @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 }
  39179. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39180. */
  39181. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39182. /**
  39183. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39184. */
  39185. dispose(disableDepthRender?: boolean): void;
  39186. private _createBlurPostProcess;
  39187. /** @hidden */
  39188. _rebuild(): void;
  39189. private _createSSAOPostProcess;
  39190. private _createSSAOCombinePostProcess;
  39191. private _createRandomTexture;
  39192. }
  39193. }
  39194. declare module BABYLON {
  39195. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39196. /**
  39197. * Public members
  39198. */
  39199. originalPostProcess: Nullable<PostProcess>;
  39200. downSampleX4PostProcess: Nullable<PostProcess>;
  39201. brightPassPostProcess: Nullable<PostProcess>;
  39202. blurHPostProcesses: PostProcess[];
  39203. blurVPostProcesses: PostProcess[];
  39204. textureAdderPostProcess: Nullable<PostProcess>;
  39205. volumetricLightPostProcess: Nullable<PostProcess>;
  39206. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  39207. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  39208. volumetricLightMergePostProces: Nullable<PostProcess>;
  39209. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  39210. luminancePostProcess: Nullable<PostProcess>;
  39211. luminanceDownSamplePostProcesses: PostProcess[];
  39212. hdrPostProcess: Nullable<PostProcess>;
  39213. textureAdderFinalPostProcess: Nullable<PostProcess>;
  39214. lensFlareFinalPostProcess: Nullable<PostProcess>;
  39215. hdrFinalPostProcess: Nullable<PostProcess>;
  39216. lensFlarePostProcess: Nullable<PostProcess>;
  39217. lensFlareComposePostProcess: Nullable<PostProcess>;
  39218. motionBlurPostProcess: Nullable<PostProcess>;
  39219. depthOfFieldPostProcess: Nullable<PostProcess>;
  39220. brightThreshold: number;
  39221. blurWidth: number;
  39222. horizontalBlur: boolean;
  39223. exposure: number;
  39224. lensTexture: Nullable<Texture>;
  39225. volumetricLightCoefficient: number;
  39226. volumetricLightPower: number;
  39227. volumetricLightBlurScale: number;
  39228. sourceLight: Nullable<SpotLight | DirectionalLight>;
  39229. hdrMinimumLuminance: number;
  39230. hdrDecreaseRate: number;
  39231. hdrIncreaseRate: number;
  39232. lensColorTexture: Nullable<Texture>;
  39233. lensFlareStrength: number;
  39234. lensFlareGhostDispersal: number;
  39235. lensFlareHaloWidth: number;
  39236. lensFlareDistortionStrength: number;
  39237. lensStarTexture: Nullable<Texture>;
  39238. lensFlareDirtTexture: Nullable<Texture>;
  39239. depthOfFieldDistance: number;
  39240. depthOfFieldBlurWidth: number;
  39241. motionStrength: number;
  39242. animations: Animation[];
  39243. /**
  39244. * Private members
  39245. */
  39246. private _scene;
  39247. private _currentDepthOfFieldSource;
  39248. private _basePostProcess;
  39249. private _hdrCurrentLuminance;
  39250. private _floatTextureType;
  39251. private _ratio;
  39252. private _bloomEnabled;
  39253. private _depthOfFieldEnabled;
  39254. private _vlsEnabled;
  39255. private _lensFlareEnabled;
  39256. private _hdrEnabled;
  39257. private _motionBlurEnabled;
  39258. private _motionBlurSamples;
  39259. private _volumetricLightStepsCount;
  39260. BloomEnabled: boolean;
  39261. DepthOfFieldEnabled: boolean;
  39262. LensFlareEnabled: boolean;
  39263. HDREnabled: boolean;
  39264. VLSEnabled: boolean;
  39265. MotionBlurEnabled: boolean;
  39266. volumetricLightStepsCount: number;
  39267. motionBlurSamples: number;
  39268. /**
  39269. * @constructor
  39270. * @param {string} name - The rendering pipeline name
  39271. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39272. * @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)
  39273. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  39274. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39275. */
  39276. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  39277. private _buildPipeline;
  39278. private _createDownSampleX4PostProcess;
  39279. private _createBrightPassPostProcess;
  39280. private _createBlurPostProcesses;
  39281. private _createTextureAdderPostProcess;
  39282. private _createVolumetricLightPostProcess;
  39283. private _createLuminancePostProcesses;
  39284. private _createHdrPostProcess;
  39285. private _createLensFlarePostProcess;
  39286. private _createDepthOfFieldPostProcess;
  39287. private _createMotionBlurPostProcess;
  39288. private _getDepthTexture;
  39289. private _disposePostProcesses;
  39290. /**
  39291. * Dispose of the pipeline and stop all post processes
  39292. */
  39293. dispose(): void;
  39294. /**
  39295. * Serialize the rendering pipeline (Used when exporting)
  39296. * @returns the serialized object
  39297. */
  39298. serialize(): any;
  39299. /**
  39300. * Parse the serialized pipeline
  39301. * @param source Source pipeline.
  39302. * @param scene The scene to load the pipeline to.
  39303. * @param rootUrl The URL of the serialized pipeline.
  39304. * @returns An instantiated pipeline from the serialized object.
  39305. */
  39306. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  39307. static LuminanceSteps: number;
  39308. }
  39309. }