babylon.d.ts 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038
  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. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Sounds to keep.
  127. */
  128. sounds: Sound[];
  129. /**
  130. * Textures to keep.
  131. */
  132. textures: BaseTexture[];
  133. }
  134. }
  135. declare module BABYLON {
  136. /**
  137. * Set of assets to keep when moving a scene into an asset container.
  138. */
  139. class KeepAssets extends AbstractScene {
  140. }
  141. /**
  142. * Container with a set of assets that can be added or removed from a scene.
  143. */
  144. class AssetContainer extends AbstractScene {
  145. /**
  146. * The scene the AssetContainer belongs to.
  147. */
  148. scene: Scene;
  149. /**
  150. * Instantiates an AssetContainer.
  151. * @param scene The scene the AssetContainer belongs to.
  152. */
  153. constructor(scene: Scene);
  154. /**
  155. * Adds all the assets from the container to the scene.
  156. */
  157. addAllToScene(): void;
  158. /**
  159. * Removes all the assets in the container from the scene
  160. */
  161. removeAllFromScene(): void;
  162. private _moveAssets;
  163. /**
  164. * Removes all the assets contained in the scene and adds them to the container.
  165. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  166. */
  167. moveAllFromScene(keepAssets?: KeepAssets): void;
  168. /**
  169. * 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.
  170. * @returns the root mesh
  171. */
  172. createRootMesh(): Mesh;
  173. }
  174. }
  175. interface Window {
  176. mozIndexedDB: IDBFactory;
  177. webkitIndexedDB: IDBFactory;
  178. msIndexedDB: IDBFactory;
  179. webkitURL: typeof URL;
  180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  182. WebGLRenderingContext: WebGLRenderingContext;
  183. MSGesture: MSGesture;
  184. CANNON: any;
  185. AudioContext: AudioContext;
  186. webkitAudioContext: AudioContext;
  187. PointerEvent: any;
  188. Math: Math;
  189. Uint8Array: Uint8ArrayConstructor;
  190. Float32Array: Float32ArrayConstructor;
  191. mozURL: typeof URL;
  192. msURL: typeof URL;
  193. VRFrameData: any;
  194. DracoDecoderModule: any;
  195. }
  196. interface WebGLRenderingContext {
  197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  199. vertexAttribDivisor(index: number, divisor: number): void;
  200. createVertexArray(): any;
  201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  204. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  208. createQuery(): WebGLQuery;
  209. deleteQuery(query: WebGLQuery): void;
  210. beginQuery(target: number, query: WebGLQuery): void;
  211. endQuery(target: number): void;
  212. getQueryParameter(query: WebGLQuery, pname: number): any;
  213. getQuery(target: number, pname: number): any;
  214. MAX_SAMPLES: number;
  215. RGBA8: number;
  216. READ_FRAMEBUFFER: number;
  217. DRAW_FRAMEBUFFER: number;
  218. UNIFORM_BUFFER: number;
  219. HALF_FLOAT_OES: number;
  220. RGBA16F: number;
  221. RGBA32F: number;
  222. R32F: number;
  223. RG32F: number;
  224. RGB32F: number;
  225. R16F: number;
  226. RG16F: number;
  227. RGB16F: number;
  228. RED: number;
  229. RG: number;
  230. R8: number;
  231. RG8: number;
  232. UNSIGNED_INT_24_8: number;
  233. DEPTH24_STENCIL8: number;
  234. drawBuffers(buffers: number[]): void;
  235. readBuffer(src: number): void;
  236. readonly COLOR_ATTACHMENT0: number;
  237. readonly COLOR_ATTACHMENT1: number;
  238. readonly COLOR_ATTACHMENT2: number;
  239. readonly COLOR_ATTACHMENT3: number;
  240. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  241. ANY_SAMPLES_PASSED: number;
  242. QUERY_RESULT_AVAILABLE: number;
  243. QUERY_RESULT: number;
  244. }
  245. interface Document {
  246. mozCancelFullScreen(): void;
  247. msCancelFullScreen(): void;
  248. mozFullScreen: boolean;
  249. msIsFullScreen: boolean;
  250. fullscreen: boolean;
  251. mozPointerLockElement: HTMLElement;
  252. msPointerLockElement: HTMLElement;
  253. webkitPointerLockElement: HTMLElement;
  254. }
  255. interface HTMLCanvasElement {
  256. msRequestPointerLock?(): void;
  257. mozRequestPointerLock?(): void;
  258. webkitRequestPointerLock?(): void;
  259. }
  260. interface CanvasRenderingContext2D {
  261. msImageSmoothingEnabled: boolean;
  262. }
  263. interface WebGLBuffer {
  264. references: number;
  265. capacity: number;
  266. is32Bits: boolean;
  267. }
  268. interface WebGLProgram {
  269. transformFeedback?: WebGLTransformFeedback | null;
  270. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  271. }
  272. interface MouseEvent {
  273. mozMovementX: number;
  274. mozMovementY: number;
  275. webkitMovementX: number;
  276. webkitMovementY: number;
  277. msMovementX: number;
  278. msMovementY: number;
  279. }
  280. interface Navigator {
  281. mozGetVRDevices: (any: any) => any;
  282. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  283. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  284. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  285. webkitGetGamepads(): Gamepad[];
  286. msGetGamepads(): Gamepad[];
  287. webkitGamepads(): Gamepad[];
  288. }
  289. interface HTMLVideoElement {
  290. mozSrcObject: any;
  291. }
  292. interface Screen {
  293. orientation: string;
  294. mozOrientation: string;
  295. }
  296. interface Math {
  297. fround(x: number): number;
  298. imul(a: number, b: number): number;
  299. }
  300. interface EXT_disjoint_timer_query {
  301. QUERY_COUNTER_BITS_EXT: number;
  302. TIME_ELAPSED_EXT: number;
  303. TIMESTAMP_EXT: number;
  304. GPU_DISJOINT_EXT: number;
  305. QUERY_RESULT_EXT: number;
  306. QUERY_RESULT_AVAILABLE_EXT: number;
  307. queryCounterEXT(query: WebGLQuery, target: number): void;
  308. createQueryEXT(): WebGLQuery;
  309. beginQueryEXT(target: number, query: WebGLQuery): void;
  310. endQueryEXT(target: number): void;
  311. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  312. deleteQueryEXT(query: WebGLQuery): void;
  313. }
  314. interface WebGLUniformLocation {
  315. _currentState: any;
  316. }
  317. declare module BABYLON {
  318. /**
  319. * Defines how a node can be built from a string name.
  320. */
  321. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  322. /**
  323. * Node is the basic class for all scene objects (Mesh, Light Camera).
  324. */
  325. class Node implements IBehaviorAware<Node> {
  326. private static _NodeConstructors;
  327. /**
  328. * Add a new node constructor
  329. * @param type defines the type name of the node to construct
  330. * @param constructorFunc defines the constructor function
  331. */
  332. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  333. /**
  334. * Returns a node constructor based on type name
  335. * @param type defines the type name
  336. * @param name defines the new node name
  337. * @param scene defines the hosting scene
  338. * @param options defines optional options to transmit to constructors
  339. * @returns the new constructor or null
  340. */
  341. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  342. /**
  343. * Gets or sets the name of the node
  344. */
  345. name: string;
  346. /**
  347. * Gets or sets the id of the node
  348. */
  349. id: string;
  350. /**
  351. * Gets or sets the unique id of the node
  352. */
  353. uniqueId: number;
  354. /**
  355. * Gets or sets a string used to store user defined state for the node
  356. */
  357. state: string;
  358. /**
  359. * Gets or sets an object used to store user defined information for the node
  360. */
  361. metadata: any;
  362. /**
  363. * Gets or sets a boolean used to define if the node must be serialized
  364. */
  365. doNotSerialize: boolean;
  366. /** @hidden */
  367. _isDisposed: boolean;
  368. /**
  369. * Gets a list of Animations associated with the node
  370. */
  371. animations: Animation[];
  372. protected _ranges: {
  373. [name: string]: Nullable<AnimationRange>;
  374. };
  375. /**
  376. * Callback raised when the node is ready to be used
  377. */
  378. onReady: (node: Node) => void;
  379. private _isEnabled;
  380. private _isReady;
  381. /** @hidden */
  382. _currentRenderId: number;
  383. private _parentRenderId;
  384. protected _childRenderId: number;
  385. /** @hidden */
  386. _waitingParentId: Nullable<string>;
  387. /** @hidden */
  388. _scene: Scene;
  389. /** @hidden */
  390. _cache: any;
  391. private _parentNode;
  392. private _children;
  393. /** @hidden */
  394. _worldMatrix: Matrix;
  395. /** @hidden */
  396. _worldMatrixDeterminant: number;
  397. /**
  398. * Gets a boolean indicating if the node has been disposed
  399. * @returns true if the node was disposed
  400. */
  401. isDisposed(): boolean;
  402. /**
  403. * Gets or sets the parent of the node
  404. */
  405. parent: Nullable<Node>;
  406. private _animationPropertiesOverride;
  407. /**
  408. * Gets or sets the animation properties override
  409. */
  410. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  411. /**
  412. * Gets a string idenfifying the name of the class
  413. * @returns "Node" string
  414. */
  415. getClassName(): string;
  416. /**
  417. * An event triggered when the mesh is disposed
  418. */
  419. onDisposeObservable: Observable<Node>;
  420. private _onDisposeObserver;
  421. /**
  422. * Sets a callback that will be raised when the node will be disposed
  423. */
  424. onDispose: () => void;
  425. /**
  426. * Creates a new Node
  427. * @param {string} name - the name and id to be given to this node
  428. * @param {BABYLON.Scene} the scene this node will be added to
  429. */
  430. constructor(name: string, scene?: Nullable<Scene>);
  431. /**
  432. * Gets the scene of the node
  433. * @returns a {BABYLON.Scene}
  434. */
  435. getScene(): Scene;
  436. /**
  437. * Gets the engine of the node
  438. * @returns a {BABYLON.Engine}
  439. */
  440. getEngine(): Engine;
  441. private _behaviors;
  442. /**
  443. * Attach a behavior to the node
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. * @param behavior defines the behavior to attach
  446. * @returns the current Node
  447. */
  448. addBehavior(behavior: Behavior<Node>): Node;
  449. /**
  450. * Remove an attached behavior
  451. * @see http://doc.babylonjs.com/features/behaviour
  452. * @param behavior defines the behavior to attach
  453. * @returns the current Node
  454. */
  455. removeBehavior(behavior: Behavior<Node>): Node;
  456. /**
  457. * Gets the list of attached behaviors
  458. * @see http://doc.babylonjs.com/features/behaviour
  459. */
  460. readonly behaviors: Behavior<Node>[];
  461. /**
  462. * Gets an attached behavior by name
  463. * @param name defines the name of the behavior to look for
  464. * @see http://doc.babylonjs.com/features/behaviour
  465. * @returns null if behavior was not found else the requested behavior
  466. */
  467. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  468. /**
  469. * Returns the latest update of the World matrix
  470. * @returns a Matrix
  471. */
  472. getWorldMatrix(): Matrix;
  473. /** @hidden */
  474. _getWorldMatrixDeterminant(): number;
  475. /**
  476. * Returns directly the latest state of the mesh World matrix.
  477. * A Matrix is returned.
  478. */
  479. readonly worldMatrixFromCache: Matrix;
  480. /** @hidden */
  481. _initCache(): void;
  482. /** @hidden */
  483. updateCache(force?: boolean): void;
  484. /** @hidden */
  485. _updateCache(ignoreParentClass?: boolean): void;
  486. /** @hidden */
  487. _isSynchronized(): boolean;
  488. /** @hidden */
  489. _markSyncedWithParent(): void;
  490. /** @hidden */
  491. isSynchronizedWithParent(): boolean;
  492. /** @hidden */
  493. isSynchronized(): boolean;
  494. /**
  495. * Is this node ready to be used/rendered
  496. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  497. * @return true if the node is ready
  498. */
  499. isReady(completeCheck?: boolean): boolean;
  500. /**
  501. * Is this node enabled?
  502. * 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
  503. * @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
  504. * @return whether this node (and its parent) is enabled
  505. */
  506. isEnabled(checkAncestors?: boolean): boolean;
  507. /**
  508. * Set the enabled state of this node
  509. * @param value defines the new enabled state
  510. */
  511. setEnabled(value: boolean): void;
  512. /**
  513. * Is this node a descendant of the given node?
  514. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  515. * @param ancestor defines the parent node to inspect
  516. * @returns a boolean indicating if this node is a descendant of the given node
  517. */
  518. isDescendantOf(ancestor: Node): boolean;
  519. /** @hidden */
  520. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  521. /**
  522. * Will return all nodes that have this node as ascendant
  523. * @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
  524. * @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
  525. * @return all children nodes of all types
  526. */
  527. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  528. /**
  529. * Get all child-meshes of this node
  530. * @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
  531. * @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
  532. * @returns an array of {BABYLON.AbstractMesh}
  533. */
  534. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  535. /**
  536. * Get all child-transformNodes of this node
  537. * @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
  538. * @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
  539. * @returns an array of {BABYLON.TransformNode}
  540. */
  541. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  542. /**
  543. * Get all direct children of this node
  544. * @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
  545. * @returns an array of {BABYLON.Node}
  546. */
  547. getChildren(predicate?: (node: Node) => boolean): Node[];
  548. /** @hidden */
  549. _setReady(state: boolean): void;
  550. /**
  551. * Get an animation by name
  552. * @param name defines the name of the animation to look for
  553. * @returns null if not found else the requested animation
  554. */
  555. getAnimationByName(name: string): Nullable<Animation>;
  556. /**
  557. * Creates an animation range for this node
  558. * @param name defines the name of the range
  559. * @param from defines the starting key
  560. * @param to defines the end key
  561. */
  562. createAnimationRange(name: string, from: number, to: number): void;
  563. /**
  564. * Delete a specific animation range
  565. * @param name defines the name of the range to delete
  566. * @param deleteFrames defines if animation frames from the range must be deleted as well
  567. */
  568. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  569. /**
  570. * Get an animation range by name
  571. * @param name defines the name of the animation range to look for
  572. * @returns null if not found else the requested animation range
  573. */
  574. getAnimationRange(name: string): Nullable<AnimationRange>;
  575. /**
  576. * Will start the animation sequence
  577. * @param name defines the range frames for animation sequence
  578. * @param loop defines if the animation should loop (false by default)
  579. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  580. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  581. * @returns the object created for this animation. If range does not exist, it will return null
  582. */
  583. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  584. /**
  585. * Serialize animation ranges into a JSON compatible object
  586. * @returns serialization object
  587. */
  588. serializeAnimationRanges(): any;
  589. /**
  590. * Computes the world matrix of the node
  591. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  592. * @returns the world matrix
  593. */
  594. computeWorldMatrix(force?: boolean): Matrix;
  595. /**
  596. * Releases resources associated with this node.
  597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  599. */
  600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  601. /**
  602. * Parse animation range data from a serialization object and store them into a given node
  603. * @param node defines where to store the animation ranges
  604. * @param parsedNode defines the serialization object to read data from
  605. * @param scene defines the hosting scene
  606. */
  607. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  608. }
  609. }
  610. declare module BABYLON {
  611. /**
  612. * Define an interface for all classes that will hold resources
  613. */
  614. interface IDisposable {
  615. /**
  616. * Releases all held resources
  617. */
  618. dispose(): void;
  619. }
  620. /**
  621. * This class is used by the onRenderingGroupObservable
  622. */
  623. class RenderingGroupInfo {
  624. /**
  625. * The Scene that being rendered
  626. */
  627. scene: Scene;
  628. /**
  629. * The camera currently used for the rendering pass
  630. */
  631. camera: Nullable<Camera>;
  632. /**
  633. * The ID of the renderingGroup being processed
  634. */
  635. renderingGroupId: number;
  636. }
  637. /**
  638. * Represents a scene to be rendered by the engine.
  639. * @see http://doc.babylonjs.com/features/scene
  640. */
  641. class Scene extends AbstractScene implements IAnimatable {
  642. private static _uniqueIdCounter;
  643. /** The fog is deactivated */
  644. static readonly FOGMODE_NONE: number;
  645. /** The fog density is following an exponential function */
  646. static readonly FOGMODE_EXP: number;
  647. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  648. static readonly FOGMODE_EXP2: number;
  649. /** The fog density is following a linear function. */
  650. static readonly FOGMODE_LINEAR: number;
  651. /**
  652. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  654. */
  655. static MinDeltaTime: number;
  656. /**
  657. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  659. */
  660. static MaxDeltaTime: number;
  661. /**
  662. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  663. */
  664. autoClear: boolean;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  667. */
  668. autoClearDepthAndStencil: boolean;
  669. /**
  670. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  671. */
  672. clearColor: Color4;
  673. /**
  674. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  675. */
  676. ambientColor: Color3;
  677. /** @hidden */
  678. _environmentBRDFTexture: BaseTexture;
  679. /** @hidden */
  680. protected _environmentTexture: BaseTexture;
  681. /**
  682. * Texture used in all pbr material as the reflection texture.
  683. * As in the majority of the scene they are the same (exception for multi room and so on),
  684. * this is easier to reference from here than from all the materials.
  685. */
  686. /**
  687. * Texture used in all pbr material as the reflection texture.
  688. * As in the majority of the scene they are the same (exception for multi room and so on),
  689. * this is easier to set here than in all the materials.
  690. */
  691. environmentTexture: BaseTexture;
  692. /** @hidden */
  693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  694. /**
  695. * Default image processing configuration used either in the rendering
  696. * Forward main pass or through the imageProcessingPostProcess if present.
  697. * As in the majority of the scene they are the same (exception for multi camera),
  698. * this is easier to reference from here than from all the materials and post process.
  699. *
  700. * No setter as we it is a shared configuration, you can set the values instead.
  701. */
  702. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  703. private _forceWireframe;
  704. /**
  705. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  706. */
  707. forceWireframe: boolean;
  708. private _forcePointsCloud;
  709. /**
  710. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  711. */
  712. forcePointsCloud: boolean;
  713. /**
  714. * Gets or sets the active clipplane 1
  715. */
  716. clipPlane: Nullable<Plane>;
  717. /**
  718. * Gets or sets the active clipplane 2
  719. */
  720. clipPlane2: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 3
  723. */
  724. clipPlane3: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 4
  727. */
  728. clipPlane4: Nullable<Plane>;
  729. /**
  730. * Gets or sets a boolean indicating if animations are enabled
  731. */
  732. animationsEnabled: boolean;
  733. private _animationPropertiesOverride;
  734. /**
  735. * Gets or sets the animation properties override
  736. */
  737. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  738. /**
  739. * Gets or sets a boolean indicating if a constant deltatime has to be used
  740. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  741. */
  742. useConstantAnimationDeltaTime: boolean;
  743. /**
  744. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  745. * Please note that it requires to run a ray cast through the scene on every frame
  746. */
  747. constantlyUpdateMeshUnderPointer: boolean;
  748. /**
  749. * Defines the HTML cursor to use when hovering over interactive elements
  750. */
  751. hoverCursor: string;
  752. /**
  753. * Defines the HTML default cursor to use (empty by default)
  754. */
  755. defaultCursor: string;
  756. /**
  757. * This is used to call preventDefault() on pointer down
  758. * in order to block unwanted artifacts like system double clicks
  759. */
  760. preventDefaultOnPointerDown: boolean;
  761. /**
  762. * Gets or sets user defined metadata
  763. */
  764. metadata: any;
  765. /**
  766. * Gets the name of the plugin used to load this scene (null by default)
  767. */
  768. loadingPluginName: string;
  769. /**
  770. * Use this array to add regular expressions used to disable offline support for specific urls
  771. */
  772. disableOfflineSupportExceptionRules: RegExp[];
  773. /**
  774. * An event triggered when the scene is disposed.
  775. */
  776. onDisposeObservable: Observable<Scene>;
  777. private _onDisposeObserver;
  778. /** Sets a function to be executed when this scene is disposed. */
  779. onDispose: () => void;
  780. /**
  781. * An event triggered before rendering the scene (right after animations and physics)
  782. */
  783. onBeforeRenderObservable: Observable<Scene>;
  784. private _onBeforeRenderObserver;
  785. /** Sets a function to be executed before rendering this scene */
  786. beforeRender: Nullable<() => void>;
  787. /**
  788. * An event triggered after rendering the scene
  789. */
  790. onAfterRenderObservable: Observable<Scene>;
  791. private _onAfterRenderObserver;
  792. /** Sets a function to be executed after rendering this scene */
  793. afterRender: Nullable<() => void>;
  794. /**
  795. * An event triggered before animating the scene
  796. */
  797. onBeforeAnimationsObservable: Observable<Scene>;
  798. /**
  799. * An event triggered after animations processing
  800. */
  801. onAfterAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered before draw calls are ready to be sent
  804. */
  805. onBeforeDrawPhaseObservable: Observable<Scene>;
  806. /**
  807. * An event triggered after draw calls have been sent
  808. */
  809. onAfterDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered when physic simulation is about to be run
  812. */
  813. onBeforePhysicsObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when physic simulation has been done
  816. */
  817. onAfterPhysicsObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when the scene is ready
  820. */
  821. onReadyObservable: Observable<Scene>;
  822. /**
  823. * An event triggered before rendering a camera
  824. */
  825. onBeforeCameraRenderObservable: Observable<Camera>;
  826. private _onBeforeCameraRenderObserver;
  827. /** Sets a function to be executed before rendering a camera*/
  828. beforeCameraRender: () => void;
  829. /**
  830. * An event triggered after rendering a camera
  831. */
  832. onAfterCameraRenderObservable: Observable<Camera>;
  833. private _onAfterCameraRenderObserver;
  834. /** Sets a function to be executed after rendering a camera*/
  835. afterCameraRender: () => void;
  836. /**
  837. * An event triggered when active meshes evaluation is about to start
  838. */
  839. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  840. /**
  841. * An event triggered when active meshes evaluation is done
  842. */
  843. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when particles rendering is about to start
  846. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  847. */
  848. onBeforeParticlesRenderingObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when particles rendering is done
  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. onAfterParticlesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  856. */
  857. onDataLoadedObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when a camera is created
  860. */
  861. onNewCameraAddedObservable: Observable<Camera>;
  862. /**
  863. * An event triggered when a camera is removed
  864. */
  865. onCameraRemovedObservable: Observable<Camera>;
  866. /**
  867. * An event triggered when a light is created
  868. */
  869. onNewLightAddedObservable: Observable<Light>;
  870. /**
  871. * An event triggered when a light is removed
  872. */
  873. onLightRemovedObservable: Observable<Light>;
  874. /**
  875. * An event triggered when a geometry is created
  876. */
  877. onNewGeometryAddedObservable: Observable<Geometry>;
  878. /**
  879. * An event triggered when a geometry is removed
  880. */
  881. onGeometryRemovedObservable: Observable<Geometry>;
  882. /**
  883. * An event triggered when a transform node is created
  884. */
  885. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  886. /**
  887. * An event triggered when a transform node is removed
  888. */
  889. onTransformNodeRemovedObservable: Observable<TransformNode>;
  890. /**
  891. * An event triggered when a mesh is created
  892. */
  893. onNewMeshAddedObservable: Observable<AbstractMesh>;
  894. /**
  895. * An event triggered when a mesh is removed
  896. */
  897. onMeshRemovedObservable: Observable<AbstractMesh>;
  898. /**
  899. * An event triggered when render targets are about to be rendered
  900. * Can happen multiple times per frame.
  901. */
  902. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  903. /**
  904. * An event triggered when render targets were rendered.
  905. * Can happen multiple times per frame.
  906. */
  907. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  908. /**
  909. * An event triggered before calculating deterministic simulation step
  910. */
  911. onBeforeStepObservable: Observable<Scene>;
  912. /**
  913. * An event triggered after calculating deterministic simulation step
  914. */
  915. onAfterStepObservable: Observable<Scene>;
  916. /**
  917. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  918. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  919. * 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)
  920. */
  921. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  922. /**
  923. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  924. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  925. * 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)
  926. */
  927. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  928. /**
  929. * This Observable will when a mesh has been imported into the scene.
  930. */
  931. onMeshImportedObservable: Observable<AbstractMesh>;
  932. private _registeredForLateAnimationBindings;
  933. /**
  934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  935. */
  936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  937. /**
  938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  939. */
  940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  943. */
  944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  945. private _onPointerMove;
  946. private _onPointerDown;
  947. private _onPointerUp;
  948. /** Deprecated. Use onPointerObservable instead */
  949. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  950. /** Deprecated. Use onPointerObservable instead */
  951. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  952. /** Deprecated. Use onPointerObservable instead */
  953. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  954. /** Deprecated. Use onPointerObservable instead */
  955. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  956. /**
  957. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  958. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  959. */
  960. onPrePointerObservable: Observable<PointerInfoPre>;
  961. /**
  962. * Observable event triggered each time an input event is received from the rendering canvas
  963. */
  964. onPointerObservable: Observable<PointerInfo>;
  965. /**
  966. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  967. */
  968. readonly unTranslatedPointer: Vector2;
  969. /** The distance in pixel that you have to move to prevent some events */
  970. static DragMovementThreshold: number;
  971. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  972. static LongPressDelay: number;
  973. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  974. static DoubleClickDelay: number;
  975. /** If you need to check double click without raising a single click at first click, enable this flag */
  976. static ExclusiveDoubleClickMode: boolean;
  977. private _initClickEvent;
  978. private _initActionManager;
  979. private _delayedSimpleClick;
  980. private _delayedSimpleClickTimeout;
  981. private _previousDelayedSimpleClickTimeout;
  982. private _meshPickProceed;
  983. private _previousButtonPressed;
  984. private _currentPickResult;
  985. private _previousPickResult;
  986. private _totalPointersPressed;
  987. private _doubleClickOccured;
  988. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  989. cameraToUseForPointers: Nullable<Camera>;
  990. private _pointerX;
  991. private _pointerY;
  992. private _unTranslatedPointerX;
  993. private _unTranslatedPointerY;
  994. private _startingPointerPosition;
  995. private _previousStartingPointerPosition;
  996. private _startingPointerTime;
  997. private _previousStartingPointerTime;
  998. private _pointerCaptures;
  999. private _timeAccumulator;
  1000. private _currentStepId;
  1001. private _currentInternalStep;
  1002. /** @hidden */
  1003. _mirroredCameraPosition: Nullable<Vector3>;
  1004. /**
  1005. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1006. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1007. */
  1008. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1009. /**
  1010. * Observable event triggered each time an keyboard event is received from the hosting window
  1011. */
  1012. onKeyboardObservable: Observable<KeyboardInfo>;
  1013. private _onKeyDown;
  1014. private _onKeyUp;
  1015. private _onCanvasFocusObserver;
  1016. private _onCanvasBlurObserver;
  1017. private _useRightHandedSystem;
  1018. /**
  1019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1020. */
  1021. useRightHandedSystem: boolean;
  1022. /**
  1023. * Sets the step Id used by deterministic lock step
  1024. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1025. * @param newStepId defines the step Id
  1026. */
  1027. setStepId(newStepId: number): void;
  1028. /**
  1029. * Gets the step Id used by deterministic lock step
  1030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1031. * @returns the step Id
  1032. */
  1033. getStepId(): number;
  1034. /**
  1035. * Gets the internal step used by deterministic lock step
  1036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1037. * @returns the internal step
  1038. */
  1039. getInternalStep(): number;
  1040. private _fogEnabled;
  1041. /**
  1042. * Gets or sets a boolean indicating if fog is enabled on this scene
  1043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1044. */
  1045. fogEnabled: boolean;
  1046. private _fogMode;
  1047. /**
  1048. * Gets or sets the fog mode to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogMode: number;
  1052. /**
  1053. * Gets or sets the fog color to use
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogColor: Color3;
  1057. /**
  1058. * Gets or sets the fog density to use
  1059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1060. */
  1061. fogDensity: number;
  1062. /**
  1063. * Gets or sets the fog start distance to use
  1064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1065. */
  1066. fogStart: number;
  1067. /**
  1068. * Gets or sets the fog end distance to use
  1069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1070. */
  1071. fogEnd: number;
  1072. private _shadowsEnabled;
  1073. /**
  1074. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1075. */
  1076. shadowsEnabled: boolean;
  1077. private _lightsEnabled;
  1078. /**
  1079. * Gets or sets a boolean indicating if lights are enabled on this scene
  1080. */
  1081. lightsEnabled: boolean;
  1082. /** All of the active cameras added to this scene. */
  1083. activeCameras: Camera[];
  1084. /** The current active camera */
  1085. activeCamera: Nullable<Camera>;
  1086. private _defaultMaterial;
  1087. /** The default material used on meshes when no material is affected */
  1088. /** The default material used on meshes when no material is affected */
  1089. defaultMaterial: Material;
  1090. private _texturesEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if textures are enabled on this scene
  1093. */
  1094. texturesEnabled: boolean;
  1095. /**
  1096. * Gets or sets a boolean indicating if particles are enabled on this scene
  1097. */
  1098. particlesEnabled: boolean;
  1099. /**
  1100. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1101. */
  1102. spritesEnabled: boolean;
  1103. private _skeletonsEnabled;
  1104. /**
  1105. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1106. */
  1107. skeletonsEnabled: boolean;
  1108. /**
  1109. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1110. */
  1111. lensFlaresEnabled: boolean;
  1112. /**
  1113. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1115. */
  1116. collisionsEnabled: boolean;
  1117. private _workerCollisions;
  1118. /** @hidden */
  1119. collisionCoordinator: ICollisionCoordinator;
  1120. /**
  1121. * Defines the gravity applied to this scene (used only for collisions)
  1122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1123. */
  1124. gravity: Vector3;
  1125. /**
  1126. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1127. */
  1128. postProcessesEnabled: boolean;
  1129. /**
  1130. * The list of postprocesses added to the scene
  1131. */
  1132. postProcesses: PostProcess[];
  1133. /**
  1134. * Gets the current postprocess manager
  1135. */
  1136. postProcessManager: PostProcessManager;
  1137. /**
  1138. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1139. */
  1140. renderTargetsEnabled: boolean;
  1141. /**
  1142. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1143. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1144. */
  1145. dumpNextRenderTargets: boolean;
  1146. /**
  1147. * The list of user defined render targets added to the scene
  1148. */
  1149. customRenderTargets: RenderTargetTexture[];
  1150. /**
  1151. * Defines if texture loading must be delayed
  1152. * If true, textures will only be loaded when they need to be rendered
  1153. */
  1154. useDelayedTextureLoading: boolean;
  1155. /**
  1156. * Gets the list of meshes imported to the scene through SceneLoader
  1157. */
  1158. importedMeshesFiles: String[];
  1159. /**
  1160. * Gets or sets a boolean indicating if probes are enabled on this scene
  1161. */
  1162. probesEnabled: boolean;
  1163. /**
  1164. * @hidden
  1165. */
  1166. database: Database;
  1167. /**
  1168. * Gets or sets the action manager associated with the scene
  1169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1170. */
  1171. actionManager: ActionManager;
  1172. private _meshesForIntersections;
  1173. /**
  1174. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1175. */
  1176. proceduralTexturesEnabled: boolean;
  1177. private _mainSoundTrack;
  1178. /**
  1179. * The list of sound tracks added to the scene
  1180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1181. */
  1182. soundTracks: SoundTrack[];
  1183. private _audioEnabled;
  1184. private _headphone;
  1185. /**
  1186. * Gets the main soundtrack associated with the scene
  1187. */
  1188. readonly mainSoundTrack: SoundTrack;
  1189. private _engine;
  1190. private _totalVertices;
  1191. /** @hidden */
  1192. _activeIndices: PerfCounter;
  1193. /** @hidden */
  1194. _activeParticles: PerfCounter;
  1195. /** @hidden */
  1196. _activeBones: PerfCounter;
  1197. private _animationRatio;
  1198. private _animationTimeLast;
  1199. private _animationTime;
  1200. /**
  1201. * Gets or sets a general scale for animation speed
  1202. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1203. */
  1204. animationTimeScale: number;
  1205. /** @hidden */
  1206. _cachedMaterial: Nullable<Material>;
  1207. /** @hidden */
  1208. _cachedEffect: Nullable<Effect>;
  1209. /** @hidden */
  1210. _cachedVisibility: Nullable<number>;
  1211. private _renderId;
  1212. private _frameId;
  1213. private _executeWhenReadyTimeoutId;
  1214. private _intermediateRendering;
  1215. private _viewUpdateFlag;
  1216. private _projectionUpdateFlag;
  1217. private _alternateViewUpdateFlag;
  1218. private _alternateProjectionUpdateFlag;
  1219. /** @hidden */
  1220. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1221. private _activeRequests;
  1222. private _pendingData;
  1223. private _isDisposed;
  1224. /**
  1225. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1226. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1227. */
  1228. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1229. private _activeMeshes;
  1230. private _processedMaterials;
  1231. private _renderTargets;
  1232. /** @hidden */
  1233. _activeParticleSystems: SmartArray<IParticleSystem>;
  1234. private _activeSkeletons;
  1235. private _softwareSkinnedMeshes;
  1236. private _renderingManager;
  1237. private _physicsEngine;
  1238. /** @hidden */
  1239. _activeAnimatables: Animatable[];
  1240. private _transformMatrix;
  1241. private _sceneUbo;
  1242. private _alternateSceneUbo;
  1243. private _pickWithRayInverseMatrix;
  1244. private _viewMatrix;
  1245. private _projectionMatrix;
  1246. private _alternateViewMatrix;
  1247. private _alternateProjectionMatrix;
  1248. private _alternateTransformMatrix;
  1249. private _useAlternateCameraConfiguration;
  1250. private _alternateRendering;
  1251. /** @hidden */
  1252. _forcedViewPosition: Nullable<Vector3>;
  1253. /** @hidden */
  1254. readonly _isAlternateRenderingEnabled: boolean;
  1255. private _frustumPlanes;
  1256. /**
  1257. * Gets the list of frustum planes (built from the active camera)
  1258. */
  1259. readonly frustumPlanes: Plane[];
  1260. /**
  1261. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1262. * This is useful if there are more lights that the maximum simulteanous authorized
  1263. */
  1264. requireLightSorting: boolean;
  1265. private _pointerOverMesh;
  1266. private _pickedDownMesh;
  1267. private _pickedUpMesh;
  1268. private _externalData;
  1269. private _uid;
  1270. /**
  1271. * @hidden
  1272. * Backing store of defined scene components.
  1273. */
  1274. _components: ISceneComponent[];
  1275. /**
  1276. * @hidden
  1277. * Backing store of defined scene components.
  1278. */
  1279. _serializableComponents: ISceneSerializableComponent[];
  1280. /**
  1281. * List of components to register on the next registration step.
  1282. */
  1283. private _transientComponents;
  1284. /**
  1285. * Registers the transient components if needed.
  1286. */
  1287. private _registerTransientComponents;
  1288. /**
  1289. * @hidden
  1290. * Add a component to the scene.
  1291. * Note that the ccomponent could be registered on th next frame if this is called after
  1292. * the register component stage.
  1293. * @param component Defines the component to add to the scene
  1294. */
  1295. _addComponent(component: ISceneComponent): void;
  1296. /**
  1297. * @hidden
  1298. * Gets a component from the scene.
  1299. * @param name defines the name of the component to retrieve
  1300. * @returns the component or null if not present
  1301. */
  1302. _getComponent(name: string): Nullable<ISceneComponent>;
  1303. /**
  1304. * @hidden
  1305. * Defines the actions happening before camera updates.
  1306. */
  1307. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1308. /**
  1309. * @hidden
  1310. * Defines the actions happening before clear the canvas.
  1311. */
  1312. _beforeClearStage: Stage<SimpleStageAction>;
  1313. /**
  1314. * @hidden
  1315. * Defines the actions when collecting render targets for the frame.
  1316. */
  1317. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening for one camera in the frame.
  1321. */
  1322. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1323. /**
  1324. * @hidden
  1325. * Defines the actions happening during the per mesh ready checks.
  1326. */
  1327. _isReadyForMeshStage: Stage<MeshStageAction>;
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening before evaluate active mesh checks.
  1331. */
  1332. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1333. /**
  1334. * @hidden
  1335. * Defines the actions happening during the evaluate sub mesh checks.
  1336. */
  1337. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening during the active mesh stage.
  1341. */
  1342. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening during the per camera render target step.
  1346. */
  1347. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions happening just before the active camera is drawing.
  1351. */
  1352. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening just before a rendering group is drawing.
  1356. */
  1357. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening just before a mesh is drawing.
  1361. */
  1362. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening just after a mesh has been drawn.
  1366. */
  1367. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening just after a rendering group has been drawn.
  1371. */
  1372. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening just after the active camera has been drawn.
  1376. */
  1377. _afterCameraDrawStage: Stage<CameraStageAction>;
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening when a pointer move event happens.
  1381. */
  1382. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening when a pointer down event happens.
  1386. */
  1387. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening when a pointer up event happens.
  1391. */
  1392. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1393. /**
  1394. * Creates a new Scene
  1395. * @param engine defines the engine to use to render this scene
  1396. */
  1397. constructor(engine: Engine);
  1398. private _defaultMeshCandidates;
  1399. /**
  1400. * @hidden
  1401. */
  1402. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1403. private _defaultSubMeshCandidates;
  1404. /**
  1405. * @hidden
  1406. */
  1407. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1408. /**
  1409. * Sets the default candidate providers for the scene.
  1410. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1411. * and getCollidingSubMeshCandidates to their default function
  1412. */
  1413. setDefaultCandidateProviders(): void;
  1414. /**
  1415. * Gets a boolean indicating if collisions are processed on a web worker
  1416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1417. */
  1418. workerCollisions: boolean;
  1419. /**
  1420. * Gets the mesh that is currently under the pointer
  1421. */
  1422. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1423. /**
  1424. * Gets the current on-screen X position of the pointer
  1425. */
  1426. readonly pointerX: number;
  1427. /**
  1428. * Gets the current on-screen Y position of the pointer
  1429. */
  1430. readonly pointerY: number;
  1431. /**
  1432. * Gets the cached material (ie. the latest rendered one)
  1433. * @returns the cached material
  1434. */
  1435. getCachedMaterial(): Nullable<Material>;
  1436. /**
  1437. * Gets the cached effect (ie. the latest rendered one)
  1438. * @returns the cached effect
  1439. */
  1440. getCachedEffect(): Nullable<Effect>;
  1441. /**
  1442. * Gets the cached visibility state (ie. the latest rendered one)
  1443. * @returns the cached visibility state
  1444. */
  1445. getCachedVisibility(): Nullable<number>;
  1446. /**
  1447. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1448. * @param material defines the current material
  1449. * @param effect defines the current effect
  1450. * @param visibility defines the current visibility state
  1451. * @returns true if one parameter is not cached
  1452. */
  1453. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1454. /**
  1455. * Gets the engine associated with the scene
  1456. * @returns an Engine
  1457. */
  1458. getEngine(): Engine;
  1459. /**
  1460. * Gets the total number of vertices rendered per frame
  1461. * @returns the total number of vertices rendered per frame
  1462. */
  1463. getTotalVertices(): number;
  1464. /**
  1465. * Gets the performance counter for total vertices
  1466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1467. */
  1468. readonly totalVerticesPerfCounter: PerfCounter;
  1469. /**
  1470. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1471. * @returns the total number of active indices rendered per frame
  1472. */
  1473. getActiveIndices(): number;
  1474. /**
  1475. * Gets the performance counter for active indices
  1476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1477. */
  1478. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1479. /**
  1480. * Gets the total number of active particles rendered per frame
  1481. * @returns the total number of active particles rendered per frame
  1482. */
  1483. getActiveParticles(): number;
  1484. /**
  1485. * Gets the performance counter for active particles
  1486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1487. */
  1488. readonly activeParticlesPerfCounter: PerfCounter;
  1489. /**
  1490. * Gets the total number of active bones rendered per frame
  1491. * @returns the total number of active bones rendered per frame
  1492. */
  1493. getActiveBones(): number;
  1494. /**
  1495. * Gets the performance counter for active bones
  1496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1497. */
  1498. readonly activeBonesPerfCounter: PerfCounter;
  1499. /** @hidden */
  1500. getInterFramePerfCounter(): number;
  1501. /** @hidden */
  1502. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1503. /** @hidden */
  1504. getLastFrameDuration(): number;
  1505. /** @hidden */
  1506. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1507. /** @hidden */
  1508. getEvaluateActiveMeshesDuration(): number;
  1509. /** @hidden */
  1510. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1511. /**
  1512. * Gets the array of active meshes
  1513. * @returns an array of AbstractMesh
  1514. */
  1515. getActiveMeshes(): SmartArray<AbstractMesh>;
  1516. /** @hidden */
  1517. getRenderTargetsDuration(): number;
  1518. /** @hidden */
  1519. getRenderDuration(): number;
  1520. /** @hidden */
  1521. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1522. /** @hidden */
  1523. getParticlesDuration(): number;
  1524. /** @hidden */
  1525. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1526. /** @hidden */
  1527. getSpritesDuration(): number;
  1528. /** @hidden */
  1529. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1530. /**
  1531. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1532. * @returns a number
  1533. */
  1534. getAnimationRatio(): number;
  1535. /**
  1536. * Gets an unique Id for the current render phase
  1537. * @returns a number
  1538. */
  1539. getRenderId(): number;
  1540. /**
  1541. * Gets an unique Id for the current frame
  1542. * @returns a number
  1543. */
  1544. getFrameId(): number;
  1545. /** Call this function if you want to manually increment the render Id*/
  1546. incrementRenderId(): void;
  1547. private _updatePointerPosition;
  1548. private _createUbo;
  1549. private _createAlternateUbo;
  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. /** @hidden */
  1586. _isPointerSwiping(): boolean;
  1587. /**
  1588. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1589. * @param attachUp defines if you want to attach events to pointerup
  1590. * @param attachDown defines if you want to attach events to pointerdown
  1591. * @param attachMove defines if you want to attach events to pointermove
  1592. */
  1593. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1594. /** Detaches all event handlers*/
  1595. detachControl(): void;
  1596. /**
  1597. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1598. * Delay loaded resources are not taking in account
  1599. * @return true if all required resources are ready
  1600. */
  1601. isReady(): boolean;
  1602. /** Resets all cached information relative to material (including effect and visibility) */
  1603. resetCachedMaterial(): void;
  1604. /**
  1605. * Registers a function to be called before every frame render
  1606. * @param func defines the function to register
  1607. */
  1608. registerBeforeRender(func: () => void): void;
  1609. /**
  1610. * Unregisters a function called before every frame render
  1611. * @param func defines the function to unregister
  1612. */
  1613. unregisterBeforeRender(func: () => void): void;
  1614. /**
  1615. * Registers a function to be called after every frame render
  1616. * @param func defines the function to register
  1617. */
  1618. registerAfterRender(func: () => void): void;
  1619. /**
  1620. * Unregisters a function called after every frame render
  1621. * @param func defines the function to unregister
  1622. */
  1623. unregisterAfterRender(func: () => void): void;
  1624. private _executeOnceBeforeRender;
  1625. /**
  1626. * The provided function will run before render once and will be disposed afterwards.
  1627. * A timeout delay can be provided so that the function will be executed in N ms.
  1628. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1629. * @param func The function to be executed.
  1630. * @param timeout optional delay in ms
  1631. */
  1632. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1633. /** @hidden */
  1634. _addPendingData(data: any): void;
  1635. /** @hidden */
  1636. _removePendingData(data: any): void;
  1637. /**
  1638. * Returns the number of items waiting to be loaded
  1639. * @returns the number of items waiting to be loaded
  1640. */
  1641. getWaitingItemsCount(): number;
  1642. /**
  1643. * Returns a boolean indicating if the scene is still loading data
  1644. */
  1645. readonly isLoading: boolean;
  1646. /**
  1647. * Registers a function to be executed when the scene is ready
  1648. * @param {Function} func - the function to be executed
  1649. */
  1650. executeWhenReady(func: () => void): void;
  1651. /**
  1652. * Returns a promise that resolves when the scene is ready
  1653. * @returns A promise that resolves when the scene is ready
  1654. */
  1655. whenReadyAsync(): Promise<void>;
  1656. /** @hidden */
  1657. _checkIsReady(): void;
  1658. /**
  1659. * Will start the animation sequence of a given target
  1660. * @param target defines the target
  1661. * @param from defines from which frame should animation start
  1662. * @param to defines until which frame should animation run.
  1663. * @param weight defines the weight to apply to the animation (1.0 by default)
  1664. * @param loop defines if the animation loops
  1665. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1666. * @param onAnimationEnd defines the function to be executed when the animation ends
  1667. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1668. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1669. * @returns the animatable object created for this animation
  1670. */
  1671. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1672. /**
  1673. * Will start the animation sequence of a given target
  1674. * @param target defines the target
  1675. * @param from defines from which frame should animation start
  1676. * @param to defines until which frame should animation run.
  1677. * @param loop defines if the animation loops
  1678. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1679. * @param onAnimationEnd defines the function to be executed when the animation ends
  1680. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1681. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1682. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1683. * @returns the animatable object created for this animation
  1684. */
  1685. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1686. /**
  1687. * Begin a new animation on a given node
  1688. * @param target defines the target where the animation will take place
  1689. * @param animations defines the list of animations to start
  1690. * @param from defines the initial value
  1691. * @param to defines the final value
  1692. * @param loop defines if you want animation to loop (off by default)
  1693. * @param speedRatio defines the speed ratio to apply to all animations
  1694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1695. * @returns the list of created animatables
  1696. */
  1697. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1698. /**
  1699. * Begin a new animation on a given node and its hierarchy
  1700. * @param target defines the root node where the animation will take place
  1701. * @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.
  1702. * @param animations defines the list of animations to start
  1703. * @param from defines the initial value
  1704. * @param to defines the final value
  1705. * @param loop defines if you want animation to loop (off by default)
  1706. * @param speedRatio defines the speed ratio to apply to all animations
  1707. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1708. * @returns the list of animatables created for all nodes
  1709. */
  1710. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1711. /**
  1712. * Gets the animatable associated with a specific target
  1713. * @param target defines the target of the animatable
  1714. * @returns the required animatable if found
  1715. */
  1716. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1717. /**
  1718. * Gets all animatables associated with a given target
  1719. * @param target defines the target to look animatables for
  1720. * @returns an array of Animatables
  1721. */
  1722. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1723. /**
  1724. * Gets all animatable attached to the scene
  1725. */
  1726. readonly animatables: Animatable[];
  1727. /**
  1728. * Will stop the animation of the given target
  1729. * @param target - the target
  1730. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1731. * @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)
  1732. */
  1733. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1734. /**
  1735. * Stops and removes all animations that have been applied to the scene
  1736. */
  1737. stopAllAnimations(): void;
  1738. private _animate;
  1739. /** @hidden */
  1740. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1741. private _processLateAnimationBindingsForMatrices;
  1742. private _processLateAnimationBindingsForQuaternions;
  1743. private _processLateAnimationBindings;
  1744. /** @hidden */
  1745. _switchToAlternateCameraConfiguration(active: boolean): void;
  1746. /**
  1747. * Gets the current view matrix
  1748. * @returns a Matrix
  1749. */
  1750. getViewMatrix(): Matrix;
  1751. /**
  1752. * Gets the current projection matrix
  1753. * @returns a Matrix
  1754. */
  1755. getProjectionMatrix(): Matrix;
  1756. /**
  1757. * Gets the current transform matrix
  1758. * @returns a Matrix made of View * Projection
  1759. */
  1760. getTransformMatrix(): Matrix;
  1761. /**
  1762. * Sets the current transform matrix
  1763. * @param view defines the View matrix to use
  1764. * @param projection defines the Projection matrix to use
  1765. */
  1766. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1767. /** @hidden */
  1768. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1769. /**
  1770. * Gets the uniform buffer used to store scene data
  1771. * @returns a UniformBuffer
  1772. */
  1773. getSceneUniformBuffer(): UniformBuffer;
  1774. /**
  1775. * Gets an unique (relatively to the current scene) Id
  1776. * @returns an unique number for the scene
  1777. */
  1778. getUniqueId(): number;
  1779. /**
  1780. * Add a mesh to the list of scene's meshes
  1781. * @param newMesh defines the mesh to add
  1782. * @param recursive if all child meshes should also be added to the scene
  1783. */
  1784. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1785. /**
  1786. * Remove a mesh for the list of scene's meshes
  1787. * @param toRemove defines the mesh to remove
  1788. * @param recursive if all child meshes should also be removed from the scene
  1789. * @returns the index where the mesh was in the mesh list
  1790. */
  1791. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1792. /**
  1793. * Add a transform node to the list of scene's transform nodes
  1794. * @param newTransformNode defines the transform node to add
  1795. */
  1796. addTransformNode(newTransformNode: TransformNode): void;
  1797. /**
  1798. * Remove a transform node for the list of scene's transform nodes
  1799. * @param toRemove defines the transform node to remove
  1800. * @returns the index where the transform node was in the transform node list
  1801. */
  1802. removeTransformNode(toRemove: TransformNode): number;
  1803. /**
  1804. * Remove a skeleton for the list of scene's skeletons
  1805. * @param toRemove defines the skeleton to remove
  1806. * @returns the index where the skeleton was in the skeleton list
  1807. */
  1808. removeSkeleton(toRemove: Skeleton): number;
  1809. /**
  1810. * Remove a morph target for the list of scene's morph targets
  1811. * @param toRemove defines the morph target to remove
  1812. * @returns the index where the morph target was in the morph target list
  1813. */
  1814. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1815. /**
  1816. * Remove a light for the list of scene's lights
  1817. * @param toRemove defines the light to remove
  1818. * @returns the index where the light was in the light list
  1819. */
  1820. removeLight(toRemove: Light): number;
  1821. /**
  1822. * Remove a camera for the list of scene's cameras
  1823. * @param toRemove defines the camera to remove
  1824. * @returns the index where the camera was in the camera list
  1825. */
  1826. removeCamera(toRemove: Camera): number;
  1827. /**
  1828. * Remove a particle system for the list of scene's particle systems
  1829. * @param toRemove defines the particle system to remove
  1830. * @returns the index where the particle system was in the particle system list
  1831. */
  1832. removeParticleSystem(toRemove: IParticleSystem): number;
  1833. /**
  1834. * Remove a animation for the list of scene's animations
  1835. * @param toRemove defines the animation to remove
  1836. * @returns the index where the animation was in the animation list
  1837. */
  1838. removeAnimation(toRemove: Animation): number;
  1839. /**
  1840. * Removes the given animation group from this scene.
  1841. * @param toRemove The animation group to remove
  1842. * @returns The index of the removed animation group
  1843. */
  1844. removeAnimationGroup(toRemove: AnimationGroup): number;
  1845. /**
  1846. * Removes the given multi-material from this scene.
  1847. * @param toRemove The multi-material to remove
  1848. * @returns The index of the removed multi-material
  1849. */
  1850. removeMultiMaterial(toRemove: MultiMaterial): number;
  1851. /**
  1852. * Removes the given material from this scene.
  1853. * @param toRemove The material to remove
  1854. * @returns The index of the removed material
  1855. */
  1856. removeMaterial(toRemove: Material): number;
  1857. /**
  1858. * Removes the given action manager from this scene.
  1859. * @param toRemove The action manager to remove
  1860. * @returns The index of the removed action manager
  1861. */
  1862. removeActionManager(toRemove: ActionManager): number;
  1863. /**
  1864. * Removes the given texture from this scene.
  1865. * @param toRemove The texture to remove
  1866. * @returns The index of the removed texture
  1867. */
  1868. removeTexture(toRemove: BaseTexture): number;
  1869. /**
  1870. * Adds the given light to this scene
  1871. * @param newLight The light to add
  1872. */
  1873. addLight(newLight: Light): void;
  1874. /**
  1875. * Sorts the list list based on light priorities
  1876. */
  1877. sortLightsByPriority(): void;
  1878. /**
  1879. * Adds the given camera to this scene
  1880. * @param newCamera The camera to add
  1881. */
  1882. addCamera(newCamera: Camera): void;
  1883. /**
  1884. * Adds the given skeleton to this scene
  1885. * @param newSkeleton The skeleton to add
  1886. */
  1887. addSkeleton(newSkeleton: Skeleton): void;
  1888. /**
  1889. * Adds the given particle system to this scene
  1890. * @param newParticleSystem The particle system to add
  1891. */
  1892. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1893. /**
  1894. * Adds the given animation to this scene
  1895. * @param newAnimation The animation to add
  1896. */
  1897. addAnimation(newAnimation: Animation): void;
  1898. /**
  1899. * Adds the given animation group to this scene.
  1900. * @param newAnimationGroup The animation group to add
  1901. */
  1902. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1903. /**
  1904. * Adds the given multi-material to this scene
  1905. * @param newMultiMaterial The multi-material to add
  1906. */
  1907. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1908. /**
  1909. * Adds the given material to this scene
  1910. * @param newMaterial The material to add
  1911. */
  1912. addMaterial(newMaterial: Material): void;
  1913. /**
  1914. * Adds the given morph target to this scene
  1915. * @param newMorphTargetManager The morph target to add
  1916. */
  1917. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1918. /**
  1919. * Adds the given geometry to this scene
  1920. * @param newGeometry The geometry to add
  1921. */
  1922. addGeometry(newGeometry: Geometry): void;
  1923. /**
  1924. * Adds the given action manager to this scene
  1925. * @param newActionManager The action manager to add
  1926. */
  1927. addActionManager(newActionManager: ActionManager): void;
  1928. /**
  1929. * Adds the given texture to this scene.
  1930. * @param newTexture The texture to add
  1931. */
  1932. addTexture(newTexture: BaseTexture): void;
  1933. /**
  1934. * Switch active camera
  1935. * @param newCamera defines the new active camera
  1936. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1937. */
  1938. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1939. /**
  1940. * sets the active camera of the scene using its ID
  1941. * @param id defines the camera's ID
  1942. * @return the new active camera or null if none found.
  1943. */
  1944. setActiveCameraByID(id: string): Nullable<Camera>;
  1945. /**
  1946. * sets the active camera of the scene using its name
  1947. * @param name defines the camera's name
  1948. * @returns the new active camera or null if none found.
  1949. */
  1950. setActiveCameraByName(name: string): Nullable<Camera>;
  1951. /**
  1952. * get an animation group using its name
  1953. * @param name defines the material's name
  1954. * @return the animation group or null if none found.
  1955. */
  1956. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1957. /**
  1958. * get a material using its id
  1959. * @param id defines the material's ID
  1960. * @return the material or null if none found.
  1961. */
  1962. getMaterialByID(id: string): Nullable<Material>;
  1963. /**
  1964. * Gets a material using its name
  1965. * @param name defines the material's name
  1966. * @return the material or null if none found.
  1967. */
  1968. getMaterialByName(name: string): Nullable<Material>;
  1969. /**
  1970. * Gets a camera using its id
  1971. * @param id defines the id to look for
  1972. * @returns the camera or null if not found
  1973. */
  1974. getCameraByID(id: string): Nullable<Camera>;
  1975. /**
  1976. * Gets a camera using its unique id
  1977. * @param uniqueId defines the unique id to look for
  1978. * @returns the camera or null if not found
  1979. */
  1980. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1981. /**
  1982. * Gets a camera using its name
  1983. * @param name defines the camera's name
  1984. * @return the camera or null if none found.
  1985. */
  1986. getCameraByName(name: string): Nullable<Camera>;
  1987. /**
  1988. * Gets a bone using its id
  1989. * @param id defines the bone's id
  1990. * @return the bone or null if not found
  1991. */
  1992. getBoneByID(id: string): Nullable<Bone>;
  1993. /**
  1994. * Gets a bone using its id
  1995. * @param name defines the bone's name
  1996. * @return the bone or null if not found
  1997. */
  1998. getBoneByName(name: string): Nullable<Bone>;
  1999. /**
  2000. * Gets a light node using its name
  2001. * @param name defines the the light's name
  2002. * @return the light or null if none found.
  2003. */
  2004. getLightByName(name: string): Nullable<Light>;
  2005. /**
  2006. * Gets a light node using its id
  2007. * @param id defines the light's id
  2008. * @return the light or null if none found.
  2009. */
  2010. getLightByID(id: string): Nullable<Light>;
  2011. /**
  2012. * Gets a light node using its scene-generated unique ID
  2013. * @param uniqueId defines the light's unique id
  2014. * @return the light or null if none found.
  2015. */
  2016. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2017. /**
  2018. * Gets a particle system by id
  2019. * @param id defines the particle system id
  2020. * @return the corresponding system or null if none found
  2021. */
  2022. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2023. /**
  2024. * Gets a geometry using its ID
  2025. * @param id defines the geometry's id
  2026. * @return the geometry or null if none found.
  2027. */
  2028. getGeometryByID(id: string): Nullable<Geometry>;
  2029. /**
  2030. * Add a new geometry to this scene
  2031. * @param geometry defines the geometry to be added to the scene.
  2032. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2033. * @return a boolean defining if the geometry was added or not
  2034. */
  2035. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2036. /**
  2037. * Removes an existing geometry
  2038. * @param geometry defines the geometry to be removed from the scene
  2039. * @return a boolean defining if the geometry was removed or not
  2040. */
  2041. removeGeometry(geometry: Geometry): boolean;
  2042. /**
  2043. * Gets the list of geometries attached to the scene
  2044. * @returns an array of Geometry
  2045. */
  2046. getGeometries(): Geometry[];
  2047. /**
  2048. * Gets the first added mesh found of a given ID
  2049. * @param id defines the id to search for
  2050. * @return the mesh found or null if not found at all
  2051. */
  2052. getMeshByID(id: string): Nullable<AbstractMesh>;
  2053. /**
  2054. * Gets a list of meshes using their id
  2055. * @param id defines the id to search for
  2056. * @returns a list of meshes
  2057. */
  2058. getMeshesByID(id: string): Array<AbstractMesh>;
  2059. /**
  2060. * Gets the first added transform node found of a given ID
  2061. * @param id defines the id to search for
  2062. * @return the found transform node or null if not found at all.
  2063. */
  2064. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2065. /**
  2066. * Gets a list of transform nodes using their id
  2067. * @param id defines the id to search for
  2068. * @returns a list of transform nodes
  2069. */
  2070. getTransformNodesByID(id: string): Array<TransformNode>;
  2071. /**
  2072. * Gets a mesh with its auto-generated unique id
  2073. * @param uniqueId defines the unique id to search for
  2074. * @return the found mesh or null if not found at all.
  2075. */
  2076. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2077. /**
  2078. * Gets a the last added mesh using a given id
  2079. * @param id defines the id to search for
  2080. * @return the found mesh or null if not found at all.
  2081. */
  2082. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2083. /**
  2084. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2085. * @param id defines the id to search for
  2086. * @return the found node or null if not found at all
  2087. */
  2088. getLastEntryByID(id: string): Nullable<Node>;
  2089. /**
  2090. * Gets a node (Mesh, Camera, Light) using a given id
  2091. * @param id defines the id to search for
  2092. * @return the found node or null if not found at all
  2093. */
  2094. getNodeByID(id: string): Nullable<Node>;
  2095. /**
  2096. * Gets a node (Mesh, Camera, Light) using a given name
  2097. * @param name defines the name to search for
  2098. * @return the found node or null if not found at all.
  2099. */
  2100. getNodeByName(name: string): Nullable<Node>;
  2101. /**
  2102. * Gets a mesh using a given name
  2103. * @param name defines the name to search for
  2104. * @return the found mesh or null if not found at all.
  2105. */
  2106. getMeshByName(name: string): Nullable<AbstractMesh>;
  2107. /**
  2108. * Gets a transform node using a given name
  2109. * @param name defines the name to search for
  2110. * @return the found transform node or null if not found at all.
  2111. */
  2112. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2113. /**
  2114. * Gets a sound using a given name
  2115. * @param name defines the name to search for
  2116. * @return the found sound or null if not found at all.
  2117. */
  2118. getSoundByName(name: string): Nullable<Sound>;
  2119. /**
  2120. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2121. * @param id defines the id to search for
  2122. * @return the found skeleton or null if not found at all.
  2123. */
  2124. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2125. /**
  2126. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2127. * @param id defines the id to search for
  2128. * @return the found skeleton or null if not found at all.
  2129. */
  2130. getSkeletonById(id: string): Nullable<Skeleton>;
  2131. /**
  2132. * Gets a skeleton using a given name
  2133. * @param name defines the name to search for
  2134. * @return the found skeleton or null if not found at all.
  2135. */
  2136. getSkeletonByName(name: string): Nullable<Skeleton>;
  2137. /**
  2138. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2139. * @param id defines the id to search for
  2140. * @return the found morph target manager or null if not found at all.
  2141. */
  2142. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2143. /**
  2144. * Gets a boolean indicating if the given mesh is active
  2145. * @param mesh defines the mesh to look for
  2146. * @returns true if the mesh is in the active list
  2147. */
  2148. isActiveMesh(mesh: AbstractMesh): boolean;
  2149. /**
  2150. * Return a unique id as a string which can serve as an identifier for the scene
  2151. */
  2152. readonly uid: string;
  2153. /**
  2154. * Add an externaly attached data from its key.
  2155. * This method call will fail and return false, if such key already exists.
  2156. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2157. * @param key the unique key that identifies the data
  2158. * @param data the data object to associate to the key for this Engine instance
  2159. * @return true if no such key were already present and the data was added successfully, false otherwise
  2160. */
  2161. addExternalData<T>(key: string, data: T): boolean;
  2162. /**
  2163. * Get an externaly attached data from its key
  2164. * @param key the unique key that identifies the data
  2165. * @return the associated data, if present (can be null), or undefined if not present
  2166. */
  2167. getExternalData<T>(key: string): Nullable<T>;
  2168. /**
  2169. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2170. * @param key the unique key that identifies the data
  2171. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2172. * @return the associated data, can be null if the factory returned null.
  2173. */
  2174. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2175. /**
  2176. * Remove an externaly attached data from the Engine instance
  2177. * @param key the unique key that identifies the data
  2178. * @return true if the data was successfully removed, false if it doesn't exist
  2179. */
  2180. removeExternalData(key: string): boolean;
  2181. private _evaluateSubMesh;
  2182. /**
  2183. * Clear the processed materials smart array preventing retention point in material dispose.
  2184. */
  2185. freeProcessedMaterials(): void;
  2186. /**
  2187. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2188. */
  2189. freeActiveMeshes(): void;
  2190. /**
  2191. * Clear the info related to rendering groups preventing retention points during dispose.
  2192. */
  2193. freeRenderingGroups(): void;
  2194. /** @hidden */
  2195. _isInIntermediateRendering(): boolean;
  2196. /**
  2197. * Lambda returning the list of potentially active meshes.
  2198. */
  2199. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2200. /**
  2201. * Lambda returning the list of potentially active sub meshes.
  2202. */
  2203. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2204. /**
  2205. * Lambda returning the list of potentially intersecting sub meshes.
  2206. */
  2207. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2208. /**
  2209. * Lambda returning the list of potentially colliding sub meshes.
  2210. */
  2211. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2212. private _activeMeshesFrozen;
  2213. /**
  2214. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2215. * @returns the current scene
  2216. */
  2217. freezeActiveMeshes(): Scene;
  2218. /**
  2219. * Use this function to restart evaluating active meshes on every frame
  2220. * @returns the current scene
  2221. */
  2222. unfreezeActiveMeshes(): Scene;
  2223. private _evaluateActiveMeshes;
  2224. private _activeMesh;
  2225. /**
  2226. * Update the transform matrix to update from the current active camera
  2227. * @param force defines a boolean used to force the update even if cache is up to date
  2228. */
  2229. updateTransformMatrix(force?: boolean): void;
  2230. /**
  2231. * 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)
  2232. * @param alternateCamera defines the camera to use
  2233. */
  2234. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2235. /** @hidden */
  2236. _allowPostProcessClearColor: boolean;
  2237. private _renderForCamera;
  2238. private _processSubCameras;
  2239. private _checkIntersections;
  2240. /**
  2241. * Render the scene
  2242. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2243. */
  2244. render(updateCameras?: boolean): void;
  2245. private _updateAudioParameters;
  2246. /**
  2247. * Gets or sets if audio support is enabled
  2248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2249. */
  2250. audioEnabled: boolean;
  2251. private _disableAudio;
  2252. private _enableAudio;
  2253. /**
  2254. * Gets or sets if audio will be output to headphones
  2255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2256. */
  2257. headphone: boolean;
  2258. private _switchAudioModeForHeadphones;
  2259. private _switchAudioModeForNormalSpeakers;
  2260. /**
  2261. * Freeze all materials
  2262. * A frozen material will not be updatable but should be faster to render
  2263. */
  2264. freezeMaterials(): void;
  2265. /**
  2266. * Unfreeze all materials
  2267. * A frozen material will not be updatable but should be faster to render
  2268. */
  2269. unfreezeMaterials(): void;
  2270. /**
  2271. * Releases all held ressources
  2272. */
  2273. dispose(): void;
  2274. /**
  2275. * Gets if the scene is already disposed
  2276. */
  2277. readonly isDisposed: boolean;
  2278. /**
  2279. * Releases sounds & soundtracks
  2280. */
  2281. disposeSounds(): void;
  2282. /**
  2283. * Call this function to reduce memory footprint of the scene.
  2284. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2285. */
  2286. clearCachedVertexData(): void;
  2287. /**
  2288. * This function will remove the local cached buffer data from texture.
  2289. * It will save memory but will prevent the texture from being rebuilt
  2290. */
  2291. cleanCachedTextureBuffer(): void;
  2292. /**
  2293. * Get the world extend vectors with an optional filter
  2294. *
  2295. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2296. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2297. */
  2298. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2299. min: Vector3;
  2300. max: Vector3;
  2301. };
  2302. /**
  2303. * Creates a ray that can be used to pick in the scene
  2304. * @param x defines the x coordinate of the origin (on-screen)
  2305. * @param y defines the y coordinate of the origin (on-screen)
  2306. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2307. * @param camera defines the camera to use for the picking
  2308. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2309. * @returns a Ray
  2310. */
  2311. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2312. /**
  2313. * Creates a ray that can be used to pick in the scene
  2314. * @param x defines the x coordinate of the origin (on-screen)
  2315. * @param y defines the y coordinate of the origin (on-screen)
  2316. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2317. * @param result defines the ray where to store the picking ray
  2318. * @param camera defines the camera to use for the picking
  2319. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2320. * @returns the current scene
  2321. */
  2322. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2323. /**
  2324. * Creates a ray that can be used to pick in the scene
  2325. * @param x defines the x coordinate of the origin (on-screen)
  2326. * @param y defines the y coordinate of the origin (on-screen)
  2327. * @param camera defines the camera to use for the picking
  2328. * @returns a Ray
  2329. */
  2330. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2331. /**
  2332. * Creates a ray that can be used to pick in the scene
  2333. * @param x defines the x coordinate of the origin (on-screen)
  2334. * @param y defines the y coordinate of the origin (on-screen)
  2335. * @param result defines the ray where to store the picking ray
  2336. * @param camera defines the camera to use for the picking
  2337. * @returns the current scene
  2338. */
  2339. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2340. private _internalPick;
  2341. private _internalMultiPick;
  2342. private _tempPickingRay;
  2343. /** Launch a ray to try to pick a mesh in the scene
  2344. * @param x position on screen
  2345. * @param y position on screen
  2346. * @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
  2347. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2348. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2349. * @returns a PickingInfo
  2350. */
  2351. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2352. private _cachedRayForTransform;
  2353. /** Use the given ray to pick a mesh in the scene
  2354. * @param ray The ray to use to pick meshes
  2355. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2356. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2357. * @returns a PickingInfo
  2358. */
  2359. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2360. /**
  2361. * Launch a ray to try to pick a mesh in the scene
  2362. * @param x X position on screen
  2363. * @param y Y position on screen
  2364. * @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
  2365. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2366. * @returns an array of PickingInfo
  2367. */
  2368. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2369. /**
  2370. * Launch a ray to try to pick a mesh in the scene
  2371. * @param ray Ray to use
  2372. * @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
  2373. * @returns an array of PickingInfo
  2374. */
  2375. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2376. /**
  2377. * Force the value of meshUnderPointer
  2378. * @param mesh defines the mesh to use
  2379. */
  2380. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2381. /**
  2382. * Gets the mesh under the pointer
  2383. * @returns a Mesh or null if no mesh is under the pointer
  2384. */
  2385. getPointerOverMesh(): Nullable<AbstractMesh>;
  2386. /**
  2387. * Gets the current physics engine
  2388. * @returns a PhysicsEngine or null if none attached
  2389. */
  2390. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2391. /**
  2392. * Enables physics to the current scene
  2393. * @param gravity defines the scene's gravity for the physics engine
  2394. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2395. * @return a boolean indicating if the physics engine was initialized
  2396. */
  2397. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2398. /**
  2399. * Disables and disposes the physics engine associated with the scene
  2400. */
  2401. disablePhysicsEngine(): void;
  2402. /**
  2403. * Gets a boolean indicating if there is an active physics engine
  2404. * @returns a boolean indicating if there is an active physics engine
  2405. */
  2406. isPhysicsEnabled(): boolean;
  2407. /**
  2408. * Deletes a physics compound impostor
  2409. * @param compound defines the compound to delete
  2410. */
  2411. deleteCompoundImpostor(compound: any): void;
  2412. /** @hidden */
  2413. _rebuildGeometries(): void;
  2414. /** @hidden */
  2415. _rebuildTextures(): void;
  2416. private _getByTags;
  2417. /**
  2418. * Get a list of meshes by tags
  2419. * @param tagsQuery defines the tags query to use
  2420. * @param forEach defines a predicate used to filter results
  2421. * @returns an array of Mesh
  2422. */
  2423. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2424. /**
  2425. * Get a list of cameras by tags
  2426. * @param tagsQuery defines the tags query to use
  2427. * @param forEach defines a predicate used to filter results
  2428. * @returns an array of Camera
  2429. */
  2430. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2431. /**
  2432. * Get a list of lights by tags
  2433. * @param tagsQuery defines the tags query to use
  2434. * @param forEach defines a predicate used to filter results
  2435. * @returns an array of Light
  2436. */
  2437. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2438. /**
  2439. * Get a list of materials by tags
  2440. * @param tagsQuery defines the tags query to use
  2441. * @param forEach defines a predicate used to filter results
  2442. * @returns an array of Material
  2443. */
  2444. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2445. /**
  2446. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2447. * This allowed control for front to back rendering or reversly depending of the special needs.
  2448. *
  2449. * @param renderingGroupId The rendering group id corresponding to its index
  2450. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2451. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2452. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2453. */
  2454. 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;
  2455. /**
  2456. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2457. *
  2458. * @param renderingGroupId The rendering group id corresponding to its index
  2459. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2460. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2461. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2462. */
  2463. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2464. /**
  2465. * Gets the current auto clear configuration for one rendering group of the rendering
  2466. * manager.
  2467. * @param index the rendering group index to get the information for
  2468. * @returns The auto clear setup for the requested rendering group
  2469. */
  2470. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2471. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2472. blockMaterialDirtyMechanism: boolean;
  2473. /**
  2474. * Will flag all materials as dirty to trigger new shader compilation
  2475. * @param flag defines the flag used to specify which material part must be marked as dirty
  2476. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2477. */
  2478. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2479. /** @hidden */
  2480. _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;
  2481. /** @hidden */
  2482. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2483. }
  2484. }
  2485. declare module BABYLON {
  2486. /**
  2487. * Groups all the scene component constants in one place to ease maintenance.
  2488. * @hidden
  2489. */
  2490. class SceneComponentConstants {
  2491. static readonly NAME_EFFECTLAYER: string;
  2492. static readonly NAME_LAYER: string;
  2493. static readonly NAME_LENSFLARESYSTEM: string;
  2494. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2495. static readonly NAME_PARTICLESYSTEM: string;
  2496. static readonly NAME_GAMEPAD: string;
  2497. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2498. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2499. static readonly NAME_DEPTHRENDERER: string;
  2500. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2501. static readonly NAME_SPRITE: string;
  2502. static readonly NAME_OUTLINERENDERER: string;
  2503. static readonly NAME_PROCEDURALTEXTURE: string;
  2504. static readonly NAME_SHADOWGENERATOR: string;
  2505. static readonly NAME_OCTREE: string;
  2506. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2507. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2508. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2509. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2510. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2511. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2512. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2513. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2514. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2515. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2516. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2517. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2518. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2519. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2520. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2521. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2522. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2523. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2524. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2525. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2526. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2527. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2528. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2529. static readonly STEP_POINTERMOVE_SPRITE: number;
  2530. static readonly STEP_POINTERDOWN_SPRITE: number;
  2531. static readonly STEP_POINTERUP_SPRITE: number;
  2532. }
  2533. /**
  2534. * This represents a scene component.
  2535. *
  2536. * This is used to decouple the dependency the scene is having on the different workloads like
  2537. * layers, post processes...
  2538. */
  2539. interface ISceneComponent {
  2540. /**
  2541. * The name of the component. Each component must have a unique name.
  2542. */
  2543. name: string;
  2544. /**
  2545. * The scene the component belongs to.
  2546. */
  2547. scene: Scene;
  2548. /**
  2549. * Register the component to one instance of a scene.
  2550. */
  2551. register(): void;
  2552. /**
  2553. * Rebuilds the elements related to this component in case of
  2554. * context lost for instance.
  2555. */
  2556. rebuild(): void;
  2557. /**
  2558. * Disposes the component and the associated ressources.
  2559. */
  2560. dispose(): void;
  2561. }
  2562. /**
  2563. * This represents a SERIALIZABLE scene component.
  2564. *
  2565. * This extends Scene Component to add Serialization methods on top.
  2566. */
  2567. interface ISceneSerializableComponent extends ISceneComponent {
  2568. /**
  2569. * Adds all the element from the container to the scene
  2570. * @param container the container holding the elements
  2571. */
  2572. addFromContainer(container: AbstractScene): void;
  2573. /**
  2574. * Removes all the elements in the container from the scene
  2575. * @param container contains the elements to remove
  2576. */
  2577. removeFromContainer(container: AbstractScene): void;
  2578. /**
  2579. * Serializes the component data to the specified json object
  2580. * @param serializationObject The object to serialize to
  2581. */
  2582. serialize(serializationObject: any): void;
  2583. }
  2584. /**
  2585. * Strong typing of a Mesh related stage step action
  2586. */
  2587. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2588. /**
  2589. * Strong typing of a Evaluate Sub Mesh related stage step action
  2590. */
  2591. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2592. /**
  2593. * Strong typing of a Active Mesh related stage step action
  2594. */
  2595. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2596. /**
  2597. * Strong typing of a Camera related stage step action
  2598. */
  2599. type CameraStageAction = (camera: Camera) => void;
  2600. /**
  2601. * Strong typing of a RenderingGroup related stage step action
  2602. */
  2603. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2604. /**
  2605. * Strong typing of a Mesh Render related stage step action
  2606. */
  2607. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2608. /**
  2609. * Strong typing of a simple stage step action
  2610. */
  2611. type SimpleStageAction = () => void;
  2612. /**
  2613. * Strong typing of a render target action.
  2614. */
  2615. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2616. /**
  2617. * Strong typing of a pointer move action.
  2618. */
  2619. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2620. /**
  2621. * Strong typing of a pointer up/down action.
  2622. */
  2623. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2624. /**
  2625. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2626. * @hidden
  2627. */
  2628. class Stage<T extends Function> extends Array<{
  2629. index: number;
  2630. component: ISceneComponent;
  2631. action: T;
  2632. }> {
  2633. /**
  2634. * Hide ctor from the rest of the world.
  2635. * @param items The items to add.
  2636. */
  2637. private constructor();
  2638. /**
  2639. * Creates a new Stage.
  2640. * @returns A new instance of a Stage
  2641. */
  2642. static Create<T extends Function>(): Stage<T>;
  2643. /**
  2644. * Registers a step in an ordered way in the targeted stage.
  2645. * @param index Defines the position to register the step in
  2646. * @param component Defines the component attached to the step
  2647. * @param action Defines the action to launch during the step
  2648. */
  2649. registerStep(index: number, component: ISceneComponent, action: T): void;
  2650. /**
  2651. * Clears all the steps from the stage.
  2652. */
  2653. clear(): void;
  2654. }
  2655. }
  2656. declare module BABYLON {
  2657. type Nullable<T> = T | null;
  2658. type float = number;
  2659. type double = number;
  2660. type int = number;
  2661. type FloatArray = number[] | Float32Array;
  2662. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2663. /**
  2664. * Alias for types that can be used by a Buffer or VertexBuffer.
  2665. */
  2666. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2667. }
  2668. declare module BABYLON {
  2669. /**
  2670. * The action to be carried out following a trigger
  2671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2672. */
  2673. class Action {
  2674. /** the trigger, with or without parameters, for the action */
  2675. triggerOptions: any;
  2676. /**
  2677. * Trigger for the action
  2678. */
  2679. trigger: number;
  2680. /**
  2681. * Internal only - manager for action
  2682. * @hidden
  2683. */
  2684. _actionManager: ActionManager;
  2685. private _nextActiveAction;
  2686. private _child;
  2687. private _condition?;
  2688. private _triggerParameter;
  2689. /**
  2690. * An event triggered prior to action being executed.
  2691. */
  2692. onBeforeExecuteObservable: Observable<Action>;
  2693. /**
  2694. * Creates a new Action
  2695. * @param triggerOptions the trigger, with or without parameters, for the action
  2696. * @param condition an optional determinant of action
  2697. */
  2698. constructor(
  2699. /** the trigger, with or without parameters, for the action */
  2700. triggerOptions: any, condition?: Condition);
  2701. /**
  2702. * Internal only
  2703. * @hidden
  2704. */
  2705. _prepare(): void;
  2706. /**
  2707. * Gets the trigger parameters
  2708. * @returns the trigger parameters
  2709. */
  2710. getTriggerParameter(): any;
  2711. /**
  2712. * Internal only - executes current action event
  2713. * @hidden
  2714. */
  2715. _executeCurrent(evt?: ActionEvent): void;
  2716. /**
  2717. * Execute placeholder for child classes
  2718. * @param evt optional action event
  2719. */
  2720. execute(evt?: ActionEvent): void;
  2721. /**
  2722. * Skips to next active action
  2723. */
  2724. skipToNextActiveAction(): void;
  2725. /**
  2726. * Adds action to chain of actions, may be a DoNothingAction
  2727. * @param action defines the next action to execute
  2728. * @returns The action passed in
  2729. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2730. */
  2731. then(action: Action): Action;
  2732. /**
  2733. * Internal only
  2734. * @hidden
  2735. */
  2736. _getProperty(propertyPath: string): string;
  2737. /**
  2738. * Internal only
  2739. * @hidden
  2740. */
  2741. _getEffectiveTarget(target: any, propertyPath: string): any;
  2742. /**
  2743. * Serialize placeholder for child classes
  2744. * @param parent of child
  2745. * @returns the serialized object
  2746. */
  2747. serialize(parent: any): any;
  2748. /**
  2749. * Internal only called by serialize
  2750. * @hidden
  2751. */
  2752. protected _serialize(serializedAction: any, parent?: any): any;
  2753. /**
  2754. * Internal only
  2755. * @hidden
  2756. */
  2757. static _SerializeValueAsString: (value: any) => string;
  2758. /**
  2759. * Internal only
  2760. * @hidden
  2761. */
  2762. static _GetTargetProperty: (target: Scene | Node) => {
  2763. name: string;
  2764. targetType: string;
  2765. value: string;
  2766. };
  2767. }
  2768. }
  2769. declare module BABYLON {
  2770. /**
  2771. * ActionEvent is the event being sent when an action is triggered.
  2772. */
  2773. class ActionEvent {
  2774. /** The mesh or sprite that triggered the action */
  2775. source: any;
  2776. /** The X mouse cursor position at the time of the event */
  2777. pointerX: number;
  2778. /** The Y mouse cursor position at the time of the event */
  2779. pointerY: number;
  2780. /** The mesh that is currently pointed at (can be null) */
  2781. meshUnderPointer: Nullable<AbstractMesh>;
  2782. /** the original (browser) event that triggered the ActionEvent */
  2783. sourceEvent?: any;
  2784. /** additional data for the event */
  2785. additionalData?: any;
  2786. /**
  2787. * Creates a new ActionEvent
  2788. * @param source The mesh or sprite that triggered the action
  2789. * @param pointerX The X mouse cursor position at the time of the event
  2790. * @param pointerY The Y mouse cursor position at the time of the event
  2791. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2792. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2793. * @param additionalData additional data for the event
  2794. */
  2795. constructor(
  2796. /** The mesh or sprite that triggered the action */
  2797. source: any,
  2798. /** The X mouse cursor position at the time of the event */
  2799. pointerX: number,
  2800. /** The Y mouse cursor position at the time of the event */
  2801. pointerY: number,
  2802. /** The mesh that is currently pointed at (can be null) */
  2803. meshUnderPointer: Nullable<AbstractMesh>,
  2804. /** the original (browser) event that triggered the ActionEvent */
  2805. sourceEvent?: any,
  2806. /** additional data for the event */
  2807. additionalData?: any);
  2808. /**
  2809. * Helper function to auto-create an ActionEvent from a source mesh.
  2810. * @param source The source mesh that triggered the event
  2811. * @param evt The original (browser) event
  2812. * @param additionalData additional data for the event
  2813. * @returns the new ActionEvent
  2814. */
  2815. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2816. /**
  2817. * Helper function to auto-create an ActionEvent from a source sprite
  2818. * @param source The source sprite that triggered the event
  2819. * @param scene Scene associated with the sprite
  2820. * @param evt The original (browser) event
  2821. * @param additionalData additional data for the event
  2822. * @returns the new ActionEvent
  2823. */
  2824. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2825. /**
  2826. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2827. * @param scene the scene where the event occurred
  2828. * @param evt The original (browser) event
  2829. * @returns the new ActionEvent
  2830. */
  2831. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2832. /**
  2833. * Helper function to auto-create an ActionEvent from a primitive
  2834. * @param prim defines the target primitive
  2835. * @param pointerPos defines the pointer position
  2836. * @param evt The original (browser) event
  2837. * @param additionalData additional data for the event
  2838. * @returns the new ActionEvent
  2839. */
  2840. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2841. }
  2842. /**
  2843. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2844. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2846. */
  2847. class ActionManager {
  2848. private static _NothingTrigger;
  2849. private static _OnPickTrigger;
  2850. private static _OnLeftPickTrigger;
  2851. private static _OnRightPickTrigger;
  2852. private static _OnCenterPickTrigger;
  2853. private static _OnPickDownTrigger;
  2854. private static _OnDoublePickTrigger;
  2855. private static _OnPickUpTrigger;
  2856. private static _OnLongPressTrigger;
  2857. private static _OnPointerOverTrigger;
  2858. private static _OnPointerOutTrigger;
  2859. private static _OnEveryFrameTrigger;
  2860. private static _OnIntersectionEnterTrigger;
  2861. private static _OnIntersectionExitTrigger;
  2862. private static _OnKeyDownTrigger;
  2863. private static _OnKeyUpTrigger;
  2864. private static _OnPickOutTrigger;
  2865. /**
  2866. * Nothing
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly NothingTrigger: number;
  2870. /**
  2871. * On pick
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickTrigger: number;
  2875. /**
  2876. * On left pick
  2877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2878. */
  2879. static readonly OnLeftPickTrigger: number;
  2880. /**
  2881. * On right pick
  2882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2883. */
  2884. static readonly OnRightPickTrigger: number;
  2885. /**
  2886. * On center pick
  2887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2888. */
  2889. static readonly OnCenterPickTrigger: number;
  2890. /**
  2891. * On pick down
  2892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2893. */
  2894. static readonly OnPickDownTrigger: number;
  2895. /**
  2896. * On double pick
  2897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2898. */
  2899. static readonly OnDoublePickTrigger: number;
  2900. /**
  2901. * On pick up
  2902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2903. */
  2904. static readonly OnPickUpTrigger: number;
  2905. /**
  2906. * On pick out.
  2907. * This trigger will only be raised if you also declared a OnPickDown
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnPickOutTrigger: number;
  2911. /**
  2912. * On long press
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnLongPressTrigger: number;
  2916. /**
  2917. * On pointer over
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnPointerOverTrigger: number;
  2921. /**
  2922. * On pointer out
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnPointerOutTrigger: number;
  2926. /**
  2927. * On every frame
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnEveryFrameTrigger: number;
  2931. /**
  2932. * On intersection enter
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnIntersectionEnterTrigger: number;
  2936. /**
  2937. * On intersection exit
  2938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2939. */
  2940. static readonly OnIntersectionExitTrigger: number;
  2941. /**
  2942. * On key down
  2943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2944. */
  2945. static readonly OnKeyDownTrigger: number;
  2946. /**
  2947. * On key up
  2948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2949. */
  2950. static readonly OnKeyUpTrigger: number;
  2951. /** Gets the list of active triggers */
  2952. static Triggers: {
  2953. [key: string]: number;
  2954. };
  2955. /** Gets the list of actions */
  2956. actions: Action[];
  2957. /** Gets the cursor to use when hovering items */
  2958. hoverCursor: string;
  2959. private _scene;
  2960. /**
  2961. * Creates a new action manager
  2962. * @param scene defines the hosting scene
  2963. */
  2964. constructor(scene: Scene);
  2965. /**
  2966. * Releases all associated resources
  2967. */
  2968. dispose(): void;
  2969. /**
  2970. * Gets hosting scene
  2971. * @returns the hosting scene
  2972. */
  2973. getScene(): Scene;
  2974. /**
  2975. * Does this action manager handles actions of any of the given triggers
  2976. * @param triggers defines the triggers to be tested
  2977. * @return a boolean indicating whether one (or more) of the triggers is handled
  2978. */
  2979. hasSpecificTriggers(triggers: number[]): boolean;
  2980. /**
  2981. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2982. * speed.
  2983. * @param triggerA defines the trigger to be tested
  2984. * @param triggerB defines the trigger to be tested
  2985. * @return a boolean indicating whether one (or more) of the triggers is handled
  2986. */
  2987. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2988. /**
  2989. * Does this action manager handles actions of a given trigger
  2990. * @param trigger defines the trigger to be tested
  2991. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2992. * @return whether the trigger is handled
  2993. */
  2994. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2995. /**
  2996. * Does this action manager has pointer triggers
  2997. */
  2998. readonly hasPointerTriggers: boolean;
  2999. /**
  3000. * Does this action manager has pick triggers
  3001. */
  3002. readonly hasPickTriggers: boolean;
  3003. /**
  3004. * Does exist one action manager with at least one trigger
  3005. **/
  3006. static readonly HasTriggers: boolean;
  3007. /**
  3008. * Does exist one action manager with at least one pick trigger
  3009. **/
  3010. static readonly HasPickTriggers: boolean;
  3011. /**
  3012. * Does exist one action manager that handles actions of a given trigger
  3013. * @param trigger defines the trigger to be tested
  3014. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3015. **/
  3016. static HasSpecificTrigger(trigger: number): boolean;
  3017. /**
  3018. * Registers an action to this action manager
  3019. * @param action defines the action to be registered
  3020. * @return the action amended (prepared) after registration
  3021. */
  3022. registerAction(action: Action): Nullable<Action>;
  3023. /**
  3024. * Unregisters an action to this action manager
  3025. * @param action defines the action to be unregistered
  3026. * @return a boolean indicating whether the action has been unregistered
  3027. */
  3028. unregisterAction(action: Action): Boolean;
  3029. /**
  3030. * Process a specific trigger
  3031. * @param trigger defines the trigger to process
  3032. * @param evt defines the event details to be processed
  3033. */
  3034. processTrigger(trigger: number, evt?: ActionEvent): void;
  3035. /** @hidden */
  3036. _getEffectiveTarget(target: any, propertyPath: string): any;
  3037. /** @hidden */
  3038. _getProperty(propertyPath: string): string;
  3039. /**
  3040. * Serialize this manager to a JSON object
  3041. * @param name defines the property name to store this manager
  3042. * @returns a JSON representation of this manager
  3043. */
  3044. serialize(name: string): any;
  3045. /**
  3046. * Creates a new ActionManager from a JSON data
  3047. * @param parsedActions defines the JSON data to read from
  3048. * @param object defines the hosting mesh
  3049. * @param scene defines the hosting scene
  3050. */
  3051. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3052. /**
  3053. * Get a trigger name by index
  3054. * @param trigger defines the trigger index
  3055. * @returns a trigger name
  3056. */
  3057. static GetTriggerName(trigger: number): string;
  3058. }
  3059. }
  3060. declare module BABYLON {
  3061. /**
  3062. * A Condition applied to an Action
  3063. */
  3064. class Condition {
  3065. /**
  3066. * Internal only - manager for action
  3067. * @hidden
  3068. */
  3069. _actionManager: ActionManager;
  3070. /**
  3071. * Internal only
  3072. * @hidden
  3073. */
  3074. _evaluationId: number;
  3075. /**
  3076. * Internal only
  3077. * @hidden
  3078. */
  3079. _currentResult: boolean;
  3080. /**
  3081. * Creates a new Condition
  3082. * @param actionManager the manager of the action the condition is applied to
  3083. */
  3084. constructor(actionManager: ActionManager);
  3085. /**
  3086. * Check if the current condition is valid
  3087. * @returns a boolean
  3088. */
  3089. isValid(): boolean;
  3090. /**
  3091. * Internal only
  3092. * @hidden
  3093. */
  3094. _getProperty(propertyPath: string): string;
  3095. /**
  3096. * Internal only
  3097. * @hidden
  3098. */
  3099. _getEffectiveTarget(target: any, propertyPath: string): any;
  3100. /**
  3101. * Serialize placeholder for child classes
  3102. * @returns the serialized object
  3103. */
  3104. serialize(): any;
  3105. /**
  3106. * Internal only
  3107. * @hidden
  3108. */
  3109. protected _serialize(serializedCondition: any): any;
  3110. }
  3111. /**
  3112. * Defines specific conditional operators as extensions of Condition
  3113. */
  3114. class ValueCondition extends Condition {
  3115. /** path to specify the property of the target the conditional operator uses */
  3116. propertyPath: string;
  3117. /** the value compared by the conditional operator against the current value of the property */
  3118. value: any;
  3119. /** the conditional operator, default ValueCondition.IsEqual */
  3120. operator: number;
  3121. /**
  3122. * Internal only
  3123. * @hidden
  3124. */
  3125. private static _IsEqual;
  3126. /**
  3127. * Internal only
  3128. * @hidden
  3129. */
  3130. private static _IsDifferent;
  3131. /**
  3132. * Internal only
  3133. * @hidden
  3134. */
  3135. private static _IsGreater;
  3136. /**
  3137. * Internal only
  3138. * @hidden
  3139. */
  3140. private static _IsLesser;
  3141. /**
  3142. * returns the number for IsEqual
  3143. */
  3144. static readonly IsEqual: number;
  3145. /**
  3146. * Returns the number for IsDifferent
  3147. */
  3148. static readonly IsDifferent: number;
  3149. /**
  3150. * Returns the number for IsGreater
  3151. */
  3152. static readonly IsGreater: number;
  3153. /**
  3154. * Returns the number for IsLesser
  3155. */
  3156. static readonly IsLesser: number;
  3157. /**
  3158. * Internal only The action manager for the condition
  3159. * @hidden
  3160. */
  3161. _actionManager: ActionManager;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. private _target;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private _effectiveTarget;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private _property;
  3177. /**
  3178. * Creates a new ValueCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param target for the action
  3181. * @param propertyPath path to specify the property of the target the conditional operator uses
  3182. * @param value the value compared by the conditional operator against the current value of the property
  3183. * @param operator the conditional operator, default ValueCondition.IsEqual
  3184. */
  3185. constructor(actionManager: ActionManager, target: any,
  3186. /** path to specify the property of the target the conditional operator uses */
  3187. propertyPath: string,
  3188. /** the value compared by the conditional operator against the current value of the property */
  3189. value: any,
  3190. /** the conditional operator, default ValueCondition.IsEqual */
  3191. operator?: number);
  3192. /**
  3193. * Compares the given value with the property value for the specified conditional operator
  3194. * @returns the result of the comparison
  3195. */
  3196. isValid(): boolean;
  3197. /**
  3198. * Serialize the ValueCondition into a JSON compatible object
  3199. * @returns serialization object
  3200. */
  3201. serialize(): any;
  3202. /**
  3203. * Gets the name of the conditional operator for the ValueCondition
  3204. * @param operator the conditional operator
  3205. * @returns the name
  3206. */
  3207. static GetOperatorName(operator: number): string;
  3208. }
  3209. /**
  3210. * Defines a predicate condition as an extension of Condition
  3211. */
  3212. class PredicateCondition extends Condition {
  3213. /** defines the predicate function used to validate the condition */
  3214. predicate: () => boolean;
  3215. /**
  3216. * Internal only - manager for action
  3217. * @hidden
  3218. */
  3219. _actionManager: ActionManager;
  3220. /**
  3221. * Creates a new PredicateCondition
  3222. * @param actionManager manager for the action the condition applies to
  3223. * @param predicate defines the predicate function used to validate the condition
  3224. */
  3225. constructor(actionManager: ActionManager,
  3226. /** defines the predicate function used to validate the condition */
  3227. predicate: () => boolean);
  3228. /**
  3229. * @returns the validity of the predicate condition
  3230. */
  3231. isValid(): boolean;
  3232. }
  3233. /**
  3234. * Defines a state condition as an extension of Condition
  3235. */
  3236. class StateCondition extends Condition {
  3237. value: string;
  3238. /**
  3239. * Internal only - manager for action
  3240. * @hidden
  3241. */
  3242. _actionManager: ActionManager;
  3243. /**
  3244. * Internal only
  3245. * @hidden
  3246. */
  3247. private _target;
  3248. /**
  3249. * Creates a new StateCondition
  3250. * @param actionManager manager for the action the condition applies to
  3251. * @param target of the condition
  3252. * @param value to compare with target state
  3253. */
  3254. constructor(actionManager: ActionManager, target: any, value: string);
  3255. /**
  3256. * @returns the validity of the state
  3257. */
  3258. isValid(): boolean;
  3259. /**
  3260. * Serialize the StateCondition into a JSON compatible object
  3261. * @returns serialization object
  3262. */
  3263. serialize(): any;
  3264. }
  3265. }
  3266. declare module BABYLON {
  3267. class SwitchBooleanAction extends Action {
  3268. propertyPath: string;
  3269. private _target;
  3270. private _effectiveTarget;
  3271. private _property;
  3272. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3273. /** @hidden */
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class SetStateAction extends Action {
  3279. value: string;
  3280. private _target;
  3281. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class SetValueAction extends Action {
  3286. propertyPath: string;
  3287. value: any;
  3288. private _target;
  3289. private _effectiveTarget;
  3290. private _property;
  3291. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3292. /** @hidden */
  3293. _prepare(): void;
  3294. execute(): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class IncrementValueAction extends Action {
  3298. propertyPath: string;
  3299. value: any;
  3300. private _target;
  3301. private _effectiveTarget;
  3302. private _property;
  3303. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3304. /** @hidden */
  3305. _prepare(): void;
  3306. execute(): void;
  3307. serialize(parent: any): any;
  3308. }
  3309. class PlayAnimationAction extends Action {
  3310. from: number;
  3311. to: number;
  3312. loop?: boolean | undefined;
  3313. private _target;
  3314. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3315. /** @hidden */
  3316. _prepare(): void;
  3317. execute(): void;
  3318. serialize(parent: any): any;
  3319. }
  3320. class StopAnimationAction extends Action {
  3321. private _target;
  3322. constructor(triggerOptions: any, target: any, condition?: Condition);
  3323. /** @hidden */
  3324. _prepare(): void;
  3325. execute(): void;
  3326. serialize(parent: any): any;
  3327. }
  3328. class DoNothingAction extends Action {
  3329. constructor(triggerOptions?: any, condition?: Condition);
  3330. execute(): void;
  3331. serialize(parent: any): any;
  3332. }
  3333. class CombineAction extends Action {
  3334. children: Action[];
  3335. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3336. /** @hidden */
  3337. _prepare(): void;
  3338. execute(evt: ActionEvent): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. class ExecuteCodeAction extends Action {
  3342. func: (evt: ActionEvent) => void;
  3343. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3344. execute(evt: ActionEvent): void;
  3345. }
  3346. class SetParentAction extends Action {
  3347. private _parent;
  3348. private _target;
  3349. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3350. /** @hidden */
  3351. _prepare(): void;
  3352. execute(): void;
  3353. serialize(parent: any): any;
  3354. }
  3355. class PlaySoundAction extends Action {
  3356. private _sound;
  3357. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3358. /** @hidden */
  3359. _prepare(): void;
  3360. execute(): void;
  3361. serialize(parent: any): any;
  3362. }
  3363. class StopSoundAction extends Action {
  3364. private _sound;
  3365. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3366. /** @hidden */
  3367. _prepare(): void;
  3368. execute(): void;
  3369. serialize(parent: any): any;
  3370. }
  3371. }
  3372. declare module BABYLON {
  3373. class InterpolateValueAction extends Action {
  3374. propertyPath: string;
  3375. value: any;
  3376. duration: number;
  3377. stopOtherAnimations?: boolean | undefined;
  3378. onInterpolationDone?: (() => void) | undefined;
  3379. private _target;
  3380. private _effectiveTarget;
  3381. private _property;
  3382. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3383. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3384. /** @hidden */
  3385. _prepare(): void;
  3386. execute(): void;
  3387. serialize(parent: any): any;
  3388. }
  3389. }
  3390. declare module BABYLON {
  3391. /**
  3392. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3394. */
  3395. class Analyser {
  3396. /**
  3397. * Gets or sets the smoothing
  3398. * @ignorenaming
  3399. */
  3400. SMOOTHING: number;
  3401. /**
  3402. * Gets or sets the FFT table size
  3403. * @ignorenaming
  3404. */
  3405. FFT_SIZE: number;
  3406. /**
  3407. * Gets or sets the bar graph amplitude
  3408. * @ignorenaming
  3409. */
  3410. BARGRAPHAMPLITUDE: number;
  3411. /**
  3412. * Gets or sets the position of the debug canvas
  3413. * @ignorenaming
  3414. */
  3415. DEBUGCANVASPOS: {
  3416. x: number;
  3417. y: number;
  3418. };
  3419. /**
  3420. * Gets or sets the debug canvas size
  3421. * @ignorenaming
  3422. */
  3423. DEBUGCANVASSIZE: {
  3424. width: number;
  3425. height: number;
  3426. };
  3427. private _byteFreqs;
  3428. private _byteTime;
  3429. private _floatFreqs;
  3430. private _webAudioAnalyser;
  3431. private _debugCanvas;
  3432. private _debugCanvasContext;
  3433. private _scene;
  3434. private _registerFunc;
  3435. private _audioEngine;
  3436. /**
  3437. * Creates a new analyser
  3438. * @param scene defines hosting scene
  3439. */
  3440. constructor(scene: Scene);
  3441. /**
  3442. * Get the number of data values you will have to play with for the visualization
  3443. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3444. * @returns a number
  3445. */
  3446. getFrequencyBinCount(): number;
  3447. /**
  3448. * Gets the current frequency data as a byte array
  3449. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3450. * @returns a Uint8Array
  3451. */
  3452. getByteFrequencyData(): Uint8Array;
  3453. /**
  3454. * Gets the current waveform as a byte array
  3455. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3456. * @returns a Uint8Array
  3457. */
  3458. getByteTimeDomainData(): Uint8Array;
  3459. /**
  3460. * Gets the current frequency data as a float array
  3461. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3462. * @returns a Float32Array
  3463. */
  3464. getFloatFrequencyData(): Float32Array;
  3465. /**
  3466. * Renders the debug canvas
  3467. */
  3468. drawDebugCanvas(): void;
  3469. /**
  3470. * Stops rendering the debug canvas and removes it
  3471. */
  3472. stopDebugCanvas(): void;
  3473. /**
  3474. * Connects two audio nodes
  3475. * @param inputAudioNode defines first node to connect
  3476. * @param outputAudioNode defines second node to connect
  3477. */
  3478. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3479. /**
  3480. * Releases all associated resources
  3481. */
  3482. dispose(): void;
  3483. }
  3484. }
  3485. declare module BABYLON {
  3486. class AudioEngine {
  3487. private _audioContext;
  3488. private _audioContextInitialized;
  3489. canUseWebAudio: boolean;
  3490. masterGain: GainNode;
  3491. private _connectedAnalyser;
  3492. WarnedWebAudioUnsupported: boolean;
  3493. unlocked: boolean;
  3494. onAudioUnlocked: () => any;
  3495. isMP3supported: boolean;
  3496. isOGGsupported: boolean;
  3497. readonly audioContext: Nullable<AudioContext>;
  3498. constructor();
  3499. private _unlockiOSaudio;
  3500. private _initializeAudioContext;
  3501. dispose(): void;
  3502. getGlobalVolume(): number;
  3503. setGlobalVolume(newVolume: number): void;
  3504. connectToAnalyser(analyser: Analyser): void;
  3505. }
  3506. }
  3507. declare module BABYLON {
  3508. class Sound {
  3509. name: string;
  3510. autoplay: boolean;
  3511. loop: boolean;
  3512. useCustomAttenuation: boolean;
  3513. soundTrackId: number;
  3514. spatialSound: boolean;
  3515. refDistance: number;
  3516. rolloffFactor: number;
  3517. maxDistance: number;
  3518. distanceModel: string;
  3519. private _panningModel;
  3520. onended: () => any;
  3521. /**
  3522. * Observable event when the current playing sound finishes.
  3523. */
  3524. onEndedObservable: Observable<Sound>;
  3525. private _playbackRate;
  3526. private _streaming;
  3527. private _startTime;
  3528. private _startOffset;
  3529. private _position;
  3530. /** @hidden */
  3531. _positionInEmitterSpace: boolean;
  3532. private _localDirection;
  3533. private _volume;
  3534. private _isReadyToPlay;
  3535. isPlaying: boolean;
  3536. isPaused: boolean;
  3537. private _isDirectional;
  3538. private _readyToPlayCallback;
  3539. private _audioBuffer;
  3540. private _soundSource;
  3541. private _streamingSource;
  3542. private _soundPanner;
  3543. private _soundGain;
  3544. private _inputAudioNode;
  3545. private _outputAudioNode;
  3546. private _coneInnerAngle;
  3547. private _coneOuterAngle;
  3548. private _coneOuterGain;
  3549. private _scene;
  3550. private _connectedMesh;
  3551. private _customAttenuationFunction;
  3552. private _registerFunc;
  3553. private _isOutputConnected;
  3554. private _htmlAudioElement;
  3555. private _urlType;
  3556. /**
  3557. * Create a sound and attach it to a scene
  3558. * @param name Name of your sound
  3559. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  3560. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3561. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3562. */
  3563. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3564. dispose(): void;
  3565. isReady(): boolean;
  3566. private _soundLoaded;
  3567. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3568. updateOptions(options: any): void;
  3569. private _createSpatialParameters;
  3570. private _updateSpatialParameters;
  3571. switchPanningModelToHRTF(): void;
  3572. switchPanningModelToEqualPower(): void;
  3573. private _switchPanningModel;
  3574. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3575. /**
  3576. * Transform this sound into a directional source
  3577. * @param coneInnerAngle Size of the inner cone in degree
  3578. * @param coneOuterAngle Size of the outer cone in degree
  3579. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3580. */
  3581. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3582. /**
  3583. * Gets or sets the inner angle for the directional cone.
  3584. */
  3585. /**
  3586. * Gets or sets the inner angle for the directional cone.
  3587. */
  3588. directionalConeInnerAngle: number;
  3589. /**
  3590. * Gets or sets the outer angle for the directional cone.
  3591. */
  3592. /**
  3593. * Gets or sets the outer angle for the directional cone.
  3594. */
  3595. directionalConeOuterAngle: number;
  3596. setPosition(newPosition: Vector3): void;
  3597. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3598. private _updateDirection;
  3599. updateDistanceFromListener(): void;
  3600. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3601. /**
  3602. * Play the sound
  3603. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3604. * @param offset (optional) Start the sound setting it at a specific time
  3605. */
  3606. play(time?: number, offset?: number): void;
  3607. private _onended;
  3608. /**
  3609. * Stop the sound
  3610. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3611. */
  3612. stop(time?: number): void;
  3613. pause(): void;
  3614. setVolume(newVolume: number, time?: number): void;
  3615. setPlaybackRate(newPlaybackRate: number): void;
  3616. getVolume(): number;
  3617. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3618. detachFromMesh(): void;
  3619. private _onRegisterAfterWorldMatrixUpdate;
  3620. clone(): Nullable<Sound>;
  3621. getAudioBuffer(): AudioBuffer | null;
  3622. serialize(): any;
  3623. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3624. }
  3625. }
  3626. declare module BABYLON {
  3627. class SoundTrack {
  3628. private _outputAudioNode;
  3629. private _scene;
  3630. id: number;
  3631. soundCollection: Array<Sound>;
  3632. private _isMainTrack;
  3633. private _connectedAnalyser;
  3634. private _options;
  3635. private _isInitialized;
  3636. constructor(scene: Scene, options?: any);
  3637. private _initializeSoundTrackAudioGraph;
  3638. dispose(): void;
  3639. AddSound(sound: Sound): void;
  3640. RemoveSound(sound: Sound): void;
  3641. setVolume(newVolume: number): void;
  3642. switchPanningModelToHRTF(): void;
  3643. switchPanningModelToEqualPower(): void;
  3644. connectToAnalyser(analyser: Analyser): void;
  3645. }
  3646. }
  3647. declare module BABYLON {
  3648. /**
  3649. * Wraps one or more Sound objects and selects one with random weight for playback.
  3650. */
  3651. class WeightedSound {
  3652. /** When true a Sound will be selected and played when the current playing Sound completes. */
  3653. loop: boolean;
  3654. private _coneInnerAngle;
  3655. private _coneOuterAngle;
  3656. private _volume;
  3657. /** A Sound is currently playing. */
  3658. isPlaying: boolean;
  3659. /** A Sound is currently paused. */
  3660. isPaused: boolean;
  3661. private _sounds;
  3662. private _weights;
  3663. private _currentIndex?;
  3664. /**
  3665. * Creates a new WeightedSound from the list of sounds given.
  3666. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  3667. * @param sounds Array of Sounds that will be selected from.
  3668. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  3669. */
  3670. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  3671. /**
  3672. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  3673. */
  3674. /**
  3675. * The size of cone in degress for a directional sound in which there will be no attenuation.
  3676. */
  3677. directionalConeInnerAngle: number;
  3678. /**
  3679. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  3680. * Listener angles between innerAngle and outerAngle will falloff linearly.
  3681. */
  3682. /**
  3683. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  3684. * Listener angles between innerAngle and outerAngle will falloff linearly.
  3685. */
  3686. directionalConeOuterAngle: number;
  3687. /**
  3688. * Playback volume.
  3689. */
  3690. /**
  3691. * Playback volume.
  3692. */
  3693. volume: number;
  3694. private _onended;
  3695. /**
  3696. * Suspend playback
  3697. */
  3698. pause(): void;
  3699. /**
  3700. * Stop playback
  3701. */
  3702. stop(): void;
  3703. /**
  3704. * Start playback.
  3705. * @param startOffset Position the clip head at a specific time in seconds.
  3706. */
  3707. play(startOffset?: number): void;
  3708. }
  3709. }
  3710. declare module BABYLON {
  3711. /**
  3712. * Class used to store an actual running animation
  3713. */
  3714. class Animatable {
  3715. /** defines the target object */
  3716. target: any;
  3717. /** defines the starting frame number (default is 0) */
  3718. fromFrame: number;
  3719. /** defines the ending frame number (default is 100) */
  3720. toFrame: number;
  3721. /** defines if the animation must loop (default is false) */
  3722. loopAnimation: boolean;
  3723. /** defines a callback to call when animation ends if it is not looping */
  3724. onAnimationEnd?: (() => void) | null | undefined;
  3725. private _localDelayOffset;
  3726. private _pausedDelay;
  3727. private _runtimeAnimations;
  3728. private _paused;
  3729. private _scene;
  3730. private _speedRatio;
  3731. private _weight;
  3732. private _syncRoot;
  3733. /**
  3734. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3735. * This will only apply for non looping animation (default is true)
  3736. */
  3737. disposeOnEnd: boolean;
  3738. /**
  3739. * Gets a boolean indicating if the animation has started
  3740. */
  3741. animationStarted: boolean;
  3742. /**
  3743. * Observer raised when the animation ends
  3744. */
  3745. onAnimationEndObservable: Observable<Animatable>;
  3746. /**
  3747. * Gets the root Animatable used to synchronize and normalize animations
  3748. */
  3749. readonly syncRoot: Animatable;
  3750. /**
  3751. * Gets the current frame of the first RuntimeAnimation
  3752. * Used to synchronize Animatables
  3753. */
  3754. readonly masterFrame: number;
  3755. /**
  3756. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3757. */
  3758. weight: number;
  3759. /**
  3760. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3761. */
  3762. speedRatio: number;
  3763. /**
  3764. * Creates a new Animatable
  3765. * @param scene defines the hosting scene
  3766. * @param target defines the target object
  3767. * @param fromFrame defines the starting frame number (default is 0)
  3768. * @param toFrame defines the ending frame number (default is 100)
  3769. * @param loopAnimation defines if the animation must loop (default is false)
  3770. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3771. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3772. * @param animations defines a group of animation to add to the new Animatable
  3773. */
  3774. constructor(scene: Scene,
  3775. /** defines the target object */
  3776. target: any,
  3777. /** defines the starting frame number (default is 0) */
  3778. fromFrame?: number,
  3779. /** defines the ending frame number (default is 100) */
  3780. toFrame?: number,
  3781. /** defines if the animation must loop (default is false) */
  3782. loopAnimation?: boolean, speedRatio?: number,
  3783. /** defines a callback to call when animation ends if it is not looping */
  3784. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3785. /**
  3786. * Synchronize and normalize current Animatable with a source Animatable
  3787. * This is useful when using animation weights and when animations are not of the same length
  3788. * @param root defines the root Animatable to synchronize with
  3789. * @returns the current Animatable
  3790. */
  3791. syncWith(root: Animatable): Animatable;
  3792. /**
  3793. * Gets the list of runtime animations
  3794. * @returns an array of RuntimeAnimation
  3795. */
  3796. getAnimations(): RuntimeAnimation[];
  3797. /**
  3798. * Adds more animations to the current animatable
  3799. * @param target defines the target of the animations
  3800. * @param animations defines the new animations to add
  3801. */
  3802. appendAnimations(target: any, animations: Animation[]): void;
  3803. /**
  3804. * Gets the source animation for a specific property
  3805. * @param property defines the propertyu to look for
  3806. * @returns null or the source animation for the given property
  3807. */
  3808. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3809. /**
  3810. * Gets the runtime animation for a specific property
  3811. * @param property defines the propertyu to look for
  3812. * @returns null or the runtime animation for the given property
  3813. */
  3814. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3815. /**
  3816. * Resets the animatable to its original state
  3817. */
  3818. reset(): void;
  3819. /**
  3820. * Allows the animatable to blend with current running animations
  3821. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3822. * @param blendingSpeed defines the blending speed to use
  3823. */
  3824. enableBlending(blendingSpeed: number): void;
  3825. /**
  3826. * Disable animation blending
  3827. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3828. */
  3829. disableBlending(): void;
  3830. /**
  3831. * Jump directly to a given frame
  3832. * @param frame defines the frame to jump to
  3833. */
  3834. goToFrame(frame: number): void;
  3835. /**
  3836. * Pause the animation
  3837. */
  3838. pause(): void;
  3839. /**
  3840. * Restart the animation
  3841. */
  3842. restart(): void;
  3843. private _raiseOnAnimationEnd;
  3844. /**
  3845. * Stop and delete the current animation
  3846. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3847. * @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)
  3848. */
  3849. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3850. /**
  3851. * Wait asynchronously for the animation to end
  3852. * @returns a promise which will be fullfilled when the animation ends
  3853. */
  3854. waitAsync(): Promise<Animatable>;
  3855. /** @hidden */
  3856. _animate(delay: number): boolean;
  3857. }
  3858. }
  3859. declare module BABYLON {
  3860. /**
  3861. * Represents the range of an animation
  3862. */
  3863. class AnimationRange {
  3864. /**The name of the animation range**/
  3865. name: string;
  3866. /**The starting frame of the animation */
  3867. from: number;
  3868. /**The ending frame of the animation*/
  3869. to: number;
  3870. /**
  3871. * Initializes the range of an animation
  3872. * @param name The name of the animation range
  3873. * @param from The starting frame of the animation
  3874. * @param to The ending frame of the animation
  3875. */
  3876. constructor(
  3877. /**The name of the animation range**/
  3878. name: string,
  3879. /**The starting frame of the animation */
  3880. from: number,
  3881. /**The ending frame of the animation*/
  3882. to: number);
  3883. /**
  3884. * Makes a copy of the animation range
  3885. * @returns A copy of the animation range
  3886. */
  3887. clone(): AnimationRange;
  3888. }
  3889. /**
  3890. * Composed of a frame, and an action function
  3891. */
  3892. class AnimationEvent {
  3893. /** The frame for which the event is triggered **/
  3894. frame: number;
  3895. /** The event to perform when triggered **/
  3896. action: (currentFrame: number) => void;
  3897. /** Specifies if the event should be triggered only once**/
  3898. onlyOnce?: boolean | undefined;
  3899. /**
  3900. * Specifies if the animation event is done
  3901. */
  3902. isDone: boolean;
  3903. /**
  3904. * Initializes the animation event
  3905. * @param frame The frame for which the event is triggered
  3906. * @param action The event to perform when triggered
  3907. * @param onlyOnce Specifies if the event should be triggered only once
  3908. */
  3909. constructor(
  3910. /** The frame for which the event is triggered **/
  3911. frame: number,
  3912. /** The event to perform when triggered **/
  3913. action: (currentFrame: number) => void,
  3914. /** Specifies if the event should be triggered only once**/
  3915. onlyOnce?: boolean | undefined);
  3916. /** @hidden */
  3917. _clone(): AnimationEvent;
  3918. }
  3919. /**
  3920. * A cursor which tracks a point on a path
  3921. */
  3922. class PathCursor {
  3923. private path;
  3924. /**
  3925. * Stores path cursor callbacks for when an onchange event is triggered
  3926. */
  3927. private _onchange;
  3928. /**
  3929. * The value of the path cursor
  3930. */
  3931. value: number;
  3932. /**
  3933. * The animation array of the path cursor
  3934. */
  3935. animations: Animation[];
  3936. /**
  3937. * Initializes the path cursor
  3938. * @param path The path to track
  3939. */
  3940. constructor(path: Path2);
  3941. /**
  3942. * Gets the cursor point on the path
  3943. * @returns A point on the path cursor at the cursor location
  3944. */
  3945. getPoint(): Vector3;
  3946. /**
  3947. * Moves the cursor ahead by the step amount
  3948. * @param step The amount to move the cursor forward
  3949. * @returns This path cursor
  3950. */
  3951. moveAhead(step?: number): PathCursor;
  3952. /**
  3953. * Moves the cursor behind by the step amount
  3954. * @param step The amount to move the cursor back
  3955. * @returns This path cursor
  3956. */
  3957. moveBack(step?: number): PathCursor;
  3958. /**
  3959. * Moves the cursor by the step amount
  3960. * If the step amount is greater than one, an exception is thrown
  3961. * @param step The amount to move the cursor
  3962. * @returns This path cursor
  3963. */
  3964. move(step: number): PathCursor;
  3965. /**
  3966. * Ensures that the value is limited between zero and one
  3967. * @returns This path cursor
  3968. */
  3969. private ensureLimits;
  3970. /**
  3971. * Runs onchange callbacks on change (used by the animation engine)
  3972. * @returns This path cursor
  3973. */
  3974. private raiseOnChange;
  3975. /**
  3976. * Executes a function on change
  3977. * @param f A path cursor onchange callback
  3978. * @returns This path cursor
  3979. */
  3980. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3981. }
  3982. /**
  3983. * Defines an interface which represents an animation key frame
  3984. */
  3985. interface IAnimationKey {
  3986. /**
  3987. * Frame of the key frame
  3988. */
  3989. frame: number;
  3990. /**
  3991. * Value at the specifies key frame
  3992. */
  3993. value: any;
  3994. /**
  3995. * The input tangent for the cubic hermite spline
  3996. */
  3997. inTangent?: any;
  3998. /**
  3999. * The output tangent for the cubic hermite spline
  4000. */
  4001. outTangent?: any;
  4002. /**
  4003. * The animation interpolation type
  4004. */
  4005. interpolation?: AnimationKeyInterpolation;
  4006. }
  4007. /**
  4008. * Enum for the animation key frame interpolation type
  4009. */
  4010. enum AnimationKeyInterpolation {
  4011. /**
  4012. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4013. */
  4014. STEP = 1
  4015. }
  4016. /**
  4017. * Class used to store any kind of animation
  4018. */
  4019. class Animation {
  4020. /**Name of the animation */
  4021. name: string;
  4022. /**Property to animate */
  4023. targetProperty: string;
  4024. /**The frames per second of the animation */
  4025. framePerSecond: number;
  4026. /**The data type of the animation */
  4027. dataType: number;
  4028. /**The loop mode of the animation */
  4029. loopMode?: number | undefined;
  4030. /**Specifies if blending should be enabled */
  4031. enableBlending?: boolean | undefined;
  4032. /**
  4033. * Use matrix interpolation instead of using direct key value when animating matrices
  4034. */
  4035. static AllowMatricesInterpolation: boolean;
  4036. /**
  4037. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4038. */
  4039. static AllowMatrixDecomposeForInterpolation: boolean;
  4040. /**
  4041. * Stores the key frames of the animation
  4042. */
  4043. private _keys;
  4044. /**
  4045. * Stores the easing function of the animation
  4046. */
  4047. private _easingFunction;
  4048. /**
  4049. * @hidden Internal use only
  4050. */
  4051. _runtimeAnimations: RuntimeAnimation[];
  4052. /**
  4053. * The set of event that will be linked to this animation
  4054. */
  4055. private _events;
  4056. /**
  4057. * Stores an array of target property paths
  4058. */
  4059. targetPropertyPath: string[];
  4060. /**
  4061. * Stores the blending speed of the animation
  4062. */
  4063. blendingSpeed: number;
  4064. /**
  4065. * Stores the animation ranges for the animation
  4066. */
  4067. private _ranges;
  4068. /**
  4069. * @hidden Internal use
  4070. */
  4071. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4072. /**
  4073. * Sets up an animation
  4074. * @param property The property to animate
  4075. * @param animationType The animation type to apply
  4076. * @param framePerSecond The frames per second of the animation
  4077. * @param easingFunction The easing function used in the animation
  4078. * @returns The created animation
  4079. */
  4080. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4081. /**
  4082. * Create and start an animation on a node
  4083. * @param name defines the name of the global animation that will be run on all nodes
  4084. * @param node defines the root node where the animation will take place
  4085. * @param targetProperty defines property to animate
  4086. * @param framePerSecond defines the number of frame per second yo use
  4087. * @param totalFrame defines the number of frames in total
  4088. * @param from defines the initial value
  4089. * @param to defines the final value
  4090. * @param loopMode defines which loop mode you want to use (off by default)
  4091. * @param easingFunction defines the easing function to use (linear by default)
  4092. * @param onAnimationEnd defines the callback to call when animation end
  4093. * @returns the animatable created for this animation
  4094. */
  4095. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4096. /**
  4097. * Create and start an animation on a node and its descendants
  4098. * @param name defines the name of the global animation that will be run on all nodes
  4099. * @param node defines the root node where the animation will take place
  4100. * @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
  4101. * @param targetProperty defines property to animate
  4102. * @param framePerSecond defines the number of frame per second to use
  4103. * @param totalFrame defines the number of frames in total
  4104. * @param from defines the initial value
  4105. * @param to defines the final value
  4106. * @param loopMode defines which loop mode you want to use (off by default)
  4107. * @param easingFunction defines the easing function to use (linear by default)
  4108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4109. * @returns the list of animatables created for all nodes
  4110. * @example https://www.babylonjs-playground.com/#MH0VLI
  4111. */
  4112. 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[]>;
  4113. /**
  4114. * Creates a new animation, merges it with the existing animations and starts it
  4115. * @param name Name of the animation
  4116. * @param node Node which contains the scene that begins the animations
  4117. * @param targetProperty Specifies which property to animate
  4118. * @param framePerSecond The frames per second of the animation
  4119. * @param totalFrame The total number of frames
  4120. * @param from The frame at the beginning of the animation
  4121. * @param to The frame at the end of the animation
  4122. * @param loopMode Specifies the loop mode of the animation
  4123. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4124. * @param onAnimationEnd Callback to run once the animation is complete
  4125. * @returns Nullable animation
  4126. */
  4127. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4128. /**
  4129. * Transition property of an host to the target Value
  4130. * @param property The property to transition
  4131. * @param targetValue The target Value of the property
  4132. * @param host The object where the property to animate belongs
  4133. * @param scene Scene used to run the animation
  4134. * @param frameRate Framerate (in frame/s) to use
  4135. * @param transition The transition type we want to use
  4136. * @param duration The duration of the animation, in milliseconds
  4137. * @param onAnimationEnd Callback trigger at the end of the animation
  4138. * @returns Nullable animation
  4139. */
  4140. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4141. /**
  4142. * Return the array of runtime animations currently using this animation
  4143. */
  4144. readonly runtimeAnimations: RuntimeAnimation[];
  4145. /**
  4146. * Specifies if any of the runtime animations are currently running
  4147. */
  4148. readonly hasRunningRuntimeAnimations: boolean;
  4149. /**
  4150. * Initializes the animation
  4151. * @param name Name of the animation
  4152. * @param targetProperty Property to animate
  4153. * @param framePerSecond The frames per second of the animation
  4154. * @param dataType The data type of the animation
  4155. * @param loopMode The loop mode of the animation
  4156. * @param enableBlendings Specifies if blending should be enabled
  4157. */
  4158. constructor(
  4159. /**Name of the animation */
  4160. name: string,
  4161. /**Property to animate */
  4162. targetProperty: string,
  4163. /**The frames per second of the animation */
  4164. framePerSecond: number,
  4165. /**The data type of the animation */
  4166. dataType: number,
  4167. /**The loop mode of the animation */
  4168. loopMode?: number | undefined,
  4169. /**Specifies if blending should be enabled */
  4170. enableBlending?: boolean | undefined);
  4171. /**
  4172. * Converts the animation to a string
  4173. * @param fullDetails support for multiple levels of logging within scene loading
  4174. * @returns String form of the animation
  4175. */
  4176. toString(fullDetails?: boolean): string;
  4177. /**
  4178. * Add an event to this animation
  4179. * @param event Event to add
  4180. */
  4181. addEvent(event: AnimationEvent): void;
  4182. /**
  4183. * Remove all events found at the given frame
  4184. * @param frame The frame to remove events from
  4185. */
  4186. removeEvents(frame: number): void;
  4187. /**
  4188. * Retrieves all the events from the animation
  4189. * @returns Events from the animation
  4190. */
  4191. getEvents(): AnimationEvent[];
  4192. /**
  4193. * Creates an animation range
  4194. * @param name Name of the animation range
  4195. * @param from Starting frame of the animation range
  4196. * @param to Ending frame of the animation
  4197. */
  4198. createRange(name: string, from: number, to: number): void;
  4199. /**
  4200. * Deletes an animation range by name
  4201. * @param name Name of the animation range to delete
  4202. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4203. */
  4204. deleteRange(name: string, deleteFrames?: boolean): void;
  4205. /**
  4206. * Gets the animation range by name, or null if not defined
  4207. * @param name Name of the animation range
  4208. * @returns Nullable animation range
  4209. */
  4210. getRange(name: string): Nullable<AnimationRange>;
  4211. /**
  4212. * Gets the key frames from the animation
  4213. * @returns The key frames of the animation
  4214. */
  4215. getKeys(): Array<IAnimationKey>;
  4216. /**
  4217. * Gets the highest frame rate of the animation
  4218. * @returns Highest frame rate of the animation
  4219. */
  4220. getHighestFrame(): number;
  4221. /**
  4222. * Gets the easing function of the animation
  4223. * @returns Easing function of the animation
  4224. */
  4225. getEasingFunction(): IEasingFunction;
  4226. /**
  4227. * Sets the easing function of the animation
  4228. * @param easingFunction A custom mathematical formula for animation
  4229. */
  4230. setEasingFunction(easingFunction: EasingFunction): void;
  4231. /**
  4232. * Interpolates a scalar linearly
  4233. * @param startValue Start value of the animation curve
  4234. * @param endValue End value of the animation curve
  4235. * @param gradient Scalar amount to interpolate
  4236. * @returns Interpolated scalar value
  4237. */
  4238. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4239. /**
  4240. * Interpolates a scalar cubically
  4241. * @param startValue Start value of the animation curve
  4242. * @param outTangent End tangent of the animation
  4243. * @param endValue End value of the animation curve
  4244. * @param inTangent Start tangent of the animation curve
  4245. * @param gradient Scalar amount to interpolate
  4246. * @returns Interpolated scalar value
  4247. */
  4248. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4249. /**
  4250. * Interpolates a quaternion using a spherical linear interpolation
  4251. * @param startValue Start value of the animation curve
  4252. * @param endValue End value of the animation curve
  4253. * @param gradient Scalar amount to interpolate
  4254. * @returns Interpolated quaternion value
  4255. */
  4256. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4257. /**
  4258. * Interpolates a quaternion cubically
  4259. * @param startValue Start value of the animation curve
  4260. * @param outTangent End tangent of the animation curve
  4261. * @param endValue End value of the animation curve
  4262. * @param inTangent Start tangent of the animation curve
  4263. * @param gradient Scalar amount to interpolate
  4264. * @returns Interpolated quaternion value
  4265. */
  4266. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4267. /**
  4268. * Interpolates a Vector3 linearl
  4269. * @param startValue Start value of the animation curve
  4270. * @param endValue End value of the animation curve
  4271. * @param gradient Scalar amount to interpolate
  4272. * @returns Interpolated scalar value
  4273. */
  4274. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4275. /**
  4276. * Interpolates a Vector3 cubically
  4277. * @param startValue Start value of the animation curve
  4278. * @param outTangent End tangent of the animation
  4279. * @param endValue End value of the animation curve
  4280. * @param inTangent Start tangent of the animation curve
  4281. * @param gradient Scalar amount to interpolate
  4282. * @returns InterpolatedVector3 value
  4283. */
  4284. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4285. /**
  4286. * Interpolates a Vector2 linearly
  4287. * @param startValue Start value of the animation curve
  4288. * @param endValue End value of the animation curve
  4289. * @param gradient Scalar amount to interpolate
  4290. * @returns Interpolated Vector2 value
  4291. */
  4292. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4293. /**
  4294. * Interpolates a Vector2 cubically
  4295. * @param startValue Start value of the animation curve
  4296. * @param outTangent End tangent of the animation
  4297. * @param endValue End value of the animation curve
  4298. * @param inTangent Start tangent of the animation curve
  4299. * @param gradient Scalar amount to interpolate
  4300. * @returns Interpolated Vector2 value
  4301. */
  4302. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4303. /**
  4304. * Interpolates a size linearly
  4305. * @param startValue Start value of the animation curve
  4306. * @param endValue End value of the animation curve
  4307. * @param gradient Scalar amount to interpolate
  4308. * @returns Interpolated Size value
  4309. */
  4310. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4311. /**
  4312. * Interpolates a Color3 linearly
  4313. * @param startValue Start value of the animation curve
  4314. * @param endValue End value of the animation curve
  4315. * @param gradient Scalar amount to interpolate
  4316. * @returns Interpolated Color3 value
  4317. */
  4318. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4319. /**
  4320. * @hidden Internal use only
  4321. */
  4322. _getKeyValue(value: any): any;
  4323. /**
  4324. * @hidden Internal use only
  4325. */
  4326. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4327. /**
  4328. * Defines the function to use to interpolate matrices
  4329. * @param startValue defines the start matrix
  4330. * @param endValue defines the end matrix
  4331. * @param gradient defines the gradient between both matrices
  4332. * @param result defines an optional target matrix where to store the interpolation
  4333. * @returns the interpolated matrix
  4334. */
  4335. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4336. /**
  4337. * Makes a copy of the animation
  4338. * @returns Cloned animation
  4339. */
  4340. clone(): Animation;
  4341. /**
  4342. * Sets the key frames of the animation
  4343. * @param values The animation key frames to set
  4344. */
  4345. setKeys(values: Array<IAnimationKey>): void;
  4346. /**
  4347. * Serializes the animation to an object
  4348. * @returns Serialized object
  4349. */
  4350. serialize(): any;
  4351. /**
  4352. * Float animation type
  4353. */
  4354. private static _ANIMATIONTYPE_FLOAT;
  4355. /**
  4356. * Vector3 animation type
  4357. */
  4358. private static _ANIMATIONTYPE_VECTOR3;
  4359. /**
  4360. * Quaternion animation type
  4361. */
  4362. private static _ANIMATIONTYPE_QUATERNION;
  4363. /**
  4364. * Matrix animation type
  4365. */
  4366. private static _ANIMATIONTYPE_MATRIX;
  4367. /**
  4368. * Color3 animation type
  4369. */
  4370. private static _ANIMATIONTYPE_COLOR3;
  4371. /**
  4372. * Vector2 animation type
  4373. */
  4374. private static _ANIMATIONTYPE_VECTOR2;
  4375. /**
  4376. * Size animation type
  4377. */
  4378. private static _ANIMATIONTYPE_SIZE;
  4379. /**
  4380. * Relative Loop Mode
  4381. */
  4382. private static _ANIMATIONLOOPMODE_RELATIVE;
  4383. /**
  4384. * Cycle Loop Mode
  4385. */
  4386. private static _ANIMATIONLOOPMODE_CYCLE;
  4387. /**
  4388. * Constant Loop Mode
  4389. */
  4390. private static _ANIMATIONLOOPMODE_CONSTANT;
  4391. /**
  4392. * Get the float animation type
  4393. */
  4394. static readonly ANIMATIONTYPE_FLOAT: number;
  4395. /**
  4396. * Get the Vector3 animation type
  4397. */
  4398. static readonly ANIMATIONTYPE_VECTOR3: number;
  4399. /**
  4400. * Get the Vector2 animation type
  4401. */
  4402. static readonly ANIMATIONTYPE_VECTOR2: number;
  4403. /**
  4404. * Get the Size animation type
  4405. */
  4406. static readonly ANIMATIONTYPE_SIZE: number;
  4407. /**
  4408. * Get the Quaternion animation type
  4409. */
  4410. static readonly ANIMATIONTYPE_QUATERNION: number;
  4411. /**
  4412. * Get the Matrix animation type
  4413. */
  4414. static readonly ANIMATIONTYPE_MATRIX: number;
  4415. /**
  4416. * Get the Color3 animation type
  4417. */
  4418. static readonly ANIMATIONTYPE_COLOR3: number;
  4419. /**
  4420. * Get the Relative Loop Mode
  4421. */
  4422. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4423. /**
  4424. * Get the Cycle Loop Mode
  4425. */
  4426. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4427. /**
  4428. * Get the Constant Loop Mode
  4429. */
  4430. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4431. /** @hidden */
  4432. static _UniversalLerp(left: any, right: any, amount: number): any;
  4433. /**
  4434. * Parses an animation object and creates an animation
  4435. * @param parsedAnimation Parsed animation object
  4436. * @returns Animation object
  4437. */
  4438. static Parse(parsedAnimation: any): Animation;
  4439. /**
  4440. * Appends the serialized animations from the source animations
  4441. * @param source Source containing the animations
  4442. * @param destination Target to store the animations
  4443. */
  4444. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4445. }
  4446. }
  4447. declare module BABYLON {
  4448. /**
  4449. * This class defines the direct association between an animation and a target
  4450. */
  4451. class TargetedAnimation {
  4452. animation: Animation;
  4453. target: any;
  4454. }
  4455. /**
  4456. * Use this class to create coordinated animations on multiple targets
  4457. */
  4458. class AnimationGroup implements IDisposable {
  4459. name: string;
  4460. private _scene;
  4461. private _targetedAnimations;
  4462. private _animatables;
  4463. private _from;
  4464. private _to;
  4465. private _isStarted;
  4466. private _speedRatio;
  4467. onAnimationEndObservable: Observable<TargetedAnimation>;
  4468. /**
  4469. * This observable will notify when all animations have ended.
  4470. */
  4471. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4472. /**
  4473. * This observable will notify when all animations have paused.
  4474. */
  4475. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4476. /**
  4477. * Gets the first frame
  4478. */
  4479. readonly from: number;
  4480. /**
  4481. * Gets the last frame
  4482. */
  4483. readonly to: number;
  4484. /**
  4485. * Define if the animations are started
  4486. */
  4487. readonly isStarted: boolean;
  4488. /**
  4489. * Gets or sets the speed ratio to use for all animations
  4490. */
  4491. /**
  4492. * Gets or sets the speed ratio to use for all animations
  4493. */
  4494. speedRatio: number;
  4495. /**
  4496. * Gets the targeted animations for this animation group
  4497. */
  4498. readonly targetedAnimations: Array<TargetedAnimation>;
  4499. /**
  4500. * returning the list of animatables controlled by this animation group.
  4501. */
  4502. readonly animatables: Array<Animatable>;
  4503. constructor(name: string, scene?: Nullable<Scene>);
  4504. /**
  4505. * Add an animation (with its target) in the group
  4506. * @param animation defines the animation we want to add
  4507. * @param target defines the target of the animation
  4508. * @returns the {BABYLON.TargetedAnimation} object
  4509. */
  4510. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4511. /**
  4512. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4513. * It can add constant keys at begin or end
  4514. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4515. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4516. */
  4517. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4518. /**
  4519. * Start all animations on given targets
  4520. * @param loop defines if animations must loop
  4521. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4522. * @param from defines the from key (optional)
  4523. * @param to defines the to key (optional)
  4524. * @returns the current animation group
  4525. */
  4526. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4527. /**
  4528. * Pause all animations
  4529. */
  4530. pause(): AnimationGroup;
  4531. /**
  4532. * Play all animations to initial state
  4533. * This function will start() the animations if they were not started or will restart() them if they were paused
  4534. * @param loop defines if animations must loop
  4535. */
  4536. play(loop?: boolean): AnimationGroup;
  4537. /**
  4538. * Reset all animations to initial state
  4539. */
  4540. reset(): AnimationGroup;
  4541. /**
  4542. * Restart animations from key 0
  4543. */
  4544. restart(): AnimationGroup;
  4545. /**
  4546. * Stop all animations
  4547. */
  4548. stop(): AnimationGroup;
  4549. /**
  4550. * Set animation weight for all animatables
  4551. * @param weight defines the weight to use
  4552. * @return the animationGroup
  4553. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4554. */
  4555. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4556. /**
  4557. * Synchronize and normalize all animatables with a source animatable
  4558. * @param root defines the root animatable to synchronize with
  4559. * @return the animationGroup
  4560. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4561. */
  4562. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4563. /**
  4564. * Goes to a specific frame in this animation group
  4565. * @param frame the frame number to go to
  4566. * @return the animationGroup
  4567. */
  4568. goToFrame(frame: number): AnimationGroup;
  4569. /**
  4570. * Dispose all associated resources
  4571. */
  4572. dispose(): void;
  4573. private _checkAnimationGroupEnded;
  4574. }
  4575. }
  4576. declare module BABYLON {
  4577. /**
  4578. * Class used to override all child animations of a given target
  4579. */
  4580. class AnimationPropertiesOverride {
  4581. /**
  4582. * Gets or sets a value indicating if animation blending must be used
  4583. */
  4584. enableBlending: boolean;
  4585. /**
  4586. * Gets or sets the blending speed to use when enableBlending is true
  4587. */
  4588. blendingSpeed: number;
  4589. /**
  4590. * Gets or sets the default loop mode to use
  4591. */
  4592. loopMode: number;
  4593. }
  4594. }
  4595. declare module BABYLON {
  4596. interface IEasingFunction {
  4597. ease(gradient: number): number;
  4598. }
  4599. class EasingFunction implements IEasingFunction {
  4600. private static _EASINGMODE_EASEIN;
  4601. private static _EASINGMODE_EASEOUT;
  4602. private static _EASINGMODE_EASEINOUT;
  4603. static readonly EASINGMODE_EASEIN: number;
  4604. static readonly EASINGMODE_EASEOUT: number;
  4605. static readonly EASINGMODE_EASEINOUT: number;
  4606. private _easingMode;
  4607. setEasingMode(easingMode: number): void;
  4608. getEasingMode(): number;
  4609. easeInCore(gradient: number): number;
  4610. ease(gradient: number): number;
  4611. }
  4612. class CircleEase extends EasingFunction implements IEasingFunction {
  4613. easeInCore(gradient: number): number;
  4614. }
  4615. class BackEase extends EasingFunction implements IEasingFunction {
  4616. amplitude: number;
  4617. constructor(amplitude?: number);
  4618. easeInCore(gradient: number): number;
  4619. }
  4620. class BounceEase extends EasingFunction implements IEasingFunction {
  4621. bounces: number;
  4622. bounciness: number;
  4623. constructor(bounces?: number, bounciness?: number);
  4624. easeInCore(gradient: number): number;
  4625. }
  4626. class CubicEase extends EasingFunction implements IEasingFunction {
  4627. easeInCore(gradient: number): number;
  4628. }
  4629. class ElasticEase extends EasingFunction implements IEasingFunction {
  4630. oscillations: number;
  4631. springiness: number;
  4632. constructor(oscillations?: number, springiness?: number);
  4633. easeInCore(gradient: number): number;
  4634. }
  4635. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4636. exponent: number;
  4637. constructor(exponent?: number);
  4638. easeInCore(gradient: number): number;
  4639. }
  4640. class PowerEase extends EasingFunction implements IEasingFunction {
  4641. power: number;
  4642. constructor(power?: number);
  4643. easeInCore(gradient: number): number;
  4644. }
  4645. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4646. easeInCore(gradient: number): number;
  4647. }
  4648. class QuarticEase extends EasingFunction implements IEasingFunction {
  4649. easeInCore(gradient: number): number;
  4650. }
  4651. class QuinticEase extends EasingFunction implements IEasingFunction {
  4652. easeInCore(gradient: number): number;
  4653. }
  4654. class SineEase extends EasingFunction implements IEasingFunction {
  4655. easeInCore(gradient: number): number;
  4656. }
  4657. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4658. x1: number;
  4659. y1: number;
  4660. x2: number;
  4661. y2: number;
  4662. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4663. easeInCore(gradient: number): number;
  4664. }
  4665. }
  4666. declare module BABYLON {
  4667. /**
  4668. * Defines a runtime animation
  4669. */
  4670. class RuntimeAnimation {
  4671. private _events;
  4672. /**
  4673. * The current frame of the runtime animation
  4674. */
  4675. private _currentFrame;
  4676. /**
  4677. * The animation used by the runtime animation
  4678. */
  4679. private _animation;
  4680. /**
  4681. * The target of the runtime animation
  4682. */
  4683. private _target;
  4684. /**
  4685. * The initiating animatable
  4686. */
  4687. private _host;
  4688. /**
  4689. * The original value of the runtime animation
  4690. */
  4691. private _originalValue;
  4692. /**
  4693. * The original blend value of the runtime animation
  4694. */
  4695. private _originalBlendValue;
  4696. /**
  4697. * The offsets cache of the runtime animation
  4698. */
  4699. private _offsetsCache;
  4700. /**
  4701. * The high limits cache of the runtime animation
  4702. */
  4703. private _highLimitsCache;
  4704. /**
  4705. * Specifies if the runtime animation has been stopped
  4706. */
  4707. private _stopped;
  4708. /**
  4709. * The blending factor of the runtime animation
  4710. */
  4711. private _blendingFactor;
  4712. /**
  4713. * The BabylonJS scene
  4714. */
  4715. private _scene;
  4716. /**
  4717. * The current value of the runtime animation
  4718. */
  4719. private _currentValue;
  4720. /** @hidden */
  4721. _workValue: any;
  4722. /**
  4723. * The active target of the runtime animation
  4724. */
  4725. private _activeTarget;
  4726. /**
  4727. * The target path of the runtime animation
  4728. */
  4729. private _targetPath;
  4730. /**
  4731. * The weight of the runtime animation
  4732. */
  4733. private _weight;
  4734. /**
  4735. * The ratio offset of the runtime animation
  4736. */
  4737. private _ratioOffset;
  4738. /**
  4739. * The previous delay of the runtime animation
  4740. */
  4741. private _previousDelay;
  4742. /**
  4743. * The previous ratio of the runtime animation
  4744. */
  4745. private _previousRatio;
  4746. /**
  4747. * Gets the current frame of the runtime animation
  4748. */
  4749. readonly currentFrame: number;
  4750. /**
  4751. * Gets the weight of the runtime animation
  4752. */
  4753. readonly weight: number;
  4754. /**
  4755. * Gets the current value of the runtime animation
  4756. */
  4757. readonly currentValue: any;
  4758. /**
  4759. * Gets the target path of the runtime animation
  4760. */
  4761. readonly targetPath: string;
  4762. /**
  4763. * Gets the actual target of the runtime animation
  4764. */
  4765. readonly target: any;
  4766. /**
  4767. * Create a new RuntimeAnimation object
  4768. * @param target defines the target of the animation
  4769. * @param animation defines the source animation object
  4770. * @param scene defines the hosting scene
  4771. * @param host defines the initiating Animatable
  4772. */
  4773. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4774. /**
  4775. * Gets the animation from the runtime animation
  4776. */
  4777. readonly animation: Animation;
  4778. /**
  4779. * Resets the runtime animation to the beginning
  4780. * @param restoreOriginal defines whether to restore the target property to the original value
  4781. */
  4782. reset(restoreOriginal?: boolean): void;
  4783. /**
  4784. * Specifies if the runtime animation is stopped
  4785. * @returns Boolean specifying if the runtime animation is stopped
  4786. */
  4787. isStopped(): boolean;
  4788. /**
  4789. * Disposes of the runtime animation
  4790. */
  4791. dispose(): void;
  4792. /**
  4793. * Interpolates the animation from the current frame
  4794. * @param currentFrame The frame to interpolate the animation to
  4795. * @param repeatCount The number of times that the animation should loop
  4796. * @param loopMode The type of looping mode to use
  4797. * @param offsetValue Animation offset value
  4798. * @param highLimitValue The high limit value
  4799. * @returns The interpolated value
  4800. */
  4801. private _interpolate;
  4802. /**
  4803. * Apply the interpolated value to the target
  4804. * @param currentValue defines the value computed by the animation
  4805. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4806. */
  4807. setValue(currentValue: any, weight?: number): void;
  4808. private _setValue;
  4809. /**
  4810. * Gets the loop pmode of the runtime animation
  4811. * @returns Loop Mode
  4812. */
  4813. private _getCorrectLoopMode;
  4814. /**
  4815. * Move the current animation to a given frame
  4816. * @param frame defines the frame to move to
  4817. */
  4818. goToFrame(frame: number): void;
  4819. /**
  4820. * @hidden Internal use only
  4821. */
  4822. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4823. /**
  4824. * Execute the current animation
  4825. * @param delay defines the delay to add to the current frame
  4826. * @param from defines the lower bound of the animation range
  4827. * @param to defines the upper bound of the animation range
  4828. * @param loop defines if the current animation must loop
  4829. * @param speedRatio defines the current speed ratio
  4830. * @param weight defines the weight of the animation (default is -1 so no weight)
  4831. * @returns a boolean indicating if the animation is running
  4832. */
  4833. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4834. }
  4835. }
  4836. declare module BABYLON {
  4837. /**
  4838. * Interface used to define a behavior
  4839. */
  4840. interface Behavior<T> {
  4841. /** gets or sets behavior's name */
  4842. name: string;
  4843. /**
  4844. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4845. */
  4846. init(): void;
  4847. /**
  4848. * Called when the behavior is attached to a target
  4849. * @param target defines the target where the behavior is attached to
  4850. */
  4851. attach(target: T): void;
  4852. /**
  4853. * Called when the behavior is detached from its target
  4854. */
  4855. detach(): void;
  4856. }
  4857. /**
  4858. * Interface implemented by classes supporting behaviors
  4859. */
  4860. interface IBehaviorAware<T> {
  4861. /**
  4862. * Attach a behavior
  4863. * @param behavior defines the behavior to attach
  4864. * @returns the current host
  4865. */
  4866. addBehavior(behavior: Behavior<T>): T;
  4867. /**
  4868. * Remove a behavior from the current object
  4869. * @param behavior defines the behavior to detach
  4870. * @returns the current host
  4871. */
  4872. removeBehavior(behavior: Behavior<T>): T;
  4873. /**
  4874. * Gets a behavior using its name to search
  4875. * @param name defines the name to search
  4876. * @returns the behavior or null if not found
  4877. */
  4878. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. class Collider {
  4883. /** Define if a collision was found */
  4884. collisionFound: boolean;
  4885. /**
  4886. * Define last intersection point in local space
  4887. */
  4888. intersectionPoint: Vector3;
  4889. /**
  4890. * Define last collided mesh
  4891. */
  4892. collidedMesh: Nullable<AbstractMesh>;
  4893. private _collisionPoint;
  4894. private _planeIntersectionPoint;
  4895. private _tempVector;
  4896. private _tempVector2;
  4897. private _tempVector3;
  4898. private _tempVector4;
  4899. private _edge;
  4900. private _baseToVertex;
  4901. private _destinationPoint;
  4902. private _slidePlaneNormal;
  4903. private _displacementVector;
  4904. /** @hidden */
  4905. _radius: Vector3;
  4906. /** @hidden */
  4907. _retry: number;
  4908. private _velocity;
  4909. private _basePoint;
  4910. private _epsilon;
  4911. /** @hidden */
  4912. _velocityWorldLength: number;
  4913. /** @hidden */
  4914. _basePointWorld: Vector3;
  4915. private _velocityWorld;
  4916. private _normalizedVelocity;
  4917. /** @hidden */
  4918. _initialVelocity: Vector3;
  4919. /** @hidden */
  4920. _initialPosition: Vector3;
  4921. private _nearestDistance;
  4922. private _collisionMask;
  4923. collisionMask: number;
  4924. /**
  4925. * Gets the plane normal used to compute the sliding response (in local space)
  4926. */
  4927. readonly slidePlaneNormal: Vector3;
  4928. /** @hidden */
  4929. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4930. /** @hidden */
  4931. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4932. /** @hidden */
  4933. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4934. /** @hidden */
  4935. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4936. /** @hidden */
  4937. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4938. /** @hidden */
  4939. _getResponse(pos: Vector3, vel: Vector3): void;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. var CollisionWorker: string;
  4944. interface ICollisionCoordinator {
  4945. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4946. init(scene: Scene): void;
  4947. destroy(): void;
  4948. onMeshAdded(mesh: AbstractMesh): void;
  4949. onMeshUpdated(mesh: AbstractMesh): void;
  4950. onMeshRemoved(mesh: AbstractMesh): void;
  4951. onGeometryAdded(geometry: Geometry): void;
  4952. onGeometryUpdated(geometry: Geometry): void;
  4953. onGeometryDeleted(geometry: Geometry): void;
  4954. }
  4955. interface SerializedMesh {
  4956. id: string;
  4957. name: string;
  4958. uniqueId: number;
  4959. geometryId: Nullable<string>;
  4960. sphereCenter: Array<number>;
  4961. sphereRadius: number;
  4962. boxMinimum: Array<number>;
  4963. boxMaximum: Array<number>;
  4964. worldMatrixFromCache: any;
  4965. subMeshes: Array<SerializedSubMesh>;
  4966. checkCollisions: boolean;
  4967. }
  4968. interface SerializedSubMesh {
  4969. position: number;
  4970. verticesStart: number;
  4971. verticesCount: number;
  4972. indexStart: number;
  4973. indexCount: number;
  4974. hasMaterial: boolean;
  4975. sphereCenter: Array<number>;
  4976. sphereRadius: number;
  4977. boxMinimum: Array<number>;
  4978. boxMaximum: Array<number>;
  4979. }
  4980. /**
  4981. * Interface describing the value associated with a geometry
  4982. */
  4983. interface SerializedGeometry {
  4984. /**
  4985. * Defines the unique ID of the geometry
  4986. */
  4987. id: string;
  4988. /**
  4989. * Defines the array containing the positions
  4990. */
  4991. positions: Float32Array;
  4992. /**
  4993. * Defines the array containing the indices
  4994. */
  4995. indices: Uint32Array;
  4996. /**
  4997. * Defines the array containing the normals
  4998. */
  4999. normals: Float32Array;
  5000. }
  5001. interface BabylonMessage {
  5002. taskType: WorkerTaskType;
  5003. payload: InitPayload | CollidePayload | UpdatePayload;
  5004. }
  5005. interface SerializedColliderToWorker {
  5006. position: Array<number>;
  5007. velocity: Array<number>;
  5008. radius: Array<number>;
  5009. }
  5010. /** Defines supported task for worker process */
  5011. enum WorkerTaskType {
  5012. /** Initialization */
  5013. INIT = 0,
  5014. /** Update of geometry */
  5015. UPDATE = 1,
  5016. /** Evaluate collision */
  5017. COLLIDE = 2
  5018. }
  5019. interface WorkerReply {
  5020. error: WorkerReplyType;
  5021. taskType: WorkerTaskType;
  5022. payload?: any;
  5023. }
  5024. interface CollisionReplyPayload {
  5025. newPosition: Array<number>;
  5026. collisionId: number;
  5027. collidedMeshUniqueId: number;
  5028. }
  5029. interface InitPayload {
  5030. }
  5031. interface CollidePayload {
  5032. collisionId: number;
  5033. collider: SerializedColliderToWorker;
  5034. maximumRetry: number;
  5035. excludedMeshUniqueId: Nullable<number>;
  5036. }
  5037. interface UpdatePayload {
  5038. updatedMeshes: {
  5039. [n: number]: SerializedMesh;
  5040. };
  5041. updatedGeometries: {
  5042. [s: string]: SerializedGeometry;
  5043. };
  5044. removedMeshes: Array<number>;
  5045. removedGeometries: Array<string>;
  5046. }
  5047. /** Defines kind of replies returned by worker */
  5048. enum WorkerReplyType {
  5049. /** Success */
  5050. SUCCESS = 0,
  5051. /** Unkown error */
  5052. UNKNOWN_ERROR = 1
  5053. }
  5054. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5055. private _scene;
  5056. private _scaledPosition;
  5057. private _scaledVelocity;
  5058. private _collisionsCallbackArray;
  5059. private _init;
  5060. private _runningUpdated;
  5061. private _worker;
  5062. private _addUpdateMeshesList;
  5063. private _addUpdateGeometriesList;
  5064. private _toRemoveMeshesArray;
  5065. private _toRemoveGeometryArray;
  5066. constructor();
  5067. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5068. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5069. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5070. init(scene: Scene): void;
  5071. destroy(): void;
  5072. onMeshAdded(mesh: AbstractMesh): void;
  5073. onMeshUpdated: (transformNode: TransformNode) => void;
  5074. onMeshRemoved(mesh: AbstractMesh): void;
  5075. onGeometryAdded(geometry: Geometry): void;
  5076. onGeometryUpdated: (geometry: Geometry) => void;
  5077. onGeometryDeleted(geometry: Geometry): void;
  5078. private _afterRender;
  5079. private _onMessageFromWorker;
  5080. }
  5081. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5082. private _scene;
  5083. private _scaledPosition;
  5084. private _scaledVelocity;
  5085. private _finalPosition;
  5086. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5087. init(scene: Scene): void;
  5088. destroy(): void;
  5089. onMeshAdded(mesh: AbstractMesh): void;
  5090. onMeshUpdated(mesh: AbstractMesh): void;
  5091. onMeshRemoved(mesh: AbstractMesh): void;
  5092. onGeometryAdded(geometry: Geometry): void;
  5093. onGeometryUpdated(geometry: Geometry): void;
  5094. onGeometryDeleted(geometry: Geometry): void;
  5095. private _collideWithWorld;
  5096. }
  5097. }
  5098. declare function importScripts(...urls: string[]): void;
  5099. declare const safePostMessage: any;
  5100. declare module BABYLON {
  5101. var WorkerIncluded: boolean;
  5102. class CollisionCache {
  5103. private _meshes;
  5104. private _geometries;
  5105. getMeshes(): {
  5106. [n: number]: SerializedMesh;
  5107. };
  5108. getGeometries(): {
  5109. [s: number]: SerializedGeometry;
  5110. };
  5111. getMesh(id: any): SerializedMesh;
  5112. addMesh(mesh: SerializedMesh): void;
  5113. removeMesh(uniqueId: number): void;
  5114. getGeometry(id: string): SerializedGeometry;
  5115. addGeometry(geometry: SerializedGeometry): void;
  5116. removeGeometry(id: string): void;
  5117. }
  5118. class CollideWorker {
  5119. collider: Collider;
  5120. private _collisionCache;
  5121. private finalPosition;
  5122. private collisionsScalingMatrix;
  5123. private collisionTranformationMatrix;
  5124. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5125. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5126. private checkCollision;
  5127. private processCollisionsForSubMeshes;
  5128. private collideForSubMesh;
  5129. private checkSubmeshCollision;
  5130. }
  5131. interface ICollisionDetector {
  5132. onInit(payload: InitPayload): void;
  5133. onUpdate(payload: UpdatePayload): void;
  5134. onCollision(payload: CollidePayload): void;
  5135. }
  5136. class CollisionDetectorTransferable implements ICollisionDetector {
  5137. private _collisionCache;
  5138. onInit(payload: InitPayload): void;
  5139. onUpdate(payload: UpdatePayload): void;
  5140. onCollision(payload: CollidePayload): void;
  5141. }
  5142. }
  5143. declare module BABYLON {
  5144. class IntersectionInfo {
  5145. bu: Nullable<number>;
  5146. bv: Nullable<number>;
  5147. distance: number;
  5148. faceId: number;
  5149. subMeshId: number;
  5150. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5151. }
  5152. /**
  5153. * Information about the result of picking within a scene
  5154. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5155. */
  5156. class PickingInfo {
  5157. /**
  5158. * If the pick collided with an object
  5159. */
  5160. hit: boolean;
  5161. /**
  5162. * Distance away where the pick collided
  5163. */
  5164. distance: number;
  5165. /**
  5166. * The location of pick collision
  5167. */
  5168. pickedPoint: Nullable<Vector3>;
  5169. /**
  5170. * The mesh corresponding the the pick collision
  5171. */
  5172. pickedMesh: Nullable<AbstractMesh>;
  5173. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5174. bu: number;
  5175. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5176. bv: number;
  5177. /** The id of the face on the mesh that was picked */
  5178. faceId: number;
  5179. /** Id of the the submesh that was picked */
  5180. subMeshId: number;
  5181. /** If a sprite was picked, this will be the sprite the pick collided with */
  5182. pickedSprite: Nullable<Sprite>;
  5183. /**
  5184. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5185. */
  5186. originMesh: Nullable<AbstractMesh>;
  5187. /**
  5188. * The ray that was used to perform the picking.
  5189. */
  5190. ray: Nullable<Ray>;
  5191. /**
  5192. * Gets the normal correspodning to the face the pick collided with
  5193. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5194. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5195. * @returns The normal correspodning to the face the pick collided with
  5196. */
  5197. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5198. /**
  5199. * Gets the texture coordinates of where the pick occured
  5200. * @returns the vector containing the coordnates of the texture
  5201. */
  5202. getTextureCoordinates(): Nullable<Vector2>;
  5203. }
  5204. }
  5205. declare module BABYLON {
  5206. /**
  5207. * Class used to store bone information
  5208. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5209. */
  5210. class Bone extends Node {
  5211. /**
  5212. * defines the bone name
  5213. */
  5214. name: string;
  5215. private static _tmpVecs;
  5216. private static _tmpQuat;
  5217. private static _tmpMats;
  5218. /**
  5219. * Gets the list of child bones
  5220. */
  5221. children: Bone[];
  5222. /** Gets the animations associated with this bone */
  5223. animations: Animation[];
  5224. /**
  5225. * Gets or sets bone length
  5226. */
  5227. length: number;
  5228. /**
  5229. * @hidden Internal only
  5230. * Set this value to map this bone to a different index in the transform matrices
  5231. * Set this value to -1 to exclude the bone from the transform matrices
  5232. */
  5233. _index: Nullable<number>;
  5234. private _skeleton;
  5235. private _localMatrix;
  5236. private _restPose;
  5237. private _baseMatrix;
  5238. private _absoluteTransform;
  5239. private _invertedAbsoluteTransform;
  5240. private _parent;
  5241. private _scalingDeterminant;
  5242. private _worldTransform;
  5243. private _localScaling;
  5244. private _localRotation;
  5245. private _localPosition;
  5246. private _needToDecompose;
  5247. private _needToCompose;
  5248. /** @hidden */
  5249. /** @hidden */
  5250. _matrix: Matrix;
  5251. /**
  5252. * Create a new bone
  5253. * @param name defines the bone name
  5254. * @param skeleton defines the parent skeleton
  5255. * @param parentBone defines the parent (can be null if the bone is the root)
  5256. * @param localMatrix defines the local matrix
  5257. * @param restPose defines the rest pose matrix
  5258. * @param baseMatrix defines the base matrix
  5259. * @param index defines index of the bone in the hiearchy
  5260. */
  5261. constructor(
  5262. /**
  5263. * defines the bone name
  5264. */
  5265. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5266. /**
  5267. * Gets the parent skeleton
  5268. * @returns a skeleton
  5269. */
  5270. getSkeleton(): Skeleton;
  5271. /**
  5272. * Gets parent bone
  5273. * @returns a bone or null if the bone is the root of the bone hierarchy
  5274. */
  5275. getParent(): Nullable<Bone>;
  5276. /**
  5277. * Sets the parent bone
  5278. * @param parent defines the parent (can be null if the bone is the root)
  5279. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5280. */
  5281. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5282. /**
  5283. * Gets the local matrix
  5284. * @returns a matrix
  5285. */
  5286. getLocalMatrix(): Matrix;
  5287. /**
  5288. * Gets the base matrix (initial matrix which remains unchanged)
  5289. * @returns a matrix
  5290. */
  5291. getBaseMatrix(): Matrix;
  5292. /**
  5293. * Gets the rest pose matrix
  5294. * @returns a matrix
  5295. */
  5296. getRestPose(): Matrix;
  5297. /**
  5298. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5299. */
  5300. getWorldMatrix(): Matrix;
  5301. /**
  5302. * Sets the local matrix to rest pose matrix
  5303. */
  5304. returnToRest(): void;
  5305. /**
  5306. * Gets the inverse of the absolute transform matrix.
  5307. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5308. * @returns a matrix
  5309. */
  5310. getInvertedAbsoluteTransform(): Matrix;
  5311. /**
  5312. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5313. * @returns a matrix
  5314. */
  5315. getAbsoluteTransform(): Matrix;
  5316. /** Gets or sets current position (in local space) */
  5317. position: Vector3;
  5318. /** Gets or sets current rotation (in local space) */
  5319. rotation: Vector3;
  5320. /** Gets or sets current rotation quaternion (in local space) */
  5321. rotationQuaternion: Quaternion;
  5322. /** Gets or sets current scaling (in local space) */
  5323. scaling: Vector3;
  5324. /**
  5325. * Gets the animation properties override
  5326. */
  5327. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5328. private _decompose;
  5329. private _compose;
  5330. /**
  5331. * Update the base and local matrices
  5332. * @param matrix defines the new base or local matrix
  5333. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5334. * @param updateLocalMatrix defines if the local matrix should be updated
  5335. */
  5336. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5337. /** @hidden */
  5338. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5339. /**
  5340. * Flag the bone as dirty (Forcing it to update everything)
  5341. */
  5342. markAsDirty(): void;
  5343. private _markAsDirtyAndCompose;
  5344. private _markAsDirtyAndDecompose;
  5345. /**
  5346. * Copy an animation range from another bone
  5347. * @param source defines the source bone
  5348. * @param rangeName defines the range name to copy
  5349. * @param frameOffset defines the frame offset
  5350. * @param rescaleAsRequired defines if rescaling must be applied if required
  5351. * @param skelDimensionsRatio defines the scaling ratio
  5352. * @returns true if operation was successful
  5353. */
  5354. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5355. /**
  5356. * Translate the bone in local or world space
  5357. * @param vec The amount to translate the bone
  5358. * @param space The space that the translation is in
  5359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5360. */
  5361. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5362. /**
  5363. * Set the postion of the bone in local or world space
  5364. * @param position The position to set the bone
  5365. * @param space The space that the position is in
  5366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5367. */
  5368. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5369. /**
  5370. * Set the absolute position of the bone (world space)
  5371. * @param position The position to set the bone
  5372. * @param mesh The mesh that this bone is attached to
  5373. */
  5374. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5375. /**
  5376. * Scale the bone on the x, y and z axes (in local space)
  5377. * @param x The amount to scale the bone on the x axis
  5378. * @param y The amount to scale the bone on the y axis
  5379. * @param z The amount to scale the bone on the z axis
  5380. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5381. */
  5382. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5383. /**
  5384. * Set the bone scaling in local space
  5385. * @param scale defines the scaling vector
  5386. */
  5387. setScale(scale: Vector3): void;
  5388. /**
  5389. * Gets the current scaling in local space
  5390. * @returns the current scaling vector
  5391. */
  5392. getScale(): Vector3;
  5393. /**
  5394. * Gets the current scaling in local space and stores it in a target vector
  5395. * @param result defines the target vector
  5396. */
  5397. getScaleToRef(result: Vector3): void;
  5398. /**
  5399. * Set the yaw, pitch, and roll of the bone in local or world space
  5400. * @param yaw The rotation of the bone on the y axis
  5401. * @param pitch The rotation of the bone on the x axis
  5402. * @param roll The rotation of the bone on the z axis
  5403. * @param space The space that the axes of rotation are in
  5404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5405. */
  5406. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5407. /**
  5408. * Add a rotation to the bone on an axis in local or world space
  5409. * @param axis The axis to rotate the bone on
  5410. * @param amount The amount to rotate the bone
  5411. * @param space The space that the axis is in
  5412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5413. */
  5414. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5415. /**
  5416. * Set the rotation of the bone to a particular axis angle in local or world space
  5417. * @param axis The axis to rotate the bone on
  5418. * @param angle The angle that the bone should be rotated to
  5419. * @param space The space that the axis is in
  5420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5421. */
  5422. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5423. /**
  5424. * Set the euler rotation of the bone in local of world space
  5425. * @param rotation The euler rotation that the bone should be set to
  5426. * @param space The space that the rotation is in
  5427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5428. */
  5429. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5430. /**
  5431. * Set the quaternion rotation of the bone in local of world space
  5432. * @param quat The quaternion rotation that the bone should be set to
  5433. * @param space The space that the rotation is in
  5434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5435. */
  5436. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5437. /**
  5438. * Set the rotation matrix of the bone in local of world space
  5439. * @param rotMat The rotation matrix that the bone should be set to
  5440. * @param space The space that the rotation is in
  5441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5442. */
  5443. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5444. private _rotateWithMatrix;
  5445. private _getNegativeRotationToRef;
  5446. /**
  5447. * Get the position of the bone in local or world space
  5448. * @param space The space that the returned position is in
  5449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5450. * @returns The position of the bone
  5451. */
  5452. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5453. /**
  5454. * Copy the position of the bone to a vector3 in local or world space
  5455. * @param space The space that the returned position is in
  5456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5457. * @param result The vector3 to copy the position to
  5458. */
  5459. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5460. /**
  5461. * Get the absolute position of the bone (world space)
  5462. * @param mesh The mesh that this bone is attached to
  5463. * @returns The absolute position of the bone
  5464. */
  5465. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5466. /**
  5467. * Copy the absolute position of the bone (world space) to the result param
  5468. * @param mesh The mesh that this bone is attached to
  5469. * @param result The vector3 to copy the absolute position to
  5470. */
  5471. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5472. /**
  5473. * Compute the absolute transforms of this bone and its children
  5474. */
  5475. computeAbsoluteTransforms(): void;
  5476. /**
  5477. * Get the world direction from an axis that is in the local space of the bone
  5478. * @param localAxis The local direction that is used to compute the world direction
  5479. * @param mesh The mesh that this bone is attached to
  5480. * @returns The world direction
  5481. */
  5482. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5483. /**
  5484. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5485. * @param localAxis The local direction that is used to compute the world direction
  5486. * @param mesh The mesh that this bone is attached to
  5487. * @param result The vector3 that the world direction will be copied to
  5488. */
  5489. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5490. /**
  5491. * Get the euler rotation of the bone in local or world space
  5492. * @param space The space that the rotation should be in
  5493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5494. * @returns The euler rotation
  5495. */
  5496. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5497. /**
  5498. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5499. * @param space The space that the rotation should be in
  5500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5501. * @param result The vector3 that the rotation should be copied to
  5502. */
  5503. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5504. /**
  5505. * Get the quaternion rotation of the bone in either local or world space
  5506. * @param space The space that the rotation should be in
  5507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5508. * @returns The quaternion rotation
  5509. */
  5510. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5511. /**
  5512. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5513. * @param space The space that the rotation should be in
  5514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5515. * @param result The quaternion that the rotation should be copied to
  5516. */
  5517. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5518. /**
  5519. * Get the rotation matrix of the bone in local or world space
  5520. * @param space The space that the rotation should be in
  5521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5522. * @returns The rotation matrix
  5523. */
  5524. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5525. /**
  5526. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5527. * @param space The space that the rotation should be in
  5528. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5529. * @param result The quaternion that the rotation should be copied to
  5530. */
  5531. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5532. /**
  5533. * Get the world position of a point that is in the local space of the bone
  5534. * @param position The local position
  5535. * @param mesh The mesh that this bone is attached to
  5536. * @returns The world position
  5537. */
  5538. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5539. /**
  5540. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5541. * @param position The local position
  5542. * @param mesh The mesh that this bone is attached to
  5543. * @param result The vector3 that the world position should be copied to
  5544. */
  5545. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5546. /**
  5547. * Get the local position of a point that is in world space
  5548. * @param position The world position
  5549. * @param mesh The mesh that this bone is attached to
  5550. * @returns The local position
  5551. */
  5552. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5553. /**
  5554. * Get the local position of a point that is in world space and copy it to the result param
  5555. * @param position The world position
  5556. * @param mesh The mesh that this bone is attached to
  5557. * @param result The vector3 that the local position should be copied to
  5558. */
  5559. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * Class used to apply inverse kinematics to bones
  5565. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5566. */
  5567. class BoneIKController {
  5568. private static _tmpVecs;
  5569. private static _tmpQuat;
  5570. private static _tmpMats;
  5571. /**
  5572. * Gets or sets the target mesh
  5573. */
  5574. targetMesh: AbstractMesh;
  5575. /** Gets or sets the mesh used as pole */
  5576. poleTargetMesh: AbstractMesh;
  5577. /**
  5578. * Gets or sets the bone used as pole
  5579. */
  5580. poleTargetBone: Nullable<Bone>;
  5581. /**
  5582. * Gets or sets the target position
  5583. */
  5584. targetPosition: Vector3;
  5585. /**
  5586. * Gets or sets the pole target position
  5587. */
  5588. poleTargetPosition: Vector3;
  5589. /**
  5590. * Gets or sets the pole target local offset
  5591. */
  5592. poleTargetLocalOffset: Vector3;
  5593. /**
  5594. * Gets or sets the pole angle
  5595. */
  5596. poleAngle: number;
  5597. /**
  5598. * Gets or sets the mesh associated with the controller
  5599. */
  5600. mesh: AbstractMesh;
  5601. /**
  5602. * 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)
  5603. */
  5604. slerpAmount: number;
  5605. private _bone1Quat;
  5606. private _bone1Mat;
  5607. private _bone2Ang;
  5608. private _bone1;
  5609. private _bone2;
  5610. private _bone1Length;
  5611. private _bone2Length;
  5612. private _maxAngle;
  5613. private _maxReach;
  5614. private _rightHandedSystem;
  5615. private _bendAxis;
  5616. private _slerping;
  5617. private _adjustRoll;
  5618. /**
  5619. * Gets or sets maximum allowed angle
  5620. */
  5621. maxAngle: number;
  5622. /**
  5623. * Creates a new BoneIKController
  5624. * @param mesh defines the mesh to control
  5625. * @param bone defines the bone to control
  5626. * @param options defines options to set up the controller
  5627. */
  5628. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5629. targetMesh?: AbstractMesh;
  5630. poleTargetMesh?: AbstractMesh;
  5631. poleTargetBone?: Bone;
  5632. poleTargetLocalOffset?: Vector3;
  5633. poleAngle?: number;
  5634. bendAxis?: Vector3;
  5635. maxAngle?: number;
  5636. slerpAmount?: number;
  5637. });
  5638. private _setMaxAngle;
  5639. /**
  5640. * Force the controller to update the bones
  5641. */
  5642. update(): void;
  5643. }
  5644. }
  5645. declare module BABYLON {
  5646. /**
  5647. * Class used to make a bone look toward a point in space
  5648. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5649. */
  5650. class BoneLookController {
  5651. private static _tmpVecs;
  5652. private static _tmpQuat;
  5653. private static _tmpMats;
  5654. /**
  5655. * The target Vector3 that the bone will look at
  5656. */
  5657. target: Vector3;
  5658. /**
  5659. * The mesh that the bone is attached to
  5660. */
  5661. mesh: AbstractMesh;
  5662. /**
  5663. * The bone that will be looking to the target
  5664. */
  5665. bone: Bone;
  5666. /**
  5667. * The up axis of the coordinate system that is used when the bone is rotated
  5668. */
  5669. upAxis: Vector3;
  5670. /**
  5671. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5672. */
  5673. upAxisSpace: Space;
  5674. /**
  5675. * Used to make an adjustment to the yaw of the bone
  5676. */
  5677. adjustYaw: number;
  5678. /**
  5679. * Used to make an adjustment to the pitch of the bone
  5680. */
  5681. adjustPitch: number;
  5682. /**
  5683. * Used to make an adjustment to the roll of the bone
  5684. */
  5685. adjustRoll: number;
  5686. /**
  5687. * 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)
  5688. */
  5689. slerpAmount: number;
  5690. private _minYaw;
  5691. private _maxYaw;
  5692. private _minPitch;
  5693. private _maxPitch;
  5694. private _minYawSin;
  5695. private _minYawCos;
  5696. private _maxYawSin;
  5697. private _maxYawCos;
  5698. private _midYawConstraint;
  5699. private _minPitchTan;
  5700. private _maxPitchTan;
  5701. private _boneQuat;
  5702. private _slerping;
  5703. private _transformYawPitch;
  5704. private _transformYawPitchInv;
  5705. private _firstFrameSkipped;
  5706. private _yawRange;
  5707. private _fowardAxis;
  5708. /**
  5709. * Gets or sets the minimum yaw angle that the bone can look to
  5710. */
  5711. minYaw: number;
  5712. /**
  5713. * Gets or sets the maximum yaw angle that the bone can look to
  5714. */
  5715. maxYaw: number;
  5716. /**
  5717. * Gets or sets the minimum pitch angle that the bone can look to
  5718. */
  5719. minPitch: number;
  5720. /**
  5721. * Gets or sets the maximum pitch angle that the bone can look to
  5722. */
  5723. maxPitch: number;
  5724. /**
  5725. * Create a BoneLookController
  5726. * @param mesh the mesh that the bone belongs to
  5727. * @param bone the bone that will be looking to the target
  5728. * @param target the target Vector3 to look at
  5729. * @param settings optional settings:
  5730. * * maxYaw: the maximum angle the bone will yaw to
  5731. * * minYaw: the minimum angle the bone will yaw to
  5732. * * maxPitch: the maximum angle the bone will pitch to
  5733. * * minPitch: the minimum angle the bone will yaw to
  5734. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5735. * * upAxis: the up axis of the coordinate system
  5736. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5737. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5738. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5739. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5740. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5741. * * adjustRoll: used to make an adjustment to the roll of the bone
  5742. **/
  5743. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5744. maxYaw?: number;
  5745. minYaw?: number;
  5746. maxPitch?: number;
  5747. minPitch?: number;
  5748. slerpAmount?: number;
  5749. upAxis?: Vector3;
  5750. upAxisSpace?: Space;
  5751. yawAxis?: Vector3;
  5752. pitchAxis?: Vector3;
  5753. adjustYaw?: number;
  5754. adjustPitch?: number;
  5755. adjustRoll?: number;
  5756. });
  5757. /**
  5758. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5759. */
  5760. update(): void;
  5761. private _getAngleDiff;
  5762. private _getAngleBetween;
  5763. private _isAngleBetween;
  5764. }
  5765. }
  5766. declare module BABYLON {
  5767. /**
  5768. * Class used to handle skinning animations
  5769. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5770. */
  5771. class Skeleton implements IAnimatable {
  5772. /** defines the skeleton name */
  5773. name: string;
  5774. /** defines the skeleton Id */
  5775. id: string;
  5776. /**
  5777. * Gets the list of child bones
  5778. */
  5779. bones: Bone[];
  5780. /**
  5781. * Gets an estimate of the dimension of the skeleton at rest
  5782. */
  5783. dimensionsAtRest: Vector3;
  5784. /**
  5785. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5786. */
  5787. needInitialSkinMatrix: boolean;
  5788. /**
  5789. * Gets the list of animations attached to this skeleton
  5790. */
  5791. animations: Array<Animation>;
  5792. private _scene;
  5793. private _isDirty;
  5794. private _transformMatrices;
  5795. private _meshesWithPoseMatrix;
  5796. private _animatables;
  5797. private _identity;
  5798. private _synchronizedWithMesh;
  5799. private _ranges;
  5800. private _lastAbsoluteTransformsUpdateId;
  5801. /**
  5802. * Specifies if the skeleton should be serialized
  5803. */
  5804. doNotSerialize: boolean;
  5805. private _animationPropertiesOverride;
  5806. /**
  5807. * Gets or sets the animation properties override
  5808. */
  5809. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5810. /**
  5811. * An observable triggered before computing the skeleton's matrices
  5812. */
  5813. onBeforeComputeObservable: Observable<Skeleton>;
  5814. /**
  5815. * Creates a new skeleton
  5816. * @param name defines the skeleton name
  5817. * @param id defines the skeleton Id
  5818. * @param scene defines the hosting scene
  5819. */
  5820. constructor(
  5821. /** defines the skeleton name */
  5822. name: string,
  5823. /** defines the skeleton Id */
  5824. id: string, scene: Scene);
  5825. /**
  5826. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5827. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5828. * @returns a Float32Array containing matrices data
  5829. */
  5830. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5831. /**
  5832. * Gets the current hosting scene
  5833. * @returns a scene object
  5834. */
  5835. getScene(): Scene;
  5836. /**
  5837. * Gets a string representing the current skeleton data
  5838. * @param fullDetails defines a boolean indicating if we want a verbose version
  5839. * @returns a string representing the current skeleton data
  5840. */
  5841. toString(fullDetails?: boolean): string;
  5842. /**
  5843. * Get bone's index searching by name
  5844. * @param name defines bone's name to search for
  5845. * @return the indice of the bone. Returns -1 if not found
  5846. */
  5847. getBoneIndexByName(name: string): number;
  5848. /**
  5849. * Creater a new animation range
  5850. * @param name defines the name of the range
  5851. * @param from defines the start key
  5852. * @param to defines the end key
  5853. */
  5854. createAnimationRange(name: string, from: number, to: number): void;
  5855. /**
  5856. * Delete a specific animation range
  5857. * @param name defines the name of the range
  5858. * @param deleteFrames defines if frames must be removed as well
  5859. */
  5860. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5861. /**
  5862. * Gets a specific animation range
  5863. * @param name defines the name of the range to look for
  5864. * @returns the requested animation range or null if not found
  5865. */
  5866. getAnimationRange(name: string): Nullable<AnimationRange>;
  5867. /**
  5868. * Gets the list of all animation ranges defined on this skeleton
  5869. * @returns an array
  5870. */
  5871. getAnimationRanges(): Nullable<AnimationRange>[];
  5872. /**
  5873. * Copy animation range from a source skeleton.
  5874. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5875. * @param source defines the source skeleton
  5876. * @param name defines the name of the range to copy
  5877. * @param rescaleAsRequired defines if rescaling must be applied if required
  5878. * @returns true if operation was successful
  5879. */
  5880. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5881. /**
  5882. * Forces the skeleton to go to rest pose
  5883. */
  5884. returnToRest(): void;
  5885. private _getHighestAnimationFrame;
  5886. /**
  5887. * Begin a specific animation range
  5888. * @param name defines the name of the range to start
  5889. * @param loop defines if looping must be turned on (false by default)
  5890. * @param speedRatio defines the speed ratio to apply (1 by default)
  5891. * @param onAnimationEnd defines a callback which will be called when animation will end
  5892. * @returns a new animatable
  5893. */
  5894. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5895. /** @hidden */
  5896. _markAsDirty(): void;
  5897. /** @hidden */
  5898. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5899. /** @hidden */
  5900. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5901. /** @hidden */
  5902. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5903. /**
  5904. * Build all resources required to render a skeleton
  5905. */
  5906. prepare(): void;
  5907. /**
  5908. * Gets the list of animatables currently running for this skeleton
  5909. * @returns an array of animatables
  5910. */
  5911. getAnimatables(): IAnimatable[];
  5912. /**
  5913. * Clone the current skeleton
  5914. * @param name defines the name of the new skeleton
  5915. * @param id defines the id of the enw skeleton
  5916. * @returns the new skeleton
  5917. */
  5918. clone(name: string, id: string): Skeleton;
  5919. /**
  5920. * Enable animation blending for this skeleton
  5921. * @param blendingSpeed defines the blending speed to apply
  5922. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5923. */
  5924. enableBlending(blendingSpeed?: number): void;
  5925. /**
  5926. * Releases all resources associated with the current skeleton
  5927. */
  5928. dispose(): void;
  5929. /**
  5930. * Serialize the skeleton in a JSON object
  5931. * @returns a JSON object
  5932. */
  5933. serialize(): any;
  5934. /**
  5935. * Creates a new skeleton from serialized data
  5936. * @param parsedSkeleton defines the serialized data
  5937. * @param scene defines the hosting scene
  5938. * @returns a new skeleton
  5939. */
  5940. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5941. /**
  5942. * Compute all node absolute transforms
  5943. * @param forceUpdate defines if computation must be done even if cache is up to date
  5944. */
  5945. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5946. /**
  5947. * Gets the root pose matrix
  5948. * @returns a matrix
  5949. */
  5950. getPoseMatrix(): Nullable<Matrix>;
  5951. /**
  5952. * Sorts bones per internal index
  5953. */
  5954. sortBones(): void;
  5955. private _sortBones;
  5956. }
  5957. }
  5958. declare module BABYLON {
  5959. class BoundingBox implements ICullable {
  5960. vectors: Vector3[];
  5961. center: Vector3;
  5962. centerWorld: Vector3;
  5963. extendSize: Vector3;
  5964. extendSizeWorld: Vector3;
  5965. directions: Vector3[];
  5966. vectorsWorld: Vector3[];
  5967. minimumWorld: Vector3;
  5968. maximumWorld: Vector3;
  5969. minimum: Vector3;
  5970. maximum: Vector3;
  5971. private _worldMatrix;
  5972. /**
  5973. * Creates a new bounding box
  5974. * @param min defines the minimum vector (in local space)
  5975. * @param max defines the maximum vector (in local space)
  5976. */
  5977. constructor(min: Vector3, max: Vector3);
  5978. /**
  5979. * Recreates the entire bounding box from scratch
  5980. * @param min defines the new minimum vector (in local space)
  5981. * @param max defines the new maximum vector (in local space)
  5982. */
  5983. reConstruct(min: Vector3, max: Vector3): void;
  5984. /**
  5985. * Scale the current bounding box by applying a scale factor
  5986. * @param factor defines the scale factor to apply
  5987. * @returns the current bounding box
  5988. */
  5989. scale(factor: number): BoundingBox;
  5990. getWorldMatrix(): Matrix;
  5991. setWorldMatrix(matrix: Matrix): BoundingBox;
  5992. /** @hidden */
  5993. _update(world: Matrix): void;
  5994. isInFrustum(frustumPlanes: Plane[]): boolean;
  5995. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5996. intersectsPoint(point: Vector3): boolean;
  5997. intersectsSphere(sphere: BoundingSphere): boolean;
  5998. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5999. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6000. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6001. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6002. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6003. }
  6004. }
  6005. declare module BABYLON {
  6006. interface ICullable {
  6007. isInFrustum(frustumPlanes: Plane[]): boolean;
  6008. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6009. }
  6010. class BoundingInfo implements ICullable {
  6011. minimum: Vector3;
  6012. maximum: Vector3;
  6013. boundingBox: BoundingBox;
  6014. boundingSphere: BoundingSphere;
  6015. private _isLocked;
  6016. constructor(minimum: Vector3, maximum: Vector3);
  6017. isLocked: boolean;
  6018. update(world: Matrix): void;
  6019. /**
  6020. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6021. * @param center New center of the bounding info
  6022. * @param extend New extend of the bounding info
  6023. */
  6024. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6025. /**
  6026. * Scale the current bounding info by applying a scale factor
  6027. * @param factor defines the scale factor to apply
  6028. * @returns the current bounding info
  6029. */
  6030. scale(factor: number): BoundingInfo;
  6031. /**
  6032. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6033. * @param frustumPlanes defines the frustum to test
  6034. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6035. * @returns true if the bounding info is in the frustum planes
  6036. */
  6037. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6038. /**
  6039. * Gets the world distance between the min and max points of the bounding box
  6040. */
  6041. readonly diagonalLength: number;
  6042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6043. /** @hidden */
  6044. _checkCollision(collider: Collider): boolean;
  6045. intersectsPoint(point: Vector3): boolean;
  6046. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6047. }
  6048. }
  6049. declare module BABYLON {
  6050. class BoundingSphere {
  6051. center: Vector3;
  6052. radius: number;
  6053. centerWorld: Vector3;
  6054. radiusWorld: number;
  6055. minimum: Vector3;
  6056. maximum: Vector3;
  6057. /**
  6058. * Creates a new bounding sphere
  6059. * @param min defines the minimum vector (in local space)
  6060. * @param max defines the maximum vector (in local space)
  6061. */
  6062. constructor(min: Vector3, max: Vector3);
  6063. /**
  6064. * Recreates the entire bounding sphere from scratch
  6065. * @param min defines the new minimum vector (in local space)
  6066. * @param max defines the new maximum vector (in local space)
  6067. */
  6068. reConstruct(min: Vector3, max: Vector3): void;
  6069. /**
  6070. * Scale the current bounding sphere by applying a scale factor
  6071. * @param factor defines the scale factor to apply
  6072. * @returns the current bounding box
  6073. */
  6074. scale(factor: number): BoundingSphere;
  6075. /** @hidden */
  6076. _update(world: Matrix): void;
  6077. isInFrustum(frustumPlanes: Plane[]): boolean;
  6078. intersectsPoint(point: Vector3): boolean;
  6079. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. class Ray {
  6084. origin: Vector3;
  6085. direction: Vector3;
  6086. length: number;
  6087. private _edge1;
  6088. private _edge2;
  6089. private _pvec;
  6090. private _tvec;
  6091. private _qvec;
  6092. private _tmpRay;
  6093. constructor(origin: Vector3, direction: Vector3, length?: number);
  6094. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6095. intersectsBox(box: BoundingBox): boolean;
  6096. intersectsSphere(sphere: BoundingSphere): boolean;
  6097. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6098. intersectsPlane(plane: Plane): Nullable<number>;
  6099. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6100. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6101. private _comparePickingInfo;
  6102. private static smallnum;
  6103. private static rayl;
  6104. /**
  6105. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6106. * @param sega the first point of the segment to test the intersection against
  6107. * @param segb the second point of the segment to test the intersection against
  6108. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6109. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6110. */
  6111. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6112. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6113. static Zero(): Ray;
  6114. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6115. /**
  6116. * 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
  6117. * transformed to the given world matrix.
  6118. * @param origin The origin point
  6119. * @param end The end point
  6120. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6121. */
  6122. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6123. static Transform(ray: Ray, matrix: Matrix): Ray;
  6124. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. class ArcRotateCamera extends TargetCamera {
  6129. alpha: number;
  6130. beta: number;
  6131. radius: number;
  6132. protected _target: Vector3;
  6133. protected _targetHost: Nullable<AbstractMesh>;
  6134. target: Vector3;
  6135. inertialAlphaOffset: number;
  6136. inertialBetaOffset: number;
  6137. inertialRadiusOffset: number;
  6138. lowerAlphaLimit: Nullable<number>;
  6139. upperAlphaLimit: Nullable<number>;
  6140. lowerBetaLimit: number;
  6141. upperBetaLimit: number;
  6142. lowerRadiusLimit: Nullable<number>;
  6143. upperRadiusLimit: Nullable<number>;
  6144. inertialPanningX: number;
  6145. inertialPanningY: number;
  6146. pinchToPanMaxDistance: number;
  6147. panningDistanceLimit: Nullable<number>;
  6148. panningOriginTarget: Vector3;
  6149. panningInertia: number;
  6150. angularSensibilityX: number;
  6151. angularSensibilityY: number;
  6152. pinchPrecision: number;
  6153. pinchDeltaPercentage: number;
  6154. panningSensibility: number;
  6155. keysUp: number[];
  6156. keysDown: number[];
  6157. keysLeft: number[];
  6158. keysRight: number[];
  6159. wheelPrecision: number;
  6160. wheelDeltaPercentage: number;
  6161. zoomOnFactor: number;
  6162. targetScreenOffset: Vector2;
  6163. allowUpsideDown: boolean;
  6164. /** @hidden */
  6165. _viewMatrix: Matrix;
  6166. /** @hidden */
  6167. _useCtrlForPanning: boolean;
  6168. /** @hidden */
  6169. _panningMouseButton: number;
  6170. inputs: ArcRotateCameraInputsManager;
  6171. /** @hidden */
  6172. _reset: () => void;
  6173. panningAxis: Vector3;
  6174. protected _localDirection: Vector3;
  6175. protected _transformedDirection: Vector3;
  6176. private _bouncingBehavior;
  6177. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6178. useBouncingBehavior: boolean;
  6179. private _framingBehavior;
  6180. readonly framingBehavior: Nullable<FramingBehavior>;
  6181. useFramingBehavior: boolean;
  6182. private _autoRotationBehavior;
  6183. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6184. useAutoRotationBehavior: boolean;
  6185. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6186. onCollide: (collidedMesh: AbstractMesh) => void;
  6187. checkCollisions: boolean;
  6188. collisionRadius: Vector3;
  6189. protected _collider: Collider;
  6190. protected _previousPosition: Vector3;
  6191. protected _collisionVelocity: Vector3;
  6192. protected _newPosition: Vector3;
  6193. protected _previousAlpha: number;
  6194. protected _previousBeta: number;
  6195. protected _previousRadius: number;
  6196. protected _collisionTriggered: boolean;
  6197. protected _targetBoundingCenter: Nullable<Vector3>;
  6198. private _computationVector;
  6199. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6200. /** @hidden */
  6201. _initCache(): void;
  6202. /** @hidden */
  6203. _updateCache(ignoreParentClass?: boolean): void;
  6204. protected _getTargetPosition(): Vector3;
  6205. /**
  6206. * Store current camera state (fov, position, etc..)
  6207. */
  6208. private _storedAlpha;
  6209. private _storedBeta;
  6210. private _storedRadius;
  6211. private _storedTarget;
  6212. storeState(): Camera;
  6213. /**
  6214. * @hidden
  6215. * Restored camera state. You must call storeState() first
  6216. */
  6217. _restoreStateValues(): boolean;
  6218. /** @hidden */
  6219. _isSynchronizedViewMatrix(): boolean;
  6220. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6221. detachControl(element: HTMLElement): void;
  6222. /** @hidden */
  6223. _checkInputs(): void;
  6224. protected _checkLimits(): void;
  6225. rebuildAnglesAndRadius(): void;
  6226. setPosition(position: Vector3): void;
  6227. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6228. /** @hidden */
  6229. _getViewMatrix(): Matrix;
  6230. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6231. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6232. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6233. min: Vector3;
  6234. max: Vector3;
  6235. distance: number;
  6236. }, doNotUpdateMaxZ?: boolean): void;
  6237. /**
  6238. * @override
  6239. * Override Camera.createRigCamera
  6240. */
  6241. createRigCamera(name: string, cameraIndex: number): Camera;
  6242. /**
  6243. * @hidden
  6244. * @override
  6245. * Override Camera._updateRigCameras
  6246. */
  6247. _updateRigCameras(): void;
  6248. dispose(): void;
  6249. getClassName(): string;
  6250. }
  6251. }
  6252. declare module BABYLON {
  6253. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  6254. constructor(camera: ArcRotateCamera);
  6255. addMouseWheel(): ArcRotateCameraInputsManager;
  6256. addPointers(): ArcRotateCameraInputsManager;
  6257. addKeyboard(): ArcRotateCameraInputsManager;
  6258. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  6259. }
  6260. }
  6261. declare module BABYLON {
  6262. class Camera extends Node {
  6263. inputs: CameraInputsManager<Camera>;
  6264. private static _PERSPECTIVE_CAMERA;
  6265. private static _ORTHOGRAPHIC_CAMERA;
  6266. private static _FOVMODE_VERTICAL_FIXED;
  6267. private static _FOVMODE_HORIZONTAL_FIXED;
  6268. private static _RIG_MODE_NONE;
  6269. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  6270. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  6271. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  6272. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  6273. private static _RIG_MODE_VR;
  6274. private static _RIG_MODE_WEBVR;
  6275. static readonly PERSPECTIVE_CAMERA: number;
  6276. static readonly ORTHOGRAPHIC_CAMERA: number;
  6277. /**
  6278. * This is the default FOV mode for perspective cameras.
  6279. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6280. *
  6281. */
  6282. static readonly FOVMODE_VERTICAL_FIXED: number;
  6283. /**
  6284. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6285. *
  6286. */
  6287. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6288. static readonly RIG_MODE_NONE: number;
  6289. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6290. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6291. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6292. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6293. static readonly RIG_MODE_VR: number;
  6294. static readonly RIG_MODE_WEBVR: number;
  6295. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6296. static UseAlternateWebVRRendering: boolean;
  6297. position: Vector3;
  6298. /**
  6299. * The vector the camera should consider as up.
  6300. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6301. */
  6302. upVector: Vector3;
  6303. orthoLeft: Nullable<number>;
  6304. orthoRight: Nullable<number>;
  6305. orthoBottom: Nullable<number>;
  6306. orthoTop: Nullable<number>;
  6307. /**
  6308. * FOV is set in Radians. (default is 0.8)
  6309. */
  6310. fov: number;
  6311. minZ: number;
  6312. maxZ: number;
  6313. inertia: number;
  6314. mode: number;
  6315. isIntermediate: boolean;
  6316. viewport: Viewport;
  6317. /**
  6318. * Restricts the camera to viewing objects with the same layerMask.
  6319. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6320. */
  6321. layerMask: number;
  6322. /**
  6323. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6324. */
  6325. fovMode: number;
  6326. cameraRigMode: number;
  6327. interaxialDistance: number;
  6328. isStereoscopicSideBySide: boolean;
  6329. /** @hidden */
  6330. _cameraRigParams: any;
  6331. /** @hidden */
  6332. _rigCameras: Camera[];
  6333. /** @hidden */
  6334. _rigPostProcess: Nullable<PostProcess>;
  6335. protected _webvrViewMatrix: Matrix;
  6336. /** @hidden */
  6337. _skipRendering: boolean;
  6338. /** @hidden */
  6339. _alternateCamera: Camera;
  6340. customRenderTargets: RenderTargetTexture[];
  6341. onViewMatrixChangedObservable: Observable<Camera>;
  6342. onProjectionMatrixChangedObservable: Observable<Camera>;
  6343. onAfterCheckInputsObservable: Observable<Camera>;
  6344. onRestoreStateObservable: Observable<Camera>;
  6345. private _computedViewMatrix;
  6346. _projectionMatrix: Matrix;
  6347. private _doNotComputeProjectionMatrix;
  6348. _postProcesses: Nullable<PostProcess>[];
  6349. private _transformMatrix;
  6350. _activeMeshes: SmartArray<AbstractMesh>;
  6351. protected _globalPosition: Vector3;
  6352. private _frustumPlanes;
  6353. private _refreshFrustumPlanes;
  6354. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6355. private _storedFov;
  6356. private _stateStored;
  6357. /**
  6358. * Store current camera state (fov, position, etc..)
  6359. */
  6360. storeState(): Camera;
  6361. /**
  6362. * Restores the camera state values if it has been stored. You must call storeState() first
  6363. */
  6364. protected _restoreStateValues(): boolean;
  6365. /**
  6366. * Restored camera state. You must call storeState() first
  6367. */
  6368. restoreState(): boolean;
  6369. getClassName(): string;
  6370. /**
  6371. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6372. */
  6373. toString(fullDetails?: boolean): string;
  6374. readonly globalPosition: Vector3;
  6375. getActiveMeshes(): SmartArray<AbstractMesh>;
  6376. isActiveMesh(mesh: Mesh): boolean;
  6377. /**
  6378. * Is this camera ready to be used/rendered
  6379. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6380. * @return true if the camera is ready
  6381. */
  6382. isReady(completeCheck?: boolean): boolean;
  6383. /** @hidden */
  6384. _initCache(): void;
  6385. /** @hidden */
  6386. _updateCache(ignoreParentClass?: boolean): void;
  6387. /** @hidden */
  6388. _isSynchronized(): boolean;
  6389. /** @hidden */
  6390. _isSynchronizedViewMatrix(): boolean;
  6391. /** @hidden */
  6392. _isSynchronizedProjectionMatrix(): boolean;
  6393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6394. detachControl(element: HTMLElement): void;
  6395. update(): void;
  6396. /** @hidden */
  6397. _checkInputs(): void;
  6398. readonly rigCameras: Camera[];
  6399. readonly rigPostProcess: Nullable<PostProcess>;
  6400. /**
  6401. * Internal, gets the first post proces.
  6402. * @returns the first post process to be run on this camera.
  6403. */
  6404. _getFirstPostProcess(): Nullable<PostProcess>;
  6405. private _cascadePostProcessesToRigCams;
  6406. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6407. detachPostProcess(postProcess: PostProcess): void;
  6408. getWorldMatrix(): Matrix;
  6409. /** @hidden */
  6410. _getViewMatrix(): Matrix;
  6411. getViewMatrix(force?: boolean): Matrix;
  6412. freezeProjectionMatrix(projection?: Matrix): void;
  6413. unfreezeProjectionMatrix(): void;
  6414. getProjectionMatrix(force?: boolean): Matrix;
  6415. /**
  6416. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  6417. * @returns a Matrix
  6418. */
  6419. getTransformationMatrix(): Matrix;
  6420. private updateFrustumPlanes;
  6421. isInFrustum(target: ICullable): boolean;
  6422. isCompletelyInFrustum(target: ICullable): boolean;
  6423. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6424. /**
  6425. * Releases resources associated with this node.
  6426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6428. */
  6429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6430. readonly leftCamera: Nullable<FreeCamera>;
  6431. readonly rightCamera: Nullable<FreeCamera>;
  6432. getLeftTarget(): Nullable<Vector3>;
  6433. getRightTarget(): Nullable<Vector3>;
  6434. setCameraRigMode(mode: number, rigParams: any): void;
  6435. private _getVRProjectionMatrix;
  6436. protected _updateCameraRotationMatrix(): void;
  6437. protected _updateWebVRCameraRotationMatrix(): void;
  6438. /**
  6439. * This function MUST be overwritten by the different WebVR cameras available.
  6440. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6441. */
  6442. protected _getWebVRProjectionMatrix(): Matrix;
  6443. /**
  6444. * This function MUST be overwritten by the different WebVR cameras available.
  6445. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6446. */
  6447. protected _getWebVRViewMatrix(): Matrix;
  6448. setCameraRigParameter(name: string, value: any): void;
  6449. /**
  6450. * needs to be overridden by children so sub has required properties to be copied
  6451. */
  6452. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6453. /**
  6454. * May need to be overridden by children
  6455. * @hidden
  6456. */
  6457. _updateRigCameras(): void;
  6458. /** @hidden */
  6459. _setupInputs(): void;
  6460. serialize(): any;
  6461. clone(name: string): Camera;
  6462. getDirection(localAxis: Vector3): Vector3;
  6463. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6464. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6465. computeWorldMatrix(): Matrix;
  6466. static Parse(parsedCamera: any, scene: Scene): Camera;
  6467. }
  6468. }
  6469. declare module BABYLON {
  6470. var CameraInputTypes: {};
  6471. interface ICameraInput<TCamera extends Camera> {
  6472. camera: Nullable<TCamera>;
  6473. getClassName(): string;
  6474. getSimpleName(): string;
  6475. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6476. detachControl: (element: Nullable<HTMLElement>) => void;
  6477. checkInputs?: () => void;
  6478. }
  6479. interface CameraInputsMap<TCamera extends Camera> {
  6480. [name: string]: ICameraInput<TCamera>;
  6481. [idx: number]: ICameraInput<TCamera>;
  6482. }
  6483. class CameraInputsManager<TCamera extends Camera> {
  6484. attached: CameraInputsMap<TCamera>;
  6485. attachedElement: Nullable<HTMLElement>;
  6486. noPreventDefault: boolean;
  6487. camera: TCamera;
  6488. checkInputs: () => void;
  6489. constructor(camera: TCamera);
  6490. /**
  6491. * Add an input method to a camera
  6492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6493. * @param input camera input method
  6494. */
  6495. add(input: ICameraInput<TCamera>): void;
  6496. /**
  6497. * Remove a specific input method from a camera
  6498. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6499. * @param inputToRemove camera input method
  6500. */
  6501. remove(inputToRemove: ICameraInput<TCamera>): void;
  6502. removeByType(inputType: string): void;
  6503. private _addCheckInputs;
  6504. attachInput(input: ICameraInput<TCamera>): void;
  6505. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6506. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6507. rebuildInputCheck(): void;
  6508. /**
  6509. * Remove all attached input methods from a camera
  6510. */
  6511. clear(): void;
  6512. serialize(serializedCamera: any): void;
  6513. parse(parsedCamera: any): void;
  6514. }
  6515. }
  6516. declare module BABYLON {
  6517. /**
  6518. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6519. * being tilted forward or back and left or right.
  6520. */
  6521. class DeviceOrientationCamera extends FreeCamera {
  6522. private _initialQuaternion;
  6523. private _quaternionCache;
  6524. /**
  6525. * Creates a new device orientation camera
  6526. * @param name The name of the camera
  6527. * @param position The start position camera
  6528. * @param scene The scene the camera belongs to
  6529. */
  6530. constructor(name: string, position: Vector3, scene: Scene);
  6531. /**
  6532. * Gets the current instance class name ("DeviceOrientationCamera").
  6533. * This helps avoiding instanceof at run time.
  6534. * @returns the class name
  6535. */
  6536. getClassName(): string;
  6537. /**
  6538. * @hidden
  6539. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6540. */
  6541. _checkInputs(): void;
  6542. /**
  6543. * Reset the camera to its default orientation on the specified axis only.
  6544. * @param axis The axis to reset
  6545. */
  6546. resetToCurrentRotation(axis?: Axis): void;
  6547. }
  6548. }
  6549. declare module BABYLON {
  6550. class FollowCamera extends TargetCamera {
  6551. radius: number;
  6552. rotationOffset: number;
  6553. heightOffset: number;
  6554. cameraAcceleration: number;
  6555. maxCameraSpeed: number;
  6556. lockedTarget: Nullable<AbstractMesh>;
  6557. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6558. private getRadians;
  6559. private follow;
  6560. /** @hidden */
  6561. _checkInputs(): void;
  6562. getClassName(): string;
  6563. }
  6564. class ArcFollowCamera extends TargetCamera {
  6565. alpha: number;
  6566. beta: number;
  6567. radius: number;
  6568. target: Nullable<AbstractMesh>;
  6569. private _cartesianCoordinates;
  6570. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6571. private follow;
  6572. /** @hidden */
  6573. _checkInputs(): void;
  6574. getClassName(): string;
  6575. }
  6576. }
  6577. declare module BABYLON {
  6578. class FreeCamera extends TargetCamera {
  6579. ellipsoid: Vector3;
  6580. ellipsoidOffset: Vector3;
  6581. checkCollisions: boolean;
  6582. applyGravity: boolean;
  6583. inputs: FreeCameraInputsManager;
  6584. /**
  6585. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6586. * Higher values reduce sensitivity.
  6587. */
  6588. /**
  6589. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6590. * Higher values reduce sensitivity.
  6591. */
  6592. angularSensibility: number;
  6593. keysUp: number[];
  6594. keysDown: number[];
  6595. keysLeft: number[];
  6596. keysRight: number[];
  6597. onCollide: (collidedMesh: AbstractMesh) => void;
  6598. private _collider;
  6599. private _needMoveForGravity;
  6600. private _oldPosition;
  6601. private _diffPosition;
  6602. private _newPosition;
  6603. /** @hidden */
  6604. _localDirection: Vector3;
  6605. /** @hidden */
  6606. _transformedDirection: Vector3;
  6607. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6609. detachControl(element: HTMLElement): void;
  6610. private _collisionMask;
  6611. collisionMask: number;
  6612. /** @hidden */
  6613. _collideWithWorld(displacement: Vector3): void;
  6614. private _onCollisionPositionChange;
  6615. /** @hidden */
  6616. _checkInputs(): void;
  6617. /** @hidden */
  6618. _decideIfNeedsToMove(): boolean;
  6619. /** @hidden */
  6620. _updatePosition(): void;
  6621. dispose(): void;
  6622. getClassName(): string;
  6623. }
  6624. }
  6625. declare module BABYLON {
  6626. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6627. constructor(camera: FreeCamera);
  6628. addKeyboard(): FreeCameraInputsManager;
  6629. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6630. addDeviceOrientation(): FreeCameraInputsManager;
  6631. addTouch(): FreeCameraInputsManager;
  6632. addVirtualJoystick(): FreeCameraInputsManager;
  6633. }
  6634. }
  6635. declare module BABYLON {
  6636. class GamepadCamera extends UniversalCamera {
  6637. gamepadAngularSensibility: number;
  6638. gamepadMoveSensibility: number;
  6639. constructor(name: string, position: Vector3, scene: Scene);
  6640. getClassName(): string;
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. class TargetCamera extends Camera {
  6645. cameraDirection: Vector3;
  6646. cameraRotation: Vector2;
  6647. rotation: Vector3;
  6648. rotationQuaternion: Quaternion;
  6649. speed: number;
  6650. noRotationConstraint: boolean;
  6651. lockedTarget: any;
  6652. /** @hidden */
  6653. _currentTarget: Vector3;
  6654. /** @hidden */
  6655. _viewMatrix: Matrix;
  6656. /** @hidden */
  6657. _camMatrix: Matrix;
  6658. /** @hidden */
  6659. _cameraTransformMatrix: Matrix;
  6660. /** @hidden */
  6661. _cameraRotationMatrix: Matrix;
  6662. private _rigCamTransformMatrix;
  6663. /** @hidden */
  6664. _referencePoint: Vector3;
  6665. /** @hidden */
  6666. _transformedReferencePoint: Vector3;
  6667. protected _globalCurrentTarget: Vector3;
  6668. protected _globalCurrentUpVector: Vector3;
  6669. /** @hidden */
  6670. _reset: () => void;
  6671. private _defaultUp;
  6672. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6673. getFrontPosition(distance: number): Vector3;
  6674. /** @hidden */
  6675. _getLockedTargetPosition(): Nullable<Vector3>;
  6676. /**
  6677. * Store current camera state (fov, position, etc..)
  6678. */
  6679. private _storedPosition;
  6680. private _storedRotation;
  6681. private _storedRotationQuaternion;
  6682. storeState(): Camera;
  6683. /**
  6684. * Restored camera state. You must call storeState() first
  6685. * @returns whether it was successful or not
  6686. * @hidden
  6687. */
  6688. _restoreStateValues(): boolean;
  6689. /** @hidden */
  6690. _initCache(): void;
  6691. /** @hidden */
  6692. _updateCache(ignoreParentClass?: boolean): void;
  6693. /** @hidden */
  6694. _isSynchronizedViewMatrix(): boolean;
  6695. /** @hidden */
  6696. _computeLocalCameraSpeed(): number;
  6697. /** @hidden */
  6698. setTarget(target: Vector3): void;
  6699. /**
  6700. * Return the current target position of the camera. This value is expressed in local space.
  6701. */
  6702. getTarget(): Vector3;
  6703. /** @hidden */
  6704. _decideIfNeedsToMove(): boolean;
  6705. /** @hidden */
  6706. _updatePosition(): void;
  6707. /** @hidden */
  6708. _checkInputs(): void;
  6709. protected _updateCameraRotationMatrix(): void;
  6710. /**
  6711. * 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)
  6712. * @returns the current camera
  6713. */
  6714. private _rotateUpVectorWithCameraRotationMatrix;
  6715. private _cachedRotationZ;
  6716. /** @hidden */
  6717. _getViewMatrix(): Matrix;
  6718. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6719. /**
  6720. * @override
  6721. * Override Camera.createRigCamera
  6722. */
  6723. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6724. /**
  6725. * @hidden
  6726. * @override
  6727. * Override Camera._updateRigCameras
  6728. */
  6729. _updateRigCameras(): void;
  6730. private _getRigCamPosition;
  6731. getClassName(): string;
  6732. }
  6733. }
  6734. declare module BABYLON {
  6735. class TouchCamera extends FreeCamera {
  6736. touchAngularSensibility: number;
  6737. touchMoveSensibility: number;
  6738. constructor(name: string, position: Vector3, scene: Scene);
  6739. getClassName(): string;
  6740. /** @hidden */
  6741. _setupInputs(): void;
  6742. }
  6743. }
  6744. declare module BABYLON {
  6745. class UniversalCamera extends TouchCamera {
  6746. gamepadAngularSensibility: number;
  6747. gamepadMoveSensibility: number;
  6748. constructor(name: string, position: Vector3, scene: Scene);
  6749. getClassName(): string;
  6750. }
  6751. }
  6752. declare module BABYLON {
  6753. class VirtualJoysticksCamera extends FreeCamera {
  6754. constructor(name: string, position: Vector3, scene: Scene);
  6755. getClassName(): string;
  6756. }
  6757. }
  6758. interface VRDisplay extends EventTarget {
  6759. /**
  6760. * Dictionary of capabilities describing the VRDisplay.
  6761. */
  6762. readonly capabilities: VRDisplayCapabilities;
  6763. /**
  6764. * z-depth defining the far plane of the eye view frustum
  6765. * enables mapping of values in the render target depth
  6766. * attachment to scene coordinates. Initially set to 10000.0.
  6767. */
  6768. depthFar: number;
  6769. /**
  6770. * z-depth defining the near plane of the eye view frustum
  6771. * enables mapping of values in the render target depth
  6772. * attachment to scene coordinates. Initially set to 0.01.
  6773. */
  6774. depthNear: number;
  6775. /**
  6776. * An identifier for this distinct VRDisplay. Used as an
  6777. * association point in the Gamepad API.
  6778. */
  6779. readonly displayId: number;
  6780. /**
  6781. * A display name, a user-readable name identifying it.
  6782. */
  6783. readonly displayName: string;
  6784. readonly isConnected: boolean;
  6785. readonly isPresenting: boolean;
  6786. /**
  6787. * If this VRDisplay supports room-scale experiences, the optional
  6788. * stage attribute contains details on the room-scale parameters.
  6789. */
  6790. readonly stageParameters: VRStageParameters | null;
  6791. /**
  6792. * Passing the value returned by `requestAnimationFrame` to
  6793. * `cancelAnimationFrame` will unregister the callback.
  6794. */
  6795. cancelAnimationFrame(handle: number): void;
  6796. /**
  6797. * Stops presenting to the VRDisplay.
  6798. */
  6799. exitPresent(): Promise<void>;
  6800. getEyeParameters(whichEye: string): VREyeParameters;
  6801. /**
  6802. * Populates the passed VRFrameData with the information required to render
  6803. * the current frame.
  6804. */
  6805. getFrameData(frameData: VRFrameData): boolean;
  6806. /**
  6807. * Get the layers currently being presented.
  6808. */
  6809. getLayers(): VRLayer[];
  6810. /**
  6811. * Return a VRPose containing the future predicted pose of the VRDisplay
  6812. * when the current frame will be presented. The value returned will not
  6813. * change until JavaScript has returned control to the browser.
  6814. *
  6815. * The VRPose will contain the position, orientation, velocity,
  6816. * and acceleration of each of these properties.
  6817. */
  6818. getPose(): VRPose;
  6819. /**
  6820. * Return the current instantaneous pose of the VRDisplay, with no
  6821. * prediction applied.
  6822. */
  6823. getImmediatePose(): VRPose;
  6824. /**
  6825. * The callback passed to `requestAnimationFrame` will be called
  6826. * any time a new frame should be rendered. When the VRDisplay is
  6827. * presenting the callback will be called at the native refresh
  6828. * rate of the HMD. When not presenting this function acts
  6829. * identically to how window.requestAnimationFrame acts. Content should
  6830. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6831. * asynchronously from other displays and at differing refresh rates.
  6832. */
  6833. requestAnimationFrame(callback: FrameRequestCallback): number;
  6834. /**
  6835. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6836. * Repeat calls while already presenting will update the VRLayers being displayed.
  6837. */
  6838. requestPresent(layers: VRLayer[]): Promise<void>;
  6839. /**
  6840. * Reset the pose for this display, treating its current position and
  6841. * orientation as the "origin/zero" values. VRPose.position,
  6842. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6843. * updated when calling resetPose(). This should be called in only
  6844. * sitting-space experiences.
  6845. */
  6846. resetPose(): void;
  6847. /**
  6848. * The VRLayer provided to the VRDisplay will be captured and presented
  6849. * in the HMD. Calling this function has the same effect on the source
  6850. * canvas as any other operation that uses its source image, and canvases
  6851. * created without preserveDrawingBuffer set to true will be cleared.
  6852. */
  6853. submitFrame(pose?: VRPose): void;
  6854. }
  6855. declare var VRDisplay: {
  6856. prototype: VRDisplay;
  6857. new (): VRDisplay;
  6858. };
  6859. interface VRLayer {
  6860. leftBounds?: number[] | Float32Array | null;
  6861. rightBounds?: number[] | Float32Array | null;
  6862. source?: HTMLCanvasElement | null;
  6863. }
  6864. interface VRDisplayCapabilities {
  6865. readonly canPresent: boolean;
  6866. readonly hasExternalDisplay: boolean;
  6867. readonly hasOrientation: boolean;
  6868. readonly hasPosition: boolean;
  6869. readonly maxLayers: number;
  6870. }
  6871. interface VREyeParameters {
  6872. /** @deprecated */
  6873. readonly fieldOfView: VRFieldOfView;
  6874. readonly offset: Float32Array;
  6875. readonly renderHeight: number;
  6876. readonly renderWidth: number;
  6877. }
  6878. interface VRFieldOfView {
  6879. readonly downDegrees: number;
  6880. readonly leftDegrees: number;
  6881. readonly rightDegrees: number;
  6882. readonly upDegrees: number;
  6883. }
  6884. interface VRFrameData {
  6885. readonly leftProjectionMatrix: Float32Array;
  6886. readonly leftViewMatrix: Float32Array;
  6887. readonly pose: VRPose;
  6888. readonly rightProjectionMatrix: Float32Array;
  6889. readonly rightViewMatrix: Float32Array;
  6890. readonly timestamp: number;
  6891. }
  6892. interface VRPose {
  6893. readonly angularAcceleration: Float32Array | null;
  6894. readonly angularVelocity: Float32Array | null;
  6895. readonly linearAcceleration: Float32Array | null;
  6896. readonly linearVelocity: Float32Array | null;
  6897. readonly orientation: Float32Array | null;
  6898. readonly position: Float32Array | null;
  6899. readonly timestamp: number;
  6900. }
  6901. interface VRStageParameters {
  6902. sittingToStandingTransform?: Float32Array;
  6903. sizeX?: number;
  6904. sizeY?: number;
  6905. }
  6906. interface Navigator {
  6907. getVRDisplays(): Promise<VRDisplay[]>;
  6908. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6909. }
  6910. interface Window {
  6911. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6912. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6913. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6914. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6915. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6916. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6917. }
  6918. interface Gamepad {
  6919. readonly displayId: number;
  6920. }
  6921. /**
  6922. * Module Debug contains the (visual) components to debug a scene correctly
  6923. */
  6924. declare module BABYLON.Debug {
  6925. /**
  6926. * The Axes viewer will show 3 axes in a specific point in space
  6927. */
  6928. class AxesViewer {
  6929. private _xline;
  6930. private _yline;
  6931. private _zline;
  6932. private _xmesh;
  6933. private _ymesh;
  6934. private _zmesh;
  6935. /**
  6936. * Gets the hosting scene
  6937. */
  6938. scene: Nullable<Scene>;
  6939. /**
  6940. * Gets or sets a number used to scale line length
  6941. */
  6942. scaleLines: number;
  6943. /**
  6944. * Creates a new AxesViewer
  6945. * @param scene defines the hosting scene
  6946. * @param scaleLines defines a number used to scale line length (1 by default)
  6947. */
  6948. constructor(scene: Scene, scaleLines?: number);
  6949. /**
  6950. * Force the viewer to update
  6951. * @param position defines the position of the viewer
  6952. * @param xaxis defines the x axis of the viewer
  6953. * @param yaxis defines the y axis of the viewer
  6954. * @param zaxis defines the z axis of the viewer
  6955. */
  6956. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6957. /** Releases resources */
  6958. dispose(): void;
  6959. }
  6960. }
  6961. declare module BABYLON.Debug {
  6962. /**
  6963. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6964. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6965. */
  6966. class BoneAxesViewer extends AxesViewer {
  6967. /**
  6968. * Gets or sets the target mesh where to display the axes viewer
  6969. */
  6970. mesh: Nullable<Mesh>;
  6971. /**
  6972. * Gets or sets the target bone where to display the axes viewer
  6973. */
  6974. bone: Nullable<Bone>;
  6975. /** Gets current position */
  6976. pos: Vector3;
  6977. /** Gets direction of X axis */
  6978. xaxis: Vector3;
  6979. /** Gets direction of Y axis */
  6980. yaxis: Vector3;
  6981. /** Gets direction of Z axis */
  6982. zaxis: Vector3;
  6983. /**
  6984. * Creates a new BoneAxesViewer
  6985. * @param scene defines the hosting scene
  6986. * @param bone defines the target bone
  6987. * @param mesh defines the target mesh
  6988. * @param scaleLines defines a scaling factor for line length (1 by default)
  6989. */
  6990. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6991. /**
  6992. * Force the viewer to update
  6993. */
  6994. update(): void;
  6995. /** Releases resources */
  6996. dispose(): void;
  6997. }
  6998. }
  6999. declare module BABYLON {
  7000. interface Scene {
  7001. /**
  7002. * @hidden
  7003. * Backing field
  7004. */
  7005. _debugLayer: DebugLayer;
  7006. /**
  7007. * Gets the debug layer (aka Inspector) associated with the scene
  7008. * @see http://doc.babylonjs.com/features/playground_debuglayer
  7009. */
  7010. debugLayer: DebugLayer;
  7011. }
  7012. class DebugLayer {
  7013. private _scene;
  7014. static InspectorURL: string;
  7015. private _inspector;
  7016. private BJSINSPECTOR;
  7017. onPropertyChangedObservable: Observable<{
  7018. object: any;
  7019. property: string;
  7020. value: any;
  7021. initialValue: any;
  7022. }>;
  7023. constructor(scene: Scene);
  7024. /** Creates the inspector window. */
  7025. private _createInspector;
  7026. isVisible(): boolean;
  7027. hide(): void;
  7028. /**
  7029. *
  7030. * Launch the debugLayer.
  7031. *
  7032. * initialTab:
  7033. * | Value | Tab Name |
  7034. * | --- | --- |
  7035. * | 0 | Scene |
  7036. * | 1 | Console |
  7037. * | 2 | Stats |
  7038. * | 3 | Textures |
  7039. * | 4 | Mesh |
  7040. * | 5 | Light |
  7041. * | 6 | Material |
  7042. * | 7 | GLTF |
  7043. * | 8 | GUI |
  7044. * | 9 | Physics |
  7045. * | 10 | Camera |
  7046. * | 11 | Audio |
  7047. *
  7048. */
  7049. show(config?: {
  7050. popup?: boolean;
  7051. initialTab?: number;
  7052. parentElement?: HTMLElement;
  7053. newColors?: {
  7054. backgroundColor?: string;
  7055. backgroundColorLighter?: string;
  7056. backgroundColorLighter2?: string;
  7057. backgroundColorLighter3?: string;
  7058. color?: string;
  7059. colorTop?: string;
  7060. colorBot?: string;
  7061. };
  7062. }): void;
  7063. /**
  7064. * Gets the active tab
  7065. * @return the index of the active tab or -1 if the inspector is hidden
  7066. */
  7067. getActiveTab(): number;
  7068. }
  7069. }
  7070. declare module BABYLON.Debug {
  7071. /**
  7072. * Used to show the physics impostor around the specific mesh
  7073. */
  7074. class PhysicsViewer {
  7075. /** @hidden */
  7076. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7077. /** @hidden */
  7078. protected _meshes: Array<Nullable<AbstractMesh>>;
  7079. /** @hidden */
  7080. protected _scene: Nullable<Scene>;
  7081. /** @hidden */
  7082. protected _numMeshes: number;
  7083. /** @hidden */
  7084. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7085. private _renderFunction;
  7086. private _debugBoxMesh;
  7087. private _debugSphereMesh;
  7088. private _debugMaterial;
  7089. /**
  7090. * Creates a new PhysicsViewer
  7091. * @param scene defines the hosting scene
  7092. */
  7093. constructor(scene: Scene);
  7094. /** @hidden */
  7095. protected _updateDebugMeshes(): void;
  7096. /**
  7097. * Renders a specified physic impostor
  7098. * @param impostor defines the impostor to render
  7099. */
  7100. showImpostor(impostor: PhysicsImpostor): void;
  7101. /**
  7102. * Hides a specified physic impostor
  7103. * @param impostor defines the impostor to hide
  7104. */
  7105. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7106. private _getDebugMaterial;
  7107. private _getDebugBoxMesh;
  7108. private _getDebugSphereMesh;
  7109. private _getDebugMesh;
  7110. /** Releases all resources */
  7111. dispose(): void;
  7112. }
  7113. }
  7114. declare module BABYLON {
  7115. class RayHelper {
  7116. ray: Nullable<Ray>;
  7117. private _renderPoints;
  7118. private _renderLine;
  7119. private _renderFunction;
  7120. private _scene;
  7121. private _updateToMeshFunction;
  7122. private _attachedToMesh;
  7123. private _meshSpaceDirection;
  7124. private _meshSpaceOrigin;
  7125. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7126. constructor(ray: Ray);
  7127. show(scene: Scene, color?: Color3): void;
  7128. hide(): void;
  7129. private _render;
  7130. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7131. detachFromMesh(): void;
  7132. private _updateToMesh;
  7133. dispose(): void;
  7134. }
  7135. }
  7136. declare module BABYLON.Debug {
  7137. /**
  7138. * Class used to render a debug view of a given skeleton
  7139. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7140. */
  7141. class SkeletonViewer {
  7142. /** defines the skeleton to render */
  7143. skeleton: Skeleton;
  7144. /** defines the mesh attached to the skeleton */
  7145. mesh: AbstractMesh;
  7146. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7147. autoUpdateBonesMatrices: boolean;
  7148. /** defines the rendering group id to use with the viewer */
  7149. renderingGroupId: number;
  7150. /** Gets or sets the color used to render the skeleton */
  7151. color: Color3;
  7152. private _scene;
  7153. private _debugLines;
  7154. private _debugMesh;
  7155. private _isEnabled;
  7156. private _renderFunction;
  7157. /**
  7158. * Creates a new SkeletonViewer
  7159. * @param skeleton defines the skeleton to render
  7160. * @param mesh defines the mesh attached to the skeleton
  7161. * @param scene defines the hosting scene
  7162. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7163. * @param renderingGroupId defines the rendering group id to use with the viewer
  7164. */
  7165. constructor(
  7166. /** defines the skeleton to render */
  7167. skeleton: Skeleton,
  7168. /** defines the mesh attached to the skeleton */
  7169. mesh: AbstractMesh, scene: Scene,
  7170. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7171. autoUpdateBonesMatrices?: boolean,
  7172. /** defines the rendering group id to use with the viewer */
  7173. renderingGroupId?: number);
  7174. /** Gets or sets a boolean indicating if the viewer is enabled */
  7175. isEnabled: boolean;
  7176. private _getBonePosition;
  7177. private _getLinesForBonesWithLength;
  7178. private _getLinesForBonesNoLength;
  7179. /** Update the viewer to sync with current skeleton state */
  7180. update(): void;
  7181. /** Release associated resources */
  7182. dispose(): void;
  7183. }
  7184. }
  7185. declare module BABYLON {
  7186. /**
  7187. * Interface for attribute information associated with buffer instanciation
  7188. */
  7189. class InstancingAttributeInfo {
  7190. /**
  7191. * Index/offset of the attribute in the vertex shader
  7192. */
  7193. index: number;
  7194. /**
  7195. * size of the attribute, 1, 2, 3 or 4
  7196. */
  7197. attributeSize: number;
  7198. /**
  7199. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7200. * default is FLOAT
  7201. */
  7202. attribyteType: number;
  7203. /**
  7204. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7205. */
  7206. normalized: boolean;
  7207. /**
  7208. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7209. */
  7210. offset: number;
  7211. /**
  7212. * Name of the GLSL attribute, for debugging purpose only
  7213. */
  7214. attributeName: string;
  7215. }
  7216. /**
  7217. * Define options used to create a render target texture
  7218. */
  7219. class RenderTargetCreationOptions {
  7220. /**
  7221. * Specifies is mipmaps must be generated
  7222. */
  7223. generateMipMaps?: boolean;
  7224. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7225. generateDepthBuffer?: boolean;
  7226. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7227. generateStencilBuffer?: boolean;
  7228. /** Defines texture type (int by default) */
  7229. type?: number;
  7230. /** Defines sampling mode (trilinear by default) */
  7231. samplingMode?: number;
  7232. /** Defines format (RGBA by default) */
  7233. format?: number;
  7234. }
  7235. /**
  7236. * Define options used to create a depth texture
  7237. */
  7238. class DepthTextureCreationOptions {
  7239. /** Specifies whether or not a stencil should be allocated in the texture */
  7240. generateStencil?: boolean;
  7241. /** Specifies whether or not bilinear filtering is enable on the texture */
  7242. bilinearFiltering?: boolean;
  7243. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7244. comparisonFunction?: number;
  7245. /** Specifies if the created texture is a cube texture */
  7246. isCube?: boolean;
  7247. }
  7248. /**
  7249. * Class used to describe the capabilities of the engine relatively to the current browser
  7250. */
  7251. class EngineCapabilities {
  7252. /** Maximum textures units per fragment shader */
  7253. maxTexturesImageUnits: number;
  7254. /** Maximum texture units per vertex shader */
  7255. maxVertexTextureImageUnits: number;
  7256. /** Maximum textures units in the entire pipeline */
  7257. maxCombinedTexturesImageUnits: number;
  7258. /** Maximum texture size */
  7259. maxTextureSize: number;
  7260. /** Maximum cube texture size */
  7261. maxCubemapTextureSize: number;
  7262. /** Maximum render texture size */
  7263. maxRenderTextureSize: number;
  7264. /** Maximum number of vertex attributes */
  7265. maxVertexAttribs: number;
  7266. /** Maximum number of varyings */
  7267. maxVaryingVectors: number;
  7268. /** Maximum number of uniforms per vertex shader */
  7269. maxVertexUniformVectors: number;
  7270. /** Maximum number of uniforms per fragment shader */
  7271. maxFragmentUniformVectors: number;
  7272. /** Defines if standard derivates (dx/dy) are supported */
  7273. standardDerivatives: boolean;
  7274. /** Defines if s3tc texture compression is supported */
  7275. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7276. /** Defines if pvrtc texture compression is supported */
  7277. pvrtc: any;
  7278. /** Defines if etc1 texture compression is supported */
  7279. etc1: any;
  7280. /** Defines if etc2 texture compression is supported */
  7281. etc2: any;
  7282. /** Defines if astc texture compression is supported */
  7283. astc: any;
  7284. /** Defines if float textures are supported */
  7285. textureFloat: boolean;
  7286. /** Defines if vertex array objects are supported */
  7287. vertexArrayObject: boolean;
  7288. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7289. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7290. /** Gets the maximum level of anisotropy supported */
  7291. maxAnisotropy: number;
  7292. /** Defines if instancing is supported */
  7293. instancedArrays: boolean;
  7294. /** Defines if 32 bits indices are supported */
  7295. uintIndices: boolean;
  7296. /** Defines if high precision shaders are supported */
  7297. highPrecisionShaderSupported: boolean;
  7298. /** Defines if depth reading in the fragment shader is supported */
  7299. fragmentDepthSupported: boolean;
  7300. /** Defines if float texture linear filtering is supported*/
  7301. textureFloatLinearFiltering: boolean;
  7302. /** Defines if rendering to float textures is supported */
  7303. textureFloatRender: boolean;
  7304. /** Defines if half float textures are supported*/
  7305. textureHalfFloat: boolean;
  7306. /** Defines if half float texture linear filtering is supported*/
  7307. textureHalfFloatLinearFiltering: boolean;
  7308. /** Defines if rendering to half float textures is supported */
  7309. textureHalfFloatRender: boolean;
  7310. /** Defines if textureLOD shader command is supported */
  7311. textureLOD: boolean;
  7312. /** Defines if draw buffers extension is supported */
  7313. drawBuffersExtension: boolean;
  7314. /** Defines if depth textures are supported */
  7315. depthTextureExtension: boolean;
  7316. /** Defines if float color buffer are supported */
  7317. colorBufferFloat: boolean;
  7318. /** Gets disjoint timer query extension (null if not supported) */
  7319. timerQuery: EXT_disjoint_timer_query;
  7320. /** Defines if timestamp can be used with timer query */
  7321. canUseTimestampForTimerQuery: boolean;
  7322. }
  7323. /** Interface defining initialization parameters for Engine class */
  7324. interface EngineOptions extends WebGLContextAttributes {
  7325. /**
  7326. * Defines if the engine should no exceed a specified device ratio
  7327. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7328. */
  7329. limitDeviceRatio?: number;
  7330. /**
  7331. * Defines if webvr should be enabled automatically
  7332. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7333. */
  7334. autoEnableWebVR?: boolean;
  7335. /**
  7336. * Defines if webgl2 should be turned off even if supported
  7337. * @see http://doc.babylonjs.com/features/webgl2
  7338. */
  7339. disableWebGL2Support?: boolean;
  7340. /**
  7341. * Defines if webaudio should be initialized as well
  7342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7343. */
  7344. audioEngine?: boolean;
  7345. /**
  7346. * Defines if animations should run using a deterministic lock step
  7347. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7348. */
  7349. deterministicLockstep?: boolean;
  7350. /** Defines the maximum steps to use with deterministic lock step mode */
  7351. lockstepMaxSteps?: number;
  7352. /**
  7353. * Defines that engine should ignore context lost events
  7354. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7355. */
  7356. doNotHandleContextLost?: boolean;
  7357. }
  7358. /**
  7359. * Defines the interface used by display changed events
  7360. */
  7361. interface IDisplayChangedEventArgs {
  7362. /** Gets the vrDisplay object (if any) */
  7363. vrDisplay: Nullable<any>;
  7364. /** Gets a boolean indicating if webVR is supported */
  7365. vrSupported: boolean;
  7366. }
  7367. /**
  7368. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7369. */
  7370. class Engine {
  7371. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7372. static ExceptionList: ({
  7373. key: string;
  7374. capture: string;
  7375. captureConstraint: number;
  7376. targets: string[];
  7377. } | {
  7378. key: string;
  7379. capture: null;
  7380. captureConstraint: null;
  7381. targets: string[];
  7382. })[];
  7383. /** Gets the list of created engines */
  7384. static Instances: Engine[];
  7385. /**
  7386. * Gets the latest created engine
  7387. */
  7388. static readonly LastCreatedEngine: Nullable<Engine>;
  7389. /**
  7390. * Gets the latest created scene
  7391. */
  7392. static readonly LastCreatedScene: Nullable<Scene>;
  7393. /**
  7394. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7395. * @param flag defines which part of the materials must be marked as dirty
  7396. * @param predicate defines a predicate used to filter which materials should be affected
  7397. */
  7398. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7399. /**
  7400. * Hidden
  7401. */
  7402. static _TextureLoaders: IInternalTextureLoader[];
  7403. /** Defines that alpha blending is disabled */
  7404. static readonly ALPHA_DISABLE: number;
  7405. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7406. static readonly ALPHA_ADD: number;
  7407. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7408. static readonly ALPHA_COMBINE: number;
  7409. /** Defines that alpha blending to DEST - SRC * DEST */
  7410. static readonly ALPHA_SUBTRACT: number;
  7411. /** Defines that alpha blending to SRC * DEST */
  7412. static readonly ALPHA_MULTIPLY: number;
  7413. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7414. static readonly ALPHA_MAXIMIZED: number;
  7415. /** Defines that alpha blending to SRC + DEST */
  7416. static readonly ALPHA_ONEONE: number;
  7417. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7418. static readonly ALPHA_PREMULTIPLIED: number;
  7419. /**
  7420. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7421. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7422. */
  7423. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7424. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7425. static readonly ALPHA_INTERPOLATE: number;
  7426. /**
  7427. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7428. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7429. */
  7430. static readonly ALPHA_SCREENMODE: number;
  7431. /** Defines that the ressource is not delayed*/
  7432. static readonly DELAYLOADSTATE_NONE: number;
  7433. /** Defines that the ressource was successfully delay loaded */
  7434. static readonly DELAYLOADSTATE_LOADED: number;
  7435. /** Defines that the ressource is currently delay loading */
  7436. static readonly DELAYLOADSTATE_LOADING: number;
  7437. /** Defines that the ressource is delayed and has not started loading */
  7438. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7439. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7440. static readonly NEVER: number;
  7441. /** 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 */
  7442. static readonly ALWAYS: number;
  7443. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7444. static readonly LESS: number;
  7445. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7446. static readonly EQUAL: number;
  7447. /** 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 */
  7448. static readonly LEQUAL: number;
  7449. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7450. static readonly GREATER: number;
  7451. /** 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 */
  7452. static readonly GEQUAL: number;
  7453. /** 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 */
  7454. static readonly NOTEQUAL: number;
  7455. /** Passed to stencilOperation to specify that stencil value must be kept */
  7456. static readonly KEEP: number;
  7457. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7458. static readonly REPLACE: number;
  7459. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7460. static readonly INCR: number;
  7461. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7462. static readonly DECR: number;
  7463. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7464. static readonly INVERT: number;
  7465. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7466. static readonly INCR_WRAP: number;
  7467. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7468. static readonly DECR_WRAP: number;
  7469. /** Texture is not repeating outside of 0..1 UVs */
  7470. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7471. /** Texture is repeating outside of 0..1 UVs */
  7472. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7473. /** Texture is repeating and mirrored */
  7474. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7475. /** ALPHA */
  7476. static readonly TEXTUREFORMAT_ALPHA: number;
  7477. /** LUMINANCE */
  7478. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7479. /** LUMINANCE_ALPHA */
  7480. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7481. /** RGB */
  7482. static readonly TEXTUREFORMAT_RGB: number;
  7483. /** RGBA */
  7484. static readonly TEXTUREFORMAT_RGBA: number;
  7485. /** RED */
  7486. static readonly TEXTUREFORMAT_RED: number;
  7487. /** RED (2nd reference) */
  7488. static readonly TEXTUREFORMAT_R: number;
  7489. /** RG */
  7490. static readonly TEXTUREFORMAT_RG: number;
  7491. /** RED_INTEGER */
  7492. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7493. /** RED_INTEGER (2nd reference) */
  7494. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7495. /** RG_INTEGER */
  7496. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7497. /** RGB_INTEGER */
  7498. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7499. /** RGBA_INTEGER */
  7500. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7501. /** UNSIGNED_BYTE */
  7502. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7503. /** UNSIGNED_BYTE (2nd reference) */
  7504. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7505. /** FLOAT */
  7506. static readonly TEXTURETYPE_FLOAT: number;
  7507. /** HALF_FLOAT */
  7508. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7509. /** BYTE */
  7510. static readonly TEXTURETYPE_BYTE: number;
  7511. /** SHORT */
  7512. static readonly TEXTURETYPE_SHORT: number;
  7513. /** UNSIGNED_SHORT */
  7514. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7515. /** INT */
  7516. static readonly TEXTURETYPE_INT: number;
  7517. /** UNSIGNED_INT */
  7518. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7519. /** UNSIGNED_SHORT_4_4_4_4 */
  7520. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7521. /** UNSIGNED_SHORT_5_5_5_1 */
  7522. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7523. /** UNSIGNED_SHORT_5_6_5 */
  7524. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7525. /** UNSIGNED_INT_2_10_10_10_REV */
  7526. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7527. /** UNSIGNED_INT_24_8 */
  7528. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7529. /** UNSIGNED_INT_10F_11F_11F_REV */
  7530. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7531. /** UNSIGNED_INT_5_9_9_9_REV */
  7532. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7533. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7534. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7535. /** nearest is mag = nearest and min = nearest and mip = linear */
  7536. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7537. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7538. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7539. /** Trilinear is mag = linear and min = linear and mip = linear */
  7540. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7541. /** nearest is mag = nearest and min = nearest and mip = linear */
  7542. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7543. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7544. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7545. /** Trilinear is mag = linear and min = linear and mip = linear */
  7546. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7547. /** mag = nearest and min = nearest and mip = nearest */
  7548. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7549. /** mag = nearest and min = linear and mip = nearest */
  7550. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7551. /** mag = nearest and min = linear and mip = linear */
  7552. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7553. /** mag = nearest and min = linear and mip = none */
  7554. static readonly TEXTURE_NEAREST_LINEAR: number;
  7555. /** mag = nearest and min = nearest and mip = none */
  7556. static readonly TEXTURE_NEAREST_NEAREST: number;
  7557. /** mag = linear and min = nearest and mip = nearest */
  7558. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7559. /** mag = linear and min = nearest and mip = linear */
  7560. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7561. /** mag = linear and min = linear and mip = none */
  7562. static readonly TEXTURE_LINEAR_LINEAR: number;
  7563. /** mag = linear and min = nearest and mip = none */
  7564. static readonly TEXTURE_LINEAR_NEAREST: number;
  7565. /** Explicit coordinates mode */
  7566. static readonly TEXTURE_EXPLICIT_MODE: number;
  7567. /** Spherical coordinates mode */
  7568. static readonly TEXTURE_SPHERICAL_MODE: number;
  7569. /** Planar coordinates mode */
  7570. static readonly TEXTURE_PLANAR_MODE: number;
  7571. /** Cubic coordinates mode */
  7572. static readonly TEXTURE_CUBIC_MODE: number;
  7573. /** Projection coordinates mode */
  7574. static readonly TEXTURE_PROJECTION_MODE: number;
  7575. /** Skybox coordinates mode */
  7576. static readonly TEXTURE_SKYBOX_MODE: number;
  7577. /** Inverse Cubic coordinates mode */
  7578. static readonly TEXTURE_INVCUBIC_MODE: number;
  7579. /** Equirectangular coordinates mode */
  7580. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7581. /** Equirectangular Fixed coordinates mode */
  7582. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7583. /** Equirectangular Fixed Mirrored coordinates mode */
  7584. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7585. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7586. static readonly SCALEMODE_FLOOR: number;
  7587. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7588. static readonly SCALEMODE_NEAREST: number;
  7589. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7590. static readonly SCALEMODE_CEILING: number;
  7591. /**
  7592. * Returns the current version of the framework
  7593. */
  7594. static readonly Version: string;
  7595. /**
  7596. * Gets or sets the epsilon value used by collision engine
  7597. */
  7598. static CollisionsEpsilon: number;
  7599. /**
  7600. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7601. */
  7602. static CodeRepository: string;
  7603. /**
  7604. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7605. */
  7606. static ShadersRepository: string;
  7607. /**
  7608. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7609. */
  7610. forcePOTTextures: boolean;
  7611. /**
  7612. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7613. */
  7614. isFullscreen: boolean;
  7615. /**
  7616. * Gets a boolean indicating if the pointer is currently locked
  7617. */
  7618. isPointerLock: boolean;
  7619. /**
  7620. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7621. */
  7622. cullBackFaces: boolean;
  7623. /**
  7624. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7625. */
  7626. renderEvenInBackground: boolean;
  7627. /**
  7628. * Gets or sets a boolean indicating that cache can be kept between frames
  7629. */
  7630. preventCacheWipeBetweenFrames: boolean;
  7631. /**
  7632. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7633. **/
  7634. enableOfflineSupport: boolean;
  7635. /**
  7636. * 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)
  7637. **/
  7638. disableManifestCheck: boolean;
  7639. /**
  7640. * Gets the list of created scenes
  7641. */
  7642. scenes: Scene[];
  7643. /**
  7644. * Gets the list of created postprocesses
  7645. */
  7646. postProcesses: PostProcess[];
  7647. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7648. validateShaderPrograms: boolean;
  7649. /**
  7650. * Observable event triggered each time the rendering canvas is resized
  7651. */
  7652. onResizeObservable: Observable<Engine>;
  7653. /**
  7654. * Observable event triggered each time the canvas loses focus
  7655. */
  7656. onCanvasBlurObservable: Observable<Engine>;
  7657. /**
  7658. * Observable event triggered each time the canvas gains focus
  7659. */
  7660. onCanvasFocusObservable: Observable<Engine>;
  7661. /**
  7662. * Observable event triggered each time the canvas receives pointerout event
  7663. */
  7664. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7665. /**
  7666. * Observable event triggered before each texture is initialized
  7667. */
  7668. onBeforeTextureInitObservable: Observable<Texture>;
  7669. private _vrDisplay;
  7670. private _vrSupported;
  7671. private _oldSize;
  7672. private _oldHardwareScaleFactor;
  7673. private _vrExclusivePointerMode;
  7674. private _webVRInitPromise;
  7675. /**
  7676. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7677. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7678. */
  7679. readonly isInVRExclusivePointerMode: boolean;
  7680. /**
  7681. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7682. */
  7683. disableUniformBuffers: boolean;
  7684. /** @hidden */
  7685. _uniformBuffers: UniformBuffer[];
  7686. /**
  7687. * Gets a boolean indicating that the engine supports uniform buffers
  7688. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7689. */
  7690. readonly supportsUniformBuffers: boolean;
  7691. /**
  7692. * Observable raised when the engine begins a new frame
  7693. */
  7694. onBeginFrameObservable: Observable<Engine>;
  7695. /**
  7696. * Observable raised when the engine ends the current frame
  7697. */
  7698. onEndFrameObservable: Observable<Engine>;
  7699. /**
  7700. * Observable raised when the engine is about to compile a shader
  7701. */
  7702. onBeforeShaderCompilationObservable: Observable<Engine>;
  7703. /**
  7704. * Observable raised when the engine has jsut compiled a shader
  7705. */
  7706. onAfterShaderCompilationObservable: Observable<Engine>;
  7707. /** @hidden */
  7708. _gl: WebGLRenderingContext;
  7709. private _renderingCanvas;
  7710. private _windowIsBackground;
  7711. private _webGLVersion;
  7712. /**
  7713. * Gets a boolean indicating that only power of 2 textures are supported
  7714. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7715. */
  7716. readonly needPOTTextures: boolean;
  7717. /** @hidden */
  7718. _badOS: boolean;
  7719. /** @hidden */
  7720. _badDesktopOS: boolean;
  7721. /**
  7722. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7723. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7724. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7725. */
  7726. disableTextureBindingOptimization: boolean;
  7727. /**
  7728. * Gets the audio engine
  7729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7730. * @ignorenaming
  7731. */
  7732. static audioEngine: AudioEngine;
  7733. private _onFocus;
  7734. private _onBlur;
  7735. private _onCanvasPointerOut;
  7736. private _onCanvasBlur;
  7737. private _onCanvasFocus;
  7738. private _onFullscreenChange;
  7739. private _onPointerLockChange;
  7740. private _onVRDisplayPointerRestricted;
  7741. private _onVRDisplayPointerUnrestricted;
  7742. private _onVrDisplayConnect;
  7743. private _onVrDisplayDisconnect;
  7744. private _onVrDisplayPresentChange;
  7745. /**
  7746. * Observable signaled when VR display mode changes
  7747. */
  7748. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7749. /**
  7750. * Observable signaled when VR request present is complete
  7751. */
  7752. onVRRequestPresentComplete: Observable<boolean>;
  7753. /**
  7754. * Observable signaled when VR request present starts
  7755. */
  7756. onVRRequestPresentStart: Observable<Engine>;
  7757. private _hardwareScalingLevel;
  7758. /** @hidden */
  7759. protected _caps: EngineCapabilities;
  7760. private _pointerLockRequested;
  7761. private _isStencilEnable;
  7762. private _colorWrite;
  7763. private _loadingScreen;
  7764. /** @hidden */
  7765. _drawCalls: PerfCounter;
  7766. /** @hidden */
  7767. _textureCollisions: PerfCounter;
  7768. private _glVersion;
  7769. private _glRenderer;
  7770. private _glVendor;
  7771. private _videoTextureSupported;
  7772. private _renderingQueueLaunched;
  7773. private _activeRenderLoops;
  7774. private _deterministicLockstep;
  7775. private _lockstepMaxSteps;
  7776. /**
  7777. * Observable signaled when a context lost event is raised
  7778. */
  7779. onContextLostObservable: Observable<Engine>;
  7780. /**
  7781. * Observable signaled when a context restored event is raised
  7782. */
  7783. onContextRestoredObservable: Observable<Engine>;
  7784. private _onContextLost;
  7785. private _onContextRestored;
  7786. private _contextWasLost;
  7787. private _doNotHandleContextLost;
  7788. /**
  7789. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7791. */
  7792. doNotHandleContextLost: boolean;
  7793. private _performanceMonitor;
  7794. private _fps;
  7795. private _deltaTime;
  7796. /**
  7797. * Turn this value on if you want to pause FPS computation when in background
  7798. */
  7799. disablePerformanceMonitorInBackground: boolean;
  7800. /**
  7801. * Gets the performance monitor attached to this engine
  7802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7803. */
  7804. readonly performanceMonitor: PerformanceMonitor;
  7805. /** @hidden */
  7806. protected _depthCullingState: _DepthCullingState;
  7807. /** @hidden */
  7808. protected _stencilState: _StencilState;
  7809. /** @hidden */
  7810. protected _alphaState: _AlphaState;
  7811. /** @hidden */
  7812. protected _alphaMode: number;
  7813. protected _internalTexturesCache: InternalTexture[];
  7814. /** @hidden */
  7815. protected _activeChannel: number;
  7816. private _currentTextureChannel;
  7817. /** @hidden */
  7818. protected _boundTexturesCache: {
  7819. [key: string]: Nullable<InternalTexture>;
  7820. };
  7821. /** @hidden */
  7822. protected _currentEffect: Nullable<Effect>;
  7823. /** @hidden */
  7824. protected _currentProgram: Nullable<WebGLProgram>;
  7825. private _compiledEffects;
  7826. private _vertexAttribArraysEnabled;
  7827. /** @hidden */
  7828. protected _cachedViewport: Nullable<Viewport>;
  7829. private _cachedVertexArrayObject;
  7830. /** @hidden */
  7831. protected _cachedVertexBuffers: any;
  7832. /** @hidden */
  7833. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7834. /** @hidden */
  7835. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7836. /** @hidden */
  7837. protected _currentRenderTarget: Nullable<InternalTexture>;
  7838. private _uintIndicesCurrentlySet;
  7839. private _currentBoundBuffer;
  7840. /** @hidden */
  7841. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7842. private _currentBufferPointers;
  7843. private _currentInstanceLocations;
  7844. private _currentInstanceBuffers;
  7845. private _textureUnits;
  7846. private _firstBoundInternalTextureTracker;
  7847. private _lastBoundInternalTextureTracker;
  7848. private _workingCanvas;
  7849. private _workingContext;
  7850. private _rescalePostProcess;
  7851. private _dummyFramebuffer;
  7852. private _externalData;
  7853. private _bindedRenderFunction;
  7854. private _vaoRecordInProgress;
  7855. private _mustWipeVertexAttributes;
  7856. private _emptyTexture;
  7857. private _emptyCubeTexture;
  7858. private _emptyTexture3D;
  7859. private _frameHandler;
  7860. private _nextFreeTextureSlots;
  7861. private _maxSimultaneousTextures;
  7862. private _activeRequests;
  7863. private _texturesSupported;
  7864. private _textureFormatInUse;
  7865. /**
  7866. * Gets the list of texture formats supported
  7867. */
  7868. readonly texturesSupported: Array<string>;
  7869. /**
  7870. * Gets the list of texture formats in use
  7871. */
  7872. readonly textureFormatInUse: Nullable<string>;
  7873. /**
  7874. * Gets the current viewport
  7875. */
  7876. readonly currentViewport: Nullable<Viewport>;
  7877. /**
  7878. * Gets the default empty texture
  7879. */
  7880. readonly emptyTexture: InternalTexture;
  7881. /**
  7882. * Gets the default empty 3D texture
  7883. */
  7884. readonly emptyTexture3D: InternalTexture;
  7885. /**
  7886. * Gets the default empty cube texture
  7887. */
  7888. readonly emptyCubeTexture: InternalTexture;
  7889. /**
  7890. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7891. */
  7892. readonly premultipliedAlpha: boolean;
  7893. /**
  7894. * Creates a new engine
  7895. * @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
  7896. * @param antialias defines enable antialiasing (default: false)
  7897. * @param options defines further options to be sent to the getContext() function
  7898. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7899. */
  7900. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7901. private _rebuildInternalTextures;
  7902. private _rebuildEffects;
  7903. private _rebuildBuffers;
  7904. private _initGLContext;
  7905. /**
  7906. * Gets version of the current webGL context
  7907. */
  7908. readonly webGLVersion: number;
  7909. /**
  7910. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7911. */
  7912. readonly isStencilEnable: boolean;
  7913. private _prepareWorkingCanvas;
  7914. /**
  7915. * Reset the texture cache to empty state
  7916. */
  7917. resetTextureCache(): void;
  7918. /**
  7919. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7920. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7921. * @returns true if engine is in deterministic lock step mode
  7922. */
  7923. isDeterministicLockStep(): boolean;
  7924. /**
  7925. * Gets the max steps when engine is running in deterministic lock step
  7926. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7927. * @returns the max steps
  7928. */
  7929. getLockstepMaxSteps(): number;
  7930. /**
  7931. * Gets an object containing information about the current webGL context
  7932. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7933. */
  7934. getGlInfo(): {
  7935. vendor: string;
  7936. renderer: string;
  7937. version: string;
  7938. };
  7939. /**
  7940. * Gets current aspect ratio
  7941. * @param camera defines the camera to use to get the aspect ratio
  7942. * @param useScreen defines if screen size must be used (or the current render target if any)
  7943. * @returns a number defining the aspect ratio
  7944. */
  7945. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7946. /**
  7947. * Gets current screen aspect ratio
  7948. * @returns a number defining the aspect ratio
  7949. */
  7950. getScreenAspectRatio(): number;
  7951. /**
  7952. * Gets the current render width
  7953. * @param useScreen defines if screen size must be used (or the current render target if any)
  7954. * @returns a number defining the current render width
  7955. */
  7956. getRenderWidth(useScreen?: boolean): number;
  7957. /**
  7958. * Gets the current render height
  7959. * @param useScreen defines if screen size must be used (or the current render target if any)
  7960. * @returns a number defining the current render height
  7961. */
  7962. getRenderHeight(useScreen?: boolean): number;
  7963. /**
  7964. * Gets the HTML canvas attached with the current webGL context
  7965. * @returns a HTML canvas
  7966. */
  7967. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7968. /**
  7969. * Gets the client rect of the HTML canvas attached with the current webGL context
  7970. * @returns a client rectanglee
  7971. */
  7972. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7973. /**
  7974. * Defines the hardware scaling level.
  7975. * By default the hardware scaling level is computed from the window device ratio.
  7976. * 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.
  7977. * @param level defines the level to use
  7978. */
  7979. setHardwareScalingLevel(level: number): void;
  7980. /**
  7981. * Gets the current hardware scaling level.
  7982. * By default the hardware scaling level is computed from the window device ratio.
  7983. * 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.
  7984. * @returns a number indicating the current hardware scaling level
  7985. */
  7986. getHardwareScalingLevel(): number;
  7987. /**
  7988. * Gets the list of loaded textures
  7989. * @returns an array containing all loaded textures
  7990. */
  7991. getLoadedTexturesCache(): InternalTexture[];
  7992. /**
  7993. * Gets the object containing all engine capabilities
  7994. * @returns the EngineCapabilities object
  7995. */
  7996. getCaps(): EngineCapabilities;
  7997. /** @hidden */
  7998. readonly drawCalls: number;
  7999. /** @hidden */
  8000. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  8001. /**
  8002. * Gets the current depth function
  8003. * @returns a number defining the depth function
  8004. */
  8005. getDepthFunction(): Nullable<number>;
  8006. /**
  8007. * Sets the current depth function
  8008. * @param depthFunc defines the function to use
  8009. */
  8010. setDepthFunction(depthFunc: number): void;
  8011. /**
  8012. * Sets the current depth function to GREATER
  8013. */
  8014. setDepthFunctionToGreater(): void;
  8015. /**
  8016. * Sets the current depth function to GEQUAL
  8017. */
  8018. setDepthFunctionToGreaterOrEqual(): void;
  8019. /**
  8020. * Sets the current depth function to LESS
  8021. */
  8022. setDepthFunctionToLess(): void;
  8023. /**
  8024. * Sets the current depth function to LEQUAL
  8025. */
  8026. setDepthFunctionToLessOrEqual(): void;
  8027. /**
  8028. * Gets a boolean indicating if stencil buffer is enabled
  8029. * @returns the current stencil buffer state
  8030. */
  8031. getStencilBuffer(): boolean;
  8032. /**
  8033. * Enable or disable the stencil buffer
  8034. * @param enable defines if the stencil buffer must be enabled or disabled
  8035. */
  8036. setStencilBuffer(enable: boolean): void;
  8037. /**
  8038. * Gets the current stencil mask
  8039. * @returns a number defining the new stencil mask to use
  8040. */
  8041. getStencilMask(): number;
  8042. /**
  8043. * Sets the current stencil mask
  8044. * @param mask defines the new stencil mask to use
  8045. */
  8046. setStencilMask(mask: number): void;
  8047. /**
  8048. * Gets the current stencil function
  8049. * @returns a number defining the stencil function to use
  8050. */
  8051. getStencilFunction(): number;
  8052. /**
  8053. * Gets the current stencil reference value
  8054. * @returns a number defining the stencil reference value to use
  8055. */
  8056. getStencilFunctionReference(): number;
  8057. /**
  8058. * Gets the current stencil mask
  8059. * @returns a number defining the stencil mask to use
  8060. */
  8061. getStencilFunctionMask(): number;
  8062. /**
  8063. * Sets the current stencil function
  8064. * @param stencilFunc defines the new stencil function to use
  8065. */
  8066. setStencilFunction(stencilFunc: number): void;
  8067. /**
  8068. * Sets the current stencil reference
  8069. * @param reference defines the new stencil reference to use
  8070. */
  8071. setStencilFunctionReference(reference: number): void;
  8072. /**
  8073. * Sets the current stencil mask
  8074. * @param mask defines the new stencil mask to use
  8075. */
  8076. setStencilFunctionMask(mask: number): void;
  8077. /**
  8078. * Gets the current stencil operation when stencil fails
  8079. * @returns a number defining stencil operation to use when stencil fails
  8080. */
  8081. getStencilOperationFail(): number;
  8082. /**
  8083. * Gets the current stencil operation when depth fails
  8084. * @returns a number defining stencil operation to use when depth fails
  8085. */
  8086. getStencilOperationDepthFail(): number;
  8087. /**
  8088. * Gets the current stencil operation when stencil passes
  8089. * @returns a number defining stencil operation to use when stencil passes
  8090. */
  8091. getStencilOperationPass(): number;
  8092. /**
  8093. * Sets the stencil operation to use when stencil fails
  8094. * @param operation defines the stencil operation to use when stencil fails
  8095. */
  8096. setStencilOperationFail(operation: number): void;
  8097. /**
  8098. * Sets the stencil operation to use when depth fails
  8099. * @param operation defines the stencil operation to use when depth fails
  8100. */
  8101. setStencilOperationDepthFail(operation: number): void;
  8102. /**
  8103. * Sets the stencil operation to use when stencil passes
  8104. * @param operation defines the stencil operation to use when stencil passes
  8105. */
  8106. setStencilOperationPass(operation: number): void;
  8107. /**
  8108. * Sets a boolean indicating if the dithering state is enabled or disabled
  8109. * @param value defines the dithering state
  8110. */
  8111. setDitheringState(value: boolean): void;
  8112. /**
  8113. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8114. * @param value defines the rasterizer state
  8115. */
  8116. setRasterizerState(value: boolean): void;
  8117. /**
  8118. * stop executing a render loop function and remove it from the execution array
  8119. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8120. */
  8121. stopRenderLoop(renderFunction?: () => void): void;
  8122. /** @hidden */
  8123. _renderLoop(): void;
  8124. /**
  8125. * Register and execute a render loop. The engine can have more than one render function
  8126. * @param renderFunction defines the function to continuously execute
  8127. */
  8128. runRenderLoop(renderFunction: () => void): void;
  8129. /**
  8130. * Toggle full screen mode
  8131. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8132. * @param options defines an option object to be sent to the requestFullscreen function
  8133. */
  8134. switchFullscreen(requestPointerLock: boolean): void;
  8135. /**
  8136. * Clear the current render buffer or the current render target (if any is set up)
  8137. * @param color defines the color to use
  8138. * @param backBuffer defines if the back buffer must be cleared
  8139. * @param depth defines if the depth buffer must be cleared
  8140. * @param stencil defines if the stencil buffer must be cleared
  8141. */
  8142. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8143. /**
  8144. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8145. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8146. * @param y defines the y-coordinate of the corner of the clear rectangle
  8147. * @param width defines the width of the clear rectangle
  8148. * @param height defines the height of the clear rectangle
  8149. * @param clearColor defines the clear color
  8150. */
  8151. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8152. private _viewportCached;
  8153. /** @hidden */
  8154. _viewport(x: number, y: number, width: number, height: number): void;
  8155. /**
  8156. * Set the WebGL's viewport
  8157. * @param viewport defines the viewport element to be used
  8158. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8159. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8160. */
  8161. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8162. /**
  8163. * Directly set the WebGL Viewport
  8164. * @param x defines the x coordinate of the viewport (in screen space)
  8165. * @param y defines the y coordinate of the viewport (in screen space)
  8166. * @param width defines the width of the viewport (in screen space)
  8167. * @param height defines the height of the viewport (in screen space)
  8168. * @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
  8169. */
  8170. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8171. /**
  8172. * Begin a new frame
  8173. */
  8174. beginFrame(): void;
  8175. /**
  8176. * Enf the current frame
  8177. */
  8178. endFrame(): void;
  8179. /**
  8180. * Resize the view according to the canvas' size
  8181. */
  8182. resize(): void;
  8183. /**
  8184. * Force a specific size of the canvas
  8185. * @param width defines the new canvas' width
  8186. * @param height defines the new canvas' height
  8187. */
  8188. setSize(width: number, height: number): void;
  8189. /**
  8190. * Gets a boolean indicating if a webVR device was detected
  8191. * @returns true if a webVR device was detected
  8192. */
  8193. isVRDevicePresent(): boolean;
  8194. /**
  8195. * Gets the current webVR device
  8196. * @returns the current webVR device (or null)
  8197. */
  8198. getVRDevice(): any;
  8199. /**
  8200. * Initializes a webVR display and starts listening to display change events
  8201. * The onVRDisplayChangedObservable will be notified upon these changes
  8202. * @returns The onVRDisplayChangedObservable
  8203. */
  8204. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8205. /**
  8206. * Initializes a webVR display and starts listening to display change events
  8207. * The onVRDisplayChangedObservable will be notified upon these changes
  8208. * @returns A promise containing a VRDisplay and if vr is supported
  8209. */
  8210. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8211. /**
  8212. * Call this function to switch to webVR mode
  8213. * Will do nothing if webVR is not supported or if there is no webVR device
  8214. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8215. */
  8216. enableVR(): void;
  8217. /**
  8218. * Call this function to leave webVR mode
  8219. * Will do nothing if webVR is not supported or if there is no webVR device
  8220. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8221. */
  8222. disableVR(): void;
  8223. private _onVRFullScreenTriggered;
  8224. private _getVRDisplaysAsync;
  8225. /**
  8226. * Binds the frame buffer to the specified texture.
  8227. * @param texture The texture to render to or null for the default canvas
  8228. * @param faceIndex The face of the texture to render to in case of cube texture
  8229. * @param requiredWidth The width of the target to render to
  8230. * @param requiredHeight The height of the target to render to
  8231. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8232. * @param depthStencilTexture The depth stencil texture to use to render
  8233. * @param lodLevel defines le lod level to bind to the frame buffer
  8234. */
  8235. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8236. private bindUnboundFramebuffer;
  8237. /**
  8238. * Unbind the current render target texture from the webGL context
  8239. * @param texture defines the render target texture to unbind
  8240. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8241. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8242. */
  8243. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8244. /**
  8245. * Unbind a list of render target textures from the webGL context
  8246. * This is used only when drawBuffer extension or webGL2 are active
  8247. * @param textures defines the render target textures to unbind
  8248. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8249. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8250. */
  8251. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8252. /**
  8253. * Force the mipmap generation for the given render target texture
  8254. * @param texture defines the render target texture to use
  8255. */
  8256. generateMipMapsForCubemap(texture: InternalTexture): void;
  8257. /**
  8258. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8259. */
  8260. flushFramebuffer(): void;
  8261. /**
  8262. * Unbind the current render target and bind the default framebuffer
  8263. */
  8264. restoreDefaultFramebuffer(): void;
  8265. /**
  8266. * Create an uniform buffer
  8267. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8268. * @param elements defines the content of the uniform buffer
  8269. * @returns the webGL uniform buffer
  8270. */
  8271. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8272. /**
  8273. * Create a dynamic uniform buffer
  8274. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8275. * @param elements defines the content of the uniform buffer
  8276. * @returns the webGL uniform buffer
  8277. */
  8278. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8279. /**
  8280. * Update an existing uniform buffer
  8281. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8282. * @param uniformBuffer defines the target uniform buffer
  8283. * @param elements defines the content to update
  8284. * @param offset defines the offset in the uniform buffer where update should start
  8285. * @param count defines the size of the data to update
  8286. */
  8287. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8288. private _resetVertexBufferBinding;
  8289. /**
  8290. * Creates a vertex buffer
  8291. * @param data the data for the vertex buffer
  8292. * @returns the new WebGL static buffer
  8293. */
  8294. createVertexBuffer(data: DataArray): WebGLBuffer;
  8295. /**
  8296. * Creates a dynamic vertex buffer
  8297. * @param data the data for the dynamic vertex buffer
  8298. * @returns the new WebGL dynamic buffer
  8299. */
  8300. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8301. /**
  8302. * Update a dynamic index buffer
  8303. * @param indexBuffer defines the target index buffer
  8304. * @param indices defines the data to update
  8305. * @param offset defines the offset in the target index buffer where update should start
  8306. */
  8307. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8308. /**
  8309. * Updates a dynamic vertex buffer.
  8310. * @param vertexBuffer the vertex buffer to update
  8311. * @param data the data used to update the vertex buffer
  8312. * @param byteOffset the byte offset of the data
  8313. * @param byteLength the byte length of the data
  8314. */
  8315. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8316. private _resetIndexBufferBinding;
  8317. /**
  8318. * Creates a new index buffer
  8319. * @param indices defines the content of the index buffer
  8320. * @param updatable defines if the index buffer must be updatable
  8321. * @returns a new webGL buffer
  8322. */
  8323. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8324. /**
  8325. * Bind a webGL buffer to the webGL context
  8326. * @param buffer defines the buffer to bind
  8327. */
  8328. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8329. /**
  8330. * Bind an uniform buffer to the current webGL context
  8331. * @param buffer defines the buffer to bind
  8332. */
  8333. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8334. /**
  8335. * Bind a buffer to the current webGL context at a given location
  8336. * @param buffer defines the buffer to bind
  8337. * @param location defines the index where to bind the buffer
  8338. */
  8339. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8340. /**
  8341. * Bind a specific block at a given index in a specific shader program
  8342. * @param shaderProgram defines the shader program
  8343. * @param blockName defines the block name
  8344. * @param index defines the index where to bind the block
  8345. */
  8346. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8347. private bindIndexBuffer;
  8348. private bindBuffer;
  8349. /**
  8350. * update the bound buffer with the given data
  8351. * @param data defines the data to update
  8352. */
  8353. updateArrayBuffer(data: Float32Array): void;
  8354. private _vertexAttribPointer;
  8355. private _bindIndexBufferWithCache;
  8356. private _bindVertexBuffersAttributes;
  8357. /**
  8358. * Records a vertex array object
  8359. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8360. * @param vertexBuffers defines the list of vertex buffers to store
  8361. * @param indexBuffer defines the index buffer to store
  8362. * @param effect defines the effect to store
  8363. * @returns the new vertex array object
  8364. */
  8365. recordVertexArrayObject(vertexBuffers: {
  8366. [key: string]: VertexBuffer;
  8367. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8368. /**
  8369. * Bind a specific vertex array object
  8370. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8371. * @param vertexArrayObject defines the vertex array object to bind
  8372. * @param indexBuffer defines the index buffer to bind
  8373. */
  8374. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8375. /**
  8376. * Bind webGl buffers directly to the webGL context
  8377. * @param vertexBuffer defines the vertex buffer to bind
  8378. * @param indexBuffer defines the index buffer to bind
  8379. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8380. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8381. * @param effect defines the effect associated with the vertex buffer
  8382. */
  8383. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8384. private _unbindVertexArrayObject;
  8385. /**
  8386. * Bind a list of vertex buffers to the webGL context
  8387. * @param vertexBuffers defines the list of vertex buffers to bind
  8388. * @param indexBuffer defines the index buffer to bind
  8389. * @param effect defines the effect associated with the vertex buffers
  8390. */
  8391. bindBuffers(vertexBuffers: {
  8392. [key: string]: Nullable<VertexBuffer>;
  8393. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8394. /**
  8395. * Unbind all instance attributes
  8396. */
  8397. unbindInstanceAttributes(): void;
  8398. /**
  8399. * Release and free the memory of a vertex array object
  8400. * @param vao defines the vertex array object to delete
  8401. */
  8402. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8403. /** @hidden */
  8404. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8405. /**
  8406. * Creates a webGL buffer to use with instanciation
  8407. * @param capacity defines the size of the buffer
  8408. * @returns the webGL buffer
  8409. */
  8410. createInstancesBuffer(capacity: number): WebGLBuffer;
  8411. /**
  8412. * Delete a webGL buffer used with instanciation
  8413. * @param buffer defines the webGL buffer to delete
  8414. */
  8415. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8416. /**
  8417. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8418. * @param instancesBuffer defines the webGL buffer to update and bind
  8419. * @param data defines the data to store in the buffer
  8420. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8421. */
  8422. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8423. /**
  8424. * Apply all cached states (depth, culling, stencil and alpha)
  8425. */
  8426. applyStates(): void;
  8427. /**
  8428. * Send a draw order
  8429. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8430. * @param indexStart defines the starting index
  8431. * @param indexCount defines the number of index to draw
  8432. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8433. */
  8434. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8435. /**
  8436. * Draw a list of points
  8437. * @param verticesStart defines the index of first vertex to draw
  8438. * @param verticesCount defines the count of vertices to draw
  8439. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8440. */
  8441. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8442. /**
  8443. * Draw a list of unindexed primitives
  8444. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8445. * @param verticesStart defines the index of first vertex to draw
  8446. * @param verticesCount defines the count of vertices to draw
  8447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8448. */
  8449. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8450. /**
  8451. * Draw a list of indexed primitives
  8452. * @param fillMode defines the primitive to use
  8453. * @param indexStart defines the starting index
  8454. * @param indexCount defines the number of index to draw
  8455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8456. */
  8457. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8458. /**
  8459. * Draw a list of unindexed primitives
  8460. * @param fillMode defines the primitive to use
  8461. * @param verticesStart defines the index of first vertex to draw
  8462. * @param verticesCount defines the count of vertices to draw
  8463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8464. */
  8465. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8466. private _drawMode;
  8467. /** @hidden */
  8468. _releaseEffect(effect: Effect): void;
  8469. /** @hidden */
  8470. _deleteProgram(program: WebGLProgram): void;
  8471. /**
  8472. * Create a new effect (used to store vertex/fragment shaders)
  8473. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8474. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8475. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8476. * @param samplers defines an array of string used to represent textures
  8477. * @param defines defines the string containing the defines to use to compile the shaders
  8478. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8479. * @param onCompiled defines a function to call when the effect creation is successful
  8480. * @param onError defines a function to call when the effect creation has failed
  8481. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8482. * @returns the new Effect
  8483. */
  8484. 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;
  8485. private _compileShader;
  8486. private _compileRawShader;
  8487. /**
  8488. * Directly creates a webGL program
  8489. * @param vertexCode defines the vertex shader code to use
  8490. * @param fragmentCode defines the fragment shader code to use
  8491. * @param context defines the webGL context to use (if not set, the current one will be used)
  8492. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8493. * @returns the new webGL program
  8494. */
  8495. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8496. /**
  8497. * Creates a webGL program
  8498. * @param vertexCode defines the vertex shader code to use
  8499. * @param fragmentCode defines the fragment shader code to use
  8500. * @param defines defines the string containing the defines to use to compile the shaders
  8501. * @param context defines the webGL context to use (if not set, the current one will be used)
  8502. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8503. * @returns the new webGL program
  8504. */
  8505. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8506. private _createShaderProgram;
  8507. /**
  8508. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8509. * @param shaderProgram defines the webGL program to use
  8510. * @param uniformsNames defines the list of uniform names
  8511. * @returns an array of webGL uniform locations
  8512. */
  8513. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8514. /**
  8515. * Gets the lsit of active attributes for a given webGL program
  8516. * @param shaderProgram defines the webGL program to use
  8517. * @param attributesNames defines the list of attribute names to get
  8518. * @returns an array of indices indicating the offset of each attribute
  8519. */
  8520. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8521. /**
  8522. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8523. * @param effect defines the effect to activate
  8524. */
  8525. enableEffect(effect: Nullable<Effect>): void;
  8526. /**
  8527. * Set the value of an uniform to an array of int32
  8528. * @param uniform defines the webGL uniform location where to store the value
  8529. * @param array defines the array of int32 to store
  8530. */
  8531. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8532. /**
  8533. * Set the value of an uniform to an array of int32 (stored as vec2)
  8534. * @param uniform defines the webGL uniform location where to store the value
  8535. * @param array defines the array of int32 to store
  8536. */
  8537. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8538. /**
  8539. * Set the value of an uniform to an array of int32 (stored as vec3)
  8540. * @param uniform defines the webGL uniform location where to store the value
  8541. * @param array defines the array of int32 to store
  8542. */
  8543. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8544. /**
  8545. * Set the value of an uniform to an array of int32 (stored as vec4)
  8546. * @param uniform defines the webGL uniform location where to store the value
  8547. * @param array defines the array of int32 to store
  8548. */
  8549. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8550. /**
  8551. * Set the value of an uniform to an array of float32
  8552. * @param uniform defines the webGL uniform location where to store the value
  8553. * @param array defines the array of float32 to store
  8554. */
  8555. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8556. /**
  8557. * Set the value of an uniform to an array of float32 (stored as vec2)
  8558. * @param uniform defines the webGL uniform location where to store the value
  8559. * @param array defines the array of float32 to store
  8560. */
  8561. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8562. /**
  8563. * Set the value of an uniform to an array of float32 (stored as vec3)
  8564. * @param uniform defines the webGL uniform location where to store the value
  8565. * @param array defines the array of float32 to store
  8566. */
  8567. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8568. /**
  8569. * Set the value of an uniform to an array of float32 (stored as vec4)
  8570. * @param uniform defines the webGL uniform location where to store the value
  8571. * @param array defines the array of float32 to store
  8572. */
  8573. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8574. /**
  8575. * Set the value of an uniform to an array of number
  8576. * @param uniform defines the webGL uniform location where to store the value
  8577. * @param array defines the array of number to store
  8578. */
  8579. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8580. /**
  8581. * Set the value of an uniform to an array of number (stored as vec2)
  8582. * @param uniform defines the webGL uniform location where to store the value
  8583. * @param array defines the array of number to store
  8584. */
  8585. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8586. /**
  8587. * Set the value of an uniform to an array of number (stored as vec3)
  8588. * @param uniform defines the webGL uniform location where to store the value
  8589. * @param array defines the array of number to store
  8590. */
  8591. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8592. /**
  8593. * Set the value of an uniform to an array of number (stored as vec4)
  8594. * @param uniform defines the webGL uniform location where to store the value
  8595. * @param array defines the array of number to store
  8596. */
  8597. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8598. /**
  8599. * Set the value of an uniform to an array of float32 (stored as matrices)
  8600. * @param uniform defines the webGL uniform location where to store the value
  8601. * @param matrices defines the array of float32 to store
  8602. */
  8603. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8604. /**
  8605. * Set the value of an uniform to a matrix
  8606. * @param uniform defines the webGL uniform location where to store the value
  8607. * @param matrix defines the matrix to store
  8608. */
  8609. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8610. /**
  8611. * Set the value of an uniform to a matrix (3x3)
  8612. * @param uniform defines the webGL uniform location where to store the value
  8613. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8614. */
  8615. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8616. /**
  8617. * Set the value of an uniform to a matrix (2x2)
  8618. * @param uniform defines the webGL uniform location where to store the value
  8619. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8620. */
  8621. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8622. /**
  8623. * Set the value of an uniform to a number (int)
  8624. * @param uniform defines the webGL uniform location where to store the value
  8625. * @param value defines the int number to store
  8626. */
  8627. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8628. /**
  8629. * Set the value of an uniform to a number (float)
  8630. * @param uniform defines the webGL uniform location where to store the value
  8631. * @param value defines the float number to store
  8632. */
  8633. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8634. /**
  8635. * Set the value of an uniform to a vec2
  8636. * @param uniform defines the webGL uniform location where to store the value
  8637. * @param x defines the 1st component of the value
  8638. * @param y defines the 2nd component of the value
  8639. */
  8640. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8641. /**
  8642. * Set the value of an uniform to a vec3
  8643. * @param uniform defines the webGL uniform location where to store the value
  8644. * @param x defines the 1st component of the value
  8645. * @param y defines the 2nd component of the value
  8646. * @param z defines the 3rd component of the value
  8647. */
  8648. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8649. /**
  8650. * Set the value of an uniform to a boolean
  8651. * @param uniform defines the webGL uniform location where to store the value
  8652. * @param bool defines the boolean to store
  8653. */
  8654. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8655. /**
  8656. * Set the value of an uniform to a vec4
  8657. * @param uniform defines the webGL uniform location where to store the value
  8658. * @param x defines the 1st component of the value
  8659. * @param y defines the 2nd component of the value
  8660. * @param z defines the 3rd component of the value
  8661. * @param w defines the 4th component of the value
  8662. */
  8663. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8664. /**
  8665. * Set the value of an uniform to a Color3
  8666. * @param uniform defines the webGL uniform location where to store the value
  8667. * @param color3 defines the color to store
  8668. */
  8669. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8670. /**
  8671. * Set the value of an uniform to a Color3 and an alpha value
  8672. * @param uniform defines the webGL uniform location where to store the value
  8673. * @param color3 defines the color to store
  8674. * @param alpha defines the alpha component to store
  8675. */
  8676. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8677. /**
  8678. * Sets a Color4 on a uniform variable
  8679. * @param uniform defines the uniform location
  8680. * @param color4 defines the value to be set
  8681. */
  8682. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8683. /**
  8684. * Set various states to the webGL context
  8685. * @param culling defines backface culling state
  8686. * @param zOffset defines the value to apply to zOffset (0 by default)
  8687. * @param force defines if states must be applied even if cache is up to date
  8688. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8689. */
  8690. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8691. /**
  8692. * Set the z offset to apply to current rendering
  8693. * @param value defines the offset to apply
  8694. */
  8695. setZOffset(value: number): void;
  8696. /**
  8697. * Gets the current value of the zOffset
  8698. * @returns the current zOffset state
  8699. */
  8700. getZOffset(): number;
  8701. /**
  8702. * Enable or disable depth buffering
  8703. * @param enable defines the state to set
  8704. */
  8705. setDepthBuffer(enable: boolean): void;
  8706. /**
  8707. * Gets a boolean indicating if depth writing is enabled
  8708. * @returns the current depth writing state
  8709. */
  8710. getDepthWrite(): boolean;
  8711. /**
  8712. * Enable or disable depth writing
  8713. * @param enable defines the state to set
  8714. */
  8715. setDepthWrite(enable: boolean): void;
  8716. /**
  8717. * Enable or disable color writing
  8718. * @param enable defines the state to set
  8719. */
  8720. setColorWrite(enable: boolean): void;
  8721. /**
  8722. * Gets a boolean indicating if color writing is enabled
  8723. * @returns the current color writing state
  8724. */
  8725. getColorWrite(): boolean;
  8726. /**
  8727. * Sets alpha constants used by some alpha blending modes
  8728. * @param r defines the red component
  8729. * @param g defines the green component
  8730. * @param b defines the blue component
  8731. * @param a defines the alpha component
  8732. */
  8733. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8734. /**
  8735. * Sets the current alpha mode
  8736. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8737. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8738. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8739. */
  8740. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8741. /**
  8742. * Gets the current alpha mode
  8743. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8744. * @returns the current alpha mode
  8745. */
  8746. getAlphaMode(): number;
  8747. /**
  8748. * Clears the list of texture accessible through engine.
  8749. * This can help preventing texture load conflict due to name collision.
  8750. */
  8751. clearInternalTexturesCache(): void;
  8752. /**
  8753. * Force the entire cache to be cleared
  8754. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8755. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8756. */
  8757. wipeCaches(bruteForce?: boolean): void;
  8758. /**
  8759. * Set the compressed texture format to use, based on the formats you have, and the formats
  8760. * supported by the hardware / browser.
  8761. *
  8762. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8763. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8764. * to API arguments needed to compressed textures. This puts the burden on the container
  8765. * generator to house the arcane code for determining these for current & future formats.
  8766. *
  8767. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8768. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8769. *
  8770. * Note: The result of this call is not taken into account when a texture is base64.
  8771. *
  8772. * @param formatsAvailable defines the list of those format families you have created
  8773. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8774. *
  8775. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8776. * @returns The extension selected.
  8777. */
  8778. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8779. private _getSamplingParameters;
  8780. private _partialLoadImg;
  8781. private _cascadeLoadImgs;
  8782. /** @hidden */
  8783. _createTexture(): WebGLTexture;
  8784. /**
  8785. * Usually called from BABYLON.Texture.ts.
  8786. * Passed information to create a WebGLTexture
  8787. * @param urlArg defines a value which contains one of the following:
  8788. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8789. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8790. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8791. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8792. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8793. * @param scene needed for loading to the correct scene
  8794. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8795. * @param onLoad optional callback to be called upon successful completion
  8796. * @param onError optional callback to be called upon failure
  8797. * @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
  8798. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8799. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8800. * @param forcedExtension defines the extension to use to pick the right loader
  8801. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8802. */
  8803. 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;
  8804. private _rescaleTexture;
  8805. /**
  8806. * Update a raw texture
  8807. * @param texture defines the texture to update
  8808. * @param data defines the data to store in the texture
  8809. * @param format defines the format of the data
  8810. * @param invertY defines if data must be stored with Y axis inverted
  8811. * @param compression defines the compression used (null by default)
  8812. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8813. */
  8814. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8815. /**
  8816. * Creates a raw texture
  8817. * @param data defines the data to store in the texture
  8818. * @param width defines the width of the texture
  8819. * @param height defines the height of the texture
  8820. * @param format defines the format of the data
  8821. * @param generateMipMaps defines if the engine should generate the mip levels
  8822. * @param invertY defines if data must be stored with Y axis inverted
  8823. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8824. * @param compression defines the compression used (null by default)
  8825. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8826. * @returns the raw texture inside an InternalTexture
  8827. */
  8828. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8829. private _unpackFlipYCached;
  8830. /**
  8831. * In case you are sharing the context with other applications, it might
  8832. * be interested to not cache the unpack flip y state to ensure a consistent
  8833. * value would be set.
  8834. */
  8835. enableUnpackFlipYCached: boolean;
  8836. /** @hidden */
  8837. _unpackFlipY(value: boolean): void;
  8838. /** @hidden */
  8839. _getUnpackAlignement(): number;
  8840. /**
  8841. * Creates a dynamic texture
  8842. * @param width defines the width of the texture
  8843. * @param height defines the height of the texture
  8844. * @param generateMipMaps defines if the engine should generate the mip levels
  8845. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8846. * @returns the dynamic texture inside an InternalTexture
  8847. */
  8848. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8849. /**
  8850. * Update the sampling mode of a given texture
  8851. * @param samplingMode defines the required sampling mode
  8852. * @param texture defines the texture to update
  8853. */
  8854. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8855. /**
  8856. * Update the content of a dynamic texture
  8857. * @param texture defines the texture to update
  8858. * @param canvas defines the canvas containing the source
  8859. * @param invertY defines if data must be stored with Y axis inverted
  8860. * @param premulAlpha defines if alpha is stored as premultiplied
  8861. * @param format defines the format of the data
  8862. */
  8863. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8864. /**
  8865. * Update a video texture
  8866. * @param texture defines the texture to update
  8867. * @param video defines the video element to use
  8868. * @param invertY defines if data must be stored with Y axis inverted
  8869. */
  8870. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8871. /**
  8872. * Updates a depth texture Comparison Mode and Function.
  8873. * If the comparison Function is equal to 0, the mode will be set to none.
  8874. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8875. * @param texture The texture to set the comparison function for
  8876. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8877. */
  8878. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8879. private _setupDepthStencilTexture;
  8880. /**
  8881. * Creates a depth stencil texture.
  8882. * This is only available in WebGL 2 or with the depth texture extension available.
  8883. * @param size The size of face edge in the texture.
  8884. * @param options The options defining the texture.
  8885. * @returns The texture
  8886. */
  8887. createDepthStencilTexture(size: number | {
  8888. width: number;
  8889. height: number;
  8890. }, options: DepthTextureCreationOptions): InternalTexture;
  8891. /**
  8892. * Creates a depth stencil texture.
  8893. * This is only available in WebGL 2 or with the depth texture extension available.
  8894. * @param size The size of face edge in the texture.
  8895. * @param options The options defining the texture.
  8896. * @returns The texture
  8897. */
  8898. private _createDepthStencilTexture;
  8899. /**
  8900. * Creates a depth stencil cube texture.
  8901. * This is only available in WebGL 2.
  8902. * @param size The size of face edge in the cube texture.
  8903. * @param options The options defining the cube texture.
  8904. * @returns The cube texture
  8905. */
  8906. private _createDepthStencilCubeTexture;
  8907. /**
  8908. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8909. * @param renderTarget The render target to set the frame buffer for
  8910. */
  8911. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8912. /**
  8913. * Creates a new render target texture
  8914. * @param size defines the size of the texture
  8915. * @param options defines the options used to create the texture
  8916. * @returns a new render target texture stored in an InternalTexture
  8917. */
  8918. createRenderTargetTexture(size: number | {
  8919. width: number;
  8920. height: number;
  8921. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8922. /**
  8923. * Create a multi render target texture
  8924. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8925. * @param size defines the size of the texture
  8926. * @param options defines the creation options
  8927. * @returns the cube texture as an InternalTexture
  8928. */
  8929. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8930. private _setupFramebufferDepthAttachments;
  8931. /**
  8932. * Updates the sample count of a render target texture
  8933. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8934. * @param texture defines the texture to update
  8935. * @param samples defines the sample count to set
  8936. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8937. */
  8938. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8939. /**
  8940. * Update the sample count for a given multiple render target texture
  8941. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8942. * @param textures defines the textures to update
  8943. * @param samples defines the sample count to set
  8944. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8945. */
  8946. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8947. /** @hidden */
  8948. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8949. /** @hidden */
  8950. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8951. /** @hidden */
  8952. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8953. /** @hidden */
  8954. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8955. /**
  8956. * Creates a new render target cube texture
  8957. * @param size defines the size of the texture
  8958. * @param options defines the options used to create the texture
  8959. * @returns a new render target cube texture stored in an InternalTexture
  8960. */
  8961. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8962. /**
  8963. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8964. * @param rootUrl defines the url where the file to load is located
  8965. * @param scene defines the current scene
  8966. * @param lodScale defines scale to apply to the mip map selection
  8967. * @param lodOffset defines offset to apply to the mip map selection
  8968. * @param onLoad defines an optional callback raised when the texture is loaded
  8969. * @param onError defines an optional callback raised if there is an issue to load the texture
  8970. * @param format defines the format of the data
  8971. * @param forcedExtension defines the extension to use to pick the right loader
  8972. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8973. * @returns the cube texture as an InternalTexture
  8974. */
  8975. 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;
  8976. /**
  8977. * Creates a cube texture
  8978. * @param rootUrl defines the url where the files to load is located
  8979. * @param scene defines the current scene
  8980. * @param files defines the list of files to load (1 per face)
  8981. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8982. * @param onLoad defines an optional callback raised when the texture is loaded
  8983. * @param onError defines an optional callback raised if there is an issue to load the texture
  8984. * @param format defines the format of the data
  8985. * @param forcedExtension defines the extension to use to pick the right loader
  8986. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8987. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8988. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8989. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8990. * @returns the cube texture as an InternalTexture
  8991. */
  8992. 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;
  8993. /**
  8994. * @hidden
  8995. */
  8996. _setCubeMapTextureParams(loadMipmap: boolean): void;
  8997. /**
  8998. * Update a raw cube texture
  8999. * @param texture defines the texture to udpdate
  9000. * @param data defines the data to store
  9001. * @param format defines the data format
  9002. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9003. * @param invertY defines if data must be stored with Y axis inverted
  9004. * @param compression defines the compression used (null by default)
  9005. * @param level defines which level of the texture to update
  9006. */
  9007. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  9008. /**
  9009. * Creates a new raw cube texture
  9010. * @param data defines the array of data to use to create each face
  9011. * @param size defines the size of the textures
  9012. * @param format defines the format of the data
  9013. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9014. * @param generateMipMaps defines if the engine should generate the mip levels
  9015. * @param invertY defines if data must be stored with Y axis inverted
  9016. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9017. * @param compression defines the compression used (null by default)
  9018. * @returns the cube texture as an InternalTexture
  9019. */
  9020. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  9021. /**
  9022. * Creates a new raw cube texture from a specified url
  9023. * @param url defines the url where the data is located
  9024. * @param scene defines the current scene
  9025. * @param size defines the size of the textures
  9026. * @param format defines the format of the data
  9027. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9028. * @param noMipmap defines if the engine should avoid generating the mip levels
  9029. * @param callback defines a callback used to extract texture data from loaded data
  9030. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9031. * @param onLoad defines a callback called when texture is loaded
  9032. * @param onError defines a callback called if there is an error
  9033. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9034. * @param invertY defines if data must be stored with Y axis inverted
  9035. * @returns the cube texture as an InternalTexture
  9036. */
  9037. 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;
  9038. /**
  9039. * Update a raw 3D texture
  9040. * @param texture defines the texture to update
  9041. * @param data defines the data to store
  9042. * @param format defines the data format
  9043. * @param invertY defines if data must be stored with Y axis inverted
  9044. * @param compression defines the used compression (can be null)
  9045. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9046. */
  9047. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  9048. /**
  9049. * Creates a new raw 3D texture
  9050. * @param data defines the data used to create the texture
  9051. * @param width defines the width of the texture
  9052. * @param height defines the height of the texture
  9053. * @param depth defines the depth of the texture
  9054. * @param format defines the format of the texture
  9055. * @param generateMipMaps defines if the engine must generate mip levels
  9056. * @param invertY defines if data must be stored with Y axis inverted
  9057. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9058. * @param compression defines the compressed used (can be null)
  9059. * @param textureType defines the compressed used (can be null)
  9060. * @returns a new raw 3D texture (stored in an InternalTexture)
  9061. */
  9062. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  9063. private _prepareWebGLTextureContinuation;
  9064. private _prepareWebGLTexture;
  9065. private _convertRGBtoRGBATextureData;
  9066. /** @hidden */
  9067. _releaseFramebufferObjects(texture: InternalTexture): void;
  9068. /** @hidden */
  9069. _releaseTexture(texture: InternalTexture): void;
  9070. private setProgram;
  9071. private _boundUniforms;
  9072. /**
  9073. * Binds an effect to the webGL context
  9074. * @param effect defines the effect to bind
  9075. */
  9076. bindSamplers(effect: Effect): void;
  9077. private _moveBoundTextureOnTop;
  9078. private _getCorrectTextureChannel;
  9079. private _linkTrackers;
  9080. private _removeDesignatedSlot;
  9081. private _activateCurrentTexture;
  9082. /** @hidden */
  9083. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  9084. /** @hidden */
  9085. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9086. /**
  9087. * Sets a texture to the webGL context from a postprocess
  9088. * @param channel defines the channel to use
  9089. * @param postProcess defines the source postprocess
  9090. */
  9091. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9092. /**
  9093. * Binds the output of the passed in post process to the texture channel specified
  9094. * @param channel The channel the texture should be bound to
  9095. * @param postProcess The post process which's output should be bound
  9096. */
  9097. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9098. /**
  9099. * Unbind all textures from the webGL context
  9100. */
  9101. unbindAllTextures(): void;
  9102. /**
  9103. * Sets a texture to the according uniform.
  9104. * @param channel The texture channel
  9105. * @param uniform The uniform to set
  9106. * @param texture The texture to apply
  9107. */
  9108. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9109. /**
  9110. * Sets a depth stencil texture from a render target to the according uniform.
  9111. * @param channel The texture channel
  9112. * @param uniform The uniform to set
  9113. * @param texture The render target texture containing the depth stencil texture to apply
  9114. */
  9115. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9116. private _bindSamplerUniformToChannel;
  9117. private _getTextureWrapMode;
  9118. private _setTexture;
  9119. /**
  9120. * Sets an array of texture to the webGL context
  9121. * @param channel defines the channel where the texture array must be set
  9122. * @param uniform defines the associated uniform location
  9123. * @param textures defines the array of textures to bind
  9124. */
  9125. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9126. /** @hidden */
  9127. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9128. private _setTextureParameterFloat;
  9129. private _setTextureParameterInteger;
  9130. /**
  9131. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9132. * @param x defines the x coordinate of the rectangle where pixels must be read
  9133. * @param y defines the y coordinate of the rectangle where pixels must be read
  9134. * @param width defines the width of the rectangle where pixels must be read
  9135. * @param height defines the height of the rectangle where pixels must be read
  9136. * @returns a Uint8Array containing RGBA colors
  9137. */
  9138. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9139. /**
  9140. * Add an externaly attached data from its key.
  9141. * This method call will fail and return false, if such key already exists.
  9142. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9143. * @param key the unique key that identifies the data
  9144. * @param data the data object to associate to the key for this Engine instance
  9145. * @return true if no such key were already present and the data was added successfully, false otherwise
  9146. */
  9147. addExternalData<T>(key: string, data: T): boolean;
  9148. /**
  9149. * Get an externaly attached data from its key
  9150. * @param key the unique key that identifies the data
  9151. * @return the associated data, if present (can be null), or undefined if not present
  9152. */
  9153. getExternalData<T>(key: string): T;
  9154. /**
  9155. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9156. * @param key the unique key that identifies the data
  9157. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9158. * @return the associated data, can be null if the factory returned null.
  9159. */
  9160. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9161. /**
  9162. * Remove an externaly attached data from the Engine instance
  9163. * @param key the unique key that identifies the data
  9164. * @return true if the data was successfully removed, false if it doesn't exist
  9165. */
  9166. removeExternalData(key: string): boolean;
  9167. /**
  9168. * Unbind all vertex attributes from the webGL context
  9169. */
  9170. unbindAllAttributes(): void;
  9171. /**
  9172. * 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
  9173. */
  9174. releaseEffects(): void;
  9175. /**
  9176. * Dispose and release all associated resources
  9177. */
  9178. dispose(): void;
  9179. /**
  9180. * Display the loading screen
  9181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9182. */
  9183. displayLoadingUI(): void;
  9184. /**
  9185. * Hide the loading screen
  9186. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9187. */
  9188. hideLoadingUI(): void;
  9189. /**
  9190. * Gets the current loading screen object
  9191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9192. */
  9193. /**
  9194. * Sets the current loading screen object
  9195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9196. */
  9197. loadingScreen: ILoadingScreen;
  9198. /**
  9199. * Sets the current loading screen text
  9200. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9201. */
  9202. loadingUIText: string;
  9203. /**
  9204. * Sets the current loading screen background color
  9205. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9206. */
  9207. loadingUIBackgroundColor: string;
  9208. /**
  9209. * Attach a new callback raised when context lost event is fired
  9210. * @param callback defines the callback to call
  9211. */
  9212. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9213. /**
  9214. * Attach a new callback raised when context restored event is fired
  9215. * @param callback defines the callback to call
  9216. */
  9217. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9218. /**
  9219. * Gets the source code of the vertex shader associated with a specific webGL program
  9220. * @param program defines the program to use
  9221. * @returns a string containing the source code of the vertex shader associated with the program
  9222. */
  9223. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9224. /**
  9225. * Gets the source code of the fragment shader associated with a specific webGL program
  9226. * @param program defines the program to use
  9227. * @returns a string containing the source code of the fragment shader associated with the program
  9228. */
  9229. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9230. /**
  9231. * Get the current error code of the webGL context
  9232. * @returns the error code
  9233. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9234. */
  9235. getError(): number;
  9236. /**
  9237. * Gets the current framerate
  9238. * @returns a number representing the framerate
  9239. */
  9240. getFps(): number;
  9241. /**
  9242. * Gets the time spent between current and previous frame
  9243. * @returns a number representing the delta time in ms
  9244. */
  9245. getDeltaTime(): number;
  9246. private _measureFps;
  9247. /** @hidden */
  9248. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9249. private _canRenderToFloatFramebuffer;
  9250. private _canRenderToHalfFloatFramebuffer;
  9251. private _canRenderToFramebuffer;
  9252. /** @hidden */
  9253. _getWebGLTextureType(type: number): number;
  9254. private _getInternalFormat;
  9255. /** @hidden */
  9256. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9257. /** @hidden */
  9258. _getRGBAMultiSampleBufferFormat(type: number): number;
  9259. /** @hidden */
  9260. _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;
  9261. /** @hidden */
  9262. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9263. private _partialLoadFile;
  9264. private _cascadeLoadFiles;
  9265. /**
  9266. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9267. * @returns true if the engine can be created
  9268. * @ignorenaming
  9269. */
  9270. static isSupported(): boolean;
  9271. }
  9272. }
  9273. declare module BABYLON {
  9274. class NullEngineOptions {
  9275. renderWidth: number;
  9276. renderHeight: number;
  9277. textureSize: number;
  9278. deterministicLockstep: boolean;
  9279. lockstepMaxSteps: number;
  9280. }
  9281. /**
  9282. * The null engine class provides support for headless version of babylon.js.
  9283. * This can be used in server side scenario or for testing purposes
  9284. */
  9285. class NullEngine extends Engine {
  9286. private _options;
  9287. isDeterministicLockStep(): boolean;
  9288. getLockstepMaxSteps(): number;
  9289. getHardwareScalingLevel(): number;
  9290. constructor(options?: NullEngineOptions);
  9291. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9292. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9293. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9294. getRenderWidth(useScreen?: boolean): number;
  9295. getRenderHeight(useScreen?: boolean): number;
  9296. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9297. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9298. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9299. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9300. bindSamplers(effect: Effect): void;
  9301. enableEffect(effect: Effect): void;
  9302. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9303. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9304. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9305. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9306. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9307. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9308. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9309. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9310. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9311. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9312. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9313. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9314. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9315. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9316. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9317. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9318. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9319. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9320. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9321. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9322. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9323. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9324. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9325. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9326. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9327. bindBuffers(vertexBuffers: {
  9328. [key: string]: VertexBuffer;
  9329. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9330. wipeCaches(bruteForce?: boolean): void;
  9331. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9332. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9333. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9334. /** @hidden */
  9335. _createTexture(): WebGLTexture;
  9336. /** @hidden */
  9337. _releaseTexture(texture: InternalTexture): void;
  9338. 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;
  9339. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9340. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9341. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9342. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9343. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9344. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9345. /**
  9346. * @hidden
  9347. * Get the current error code of the webGL context
  9348. * @returns the error code
  9349. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9350. */
  9351. getError(): number;
  9352. /** @hidden */
  9353. _getUnpackAlignement(): number;
  9354. /** @hidden */
  9355. _unpackFlipY(value: boolean): void;
  9356. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9357. /**
  9358. * Updates a dynamic vertex buffer.
  9359. * @param vertexBuffer the vertex buffer to update
  9360. * @param data the data used to update the vertex buffer
  9361. * @param byteOffset the byte offset of the data (optional)
  9362. * @param byteLength the byte length of the data (optional)
  9363. */
  9364. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9365. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9366. /** @hidden */
  9367. _bindTexture(channel: number, texture: InternalTexture): void;
  9368. /** @hidden */
  9369. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9370. releaseEffects(): void;
  9371. displayLoadingUI(): void;
  9372. hideLoadingUI(): void;
  9373. /** @hidden */
  9374. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9375. /** @hidden */
  9376. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9377. /** @hidden */
  9378. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9379. /** @hidden */
  9380. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9381. }
  9382. }
  9383. interface WebGLRenderingContext {
  9384. readonly RASTERIZER_DISCARD: number;
  9385. readonly DEPTH_COMPONENT24: number;
  9386. readonly TEXTURE_3D: number;
  9387. readonly TEXTURE_2D_ARRAY: number;
  9388. readonly TEXTURE_COMPARE_FUNC: number;
  9389. readonly TEXTURE_COMPARE_MODE: number;
  9390. readonly COMPARE_REF_TO_TEXTURE: number;
  9391. readonly TEXTURE_WRAP_R: number;
  9392. readonly HALF_FLOAT: number;
  9393. readonly RGB8: number;
  9394. readonly RED_INTEGER: number;
  9395. readonly RG_INTEGER: number;
  9396. readonly RGB_INTEGER: number;
  9397. readonly RGBA_INTEGER: number;
  9398. readonly R8_SNORM: number;
  9399. readonly RG8_SNORM: number;
  9400. readonly RGB8_SNORM: number;
  9401. readonly RGBA8_SNORM: number;
  9402. readonly R8I: number;
  9403. readonly RG8I: number;
  9404. readonly RGB8I: number;
  9405. readonly RGBA8I: number;
  9406. readonly R8UI: number;
  9407. readonly RG8UI: number;
  9408. readonly RGB8UI: number;
  9409. readonly RGBA8UI: number;
  9410. readonly R16I: number;
  9411. readonly RG16I: number;
  9412. readonly RGB16I: number;
  9413. readonly RGBA16I: number;
  9414. readonly R16UI: number;
  9415. readonly RG16UI: number;
  9416. readonly RGB16UI: number;
  9417. readonly RGBA16UI: number;
  9418. readonly R32I: number;
  9419. readonly RG32I: number;
  9420. readonly RGB32I: number;
  9421. readonly RGBA32I: number;
  9422. readonly R32UI: number;
  9423. readonly RG32UI: number;
  9424. readonly RGB32UI: number;
  9425. readonly RGBA32UI: number;
  9426. readonly RGB10_A2UI: number;
  9427. readonly R11F_G11F_B10F: number;
  9428. readonly RGB9_E5: number;
  9429. readonly RGB10_A2: number;
  9430. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9431. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9432. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9433. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9434. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9435. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9436. 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;
  9437. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9438. readonly TRANSFORM_FEEDBACK: number;
  9439. readonly INTERLEAVED_ATTRIBS: number;
  9440. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9441. createTransformFeedback(): WebGLTransformFeedback;
  9442. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9443. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9444. beginTransformFeedback(primitiveMode: number): void;
  9445. endTransformFeedback(): void;
  9446. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9447. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9448. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9449. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9450. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9451. }
  9452. interface ImageBitmap {
  9453. readonly width: number;
  9454. readonly height: number;
  9455. close(): void;
  9456. }
  9457. interface WebGLQuery extends WebGLObject {
  9458. }
  9459. declare var WebGLQuery: {
  9460. prototype: WebGLQuery;
  9461. new (): WebGLQuery;
  9462. };
  9463. interface WebGLSampler extends WebGLObject {
  9464. }
  9465. declare var WebGLSampler: {
  9466. prototype: WebGLSampler;
  9467. new (): WebGLSampler;
  9468. };
  9469. interface WebGLSync extends WebGLObject {
  9470. }
  9471. declare var WebGLSync: {
  9472. prototype: WebGLSync;
  9473. new (): WebGLSync;
  9474. };
  9475. interface WebGLTransformFeedback extends WebGLObject {
  9476. }
  9477. declare var WebGLTransformFeedback: {
  9478. prototype: WebGLTransformFeedback;
  9479. new (): WebGLTransformFeedback;
  9480. };
  9481. interface WebGLVertexArrayObject extends WebGLObject {
  9482. }
  9483. declare var WebGLVertexArrayObject: {
  9484. prototype: WebGLVertexArrayObject;
  9485. new (): WebGLVertexArrayObject;
  9486. };
  9487. declare module BABYLON {
  9488. class KeyboardEventTypes {
  9489. static _KEYDOWN: number;
  9490. static _KEYUP: number;
  9491. static readonly KEYDOWN: number;
  9492. static readonly KEYUP: number;
  9493. }
  9494. class KeyboardInfo {
  9495. type: number;
  9496. event: KeyboardEvent;
  9497. constructor(type: number, event: KeyboardEvent);
  9498. }
  9499. /**
  9500. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9501. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9502. */
  9503. class KeyboardInfoPre extends KeyboardInfo {
  9504. constructor(type: number, event: KeyboardEvent);
  9505. skipOnPointerObservable: boolean;
  9506. }
  9507. }
  9508. declare module BABYLON {
  9509. class PointerEventTypes {
  9510. static _POINTERDOWN: number;
  9511. static _POINTERUP: number;
  9512. static _POINTERMOVE: number;
  9513. static _POINTERWHEEL: number;
  9514. static _POINTERPICK: number;
  9515. static _POINTERTAP: number;
  9516. static _POINTERDOUBLETAP: number;
  9517. static readonly POINTERDOWN: number;
  9518. static readonly POINTERUP: number;
  9519. static readonly POINTERMOVE: number;
  9520. static readonly POINTERWHEEL: number;
  9521. static readonly POINTERPICK: number;
  9522. static readonly POINTERTAP: number;
  9523. static readonly POINTERDOUBLETAP: number;
  9524. }
  9525. class PointerInfoBase {
  9526. type: number;
  9527. event: PointerEvent | MouseWheelEvent;
  9528. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9529. }
  9530. /**
  9531. * This class is used to store pointer related info for the onPrePointerObservable event.
  9532. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9533. */
  9534. class PointerInfoPre extends PointerInfoBase {
  9535. /**
  9536. * Ray from a pointer if availible (eg. 6dof controller)
  9537. */
  9538. ray: Nullable<Ray>;
  9539. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9540. localPosition: Vector2;
  9541. skipOnPointerObservable: boolean;
  9542. }
  9543. /**
  9544. * This type contains all the data related to a pointer event in Babylon.js.
  9545. * 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.
  9546. */
  9547. class PointerInfo extends PointerInfoBase {
  9548. pickInfo: Nullable<PickingInfo>;
  9549. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9550. }
  9551. }
  9552. declare module BABYLON {
  9553. class StickValues {
  9554. x: number;
  9555. y: number;
  9556. constructor(x: number, y: number);
  9557. }
  9558. interface GamepadButtonChanges {
  9559. changed: boolean;
  9560. pressChanged: boolean;
  9561. touchChanged: boolean;
  9562. valueChanged: boolean;
  9563. }
  9564. class Gamepad {
  9565. id: string;
  9566. index: number;
  9567. browserGamepad: any;
  9568. type: number;
  9569. private _leftStick;
  9570. private _rightStick;
  9571. /** @hidden */
  9572. _isConnected: boolean;
  9573. private _leftStickAxisX;
  9574. private _leftStickAxisY;
  9575. private _rightStickAxisX;
  9576. private _rightStickAxisY;
  9577. private _onleftstickchanged;
  9578. private _onrightstickchanged;
  9579. static GAMEPAD: number;
  9580. static GENERIC: number;
  9581. static XBOX: number;
  9582. static POSE_ENABLED: number;
  9583. protected _invertLeftStickY: boolean;
  9584. readonly isConnected: boolean;
  9585. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9586. onleftstickchanged(callback: (values: StickValues) => void): void;
  9587. onrightstickchanged(callback: (values: StickValues) => void): void;
  9588. leftStick: StickValues;
  9589. rightStick: StickValues;
  9590. update(): void;
  9591. dispose(): void;
  9592. }
  9593. class GenericPad extends Gamepad {
  9594. private _buttons;
  9595. private _onbuttondown;
  9596. private _onbuttonup;
  9597. onButtonDownObservable: Observable<number>;
  9598. onButtonUpObservable: Observable<number>;
  9599. onbuttondown(callback: (buttonPressed: number) => void): void;
  9600. onbuttonup(callback: (buttonReleased: number) => void): void;
  9601. constructor(id: string, index: number, browserGamepad: any);
  9602. private _setButtonValue;
  9603. update(): void;
  9604. dispose(): void;
  9605. }
  9606. }
  9607. declare module BABYLON {
  9608. class GamepadManager {
  9609. private _scene?;
  9610. private _babylonGamepads;
  9611. private _oneGamepadConnected;
  9612. /** @hidden */
  9613. _isMonitoring: boolean;
  9614. private _gamepadEventSupported;
  9615. private _gamepadSupport;
  9616. onGamepadConnectedObservable: Observable<Gamepad>;
  9617. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9618. private _onGamepadConnectedEvent;
  9619. private _onGamepadDisconnectedEvent;
  9620. constructor(_scene?: Scene | undefined);
  9621. readonly gamepads: Gamepad[];
  9622. getGamepadByType(type?: number): Nullable<Gamepad>;
  9623. dispose(): void;
  9624. private _addNewGamepad;
  9625. private _startMonitoringGamepads;
  9626. private _stopMonitoringGamepads;
  9627. /** @hidden */
  9628. _checkGamepadsStatus(): void;
  9629. private _updateGamepadObjects;
  9630. }
  9631. }
  9632. declare module BABYLON {
  9633. interface Scene {
  9634. /** @hidden */
  9635. _gamepadManager: Nullable<GamepadManager>;
  9636. /**
  9637. * Gets the gamepad manager associated with the scene
  9638. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9639. */
  9640. gamepadManager: GamepadManager;
  9641. }
  9642. interface FreeCameraInputsManager {
  9643. addGamepad(): FreeCameraInputsManager;
  9644. }
  9645. interface ArcRotateCameraInputsManager {
  9646. addGamepad(): ArcRotateCameraInputsManager;
  9647. }
  9648. /**
  9649. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9650. */
  9651. class GamepadSystemSceneComponent implements ISceneComponent {
  9652. /**
  9653. * The component name helpfull to identify the component in the list of scene components.
  9654. */
  9655. readonly name: string;
  9656. /**
  9657. * The scene the component belongs to.
  9658. */
  9659. scene: Scene;
  9660. /**
  9661. * Creates a new instance of the component for the given scene
  9662. * @param scene Defines the scene to register the component in
  9663. */
  9664. constructor(scene: Scene);
  9665. /**
  9666. * Registers the component in a given scene
  9667. */
  9668. register(): void;
  9669. /**
  9670. * Rebuilds the elements related to this component in case of
  9671. * context lost for instance.
  9672. */
  9673. rebuild(): void;
  9674. /**
  9675. * Disposes the component and the associated ressources
  9676. */
  9677. dispose(): void;
  9678. private _beforeCameraUpdate;
  9679. }
  9680. }
  9681. declare module BABYLON {
  9682. /**
  9683. * Defines supported buttons for XBox360 compatible gamepads
  9684. */
  9685. enum Xbox360Button {
  9686. /** A */
  9687. A = 0,
  9688. /** B */
  9689. B = 1,
  9690. /** X */
  9691. X = 2,
  9692. /** Y */
  9693. Y = 3,
  9694. /** Start */
  9695. Start = 4,
  9696. /** Back */
  9697. Back = 5,
  9698. /** Left button */
  9699. LB = 6,
  9700. /** Right button */
  9701. RB = 7,
  9702. /** Left stick */
  9703. LeftStick = 8,
  9704. /** Right stick */
  9705. RightStick = 9
  9706. }
  9707. /** Defines values for XBox360 DPad */
  9708. enum Xbox360Dpad {
  9709. /** Up */
  9710. Up = 0,
  9711. /** Down */
  9712. Down = 1,
  9713. /** Left */
  9714. Left = 2,
  9715. /** Right */
  9716. Right = 3
  9717. }
  9718. /**
  9719. * Defines a XBox360 gamepad
  9720. */
  9721. class Xbox360Pad extends Gamepad {
  9722. private _leftTrigger;
  9723. private _rightTrigger;
  9724. private _onlefttriggerchanged;
  9725. private _onrighttriggerchanged;
  9726. private _onbuttondown;
  9727. private _onbuttonup;
  9728. private _ondpaddown;
  9729. private _ondpadup;
  9730. /** Observable raised when a button is pressed */
  9731. onButtonDownObservable: Observable<Xbox360Button>;
  9732. /** Observable raised when a button is released */
  9733. onButtonUpObservable: Observable<Xbox360Button>;
  9734. /** Observable raised when a pad is pressed */
  9735. onPadDownObservable: Observable<Xbox360Dpad>;
  9736. /** Observable raised when a pad is released */
  9737. onPadUpObservable: Observable<Xbox360Dpad>;
  9738. private _buttonA;
  9739. private _buttonB;
  9740. private _buttonX;
  9741. private _buttonY;
  9742. private _buttonBack;
  9743. private _buttonStart;
  9744. private _buttonLB;
  9745. private _buttonRB;
  9746. private _buttonLeftStick;
  9747. private _buttonRightStick;
  9748. private _dPadUp;
  9749. private _dPadDown;
  9750. private _dPadLeft;
  9751. private _dPadRight;
  9752. private _isXboxOnePad;
  9753. /**
  9754. * Creates a new XBox360 gamepad object
  9755. * @param id defines the id of this gamepad
  9756. * @param index defines its index
  9757. * @param gamepad defines the internal HTML gamepad object
  9758. * @param xboxOne defines if it is a XBox One gamepad
  9759. */
  9760. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9761. /**
  9762. * Defines the callback to call when left trigger is pressed
  9763. * @param callback defines the callback to use
  9764. */
  9765. onlefttriggerchanged(callback: (value: number) => void): void;
  9766. /**
  9767. * Defines the callback to call when right trigger is pressed
  9768. * @param callback defines the callback to use
  9769. */
  9770. onrighttriggerchanged(callback: (value: number) => void): void;
  9771. /**
  9772. * Gets or sets left trigger value
  9773. */
  9774. leftTrigger: number;
  9775. /**
  9776. * Gets or sets right trigger value
  9777. */
  9778. rightTrigger: number;
  9779. /**
  9780. * Defines the callback to call when a button is pressed
  9781. * @param callback defines the callback to use
  9782. */
  9783. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9784. /**
  9785. * Defines the callback to call when a button is released
  9786. * @param callback defines the callback to use
  9787. */
  9788. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9789. /**
  9790. * Defines the callback to call when a pad is pressed
  9791. * @param callback defines the callback to use
  9792. */
  9793. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9794. /**
  9795. * Defines the callback to call when a pad is released
  9796. * @param callback defines the callback to use
  9797. */
  9798. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9799. private _setButtonValue;
  9800. private _setDPadValue;
  9801. /** Gets or sets value of A button */
  9802. buttonA: number;
  9803. /** Gets or sets value of B button */
  9804. buttonB: number;
  9805. /** Gets or sets value of X button */
  9806. buttonX: number;
  9807. /** Gets or sets value of Y button */
  9808. buttonY: number;
  9809. /** Gets or sets value of Start button */
  9810. buttonStart: number;
  9811. /** Gets or sets value of Back button */
  9812. buttonBack: number;
  9813. /** Gets or sets value of Left button */
  9814. buttonLB: number;
  9815. /** Gets or sets value of Right button */
  9816. buttonRB: number;
  9817. /** Gets or sets value of left stick */
  9818. buttonLeftStick: number;
  9819. /** Gets or sets value of right stick */
  9820. buttonRightStick: number;
  9821. /** Gets or sets value of DPad up */
  9822. dPadUp: number;
  9823. /** Gets or sets value of DPad down */
  9824. dPadDown: number;
  9825. /** Gets or sets value of DPad left */
  9826. dPadLeft: number;
  9827. /** Gets or sets value of DPad right */
  9828. dPadRight: number;
  9829. /**
  9830. * Force the gamepad to synchronize with device values
  9831. */
  9832. update(): void;
  9833. dispose(): void;
  9834. }
  9835. }
  9836. declare module BABYLON {
  9837. /**
  9838. * Single axis drag gizmo
  9839. */
  9840. class AxisDragGizmo extends Gizmo {
  9841. /**
  9842. * Drag behavior responsible for the gizmos dragging interactions
  9843. */
  9844. dragBehavior: PointerDragBehavior;
  9845. private _pointerObserver;
  9846. /**
  9847. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9848. */
  9849. snapDistance: number;
  9850. /**
  9851. * Event that fires each time the gizmo snaps to a new location.
  9852. * * snapDistance is the the change in distance
  9853. */
  9854. onSnapObservable: Observable<{
  9855. snapDistance: number;
  9856. }>;
  9857. /**
  9858. * Creates an AxisDragGizmo
  9859. * @param gizmoLayer The utility layer the gizmo will be added to
  9860. * @param dragAxis The axis which the gizmo will be able to drag on
  9861. * @param color The color of the gizmo
  9862. */
  9863. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9865. /**
  9866. * Disposes of the gizmo
  9867. */
  9868. dispose(): void;
  9869. }
  9870. }
  9871. declare module BABYLON {
  9872. /**
  9873. * Single axis scale gizmo
  9874. */
  9875. class AxisScaleGizmo extends Gizmo {
  9876. private _coloredMaterial;
  9877. /**
  9878. * Drag behavior responsible for the gizmos dragging interactions
  9879. */
  9880. dragBehavior: PointerDragBehavior;
  9881. private _pointerObserver;
  9882. /**
  9883. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9884. */
  9885. snapDistance: number;
  9886. /**
  9887. * Event that fires each time the gizmo snaps to a new location.
  9888. * * snapDistance is the the change in distance
  9889. */
  9890. onSnapObservable: Observable<{
  9891. snapDistance: number;
  9892. }>;
  9893. /**
  9894. * If the scaling operation should be done on all axis (default: false)
  9895. */
  9896. uniformScaling: boolean;
  9897. /**
  9898. * Creates an AxisScaleGizmo
  9899. * @param gizmoLayer The utility layer the gizmo will be added to
  9900. * @param dragAxis The axis which the gizmo will be able to scale on
  9901. * @param color The color of the gizmo
  9902. */
  9903. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9904. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9905. /**
  9906. * Disposes of the gizmo
  9907. */
  9908. dispose(): void;
  9909. /**
  9910. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9911. * @param mesh The mesh to replace the default mesh of the gizmo
  9912. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9913. */
  9914. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9915. }
  9916. }
  9917. declare module BABYLON {
  9918. /**
  9919. * Bounding box gizmo
  9920. */
  9921. class BoundingBoxGizmo extends Gizmo {
  9922. private _lineBoundingBox;
  9923. private _rotateSpheresParent;
  9924. private _scaleBoxesParent;
  9925. private _boundingDimensions;
  9926. private _renderObserver;
  9927. private _pointerObserver;
  9928. private _scaleDragSpeed;
  9929. private _tmpQuaternion;
  9930. private _tmpVector;
  9931. private _tmpRotationMatrix;
  9932. /**
  9933. * 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)
  9934. */
  9935. ignoreChildren: boolean;
  9936. /**
  9937. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  9938. */
  9939. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  9940. /**
  9941. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9942. */
  9943. rotationSphereSize: number;
  9944. /**
  9945. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9946. */
  9947. scaleBoxSize: number;
  9948. /**
  9949. * 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)
  9950. */
  9951. fixedDragMeshScreenSize: boolean;
  9952. /**
  9953. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9954. */
  9955. fixedDragMeshScreenSizeDistanceFactor: number;
  9956. /**
  9957. * Fired when a rotation sphere or scale box is dragged
  9958. */
  9959. onDragStartObservable: Observable<{}>;
  9960. /**
  9961. * Fired when a scale box is dragged
  9962. */
  9963. onScaleBoxDragObservable: Observable<{}>;
  9964. /**
  9965. * Fired when a scale box drag is ended
  9966. */
  9967. onScaleBoxDragEndObservable: Observable<{}>;
  9968. /**
  9969. * Fired when a rotation sphere is dragged
  9970. */
  9971. onRotationSphereDragObservable: Observable<{}>;
  9972. /**
  9973. * Fired when a rotation sphere drag is ended
  9974. */
  9975. onRotationSphereDragEndObservable: Observable<{}>;
  9976. /**
  9977. * 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)
  9978. */
  9979. scalePivot: Nullable<Vector3>;
  9980. private _anchorMesh;
  9981. private _existingMeshScale;
  9982. private static _PivotCached;
  9983. private static _OldPivotPoint;
  9984. private static _PivotTranslation;
  9985. private static _PivotTmpVector;
  9986. /** @hidden */
  9987. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  9988. /** @hidden */
  9989. static _RestorePivotPoint(mesh: AbstractMesh): void;
  9990. /**
  9991. * Creates an BoundingBoxGizmo
  9992. * @param gizmoLayer The utility layer the gizmo will be added to
  9993. * @param color The color of the gizmo
  9994. */
  9995. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9996. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9997. private _selectNode;
  9998. /**
  9999. * Updates the bounding box information for the Gizmo
  10000. */
  10001. updateBoundingBox(): void;
  10002. /**
  10003. * Enables rotation on the specified axis and disables rotation on the others
  10004. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10005. */
  10006. setEnabledRotationAxis(axis: string): void;
  10007. /**
  10008. * Disposes of the gizmo
  10009. */
  10010. dispose(): void;
  10011. /**
  10012. * 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)
  10013. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10014. * @returns the bounding box mesh with the passed in mesh as a child
  10015. */
  10016. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10017. /**
  10018. * CustomMeshes are not supported by this gizmo
  10019. * @param mesh The mesh to replace the default mesh of the gizmo
  10020. */
  10021. setCustomMesh(mesh: Mesh): void;
  10022. }
  10023. }
  10024. declare module BABYLON {
  10025. /**
  10026. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10027. */
  10028. class Gizmo implements IDisposable {
  10029. /** The utility layer the gizmo will be added to */
  10030. gizmoLayer: UtilityLayerRenderer;
  10031. /**
  10032. * The root mesh of the gizmo
  10033. */
  10034. protected _rootMesh: Mesh;
  10035. private _attachedMesh;
  10036. /**
  10037. * Ratio for the scale of the gizmo (Default: 1)
  10038. */
  10039. scaleRatio: number;
  10040. private _tmpMatrix;
  10041. /**
  10042. * If a custom mesh has been set (Default: false)
  10043. */
  10044. protected _customMeshSet: boolean;
  10045. /**
  10046. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10047. * * When set, interactions will be enabled
  10048. */
  10049. attachedMesh: Nullable<AbstractMesh>;
  10050. /**
  10051. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10052. * @param mesh The mesh to replace the default mesh of the gizmo
  10053. */
  10054. setCustomMesh(mesh: Mesh): void;
  10055. /**
  10056. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10057. */
  10058. updateGizmoRotationToMatchAttachedMesh: boolean;
  10059. /**
  10060. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10061. */
  10062. updateGizmoPositionToMatchAttachedMesh: boolean;
  10063. /**
  10064. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10065. */
  10066. protected _updateScale: boolean;
  10067. protected _interactionsEnabled: boolean;
  10068. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10069. private _beforeRenderObserver;
  10070. /**
  10071. * Creates a gizmo
  10072. * @param gizmoLayer The utility layer the gizmo will be added to
  10073. */
  10074. constructor(
  10075. /** The utility layer the gizmo will be added to */
  10076. gizmoLayer?: UtilityLayerRenderer);
  10077. private _tempVector;
  10078. /**
  10079. * @hidden
  10080. * Updates the gizmo to match the attached mesh's position/rotation
  10081. */
  10082. protected _update(): void;
  10083. /**
  10084. * Disposes of the gizmo
  10085. */
  10086. dispose(): void;
  10087. }
  10088. }
  10089. declare module BABYLON {
  10090. /**
  10091. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10092. */
  10093. class GizmoManager implements IDisposable {
  10094. private scene;
  10095. /**
  10096. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10097. */
  10098. gizmos: {
  10099. positionGizmo: Nullable<PositionGizmo>;
  10100. rotationGizmo: Nullable<RotationGizmo>;
  10101. scaleGizmo: Nullable<ScaleGizmo>;
  10102. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10103. };
  10104. private _gizmosEnabled;
  10105. private _pointerObserver;
  10106. private _attachedMesh;
  10107. private _boundingBoxColor;
  10108. private _dragBehavior;
  10109. /**
  10110. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10111. */
  10112. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10113. /**
  10114. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10115. */
  10116. usePointerToAttachGizmos: boolean;
  10117. /**
  10118. * Instatiates a gizmo manager
  10119. * @param scene the scene to overlay the gizmos on top of
  10120. */
  10121. constructor(scene: Scene);
  10122. /**
  10123. * Attaches a set of gizmos to the specified mesh
  10124. * @param mesh The mesh the gizmo's should be attached to
  10125. */
  10126. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10127. /**
  10128. * If the position gizmo is enabled
  10129. */
  10130. positionGizmoEnabled: boolean;
  10131. /**
  10132. * If the rotation gizmo is enabled
  10133. */
  10134. rotationGizmoEnabled: boolean;
  10135. /**
  10136. * If the scale gizmo is enabled
  10137. */
  10138. scaleGizmoEnabled: boolean;
  10139. /**
  10140. * If the boundingBox gizmo is enabled
  10141. */
  10142. boundingBoxGizmoEnabled: boolean;
  10143. /**
  10144. * Disposes of the gizmo manager
  10145. */
  10146. dispose(): void;
  10147. }
  10148. }
  10149. declare module BABYLON {
  10150. /**
  10151. * Single plane rotation gizmo
  10152. */
  10153. class PlaneRotationGizmo extends Gizmo {
  10154. /**
  10155. * Drag behavior responsible for the gizmos dragging interactions
  10156. */
  10157. dragBehavior: PointerDragBehavior;
  10158. private _pointerObserver;
  10159. /**
  10160. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10161. */
  10162. snapDistance: number;
  10163. /**
  10164. * Event that fires each time the gizmo snaps to a new location.
  10165. * * snapDistance is the the change in distance
  10166. */
  10167. onSnapObservable: Observable<{
  10168. snapDistance: number;
  10169. }>;
  10170. /**
  10171. * Creates a PlaneRotationGizmo
  10172. * @param gizmoLayer The utility layer the gizmo will be added to
  10173. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10174. * @param color The color of the gizmo
  10175. */
  10176. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10177. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10178. /**
  10179. * Disposes of the gizmo
  10180. */
  10181. dispose(): void;
  10182. }
  10183. }
  10184. declare module BABYLON {
  10185. /**
  10186. * Gizmo that enables dragging a mesh along 3 axis
  10187. */
  10188. class PositionGizmo extends Gizmo {
  10189. /**
  10190. * Internal gizmo used for interactions on the x axis
  10191. */
  10192. xGizmo: AxisDragGizmo;
  10193. /**
  10194. * Internal gizmo used for interactions on the y axis
  10195. */
  10196. yGizmo: AxisDragGizmo;
  10197. /**
  10198. * Internal gizmo used for interactions on the z axis
  10199. */
  10200. zGizmo: AxisDragGizmo;
  10201. attachedMesh: Nullable<AbstractMesh>;
  10202. /**
  10203. * Creates a PositionGizmo
  10204. * @param gizmoLayer The utility layer the gizmo will be added to
  10205. */
  10206. constructor(gizmoLayer?: UtilityLayerRenderer);
  10207. updateGizmoRotationToMatchAttachedMesh: boolean;
  10208. /**
  10209. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10210. */
  10211. snapDistance: number;
  10212. /**
  10213. * Ratio for the scale of the gizmo (Default: 1)
  10214. */
  10215. scaleRatio: number;
  10216. /**
  10217. * Disposes of the gizmo
  10218. */
  10219. dispose(): void;
  10220. /**
  10221. * CustomMeshes are not supported by this gizmo
  10222. * @param mesh The mesh to replace the default mesh of the gizmo
  10223. */
  10224. setCustomMesh(mesh: Mesh): void;
  10225. }
  10226. }
  10227. declare module BABYLON {
  10228. /**
  10229. * Gizmo that enables rotating a mesh along 3 axis
  10230. */
  10231. class RotationGizmo extends Gizmo {
  10232. /**
  10233. * Internal gizmo used for interactions on the x axis
  10234. */
  10235. xGizmo: PlaneRotationGizmo;
  10236. /**
  10237. * Internal gizmo used for interactions on the y axis
  10238. */
  10239. yGizmo: PlaneRotationGizmo;
  10240. /**
  10241. * Internal gizmo used for interactions on the z axis
  10242. */
  10243. zGizmo: PlaneRotationGizmo;
  10244. attachedMesh: Nullable<AbstractMesh>;
  10245. /**
  10246. * Creates a RotationGizmo
  10247. * @param gizmoLayer The utility layer the gizmo will be added to
  10248. */
  10249. constructor(gizmoLayer?: UtilityLayerRenderer);
  10250. updateGizmoRotationToMatchAttachedMesh: boolean;
  10251. /**
  10252. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10253. */
  10254. snapDistance: number;
  10255. /**
  10256. * Ratio for the scale of the gizmo (Default: 1)
  10257. */
  10258. scaleRatio: number;
  10259. /**
  10260. * Disposes of the gizmo
  10261. */
  10262. dispose(): void;
  10263. /**
  10264. * CustomMeshes are not supported by this gizmo
  10265. * @param mesh The mesh to replace the default mesh of the gizmo
  10266. */
  10267. setCustomMesh(mesh: Mesh): void;
  10268. }
  10269. }
  10270. declare module BABYLON {
  10271. /**
  10272. * Gizmo that enables scaling a mesh along 3 axis
  10273. */
  10274. class ScaleGizmo extends Gizmo {
  10275. /**
  10276. * Internal gizmo used for interactions on the x axis
  10277. */
  10278. xGizmo: AxisScaleGizmo;
  10279. /**
  10280. * Internal gizmo used for interactions on the y axis
  10281. */
  10282. yGizmo: AxisScaleGizmo;
  10283. /**
  10284. * Internal gizmo used for interactions on the z axis
  10285. */
  10286. zGizmo: AxisScaleGizmo;
  10287. /**
  10288. * @hidden
  10289. * Internal gizmo used to scale all axis equally
  10290. */
  10291. private _uniformGizmo;
  10292. attachedMesh: Nullable<AbstractMesh>;
  10293. /**
  10294. * Creates a ScaleGizmo
  10295. * @param gizmoLayer The utility layer the gizmo will be added to
  10296. */
  10297. constructor(gizmoLayer?: UtilityLayerRenderer);
  10298. updateGizmoRotationToMatchAttachedMesh: boolean;
  10299. /**
  10300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10301. */
  10302. snapDistance: number;
  10303. /**
  10304. * Ratio for the scale of the gizmo (Default: 1)
  10305. */
  10306. scaleRatio: number;
  10307. /**
  10308. * Disposes of the gizmo
  10309. */
  10310. dispose(): void;
  10311. }
  10312. }
  10313. declare module BABYLON {
  10314. /**
  10315. * Represents the different options available during the creation of
  10316. * a Environment helper.
  10317. *
  10318. * This can control the default ground, skybox and image processing setup of your scene.
  10319. */
  10320. interface IEnvironmentHelperOptions {
  10321. /**
  10322. * Specifies wether or not to create a ground.
  10323. * True by default.
  10324. */
  10325. createGround: boolean;
  10326. /**
  10327. * Specifies the ground size.
  10328. * 15 by default.
  10329. */
  10330. groundSize: number;
  10331. /**
  10332. * The texture used on the ground for the main color.
  10333. * Comes from the BabylonJS CDN by default.
  10334. *
  10335. * Remarks: Can be either a texture or a url.
  10336. */
  10337. groundTexture: string | BaseTexture;
  10338. /**
  10339. * The color mixed in the ground texture by default.
  10340. * BabylonJS clearColor by default.
  10341. */
  10342. groundColor: Color3;
  10343. /**
  10344. * Specifies the ground opacity.
  10345. * 1 by default.
  10346. */
  10347. groundOpacity: number;
  10348. /**
  10349. * Enables the ground to receive shadows.
  10350. * True by default.
  10351. */
  10352. enableGroundShadow: boolean;
  10353. /**
  10354. * Helps preventing the shadow to be fully black on the ground.
  10355. * 0.5 by default.
  10356. */
  10357. groundShadowLevel: number;
  10358. /**
  10359. * Creates a mirror texture attach to the ground.
  10360. * false by default.
  10361. */
  10362. enableGroundMirror: boolean;
  10363. /**
  10364. * Specifies the ground mirror size ratio.
  10365. * 0.3 by default as the default kernel is 64.
  10366. */
  10367. groundMirrorSizeRatio: number;
  10368. /**
  10369. * Specifies the ground mirror blur kernel size.
  10370. * 64 by default.
  10371. */
  10372. groundMirrorBlurKernel: number;
  10373. /**
  10374. * Specifies the ground mirror visibility amount.
  10375. * 1 by default
  10376. */
  10377. groundMirrorAmount: number;
  10378. /**
  10379. * Specifies the ground mirror reflectance weight.
  10380. * This uses the standard weight of the background material to setup the fresnel effect
  10381. * of the mirror.
  10382. * 1 by default.
  10383. */
  10384. groundMirrorFresnelWeight: number;
  10385. /**
  10386. * Specifies the ground mirror Falloff distance.
  10387. * This can helps reducing the size of the reflection.
  10388. * 0 by Default.
  10389. */
  10390. groundMirrorFallOffDistance: number;
  10391. /**
  10392. * Specifies the ground mirror texture type.
  10393. * Unsigned Int by Default.
  10394. */
  10395. groundMirrorTextureType: number;
  10396. /**
  10397. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10398. * the shown objects.
  10399. */
  10400. groundYBias: number;
  10401. /**
  10402. * Specifies wether or not to create a skybox.
  10403. * True by default.
  10404. */
  10405. createSkybox: boolean;
  10406. /**
  10407. * Specifies the skybox size.
  10408. * 20 by default.
  10409. */
  10410. skyboxSize: number;
  10411. /**
  10412. * The texture used on the skybox for the main color.
  10413. * Comes from the BabylonJS CDN by default.
  10414. *
  10415. * Remarks: Can be either a texture or a url.
  10416. */
  10417. skyboxTexture: string | BaseTexture;
  10418. /**
  10419. * The color mixed in the skybox texture by default.
  10420. * BabylonJS clearColor by default.
  10421. */
  10422. skyboxColor: Color3;
  10423. /**
  10424. * The background rotation around the Y axis of the scene.
  10425. * This helps aligning the key lights of your scene with the background.
  10426. * 0 by default.
  10427. */
  10428. backgroundYRotation: number;
  10429. /**
  10430. * Compute automatically the size of the elements to best fit with the scene.
  10431. */
  10432. sizeAuto: boolean;
  10433. /**
  10434. * Default position of the rootMesh if autoSize is not true.
  10435. */
  10436. rootPosition: Vector3;
  10437. /**
  10438. * Sets up the image processing in the scene.
  10439. * true by default.
  10440. */
  10441. setupImageProcessing: boolean;
  10442. /**
  10443. * The texture used as your environment texture in the scene.
  10444. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10445. *
  10446. * Remarks: Can be either a texture or a url.
  10447. */
  10448. environmentTexture: string | BaseTexture;
  10449. /**
  10450. * The value of the exposure to apply to the scene.
  10451. * 0.6 by default if setupImageProcessing is true.
  10452. */
  10453. cameraExposure: number;
  10454. /**
  10455. * The value of the contrast to apply to the scene.
  10456. * 1.6 by default if setupImageProcessing is true.
  10457. */
  10458. cameraContrast: number;
  10459. /**
  10460. * Specifies wether or not tonemapping should be enabled in the scene.
  10461. * true by default if setupImageProcessing is true.
  10462. */
  10463. toneMappingEnabled: boolean;
  10464. }
  10465. /**
  10466. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10467. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10468. * It also helps with the default setup of your imageProcessing configuration.
  10469. */
  10470. class EnvironmentHelper {
  10471. /**
  10472. * Default ground texture URL.
  10473. */
  10474. private static _groundTextureCDNUrl;
  10475. /**
  10476. * Default skybox texture URL.
  10477. */
  10478. private static _skyboxTextureCDNUrl;
  10479. /**
  10480. * Default environment texture URL.
  10481. */
  10482. private static _environmentTextureCDNUrl;
  10483. /**
  10484. * Creates the default options for the helper.
  10485. */
  10486. private static _getDefaultOptions;
  10487. private _rootMesh;
  10488. /**
  10489. * Gets the root mesh created by the helper.
  10490. */
  10491. readonly rootMesh: Mesh;
  10492. private _skybox;
  10493. /**
  10494. * Gets the skybox created by the helper.
  10495. */
  10496. readonly skybox: Nullable<Mesh>;
  10497. private _skyboxTexture;
  10498. /**
  10499. * Gets the skybox texture created by the helper.
  10500. */
  10501. readonly skyboxTexture: Nullable<BaseTexture>;
  10502. private _skyboxMaterial;
  10503. /**
  10504. * Gets the skybox material created by the helper.
  10505. */
  10506. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10507. private _ground;
  10508. /**
  10509. * Gets the ground mesh created by the helper.
  10510. */
  10511. readonly ground: Nullable<Mesh>;
  10512. private _groundTexture;
  10513. /**
  10514. * Gets the ground texture created by the helper.
  10515. */
  10516. readonly groundTexture: Nullable<BaseTexture>;
  10517. private _groundMirror;
  10518. /**
  10519. * Gets the ground mirror created by the helper.
  10520. */
  10521. readonly groundMirror: Nullable<MirrorTexture>;
  10522. /**
  10523. * Gets the ground mirror render list to helps pushing the meshes
  10524. * you wish in the ground reflection.
  10525. */
  10526. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10527. private _groundMaterial;
  10528. /**
  10529. * Gets the ground material created by the helper.
  10530. */
  10531. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10532. /**
  10533. * Stores the creation options.
  10534. */
  10535. private readonly _scene;
  10536. private _options;
  10537. /**
  10538. * This observable will be notified with any error during the creation of the environment,
  10539. * mainly texture creation errors.
  10540. */
  10541. onErrorObservable: Observable<{
  10542. message?: string;
  10543. exception?: any;
  10544. }>;
  10545. /**
  10546. * constructor
  10547. * @param options
  10548. * @param scene The scene to add the material to
  10549. */
  10550. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10551. /**
  10552. * Updates the background according to the new options
  10553. * @param options
  10554. */
  10555. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10556. /**
  10557. * Sets the primary color of all the available elements.
  10558. * @param color the main color to affect to the ground and the background
  10559. */
  10560. setMainColor(color: Color3): void;
  10561. /**
  10562. * Setup the image processing according to the specified options.
  10563. */
  10564. private _setupImageProcessing;
  10565. /**
  10566. * Setup the environment texture according to the specified options.
  10567. */
  10568. private _setupEnvironmentTexture;
  10569. /**
  10570. * Setup the background according to the specified options.
  10571. */
  10572. private _setupBackground;
  10573. /**
  10574. * Get the scene sizes according to the setup.
  10575. */
  10576. private _getSceneSize;
  10577. /**
  10578. * Setup the ground according to the specified options.
  10579. */
  10580. private _setupGround;
  10581. /**
  10582. * Setup the ground material according to the specified options.
  10583. */
  10584. private _setupGroundMaterial;
  10585. /**
  10586. * Setup the ground diffuse texture according to the specified options.
  10587. */
  10588. private _setupGroundDiffuseTexture;
  10589. /**
  10590. * Setup the ground mirror texture according to the specified options.
  10591. */
  10592. private _setupGroundMirrorTexture;
  10593. /**
  10594. * Setup the ground to receive the mirror texture.
  10595. */
  10596. private _setupMirrorInGroundMaterial;
  10597. /**
  10598. * Setup the skybox according to the specified options.
  10599. */
  10600. private _setupSkybox;
  10601. /**
  10602. * Setup the skybox material according to the specified options.
  10603. */
  10604. private _setupSkyboxMaterial;
  10605. /**
  10606. * Setup the skybox reflection texture according to the specified options.
  10607. */
  10608. private _setupSkyboxReflectionTexture;
  10609. private _errorHandler;
  10610. /**
  10611. * Dispose all the elements created by the Helper.
  10612. */
  10613. dispose(): void;
  10614. }
  10615. }
  10616. declare module BABYLON {
  10617. /**
  10618. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10619. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10620. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10621. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10622. */
  10623. class PhotoDome extends TransformNode {
  10624. private _useDirectMapping;
  10625. /**
  10626. * The texture being displayed on the sphere
  10627. */
  10628. protected _photoTexture: Texture;
  10629. /**
  10630. * Gets or sets the texture being displayed on the sphere
  10631. */
  10632. photoTexture: Texture;
  10633. /**
  10634. * Observable raised when an error occured while loading the 360 image
  10635. */
  10636. onLoadErrorObservable: Observable<string>;
  10637. /**
  10638. * The skybox material
  10639. */
  10640. protected _material: BackgroundMaterial;
  10641. /**
  10642. * The surface used for the skybox
  10643. */
  10644. protected _mesh: Mesh;
  10645. /**
  10646. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10647. * Also see the options.resolution property.
  10648. */
  10649. fovMultiplier: number;
  10650. /**
  10651. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10652. * @param name Element's name, child elements will append suffixes for their own names.
  10653. * @param urlsOfPhoto defines the url of the photo to display
  10654. * @param options defines an object containing optional or exposed sub element properties
  10655. * @param onError defines a callback called when an error occured while loading the texture
  10656. */
  10657. constructor(name: string, urlOfPhoto: string, options: {
  10658. resolution?: number;
  10659. size?: number;
  10660. useDirectMapping?: boolean;
  10661. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10662. /**
  10663. * Releases resources associated with this node.
  10664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10666. */
  10667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10668. }
  10669. }
  10670. declare module BABYLON {
  10671. interface Scene {
  10672. /**
  10673. * Creates a default light for the scene.
  10674. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  10675. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  10676. */
  10677. createDefaultLight(replace?: boolean): void;
  10678. /**
  10679. * Creates a default camera for the scene.
  10680. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  10681. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  10682. * @param replace has default false, when true replaces the active camera in the scene
  10683. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  10684. */
  10685. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  10686. /**
  10687. * Creates a default camera and a default light.
  10688. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  10689. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  10690. * @param replace has the default false, when true replaces the active camera/light in the scene
  10691. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  10692. */
  10693. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  10694. /**
  10695. * Creates a new sky box
  10696. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  10697. * @param environmentTexture defines the texture to use as environment texture
  10698. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  10699. * @param scale defines the overall scale of the skybox
  10700. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  10701. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  10702. * @returns a new mesh holding the sky box
  10703. */
  10704. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  10705. /**
  10706. * Creates a new environment
  10707. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  10708. * @param options defines the options you can use to configure the environment
  10709. * @returns the new EnvironmentHelper
  10710. */
  10711. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  10712. /**
  10713. * Creates a new VREXperienceHelper
  10714. * @see http://doc.babylonjs.com/how_to/webvr_helper
  10715. * @param webVROptions defines the options used to create the new VREXperienceHelper
  10716. * @returns a new VREXperienceHelper
  10717. */
  10718. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  10719. }
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10724. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10725. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10726. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10727. */
  10728. class VideoDome extends TransformNode {
  10729. private _useDirectMapping;
  10730. /**
  10731. * The video texture being displayed on the sphere
  10732. */
  10733. protected _videoTexture: VideoTexture;
  10734. /**
  10735. * Gets the video texture being displayed on the sphere
  10736. */
  10737. readonly videoTexture: VideoTexture;
  10738. /**
  10739. * The skybox material
  10740. */
  10741. protected _material: BackgroundMaterial;
  10742. /**
  10743. * The surface used for the skybox
  10744. */
  10745. protected _mesh: Mesh;
  10746. /**
  10747. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10748. * Also see the options.resolution property.
  10749. */
  10750. fovMultiplier: number;
  10751. /**
  10752. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10753. * @param name Element's name, child elements will append suffixes for their own names.
  10754. * @param urlsOrVideo defines the url(s) or the video element to use
  10755. * @param options An object containing optional or exposed sub element properties
  10756. */
  10757. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10758. resolution?: number;
  10759. clickToPlay?: boolean;
  10760. autoPlay?: boolean;
  10761. loop?: boolean;
  10762. size?: number;
  10763. poster?: string;
  10764. useDirectMapping?: boolean;
  10765. }, scene: Scene);
  10766. /**
  10767. * Releases resources associated with this node.
  10768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10770. */
  10771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10772. }
  10773. }
  10774. declare module BABYLON {
  10775. /**
  10776. * This class can be used to get instrumentation data from a Babylon engine
  10777. */
  10778. class EngineInstrumentation implements IDisposable {
  10779. engine: Engine;
  10780. private _captureGPUFrameTime;
  10781. private _gpuFrameTimeToken;
  10782. private _gpuFrameTime;
  10783. private _captureShaderCompilationTime;
  10784. private _shaderCompilationTime;
  10785. private _onBeginFrameObserver;
  10786. private _onEndFrameObserver;
  10787. private _onBeforeShaderCompilationObserver;
  10788. private _onAfterShaderCompilationObserver;
  10789. /**
  10790. * Gets the perf counter used for GPU frame time
  10791. */
  10792. readonly gpuFrameTimeCounter: PerfCounter;
  10793. /**
  10794. * Gets the GPU frame time capture status
  10795. */
  10796. /**
  10797. * Enable or disable the GPU frame time capture
  10798. */
  10799. captureGPUFrameTime: boolean;
  10800. /**
  10801. * Gets the perf counter used for shader compilation time
  10802. */
  10803. readonly shaderCompilationTimeCounter: PerfCounter;
  10804. /**
  10805. * Gets the shader compilation time capture status
  10806. */
  10807. /**
  10808. * Enable or disable the shader compilation time capture
  10809. */
  10810. captureShaderCompilationTime: boolean;
  10811. constructor(engine: Engine);
  10812. dispose(): void;
  10813. }
  10814. }
  10815. declare module BABYLON {
  10816. /**
  10817. * This class can be used to get instrumentation data from a Babylon engine
  10818. */
  10819. class SceneInstrumentation implements IDisposable {
  10820. scene: Scene;
  10821. private _captureActiveMeshesEvaluationTime;
  10822. private _activeMeshesEvaluationTime;
  10823. private _captureRenderTargetsRenderTime;
  10824. private _renderTargetsRenderTime;
  10825. private _captureFrameTime;
  10826. private _frameTime;
  10827. private _captureRenderTime;
  10828. private _renderTime;
  10829. private _captureInterFrameTime;
  10830. private _interFrameTime;
  10831. private _captureParticlesRenderTime;
  10832. private _particlesRenderTime;
  10833. private _captureSpritesRenderTime;
  10834. private _spritesRenderTime;
  10835. private _capturePhysicsTime;
  10836. private _physicsTime;
  10837. private _captureAnimationsTime;
  10838. private _animationsTime;
  10839. private _captureCameraRenderTime;
  10840. private _cameraRenderTime;
  10841. private _onBeforeActiveMeshesEvaluationObserver;
  10842. private _onAfterActiveMeshesEvaluationObserver;
  10843. private _onBeforeRenderTargetsRenderObserver;
  10844. private _onAfterRenderTargetsRenderObserver;
  10845. private _onAfterRenderObserver;
  10846. private _onBeforeDrawPhaseObserver;
  10847. private _onAfterDrawPhaseObserver;
  10848. private _onBeforeAnimationsObserver;
  10849. private _onBeforeParticlesRenderingObserver;
  10850. private _onAfterParticlesRenderingObserver;
  10851. private _onBeforeSpritesRenderingObserver;
  10852. private _onAfterSpritesRenderingObserver;
  10853. private _onBeforePhysicsObserver;
  10854. private _onAfterPhysicsObserver;
  10855. private _onAfterAnimationsObserver;
  10856. private _onBeforeCameraRenderObserver;
  10857. private _onAfterCameraRenderObserver;
  10858. /**
  10859. * Gets the perf counter used for active meshes evaluation time
  10860. */
  10861. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10862. /**
  10863. * Gets the active meshes evaluation time capture status
  10864. */
  10865. /**
  10866. * Enable or disable the active meshes evaluation time capture
  10867. */
  10868. captureActiveMeshesEvaluationTime: boolean;
  10869. /**
  10870. * Gets the perf counter used for render targets render time
  10871. */
  10872. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10873. /**
  10874. * Gets the render targets render time capture status
  10875. */
  10876. /**
  10877. * Enable or disable the render targets render time capture
  10878. */
  10879. captureRenderTargetsRenderTime: boolean;
  10880. /**
  10881. * Gets the perf counter used for particles render time
  10882. */
  10883. readonly particlesRenderTimeCounter: PerfCounter;
  10884. /**
  10885. * Gets the particles render time capture status
  10886. */
  10887. /**
  10888. * Enable or disable the particles render time capture
  10889. */
  10890. captureParticlesRenderTime: boolean;
  10891. /**
  10892. * Gets the perf counter used for sprites render time
  10893. */
  10894. readonly spritesRenderTimeCounter: PerfCounter;
  10895. /**
  10896. * Gets the sprites render time capture status
  10897. */
  10898. /**
  10899. * Enable or disable the sprites render time capture
  10900. */
  10901. captureSpritesRenderTime: boolean;
  10902. /**
  10903. * Gets the perf counter used for physics time
  10904. */
  10905. readonly physicsTimeCounter: PerfCounter;
  10906. /**
  10907. * Gets the physics time capture status
  10908. */
  10909. /**
  10910. * Enable or disable the physics time capture
  10911. */
  10912. capturePhysicsTime: boolean;
  10913. /**
  10914. * Gets the perf counter used for animations time
  10915. */
  10916. readonly animationsTimeCounter: PerfCounter;
  10917. /**
  10918. * Gets the animations time capture status
  10919. */
  10920. /**
  10921. * Enable or disable the animations time capture
  10922. */
  10923. captureAnimationsTime: boolean;
  10924. /**
  10925. * Gets the perf counter used for frame time capture
  10926. */
  10927. readonly frameTimeCounter: PerfCounter;
  10928. /**
  10929. * Gets the frame time capture status
  10930. */
  10931. /**
  10932. * Enable or disable the frame time capture
  10933. */
  10934. captureFrameTime: boolean;
  10935. /**
  10936. * Gets the perf counter used for inter-frames time capture
  10937. */
  10938. readonly interFrameTimeCounter: PerfCounter;
  10939. /**
  10940. * Gets the inter-frames time capture status
  10941. */
  10942. /**
  10943. * Enable or disable the inter-frames time capture
  10944. */
  10945. captureInterFrameTime: boolean;
  10946. /**
  10947. * Gets the perf counter used for render time capture
  10948. */
  10949. readonly renderTimeCounter: PerfCounter;
  10950. /**
  10951. * Gets the render time capture status
  10952. */
  10953. /**
  10954. * Enable or disable the render time capture
  10955. */
  10956. captureRenderTime: boolean;
  10957. /**
  10958. * Gets the perf counter used for camera render time capture
  10959. */
  10960. readonly cameraRenderTimeCounter: PerfCounter;
  10961. /**
  10962. * Gets the camera render time capture status
  10963. */
  10964. /**
  10965. * Enable or disable the camera render time capture
  10966. */
  10967. captureCameraRenderTime: boolean;
  10968. /**
  10969. * Gets the perf counter used for draw calls
  10970. */
  10971. readonly drawCallsCounter: PerfCounter;
  10972. /**
  10973. * Gets the perf counter used for texture collisions
  10974. */
  10975. readonly textureCollisionsCounter: PerfCounter;
  10976. constructor(scene: Scene);
  10977. dispose(): void;
  10978. }
  10979. }
  10980. declare module BABYLON {
  10981. /**
  10982. * @hidden
  10983. **/
  10984. class _TimeToken {
  10985. _startTimeQuery: Nullable<WebGLQuery>;
  10986. _endTimeQuery: Nullable<WebGLQuery>;
  10987. _timeElapsedQuery: Nullable<WebGLQuery>;
  10988. _timeElapsedQueryEnded: boolean;
  10989. }
  10990. }
  10991. declare module BABYLON {
  10992. /**
  10993. * Effect layer options. This helps customizing the behaviour
  10994. * of the effect layer.
  10995. */
  10996. interface IEffectLayerOptions {
  10997. /**
  10998. * Multiplication factor apply to the canvas size to compute the render target size
  10999. * used to generated the objects (the smaller the faster).
  11000. */
  11001. mainTextureRatio: number;
  11002. /**
  11003. * Enforces a fixed size texture to ensure effect stability across devices.
  11004. */
  11005. mainTextureFixedSize?: number;
  11006. /**
  11007. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  11008. */
  11009. alphaBlendingMode: number;
  11010. /**
  11011. * The camera attached to the layer.
  11012. */
  11013. camera: Nullable<Camera>;
  11014. /**
  11015. * The rendering group to draw the layer in.
  11016. */
  11017. renderingGroupId: number;
  11018. }
  11019. /**
  11020. * The effect layer Helps adding post process effect blended with the main pass.
  11021. *
  11022. * This can be for instance use to generate glow or higlight effects on the scene.
  11023. *
  11024. * The effect layer class can not be used directly and is intented to inherited from to be
  11025. * customized per effects.
  11026. */
  11027. abstract class EffectLayer {
  11028. private _vertexBuffers;
  11029. private _indexBuffer;
  11030. private _cachedDefines;
  11031. private _effectLayerMapGenerationEffect;
  11032. private _effectLayerOptions;
  11033. private _mergeEffect;
  11034. protected _scene: Scene;
  11035. protected _engine: Engine;
  11036. protected _maxSize: number;
  11037. protected _mainTextureDesiredSize: ISize;
  11038. protected _mainTexture: RenderTargetTexture;
  11039. protected _shouldRender: boolean;
  11040. protected _postProcesses: PostProcess[];
  11041. protected _textures: BaseTexture[];
  11042. protected _emissiveTextureAndColor: {
  11043. texture: Nullable<BaseTexture>;
  11044. color: Color4;
  11045. };
  11046. /**
  11047. * The name of the layer
  11048. */
  11049. name: string;
  11050. /**
  11051. * The clear color of the texture used to generate the glow map.
  11052. */
  11053. neutralColor: Color4;
  11054. /**
  11055. * Specifies wether the highlight layer is enabled or not.
  11056. */
  11057. isEnabled: boolean;
  11058. /**
  11059. * Gets the camera attached to the layer.
  11060. */
  11061. readonly camera: Nullable<Camera>;
  11062. /**
  11063. * Gets the rendering group id the layer should render in.
  11064. */
  11065. readonly renderingGroupId: number;
  11066. /**
  11067. * An event triggered when the effect layer has been disposed.
  11068. */
  11069. onDisposeObservable: Observable<EffectLayer>;
  11070. /**
  11071. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11072. */
  11073. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11074. /**
  11075. * An event triggered when the generated texture is being merged in the scene.
  11076. */
  11077. onBeforeComposeObservable: Observable<EffectLayer>;
  11078. /**
  11079. * An event triggered when the generated texture has been merged in the scene.
  11080. */
  11081. onAfterComposeObservable: Observable<EffectLayer>;
  11082. /**
  11083. * An event triggered when the efffect layer changes its size.
  11084. */
  11085. onSizeChangedObservable: Observable<EffectLayer>;
  11086. /**
  11087. * Instantiates a new effect Layer and references it in the scene.
  11088. * @param name The name of the layer
  11089. * @param scene The scene to use the layer in
  11090. */
  11091. constructor(
  11092. /** The Friendly of the effect in the scene */
  11093. name: string, scene: Scene);
  11094. /**
  11095. * Get the effect name of the layer.
  11096. * @return The effect name
  11097. */
  11098. abstract getEffectName(): string;
  11099. /**
  11100. * Checks for the readiness of the element composing the layer.
  11101. * @param subMesh the mesh to check for
  11102. * @param useInstances specify wether or not to use instances to render the mesh
  11103. * @return true if ready otherwise, false
  11104. */
  11105. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11106. /**
  11107. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11108. * @returns true if the effect requires stencil during the main canvas render pass.
  11109. */
  11110. abstract needStencil(): boolean;
  11111. /**
  11112. * Create the merge effect. This is the shader use to blit the information back
  11113. * to the main canvas at the end of the scene rendering.
  11114. * @returns The effect containing the shader used to merge the effect on the main canvas
  11115. */
  11116. protected abstract _createMergeEffect(): Effect;
  11117. /**
  11118. * Creates the render target textures and post processes used in the effect layer.
  11119. */
  11120. protected abstract _createTextureAndPostProcesses(): void;
  11121. /**
  11122. * Implementation specific of rendering the generating effect on the main canvas.
  11123. * @param effect The effect used to render through
  11124. */
  11125. protected abstract _internalRender(effect: Effect): void;
  11126. /**
  11127. * Sets the required values for both the emissive texture and and the main color.
  11128. */
  11129. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11130. /**
  11131. * Free any resources and references associated to a mesh.
  11132. * Internal use
  11133. * @param mesh The mesh to free.
  11134. */
  11135. abstract _disposeMesh(mesh: Mesh): void;
  11136. /**
  11137. * Serializes this layer (Glow or Highlight for example)
  11138. * @returns a serialized layer object
  11139. */
  11140. abstract serialize?(): any;
  11141. /**
  11142. * Initializes the effect layer with the required options.
  11143. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11144. */
  11145. protected _init(options: Partial<IEffectLayerOptions>): void;
  11146. /**
  11147. * Generates the index buffer of the full screen quad blending to the main canvas.
  11148. */
  11149. private _generateIndexBuffer;
  11150. /**
  11151. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11152. */
  11153. private _genrateVertexBuffer;
  11154. /**
  11155. * Sets the main texture desired size which is the closest power of two
  11156. * of the engine canvas size.
  11157. */
  11158. private _setMainTextureSize;
  11159. /**
  11160. * Creates the main texture for the effect layer.
  11161. */
  11162. protected _createMainTexture(): void;
  11163. /**
  11164. * Checks for the readiness of the element composing the layer.
  11165. * @param subMesh the mesh to check for
  11166. * @param useInstances specify wether or not to use instances to render the mesh
  11167. * @param emissiveTexture the associated emissive texture used to generate the glow
  11168. * @return true if ready otherwise, false
  11169. */
  11170. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11171. /**
  11172. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11173. */
  11174. render(): void;
  11175. /**
  11176. * Determine if a given mesh will be used in the current effect.
  11177. * @param mesh mesh to test
  11178. * @returns true if the mesh will be used
  11179. */
  11180. hasMesh(mesh: AbstractMesh): boolean;
  11181. /**
  11182. * Returns true if the layer contains information to display, otherwise false.
  11183. * @returns true if the glow layer should be rendered
  11184. */
  11185. shouldRender(): boolean;
  11186. /**
  11187. * Returns true if the mesh should render, otherwise false.
  11188. * @param mesh The mesh to render
  11189. * @returns true if it should render otherwise false
  11190. */
  11191. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11192. /**
  11193. * Returns true if the mesh should render, otherwise false.
  11194. * @param mesh The mesh to render
  11195. * @returns true if it should render otherwise false
  11196. */
  11197. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11198. /**
  11199. * Renders the submesh passed in parameter to the generation map.
  11200. */
  11201. protected _renderSubMesh(subMesh: SubMesh): void;
  11202. /**
  11203. * Rebuild the required buffers.
  11204. * @hidden Internal use only.
  11205. */
  11206. _rebuild(): void;
  11207. /**
  11208. * Dispose only the render target textures and post process.
  11209. */
  11210. private _disposeTextureAndPostProcesses;
  11211. /**
  11212. * Dispose the highlight layer and free resources.
  11213. */
  11214. dispose(): void;
  11215. /**
  11216. * Gets the class name of the effect layer
  11217. * @returns the string with the class name of the effect layer
  11218. */
  11219. getClassName(): string;
  11220. /**
  11221. * Creates an effect layer from parsed effect layer data
  11222. * @param parsedEffectLayer defines effect layer data
  11223. * @param scene defines the current scene
  11224. * @param rootUrl defines the root URL containing the effect layer information
  11225. * @returns a parsed effect Layer
  11226. */
  11227. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11228. }
  11229. }
  11230. declare module BABYLON {
  11231. interface AbstractScene {
  11232. /**
  11233. * The list of effect layers (highlights/glow) added to the scene
  11234. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11235. * @see http://doc.babylonjs.com/how_to/glow_layer
  11236. */
  11237. effectLayers: Array<EffectLayer>;
  11238. /**
  11239. * Removes the given effect layer from this scene.
  11240. * @param toRemove defines the effect layer to remove
  11241. * @returns the index of the removed effect layer
  11242. */
  11243. removeEffectLayer(toRemove: EffectLayer): number;
  11244. /**
  11245. * Adds the given effect layer to this scene
  11246. * @param newEffectLayer defines the effect layer to add
  11247. */
  11248. addEffectLayer(newEffectLayer: EffectLayer): void;
  11249. }
  11250. /**
  11251. * Defines the layer scene component responsible to manage any effect layers
  11252. * in a given scene.
  11253. */
  11254. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11255. /**
  11256. * The component name helpfull to identify the component in the list of scene components.
  11257. */
  11258. readonly name: string;
  11259. /**
  11260. * The scene the component belongs to.
  11261. */
  11262. scene: Scene;
  11263. private _engine;
  11264. private _renderEffects;
  11265. private _needStencil;
  11266. private _previousStencilState;
  11267. /**
  11268. * Creates a new instance of the component for the given scene
  11269. * @param scene Defines the scene to register the component in
  11270. */
  11271. constructor(scene: Scene);
  11272. /**
  11273. * Registers the component in a given scene
  11274. */
  11275. register(): void;
  11276. /**
  11277. * Rebuilds the elements related to this component in case of
  11278. * context lost for instance.
  11279. */
  11280. rebuild(): void;
  11281. /**
  11282. * Serializes the component data to the specified json object
  11283. * @param serializationObject The object to serialize to
  11284. */
  11285. serialize(serializationObject: any): void;
  11286. /**
  11287. * Adds all the element from the container to the scene
  11288. * @param container the container holding the elements
  11289. */
  11290. addFromContainer(container: AbstractScene): void;
  11291. /**
  11292. * Removes all the elements in the container from the scene
  11293. * @param container contains the elements to remove
  11294. */
  11295. removeFromContainer(container: AbstractScene): void;
  11296. /**
  11297. * Disposes the component and the associated ressources.
  11298. */
  11299. dispose(): void;
  11300. private _isReadyForMesh;
  11301. private _renderMainTexture;
  11302. private _setStencil;
  11303. private _setStencilBack;
  11304. private _draw;
  11305. private _drawCamera;
  11306. private _drawRenderingGroup;
  11307. }
  11308. }
  11309. declare module BABYLON {
  11310. interface AbstractScene {
  11311. /**
  11312. * Return a the first highlight layer of the scene with a given name.
  11313. * @param name The name of the highlight layer to look for.
  11314. * @return The highlight layer if found otherwise null.
  11315. */
  11316. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11317. }
  11318. /**
  11319. * Glow layer options. This helps customizing the behaviour
  11320. * of the glow layer.
  11321. */
  11322. interface IGlowLayerOptions {
  11323. /**
  11324. * Multiplication factor apply to the canvas size to compute the render target size
  11325. * used to generated the glowing objects (the smaller the faster).
  11326. */
  11327. mainTextureRatio: number;
  11328. /**
  11329. * Enforces a fixed size texture to ensure resize independant blur.
  11330. */
  11331. mainTextureFixedSize?: number;
  11332. /**
  11333. * How big is the kernel of the blur texture.
  11334. */
  11335. blurKernelSize: number;
  11336. /**
  11337. * The camera attached to the layer.
  11338. */
  11339. camera: Nullable<Camera>;
  11340. /**
  11341. * Enable MSAA by chosing the number of samples.
  11342. */
  11343. mainTextureSamples?: number;
  11344. /**
  11345. * The rendering group to draw the layer in.
  11346. */
  11347. renderingGroupId: number;
  11348. }
  11349. /**
  11350. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11351. *
  11352. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11353. * glowy meshes to your scene.
  11354. *
  11355. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11356. */
  11357. class GlowLayer extends EffectLayer {
  11358. /**
  11359. * Effect Name of the layer.
  11360. */
  11361. static readonly EffectName: string;
  11362. /**
  11363. * The default blur kernel size used for the glow.
  11364. */
  11365. static DefaultBlurKernelSize: number;
  11366. /**
  11367. * The default texture size ratio used for the glow.
  11368. */
  11369. static DefaultTextureRatio: number;
  11370. /**
  11371. * Sets the kernel size of the blur.
  11372. */
  11373. /**
  11374. * Gets the kernel size of the blur.
  11375. */
  11376. blurKernelSize: number;
  11377. /**
  11378. * Sets the glow intensity.
  11379. */
  11380. /**
  11381. * Gets the glow intensity.
  11382. */
  11383. intensity: number;
  11384. private _options;
  11385. private _intensity;
  11386. private _horizontalBlurPostprocess1;
  11387. private _verticalBlurPostprocess1;
  11388. private _horizontalBlurPostprocess2;
  11389. private _verticalBlurPostprocess2;
  11390. private _blurTexture1;
  11391. private _blurTexture2;
  11392. private _postProcesses1;
  11393. private _postProcesses2;
  11394. private _includedOnlyMeshes;
  11395. private _excludedMeshes;
  11396. /**
  11397. * Callback used to let the user override the color selection on a per mesh basis
  11398. */
  11399. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11400. /**
  11401. * Callback used to let the user override the texture selection on a per mesh basis
  11402. */
  11403. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11404. /**
  11405. * Instantiates a new glow Layer and references it to the scene.
  11406. * @param name The name of the layer
  11407. * @param scene The scene to use the layer in
  11408. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11409. */
  11410. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11411. /**
  11412. * Get the effect name of the layer.
  11413. * @return The effect name
  11414. */
  11415. getEffectName(): string;
  11416. /**
  11417. * Create the merge effect. This is the shader use to blit the information back
  11418. * to the main canvas at the end of the scene rendering.
  11419. */
  11420. protected _createMergeEffect(): Effect;
  11421. /**
  11422. * Creates the render target textures and post processes used in the glow layer.
  11423. */
  11424. protected _createTextureAndPostProcesses(): void;
  11425. /**
  11426. * Checks for the readiness of the element composing the layer.
  11427. * @param subMesh the mesh to check for
  11428. * @param useInstances specify wether or not to use instances to render the mesh
  11429. * @param emissiveTexture the associated emissive texture used to generate the glow
  11430. * @return true if ready otherwise, false
  11431. */
  11432. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11433. /**
  11434. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11435. */
  11436. needStencil(): boolean;
  11437. /**
  11438. * Implementation specific of rendering the generating effect on the main canvas.
  11439. * @param effect The effect used to render through
  11440. */
  11441. protected _internalRender(effect: Effect): void;
  11442. /**
  11443. * Sets the required values for both the emissive texture and and the main color.
  11444. */
  11445. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11446. /**
  11447. * Returns true if the mesh should render, otherwise false.
  11448. * @param mesh The mesh to render
  11449. * @returns true if it should render otherwise false
  11450. */
  11451. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11452. /**
  11453. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11454. * @param mesh The mesh to exclude from the glow layer
  11455. */
  11456. addExcludedMesh(mesh: Mesh): void;
  11457. /**
  11458. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11459. * @param mesh The mesh to remove
  11460. */
  11461. removeExcludedMesh(mesh: Mesh): void;
  11462. /**
  11463. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11464. * @param mesh The mesh to include in the glow layer
  11465. */
  11466. addIncludedOnlyMesh(mesh: Mesh): void;
  11467. /**
  11468. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11469. * @param mesh The mesh to remove
  11470. */
  11471. removeIncludedOnlyMesh(mesh: Mesh): void;
  11472. /**
  11473. * Determine if a given mesh will be used in the glow layer
  11474. * @param mesh The mesh to test
  11475. * @returns true if the mesh will be highlighted by the current glow layer
  11476. */
  11477. hasMesh(mesh: AbstractMesh): boolean;
  11478. /**
  11479. * Free any resources and references associated to a mesh.
  11480. * Internal use
  11481. * @param mesh The mesh to free.
  11482. * @hidden
  11483. */
  11484. _disposeMesh(mesh: Mesh): void;
  11485. /**
  11486. * Gets the class name of the effect layer
  11487. * @returns the string with the class name of the effect layer
  11488. */
  11489. getClassName(): string;
  11490. /**
  11491. * Serializes this glow layer
  11492. * @returns a serialized glow layer object
  11493. */
  11494. serialize(): any;
  11495. /**
  11496. * Creates a Glow Layer from parsed glow layer data
  11497. * @param parsedGlowLayer defines glow layer data
  11498. * @param scene defines the current scene
  11499. * @param rootUrl defines the root URL containing the glow layer information
  11500. * @returns a parsed Glow Layer
  11501. */
  11502. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11503. }
  11504. }
  11505. declare module BABYLON {
  11506. interface AbstractScene {
  11507. /**
  11508. * Return a the first highlight layer of the scene with a given name.
  11509. * @param name The name of the highlight layer to look for.
  11510. * @return The highlight layer if found otherwise null.
  11511. */
  11512. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11513. }
  11514. /**
  11515. * Highlight layer options. This helps customizing the behaviour
  11516. * of the highlight layer.
  11517. */
  11518. interface IHighlightLayerOptions {
  11519. /**
  11520. * Multiplication factor apply to the canvas size to compute the render target size
  11521. * used to generated the glowing objects (the smaller the faster).
  11522. */
  11523. mainTextureRatio: number;
  11524. /**
  11525. * Enforces a fixed size texture to ensure resize independant blur.
  11526. */
  11527. mainTextureFixedSize?: number;
  11528. /**
  11529. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11530. * of the picture to blur (the smaller the faster).
  11531. */
  11532. blurTextureSizeRatio: number;
  11533. /**
  11534. * How big in texel of the blur texture is the vertical blur.
  11535. */
  11536. blurVerticalSize: number;
  11537. /**
  11538. * How big in texel of the blur texture is the horizontal blur.
  11539. */
  11540. blurHorizontalSize: number;
  11541. /**
  11542. * Alpha blending mode used to apply the blur. Default is combine.
  11543. */
  11544. alphaBlendingMode: number;
  11545. /**
  11546. * The camera attached to the layer.
  11547. */
  11548. camera: Nullable<Camera>;
  11549. /**
  11550. * Should we display highlight as a solid stroke?
  11551. */
  11552. isStroke?: boolean;
  11553. /**
  11554. * The rendering group to draw the layer in.
  11555. */
  11556. renderingGroupId: number;
  11557. }
  11558. /**
  11559. * The highlight layer Helps adding a glow effect around a mesh.
  11560. *
  11561. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11562. * glowy meshes to your scene.
  11563. *
  11564. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11565. */
  11566. class HighlightLayer extends EffectLayer {
  11567. name: string;
  11568. /**
  11569. * Effect Name of the highlight layer.
  11570. */
  11571. static readonly EffectName: string;
  11572. /**
  11573. * The neutral color used during the preparation of the glow effect.
  11574. * This is black by default as the blend operation is a blend operation.
  11575. */
  11576. static NeutralColor: Color4;
  11577. /**
  11578. * Stencil value used for glowing meshes.
  11579. */
  11580. static GlowingMeshStencilReference: number;
  11581. /**
  11582. * Stencil value used for the other meshes in the scene.
  11583. */
  11584. static NormalMeshStencilReference: number;
  11585. /**
  11586. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11587. */
  11588. innerGlow: boolean;
  11589. /**
  11590. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11591. */
  11592. outerGlow: boolean;
  11593. /**
  11594. * Specifies the horizontal size of the blur.
  11595. */
  11596. /**
  11597. * Gets the horizontal size of the blur.
  11598. */
  11599. blurHorizontalSize: number;
  11600. /**
  11601. * Specifies the vertical size of the blur.
  11602. */
  11603. /**
  11604. * Gets the vertical size of the blur.
  11605. */
  11606. blurVerticalSize: number;
  11607. /**
  11608. * An event triggered when the highlight layer is being blurred.
  11609. */
  11610. onBeforeBlurObservable: Observable<HighlightLayer>;
  11611. /**
  11612. * An event triggered when the highlight layer has been blurred.
  11613. */
  11614. onAfterBlurObservable: Observable<HighlightLayer>;
  11615. private _instanceGlowingMeshStencilReference;
  11616. private _options;
  11617. private _downSamplePostprocess;
  11618. private _horizontalBlurPostprocess;
  11619. private _verticalBlurPostprocess;
  11620. private _blurTexture;
  11621. private _meshes;
  11622. private _excludedMeshes;
  11623. /**
  11624. * Instantiates a new highlight Layer and references it to the scene..
  11625. * @param name The name of the layer
  11626. * @param scene The scene to use the layer in
  11627. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11628. */
  11629. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11630. /**
  11631. * Get the effect name of the layer.
  11632. * @return The effect name
  11633. */
  11634. getEffectName(): string;
  11635. /**
  11636. * Create the merge effect. This is the shader use to blit the information back
  11637. * to the main canvas at the end of the scene rendering.
  11638. */
  11639. protected _createMergeEffect(): Effect;
  11640. /**
  11641. * Creates the render target textures and post processes used in the highlight layer.
  11642. */
  11643. protected _createTextureAndPostProcesses(): void;
  11644. /**
  11645. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11646. */
  11647. needStencil(): boolean;
  11648. /**
  11649. * Checks for the readiness of the element composing the layer.
  11650. * @param subMesh the mesh to check for
  11651. * @param useInstances specify wether or not to use instances to render the mesh
  11652. * @param emissiveTexture the associated emissive texture used to generate the glow
  11653. * @return true if ready otherwise, false
  11654. */
  11655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11656. /**
  11657. * Implementation specific of rendering the generating effect on the main canvas.
  11658. * @param effect The effect used to render through
  11659. */
  11660. protected _internalRender(effect: Effect): void;
  11661. /**
  11662. * Returns true if the layer contains information to display, otherwise false.
  11663. */
  11664. shouldRender(): boolean;
  11665. /**
  11666. * Returns true if the mesh should render, otherwise false.
  11667. * @param mesh The mesh to render
  11668. * @returns true if it should render otherwise false
  11669. */
  11670. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11671. /**
  11672. * Sets the required values for both the emissive texture and and the main color.
  11673. */
  11674. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11675. /**
  11676. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11677. * @param mesh The mesh to exclude from the highlight layer
  11678. */
  11679. addExcludedMesh(mesh: Mesh): void;
  11680. /**
  11681. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11682. * @param mesh The mesh to highlight
  11683. */
  11684. removeExcludedMesh(mesh: Mesh): void;
  11685. /**
  11686. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11687. * @param mesh mesh to test
  11688. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11689. */
  11690. hasMesh(mesh: AbstractMesh): boolean;
  11691. /**
  11692. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11693. * @param mesh The mesh to highlight
  11694. * @param color The color of the highlight
  11695. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11696. */
  11697. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11698. /**
  11699. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11700. * @param mesh The mesh to highlight
  11701. */
  11702. removeMesh(mesh: Mesh): void;
  11703. /**
  11704. * Force the stencil to the normal expected value for none glowing parts
  11705. */
  11706. private _defaultStencilReference;
  11707. /**
  11708. * Free any resources and references associated to a mesh.
  11709. * Internal use
  11710. * @param mesh The mesh to free.
  11711. * @hidden
  11712. */
  11713. _disposeMesh(mesh: Mesh): void;
  11714. /**
  11715. * Dispose the highlight layer and free resources.
  11716. */
  11717. dispose(): void;
  11718. /**
  11719. * Gets the class name of the effect layer
  11720. * @returns the string with the class name of the effect layer
  11721. */
  11722. getClassName(): string;
  11723. /**
  11724. * Serializes this Highlight layer
  11725. * @returns a serialized Highlight layer object
  11726. */
  11727. serialize(): any;
  11728. /**
  11729. * Creates a Highlight layer from parsed Highlight layer data
  11730. * @param parsedHightlightLayer defines the Highlight layer data
  11731. * @param scene defines the current scene
  11732. * @param rootUrl defines the root URL containing the Highlight layer information
  11733. * @returns a parsed Highlight layer
  11734. */
  11735. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11736. }
  11737. }
  11738. declare module BABYLON {
  11739. class Layer {
  11740. name: string;
  11741. texture: Nullable<Texture>;
  11742. isBackground: boolean;
  11743. color: Color4;
  11744. scale: Vector2;
  11745. offset: Vector2;
  11746. alphaBlendingMode: number;
  11747. alphaTest: boolean;
  11748. layerMask: number;
  11749. private _scene;
  11750. private _vertexBuffers;
  11751. private _indexBuffer;
  11752. private _effect;
  11753. private _alphaTestEffect;
  11754. /**
  11755. * An event triggered when the layer is disposed.
  11756. */
  11757. onDisposeObservable: Observable<Layer>;
  11758. private _onDisposeObserver;
  11759. onDispose: () => void;
  11760. /**
  11761. * An event triggered before rendering the scene
  11762. */
  11763. onBeforeRenderObservable: Observable<Layer>;
  11764. private _onBeforeRenderObserver;
  11765. onBeforeRender: () => void;
  11766. /**
  11767. * An event triggered after rendering the scene
  11768. */
  11769. onAfterRenderObservable: Observable<Layer>;
  11770. private _onAfterRenderObserver;
  11771. onAfterRender: () => void;
  11772. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11773. private _createIndexBuffer;
  11774. /** @hidden */
  11775. _rebuild(): void;
  11776. render(): void;
  11777. dispose(): void;
  11778. }
  11779. }
  11780. declare module BABYLON {
  11781. interface AbstractScene {
  11782. /**
  11783. * The list of layers (background and foreground) of the scene
  11784. */
  11785. layers: Array<Layer>;
  11786. }
  11787. /**
  11788. * Defines the layer scene component responsible to manage any layers
  11789. * in a given scene.
  11790. */
  11791. class LayerSceneComponent implements ISceneComponent {
  11792. /**
  11793. * The component name helpfull to identify the component in the list of scene components.
  11794. */
  11795. readonly name: string;
  11796. /**
  11797. * The scene the component belongs to.
  11798. */
  11799. scene: Scene;
  11800. private _engine;
  11801. /**
  11802. * Creates a new instance of the component for the given scene
  11803. * @param scene Defines the scene to register the component in
  11804. */
  11805. constructor(scene: Scene);
  11806. /**
  11807. * Registers the component in a given scene
  11808. */
  11809. register(): void;
  11810. /**
  11811. * Rebuilds the elements related to this component in case of
  11812. * context lost for instance.
  11813. */
  11814. rebuild(): void;
  11815. /**
  11816. * Disposes the component and the associated ressources.
  11817. */
  11818. dispose(): void;
  11819. private _draw;
  11820. private _drawBackground;
  11821. private _drawForeground;
  11822. }
  11823. }
  11824. declare module BABYLON {
  11825. class LensFlare {
  11826. size: number;
  11827. position: number;
  11828. color: Color3;
  11829. texture: Nullable<Texture>;
  11830. alphaMode: number;
  11831. private _system;
  11832. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11833. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11834. dispose(): void;
  11835. }
  11836. }
  11837. declare module BABYLON {
  11838. class LensFlareSystem {
  11839. name: string;
  11840. lensFlares: LensFlare[];
  11841. borderLimit: number;
  11842. viewportBorder: number;
  11843. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11844. layerMask: number;
  11845. id: string;
  11846. private _scene;
  11847. private _emitter;
  11848. private _vertexBuffers;
  11849. private _indexBuffer;
  11850. private _effect;
  11851. private _positionX;
  11852. private _positionY;
  11853. private _isEnabled;
  11854. constructor(name: string, emitter: any, scene: Scene);
  11855. isEnabled: boolean;
  11856. getScene(): Scene;
  11857. getEmitter(): any;
  11858. setEmitter(newEmitter: any): void;
  11859. getEmitterPosition(): Vector3;
  11860. computeEffectivePosition(globalViewport: Viewport): boolean;
  11861. /** @hidden */
  11862. _isVisible(): boolean;
  11863. render(): boolean;
  11864. dispose(): void;
  11865. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11866. serialize(): any;
  11867. }
  11868. }
  11869. declare module BABYLON {
  11870. interface AbstractScene {
  11871. /**
  11872. * The list of lens flare system added to the scene
  11873. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11874. */
  11875. lensFlareSystems: Array<LensFlareSystem>;
  11876. /**
  11877. * Removes the given lens flare system from this scene.
  11878. * @param toRemove The lens flare system to remove
  11879. * @returns The index of the removed lens flare system
  11880. */
  11881. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11882. /**
  11883. * Adds the given lens flare system to this scene
  11884. * @param newLensFlareSystem The lens flare system to add
  11885. */
  11886. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11887. /**
  11888. * Gets a lens flare system using its name
  11889. * @param name defines the name to look for
  11890. * @returns the lens flare system or null if not found
  11891. */
  11892. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11893. /**
  11894. * Gets a lens flare system using its id
  11895. * @param id defines the id to look for
  11896. * @returns the lens flare system or null if not found
  11897. */
  11898. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11899. }
  11900. /**
  11901. * Defines the lens flare scene component responsible to manage any lens flares
  11902. * in a given scene.
  11903. */
  11904. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11905. /**
  11906. * The component name helpfull to identify the component in the list of scene components.
  11907. */
  11908. readonly name: string;
  11909. /**
  11910. * The scene the component belongs to.
  11911. */
  11912. scene: Scene;
  11913. /**
  11914. * Creates a new instance of the component for the given scene
  11915. * @param scene Defines the scene to register the component in
  11916. */
  11917. constructor(scene: Scene);
  11918. /**
  11919. * Registers the component in a given scene
  11920. */
  11921. register(): void;
  11922. /**
  11923. * Rebuilds the elements related to this component in case of
  11924. * context lost for instance.
  11925. */
  11926. rebuild(): void;
  11927. /**
  11928. * Adds all the element from the container to the scene
  11929. * @param container the container holding the elements
  11930. */
  11931. addFromContainer(container: AbstractScene): void;
  11932. /**
  11933. * Removes all the elements in the container from the scene
  11934. * @param container contains the elements to remove
  11935. */
  11936. removeFromContainer(container: AbstractScene): void;
  11937. /**
  11938. * Serializes the component data to the specified json object
  11939. * @param serializationObject The object to serialize to
  11940. */
  11941. serialize(serializationObject: any): void;
  11942. /**
  11943. * Disposes the component and the associated ressources.
  11944. */
  11945. dispose(): void;
  11946. private _draw;
  11947. }
  11948. }
  11949. declare module BABYLON {
  11950. /**
  11951. * A directional light is defined by a direction (what a surprise!).
  11952. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11953. * 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.
  11954. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11955. */
  11956. class DirectionalLight extends ShadowLight {
  11957. private _shadowFrustumSize;
  11958. /**
  11959. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11960. */
  11961. /**
  11962. * Specifies a fix frustum size for the shadow generation.
  11963. */
  11964. shadowFrustumSize: number;
  11965. private _shadowOrthoScale;
  11966. /**
  11967. * Gets the shadow projection scale against the optimal computed one.
  11968. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11969. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11970. */
  11971. /**
  11972. * Sets the shadow projection scale against the optimal computed one.
  11973. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11974. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11975. */
  11976. shadowOrthoScale: number;
  11977. /**
  11978. * Automatically compute the projection matrix to best fit (including all the casters)
  11979. * on each frame.
  11980. */
  11981. autoUpdateExtends: boolean;
  11982. private _orthoLeft;
  11983. private _orthoRight;
  11984. private _orthoTop;
  11985. private _orthoBottom;
  11986. /**
  11987. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11988. * The directional light is emitted from everywhere in the given direction.
  11989. * It can cast shawdows.
  11990. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11991. * @param name The friendly name of the light
  11992. * @param direction The direction of the light
  11993. * @param scene The scene the light belongs to
  11994. */
  11995. constructor(name: string, direction: Vector3, scene: Scene);
  11996. /**
  11997. * Returns the string "DirectionalLight".
  11998. * @return The class name
  11999. */
  12000. getClassName(): string;
  12001. /**
  12002. * Returns the integer 1.
  12003. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12004. */
  12005. getTypeID(): number;
  12006. /**
  12007. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  12008. * Returns the DirectionalLight Shadow projection matrix.
  12009. */
  12010. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12011. /**
  12012. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  12013. * Returns the DirectionalLight Shadow projection matrix.
  12014. */
  12015. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  12016. /**
  12017. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  12018. * Returns the DirectionalLight Shadow projection matrix.
  12019. */
  12020. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12021. protected _buildUniformLayout(): void;
  12022. /**
  12023. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  12024. * @param effect The effect to update
  12025. * @param lightIndex The index of the light in the effect to update
  12026. * @returns The directional light
  12027. */
  12028. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  12029. /**
  12030. * Gets the minZ used for shadow according to both the scene and the light.
  12031. *
  12032. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12033. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12034. * @param activeCamera The camera we are returning the min for
  12035. * @returns the depth min z
  12036. */
  12037. getDepthMinZ(activeCamera: Camera): number;
  12038. /**
  12039. * Gets the maxZ used for shadow according to both the scene and the light.
  12040. *
  12041. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12042. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12043. * @param activeCamera The camera we are returning the max for
  12044. * @returns the depth max z
  12045. */
  12046. getDepthMaxZ(activeCamera: Camera): number;
  12047. /**
  12048. * Prepares the list of defines specific to the light type.
  12049. * @param defines the list of defines
  12050. * @param lightIndex defines the index of the light for the effect
  12051. */
  12052. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * The HemisphericLight simulates the ambient environment light,
  12058. * so the passed direction is the light reflection direction, not the incoming direction.
  12059. */
  12060. class HemisphericLight extends Light {
  12061. /**
  12062. * The groundColor is the light in the opposite direction to the one specified during creation.
  12063. * 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.
  12064. */
  12065. groundColor: Color3;
  12066. /**
  12067. * The light reflection direction, not the incoming direction.
  12068. */
  12069. direction: Vector3;
  12070. /**
  12071. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12072. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12073. * The HemisphericLight can't cast shadows.
  12074. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12075. * @param name The friendly name of the light
  12076. * @param direction The direction of the light reflection
  12077. * @param scene The scene the light belongs to
  12078. */
  12079. constructor(name: string, direction: Vector3, scene: Scene);
  12080. protected _buildUniformLayout(): void;
  12081. /**
  12082. * Returns the string "HemisphericLight".
  12083. * @return The class name
  12084. */
  12085. getClassName(): string;
  12086. /**
  12087. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12088. * Returns the updated direction.
  12089. * @param target The target the direction should point to
  12090. * @return The computed direction
  12091. */
  12092. setDirectionToTarget(target: Vector3): Vector3;
  12093. /**
  12094. * Returns the shadow generator associated to the light.
  12095. * @returns Always null for hemispheric lights because it does not support shadows.
  12096. */
  12097. getShadowGenerator(): Nullable<IShadowGenerator>;
  12098. /**
  12099. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12100. * @param effect The effect to update
  12101. * @param lightIndex The index of the light in the effect to update
  12102. * @returns The hemispheric light
  12103. */
  12104. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12105. /**
  12106. * Computes the world matrix of the node
  12107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12108. * @param useWasUpdatedFlag defines a reserved property
  12109. * @returns the world matrix
  12110. */
  12111. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  12112. /**
  12113. * Returns the integer 3.
  12114. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12115. */
  12116. getTypeID(): number;
  12117. /**
  12118. * Prepares the list of defines specific to the light type.
  12119. * @param defines the list of defines
  12120. * @param lightIndex defines the index of the light for the effect
  12121. */
  12122. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12123. }
  12124. }
  12125. declare module BABYLON {
  12126. /**
  12127. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12128. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12129. * 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.
  12130. */
  12131. abstract class Light extends Node {
  12132. /**
  12133. * Falloff Default: light is falling off following the material specification:
  12134. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12135. */
  12136. static readonly FALLOFF_DEFAULT: number;
  12137. /**
  12138. * Falloff Physical: light is falling off following the inverse squared distance law.
  12139. */
  12140. static readonly FALLOFF_PHYSICAL: number;
  12141. /**
  12142. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12143. * to enhance interoperability with other engines.
  12144. */
  12145. static readonly FALLOFF_GLTF: number;
  12146. /**
  12147. * Falloff Standard: light is falling off like in the standard material
  12148. * to enhance interoperability with other materials.
  12149. */
  12150. static readonly FALLOFF_STANDARD: number;
  12151. /**
  12152. * If every light affecting the material is in this lightmapMode,
  12153. * material.lightmapTexture adds or multiplies
  12154. * (depends on material.useLightmapAsShadowmap)
  12155. * after every other light calculations.
  12156. */
  12157. static readonly LIGHTMAP_DEFAULT: number;
  12158. /**
  12159. * material.lightmapTexture as only diffuse lighting from this light
  12160. * adds only specular lighting from this light
  12161. * adds dynamic shadows
  12162. */
  12163. static readonly LIGHTMAP_SPECULAR: number;
  12164. /**
  12165. * material.lightmapTexture as only lighting
  12166. * no light calculation from this light
  12167. * only adds dynamic shadows from this light
  12168. */
  12169. static readonly LIGHTMAP_SHADOWSONLY: number;
  12170. /**
  12171. * Each light type uses the default quantity according to its type:
  12172. * point/spot lights use luminous intensity
  12173. * directional lights use illuminance
  12174. */
  12175. static readonly INTENSITYMODE_AUTOMATIC: number;
  12176. /**
  12177. * lumen (lm)
  12178. */
  12179. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12180. /**
  12181. * candela (lm/sr)
  12182. */
  12183. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12184. /**
  12185. * lux (lm/m^2)
  12186. */
  12187. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12188. /**
  12189. * nit (cd/m^2)
  12190. */
  12191. static readonly INTENSITYMODE_LUMINANCE: number;
  12192. /**
  12193. * Light type const id of the point light.
  12194. */
  12195. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12196. /**
  12197. * Light type const id of the directional light.
  12198. */
  12199. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12200. /**
  12201. * Light type const id of the spot light.
  12202. */
  12203. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12204. /**
  12205. * Light type const id of the hemispheric light.
  12206. */
  12207. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12208. /**
  12209. * Diffuse gives the basic color to an object.
  12210. */
  12211. diffuse: Color3;
  12212. /**
  12213. * Specular produces a highlight color on an object.
  12214. * Note: This is note affecting PBR materials.
  12215. */
  12216. specular: Color3;
  12217. /**
  12218. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12219. * falling off base on range or angle.
  12220. * This can be set to any values in Light.FALLOFF_x.
  12221. *
  12222. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12223. * other types of materials.
  12224. */
  12225. falloffType: number;
  12226. /**
  12227. * Strength of the light.
  12228. * Note: By default it is define in the framework own unit.
  12229. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12230. */
  12231. intensity: number;
  12232. private _range;
  12233. protected _inverseSquaredRange: number;
  12234. /**
  12235. * Defines how far from the source the light is impacting in scene units.
  12236. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12237. */
  12238. /**
  12239. * Defines how far from the source the light is impacting in scene units.
  12240. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12241. */
  12242. range: number;
  12243. /**
  12244. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12245. * of light.
  12246. */
  12247. private _photometricScale;
  12248. private _intensityMode;
  12249. /**
  12250. * Gets the photometric scale used to interpret the intensity.
  12251. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12252. */
  12253. /**
  12254. * Sets the photometric scale used to interpret the intensity.
  12255. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12256. */
  12257. intensityMode: number;
  12258. private _radius;
  12259. /**
  12260. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12261. */
  12262. /**
  12263. * sets the light radius used by PBR Materials to simulate soft area lights.
  12264. */
  12265. radius: number;
  12266. private _renderPriority;
  12267. /**
  12268. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12269. * exceeding the number allowed of the materials.
  12270. */
  12271. renderPriority: number;
  12272. private _shadowEnabled;
  12273. /**
  12274. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12275. * the current shadow generator.
  12276. */
  12277. /**
  12278. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12279. * the current shadow generator.
  12280. */
  12281. shadowEnabled: boolean;
  12282. private _includedOnlyMeshes;
  12283. /**
  12284. * Gets the only meshes impacted by this light.
  12285. */
  12286. /**
  12287. * Sets the only meshes impacted by this light.
  12288. */
  12289. includedOnlyMeshes: AbstractMesh[];
  12290. private _excludedMeshes;
  12291. /**
  12292. * Gets the meshes not impacted by this light.
  12293. */
  12294. /**
  12295. * Sets the meshes not impacted by this light.
  12296. */
  12297. excludedMeshes: AbstractMesh[];
  12298. private _excludeWithLayerMask;
  12299. /**
  12300. * Gets the layer id use to find what meshes are not impacted by the light.
  12301. * Inactive if 0
  12302. */
  12303. /**
  12304. * Sets the layer id use to find what meshes are not impacted by the light.
  12305. * Inactive if 0
  12306. */
  12307. excludeWithLayerMask: number;
  12308. private _includeOnlyWithLayerMask;
  12309. /**
  12310. * Gets the layer id use to find what meshes are impacted by the light.
  12311. * Inactive if 0
  12312. */
  12313. /**
  12314. * Sets the layer id use to find what meshes are impacted by the light.
  12315. * Inactive if 0
  12316. */
  12317. includeOnlyWithLayerMask: number;
  12318. private _lightmapMode;
  12319. /**
  12320. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12321. */
  12322. /**
  12323. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12324. */
  12325. lightmapMode: number;
  12326. /**
  12327. * Shadow generator associted to the light.
  12328. * @hidden Internal use only.
  12329. */
  12330. _shadowGenerator: Nullable<IShadowGenerator>;
  12331. /**
  12332. * @hidden Internal use only.
  12333. */
  12334. _excludedMeshesIds: string[];
  12335. /**
  12336. * @hidden Internal use only.
  12337. */
  12338. _includedOnlyMeshesIds: string[];
  12339. /**
  12340. * The current light unifom buffer.
  12341. * @hidden Internal use only.
  12342. */
  12343. _uniformBuffer: UniformBuffer;
  12344. /**
  12345. * Creates a Light object in the scene.
  12346. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12347. * @param name The firendly name of the light
  12348. * @param scene The scene the light belongs too
  12349. */
  12350. constructor(name: string, scene: Scene);
  12351. protected abstract _buildUniformLayout(): void;
  12352. /**
  12353. * Sets the passed Effect "effect" with the Light information.
  12354. * @param effect The effect to update
  12355. * @param lightIndex The index of the light in the effect to update
  12356. * @returns The light
  12357. */
  12358. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12359. /**
  12360. * Returns the string "Light".
  12361. * @returns the class name
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Converts the light information to a readable string for debug purpose.
  12366. * @param fullDetails Supports for multiple levels of logging within scene loading
  12367. * @returns the human readable light info
  12368. */
  12369. toString(fullDetails?: boolean): string;
  12370. /**
  12371. * Set the enabled state of this node.
  12372. * @param value - the new enabled state
  12373. */
  12374. setEnabled(value: boolean): void;
  12375. /**
  12376. * Returns the Light associated shadow generator if any.
  12377. * @return the associated shadow generator.
  12378. */
  12379. getShadowGenerator(): Nullable<IShadowGenerator>;
  12380. /**
  12381. * Returns a Vector3, the absolute light position in the World.
  12382. * @returns the world space position of the light
  12383. */
  12384. getAbsolutePosition(): Vector3;
  12385. /**
  12386. * Specifies if the light will affect the passed mesh.
  12387. * @param mesh The mesh to test against the light
  12388. * @return true the mesh is affected otherwise, false.
  12389. */
  12390. canAffectMesh(mesh: AbstractMesh): boolean;
  12391. /**
  12392. * Sort function to order lights for rendering.
  12393. * @param a First Light object to compare to second.
  12394. * @param b Second Light object to compare first.
  12395. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12396. */
  12397. static CompareLightsPriority(a: Light, b: Light): number;
  12398. /**
  12399. * Releases resources associated with this node.
  12400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12402. */
  12403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12404. /**
  12405. * Returns the light type ID (integer).
  12406. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12407. */
  12408. getTypeID(): number;
  12409. /**
  12410. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12411. * @returns the scaled intensity in intensity mode unit
  12412. */
  12413. getScaledIntensity(): number;
  12414. /**
  12415. * Returns a new Light object, named "name", from the current one.
  12416. * @param name The name of the cloned light
  12417. * @returns the new created light
  12418. */
  12419. clone(name: string): Nullable<Light>;
  12420. /**
  12421. * Serializes the current light into a Serialization object.
  12422. * @returns the serialized object.
  12423. */
  12424. serialize(): any;
  12425. /**
  12426. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12427. * This new light is named "name" and added to the passed scene.
  12428. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12429. * @param name The friendly name of the light
  12430. * @param scene The scene the new light will belong to
  12431. * @returns the constructor function
  12432. */
  12433. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12434. /**
  12435. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12436. * @param parsedLight The JSON representation of the light
  12437. * @param scene The scene to create the parsed light in
  12438. * @returns the created light after parsing
  12439. */
  12440. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12441. private _hookArrayForExcluded;
  12442. private _hookArrayForIncludedOnly;
  12443. private _resyncMeshes;
  12444. /**
  12445. * Forces the meshes to update their light related information in their rendering used effects
  12446. * @hidden Internal Use Only
  12447. */
  12448. _markMeshesAsLightDirty(): void;
  12449. /**
  12450. * Recomputes the cached photometric scale if needed.
  12451. */
  12452. private _computePhotometricScale;
  12453. /**
  12454. * Returns the Photometric Scale according to the light type and intensity mode.
  12455. */
  12456. private _getPhotometricScale;
  12457. /**
  12458. * Reorder the light in the scene according to their defined priority.
  12459. * @hidden Internal Use Only
  12460. */
  12461. _reorderLightsInScene(): void;
  12462. /**
  12463. * Prepares the list of defines specific to the light type.
  12464. * @param defines the list of defines
  12465. * @param lightIndex defines the index of the light for the effect
  12466. */
  12467. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12468. }
  12469. }
  12470. declare module BABYLON {
  12471. /**
  12472. * A point light is a light defined by an unique point in world space.
  12473. * The light is emitted in every direction from this point.
  12474. * A good example of a point light is a standard light bulb.
  12475. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12476. */
  12477. class PointLight extends ShadowLight {
  12478. private _shadowAngle;
  12479. /**
  12480. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12481. * This specifies what angle the shadow will use to be created.
  12482. *
  12483. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12484. */
  12485. /**
  12486. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12487. * This specifies what angle the shadow will use to be created.
  12488. *
  12489. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12490. */
  12491. shadowAngle: number;
  12492. /**
  12493. * Gets the direction if it has been set.
  12494. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12495. */
  12496. /**
  12497. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12498. */
  12499. direction: Vector3;
  12500. /**
  12501. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12502. * A PointLight emits the light in every direction.
  12503. * It can cast shadows.
  12504. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12505. * ```javascript
  12506. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12507. * ```
  12508. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12509. * @param name The light friendly name
  12510. * @param position The position of the point light in the scene
  12511. * @param scene The scene the lights belongs to
  12512. */
  12513. constructor(name: string, position: Vector3, scene: Scene);
  12514. /**
  12515. * Returns the string "PointLight"
  12516. * @returns the class name
  12517. */
  12518. getClassName(): string;
  12519. /**
  12520. * Returns the integer 0.
  12521. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12522. */
  12523. getTypeID(): number;
  12524. /**
  12525. * Specifies wether or not the shadowmap should be a cube texture.
  12526. * @returns true if the shadowmap needs to be a cube texture.
  12527. */
  12528. needCube(): boolean;
  12529. /**
  12530. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12531. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12532. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12533. */
  12534. getShadowDirection(faceIndex?: number): Vector3;
  12535. /**
  12536. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12537. * - fov = PI / 2
  12538. * - aspect ratio : 1.0
  12539. * - z-near and far equal to the active camera minZ and maxZ.
  12540. * Returns the PointLight.
  12541. */
  12542. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12543. protected _buildUniformLayout(): void;
  12544. /**
  12545. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12546. * @param effect The effect to update
  12547. * @param lightIndex The index of the light in the effect to update
  12548. * @returns The point light
  12549. */
  12550. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12551. /**
  12552. * Prepares the list of defines specific to the light type.
  12553. * @param defines the list of defines
  12554. * @param lightIndex defines the index of the light for the effect
  12555. */
  12556. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12557. }
  12558. }
  12559. declare module BABYLON {
  12560. /**
  12561. * Interface describing all the common properties and methods a shadow light needs to implement.
  12562. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12563. * as well as binding the different shadow properties to the effects.
  12564. */
  12565. interface IShadowLight extends Light {
  12566. /**
  12567. * The light id in the scene (used in scene.findLighById for instance)
  12568. */
  12569. id: string;
  12570. /**
  12571. * The position the shdow will be casted from.
  12572. */
  12573. position: Vector3;
  12574. /**
  12575. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12576. */
  12577. direction: Vector3;
  12578. /**
  12579. * The transformed position. Position of the light in world space taking parenting in account.
  12580. */
  12581. transformedPosition: Vector3;
  12582. /**
  12583. * The transformed direction. Direction of the light in world space taking parenting in account.
  12584. */
  12585. transformedDirection: Vector3;
  12586. /**
  12587. * The friendly name of the light in the scene.
  12588. */
  12589. name: string;
  12590. /**
  12591. * Defines the shadow projection clipping minimum z value.
  12592. */
  12593. shadowMinZ: number;
  12594. /**
  12595. * Defines the shadow projection clipping maximum z value.
  12596. */
  12597. shadowMaxZ: number;
  12598. /**
  12599. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12600. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12601. */
  12602. computeTransformedInformation(): boolean;
  12603. /**
  12604. * Gets the scene the light belongs to.
  12605. * @returns The scene
  12606. */
  12607. getScene(): Scene;
  12608. /**
  12609. * Callback defining a custom Projection Matrix Builder.
  12610. * This can be used to override the default projection matrix computation.
  12611. */
  12612. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12613. /**
  12614. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12615. * @param matrix The materix to updated with the projection information
  12616. * @param viewMatrix The transform matrix of the light
  12617. * @param renderList The list of mesh to render in the map
  12618. * @returns The current light
  12619. */
  12620. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12621. /**
  12622. * Gets the current depth scale used in ESM.
  12623. * @returns The scale
  12624. */
  12625. getDepthScale(): number;
  12626. /**
  12627. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12628. * @returns true if a cube texture needs to be use
  12629. */
  12630. needCube(): boolean;
  12631. /**
  12632. * Detects if the projection matrix requires to be recomputed this frame.
  12633. * @returns true if it requires to be recomputed otherwise, false.
  12634. */
  12635. needProjectionMatrixCompute(): boolean;
  12636. /**
  12637. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12638. */
  12639. forceProjectionMatrixCompute(): void;
  12640. /**
  12641. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12642. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12643. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12644. */
  12645. getShadowDirection(faceIndex?: number): Vector3;
  12646. /**
  12647. * Gets the minZ used for shadow according to both the scene and the light.
  12648. * @param activeCamera The camera we are returning the min for
  12649. * @returns the depth min z
  12650. */
  12651. getDepthMinZ(activeCamera: Camera): number;
  12652. /**
  12653. * Gets the maxZ used for shadow according to both the scene and the light.
  12654. * @param activeCamera The camera we are returning the max for
  12655. * @returns the depth max z
  12656. */
  12657. getDepthMaxZ(activeCamera: Camera): number;
  12658. }
  12659. /**
  12660. * Base implementation IShadowLight
  12661. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12662. */
  12663. abstract class ShadowLight extends Light implements IShadowLight {
  12664. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12665. protected _position: Vector3;
  12666. protected _setPosition(value: Vector3): void;
  12667. /**
  12668. * Sets the position the shadow will be casted from. Also use as the light position for both
  12669. * point and spot lights.
  12670. */
  12671. /**
  12672. * Sets the position the shadow will be casted from. Also use as the light position for both
  12673. * point and spot lights.
  12674. */
  12675. position: Vector3;
  12676. protected _direction: Vector3;
  12677. protected _setDirection(value: Vector3): void;
  12678. /**
  12679. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12680. * Also use as the light direction on spot and directional lights.
  12681. */
  12682. /**
  12683. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12684. * Also use as the light direction on spot and directional lights.
  12685. */
  12686. direction: Vector3;
  12687. private _shadowMinZ;
  12688. /**
  12689. * Gets the shadow projection clipping minimum z value.
  12690. */
  12691. /**
  12692. * Sets the shadow projection clipping minimum z value.
  12693. */
  12694. shadowMinZ: number;
  12695. private _shadowMaxZ;
  12696. /**
  12697. * Sets the shadow projection clipping maximum z value.
  12698. */
  12699. /**
  12700. * Gets the shadow projection clipping maximum z value.
  12701. */
  12702. shadowMaxZ: number;
  12703. /**
  12704. * Callback defining a custom Projection Matrix Builder.
  12705. * This can be used to override the default projection matrix computation.
  12706. */
  12707. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12708. /**
  12709. * The transformed position. Position of the light in world space taking parenting in account.
  12710. */
  12711. transformedPosition: Vector3;
  12712. /**
  12713. * The transformed direction. Direction of the light in world space taking parenting in account.
  12714. */
  12715. transformedDirection: Vector3;
  12716. private _needProjectionMatrixCompute;
  12717. /**
  12718. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12719. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12720. */
  12721. computeTransformedInformation(): boolean;
  12722. /**
  12723. * Return the depth scale used for the shadow map.
  12724. * @returns the depth scale.
  12725. */
  12726. getDepthScale(): number;
  12727. /**
  12728. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12729. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12730. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12731. */
  12732. getShadowDirection(faceIndex?: number): Vector3;
  12733. /**
  12734. * Returns the ShadowLight absolute position in the World.
  12735. * @returns the position vector in world space
  12736. */
  12737. getAbsolutePosition(): Vector3;
  12738. /**
  12739. * Sets the ShadowLight direction toward the passed target.
  12740. * @param target The point tot target in local space
  12741. * @returns the updated ShadowLight direction
  12742. */
  12743. setDirectionToTarget(target: Vector3): Vector3;
  12744. /**
  12745. * Returns the light rotation in euler definition.
  12746. * @returns the x y z rotation in local space.
  12747. */
  12748. getRotation(): Vector3;
  12749. /**
  12750. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12751. * @returns true if a cube texture needs to be use
  12752. */
  12753. needCube(): boolean;
  12754. /**
  12755. * Detects if the projection matrix requires to be recomputed this frame.
  12756. * @returns true if it requires to be recomputed otherwise, false.
  12757. */
  12758. needProjectionMatrixCompute(): boolean;
  12759. /**
  12760. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12761. */
  12762. forceProjectionMatrixCompute(): void;
  12763. /** @hidden */
  12764. _initCache(): void;
  12765. /** @hidden */
  12766. _isSynchronized(): boolean;
  12767. /**
  12768. * Computes the world matrix of the node
  12769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12770. * @returns the world matrix
  12771. */
  12772. computeWorldMatrix(force?: boolean): Matrix;
  12773. /**
  12774. * Gets the minZ used for shadow according to both the scene and the light.
  12775. * @param activeCamera The camera we are returning the min for
  12776. * @returns the depth min z
  12777. */
  12778. getDepthMinZ(activeCamera: Camera): number;
  12779. /**
  12780. * Gets the maxZ used for shadow according to both the scene and the light.
  12781. * @param activeCamera The camera we are returning the max for
  12782. * @returns the depth max z
  12783. */
  12784. getDepthMaxZ(activeCamera: Camera): number;
  12785. /**
  12786. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12787. * @param matrix The materix to updated with the projection information
  12788. * @param viewMatrix The transform matrix of the light
  12789. * @param renderList The list of mesh to render in the map
  12790. * @returns The current light
  12791. */
  12792. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12793. }
  12794. }
  12795. declare module BABYLON {
  12796. /**
  12797. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12798. * These values define a cone of light starting from the position, emitting toward the direction.
  12799. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12800. * and the exponent defines the speed of the decay of the light with distance (reach).
  12801. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12802. */
  12803. class SpotLight extends ShadowLight {
  12804. private _angle;
  12805. private _innerAngle;
  12806. private _cosHalfAngle;
  12807. private _lightAngleScale;
  12808. private _lightAngleOffset;
  12809. /**
  12810. * Gets the cone angle of the spot light in Radians.
  12811. */
  12812. /**
  12813. * Sets the cone angle of the spot light in Radians.
  12814. */
  12815. angle: number;
  12816. /**
  12817. * Only used in gltf falloff mode, this defines the angle where
  12818. * the directional falloff will start before cutting at angle which could be seen
  12819. * as outer angle.
  12820. */
  12821. /**
  12822. * Only used in gltf falloff mode, this defines the angle where
  12823. * the directional falloff will start before cutting at angle which could be seen
  12824. * as outer angle.
  12825. */
  12826. innerAngle: number;
  12827. private _shadowAngleScale;
  12828. /**
  12829. * Allows scaling the angle of the light for shadow generation only.
  12830. */
  12831. /**
  12832. * Allows scaling the angle of the light for shadow generation only.
  12833. */
  12834. shadowAngleScale: number;
  12835. /**
  12836. * The light decay speed with the distance from the emission spot.
  12837. */
  12838. exponent: number;
  12839. private _projectionTextureMatrix;
  12840. /**
  12841. * Allows reading the projecton texture
  12842. */
  12843. readonly projectionTextureMatrix: Matrix;
  12844. protected _projectionTextureLightNear: number;
  12845. /**
  12846. * Gets the near clip of the Spotlight for texture projection.
  12847. */
  12848. /**
  12849. * Sets the near clip of the Spotlight for texture projection.
  12850. */
  12851. projectionTextureLightNear: number;
  12852. protected _projectionTextureLightFar: number;
  12853. /**
  12854. * Gets the far clip of the Spotlight for texture projection.
  12855. */
  12856. /**
  12857. * Sets the far clip of the Spotlight for texture projection.
  12858. */
  12859. projectionTextureLightFar: number;
  12860. protected _projectionTextureUpDirection: Vector3;
  12861. /**
  12862. * Gets the Up vector of the Spotlight for texture projection.
  12863. */
  12864. /**
  12865. * Sets the Up vector of the Spotlight for texture projection.
  12866. */
  12867. projectionTextureUpDirection: Vector3;
  12868. private _projectionTexture;
  12869. /**
  12870. * Gets the projection texture of the light.
  12871. */
  12872. /**
  12873. * Sets the projection texture of the light.
  12874. */
  12875. projectionTexture: Nullable<BaseTexture>;
  12876. private _projectionTextureViewLightDirty;
  12877. private _projectionTextureProjectionLightDirty;
  12878. private _projectionTextureDirty;
  12879. private _projectionTextureViewTargetVector;
  12880. private _projectionTextureViewLightMatrix;
  12881. private _projectionTextureProjectionLightMatrix;
  12882. private _projectionTextureScalingMatrix;
  12883. /**
  12884. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12885. * It can cast shadows.
  12886. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12887. * @param name The light friendly name
  12888. * @param position The position of the spot light in the scene
  12889. * @param direction The direction of the light in the scene
  12890. * @param angle The cone angle of the light in Radians
  12891. * @param exponent The light decay speed with the distance from the emission spot
  12892. * @param scene The scene the lights belongs to
  12893. */
  12894. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12895. /**
  12896. * Returns the string "SpotLight".
  12897. * @returns the class name
  12898. */
  12899. getClassName(): string;
  12900. /**
  12901. * Returns the integer 2.
  12902. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12903. */
  12904. getTypeID(): number;
  12905. /**
  12906. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12907. */
  12908. protected _setDirection(value: Vector3): void;
  12909. /**
  12910. * Overrides the position setter to recompute the projection texture view light Matrix.
  12911. */
  12912. protected _setPosition(value: Vector3): void;
  12913. /**
  12914. * 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.
  12915. * Returns the SpotLight.
  12916. */
  12917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12918. protected _computeProjectionTextureViewLightMatrix(): void;
  12919. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12920. /**
  12921. * Main function for light texture projection matrix computing.
  12922. */
  12923. protected _computeProjectionTextureMatrix(): void;
  12924. protected _buildUniformLayout(): void;
  12925. private _computeAngleValues;
  12926. /**
  12927. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12928. * @param effect The effect to update
  12929. * @param lightIndex The index of the light in the effect to update
  12930. * @returns The spot light
  12931. */
  12932. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12933. /**
  12934. * Disposes the light and the associated resources.
  12935. */
  12936. dispose(): void;
  12937. /**
  12938. * Prepares the list of defines specific to the light type.
  12939. * @param defines the list of defines
  12940. * @param lightIndex defines the index of the light for the effect
  12941. */
  12942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12943. }
  12944. }
  12945. declare module BABYLON {
  12946. interface ILoadingScreen {
  12947. displayLoadingUI: () => void;
  12948. hideLoadingUI: () => void;
  12949. loadingUIBackgroundColor: string;
  12950. loadingUIText: string;
  12951. }
  12952. class DefaultLoadingScreen implements ILoadingScreen {
  12953. private _renderingCanvas;
  12954. private _loadingText;
  12955. private _loadingDivBackgroundColor;
  12956. private _loadingDiv;
  12957. private _loadingTextDiv;
  12958. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12959. displayLoadingUI(): void;
  12960. hideLoadingUI(): void;
  12961. loadingUIText: string;
  12962. loadingUIBackgroundColor: string;
  12963. private _resizeLoadingUI;
  12964. }
  12965. }
  12966. declare module BABYLON {
  12967. class SceneLoaderProgressEvent {
  12968. readonly lengthComputable: boolean;
  12969. readonly loaded: number;
  12970. readonly total: number;
  12971. constructor(lengthComputable: boolean, loaded: number, total: number);
  12972. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12973. }
  12974. interface ISceneLoaderPluginExtensions {
  12975. [extension: string]: {
  12976. isBinary: boolean;
  12977. };
  12978. }
  12979. interface ISceneLoaderPluginFactory {
  12980. name: string;
  12981. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12982. canDirectLoad?: (data: string) => boolean;
  12983. }
  12984. interface ISceneLoaderPlugin {
  12985. /**
  12986. * The friendly name of this plugin.
  12987. */
  12988. name: string;
  12989. /**
  12990. * The file extensions supported by this plugin.
  12991. */
  12992. extensions: string | ISceneLoaderPluginExtensions;
  12993. /**
  12994. * Import meshes into a scene.
  12995. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12996. * @param scene The scene to import into
  12997. * @param data The data to import
  12998. * @param rootUrl The root url for scene and resources
  12999. * @param meshes The meshes array to import into
  13000. * @param particleSystems The particle systems array to import into
  13001. * @param skeletons The skeletons array to import into
  13002. * @param onError The callback when import fails
  13003. * @returns True if successful or false otherwise
  13004. */
  13005. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  13006. /**
  13007. * Load into a scene.
  13008. * @param scene The scene to load into
  13009. * @param data The data to import
  13010. * @param rootUrl The root url for scene and resources
  13011. * @param onError The callback when import fails
  13012. * @returns true if successful or false otherwise
  13013. */
  13014. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  13015. /**
  13016. * The callback that returns true if the data can be directly loaded.
  13017. */
  13018. canDirectLoad?: (data: string) => boolean;
  13019. /**
  13020. * The callback that allows custom handling of the root url based on the response url.
  13021. */
  13022. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13023. /**
  13024. * Load into an asset container.
  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 onError The callback when import fails
  13029. * @returns The loaded asset container
  13030. */
  13031. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  13032. }
  13033. interface ISceneLoaderPluginAsync {
  13034. /**
  13035. * The friendly name of this plugin.
  13036. */
  13037. name: string;
  13038. /**
  13039. * The file extensions supported by this plugin.
  13040. */
  13041. extensions: string | ISceneLoaderPluginExtensions;
  13042. /**
  13043. * Import meshes into a scene.
  13044. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13045. * @param scene The scene to import into
  13046. * @param data The data to import
  13047. * @param rootUrl The root url for scene and resources
  13048. * @param onProgress The callback when the load progresses
  13049. * @param fullName Defines the FQDN of the file to load
  13050. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13051. */
  13052. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  13053. meshes: AbstractMesh[];
  13054. particleSystems: IParticleSystem[];
  13055. skeletons: Skeleton[];
  13056. animationGroups: AnimationGroup[];
  13057. }>;
  13058. /**
  13059. * Load into a scene.
  13060. * @param scene The scene to load into
  13061. * @param data The data to import
  13062. * @param rootUrl The root url for scene and resources
  13063. * @param onProgress The callback when the load progresses
  13064. * @param fullName Defines the FQDN of the file to load
  13065. * @returns Nothing
  13066. */
  13067. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  13068. /**
  13069. * The callback that returns true if the data can be directly loaded.
  13070. */
  13071. canDirectLoad?: (data: string) => boolean;
  13072. /**
  13073. * The callback that allows custom handling of the root url based on the response url.
  13074. */
  13075. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13076. /**
  13077. * Load into an asset container.
  13078. * @param scene The scene to load into
  13079. * @param data The data to import
  13080. * @param rootUrl The root url for scene and resources
  13081. * @param onProgress The callback when the load progresses
  13082. * @param fullName Defines the FQDN of the file to load
  13083. * @returns The loaded asset container
  13084. */
  13085. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<AssetContainer>;
  13086. }
  13087. class SceneLoader {
  13088. private static _ForceFullSceneLoadingForIncremental;
  13089. private static _ShowLoadingScreen;
  13090. private static _CleanBoneMatrixWeights;
  13091. static readonly NO_LOGGING: number;
  13092. static readonly MINIMAL_LOGGING: number;
  13093. static readonly SUMMARY_LOGGING: number;
  13094. static readonly DETAILED_LOGGING: number;
  13095. private static _loggingLevel;
  13096. static ForceFullSceneLoadingForIncremental: boolean;
  13097. static ShowLoadingScreen: boolean;
  13098. static loggingLevel: number;
  13099. static CleanBoneMatrixWeights: boolean;
  13100. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13101. private static _registeredPlugins;
  13102. private static _getDefaultPlugin;
  13103. private static _getPluginForExtension;
  13104. private static _getPluginForDirectLoad;
  13105. private static _getPluginForFilename;
  13106. private static _getDirectLoad;
  13107. private static _loadData;
  13108. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13109. static IsPluginForExtensionAvailable(extension: string): boolean;
  13110. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  13111. /**
  13112. * Import meshes into a scene
  13113. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13114. * @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)
  13115. * @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)
  13116. * @param scene the instance of BABYLON.Scene to append to
  13117. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13118. * @param onProgress a callback with a progress event for each file being loaded
  13119. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13120. * @param pluginExtension the extension used to determine the plugin
  13121. * @returns The loaded plugin
  13122. */
  13123. 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>;
  13124. /**
  13125. * Import meshes into a scene
  13126. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 the instance of BABYLON.Scene to append to
  13130. * @param onProgress a callback with a progress event for each file being loaded
  13131. * @param pluginExtension the extension used to determine the plugin
  13132. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13133. */
  13134. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13135. meshes: AbstractMesh[];
  13136. particleSystems: IParticleSystem[];
  13137. skeletons: Skeleton[];
  13138. animationGroups: AnimationGroup[];
  13139. }>;
  13140. /**
  13141. * Load a scene
  13142. * @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)
  13143. * @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)
  13144. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13145. * @param onSuccess a callback with the scene when import succeeds
  13146. * @param onProgress a callback with a progress event for each file being loaded
  13147. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13148. * @param pluginExtension the extension used to determine the plugin
  13149. * @returns The loaded plugin
  13150. */
  13151. 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>;
  13152. /**
  13153. * Load a scene
  13154. * @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)
  13155. * @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)
  13156. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13157. * @param onProgress a callback with a progress event for each file being loaded
  13158. * @param pluginExtension the extension used to determine the plugin
  13159. * @returns The loaded scene
  13160. */
  13161. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13162. /**
  13163. * Append a scene
  13164. * @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)
  13165. * @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)
  13166. * @param scene is the instance of BABYLON.Scene to append to
  13167. * @param onSuccess a callback with the scene when import succeeds
  13168. * @param onProgress a callback with a progress event for each file being loaded
  13169. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13170. * @param pluginExtension the extension used to determine the plugin
  13171. * @returns The loaded plugin
  13172. */
  13173. 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>;
  13174. /**
  13175. * Append a scene
  13176. * @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)
  13177. * @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)
  13178. * @param scene is the instance of BABYLON.Scene to append to
  13179. * @param onProgress a callback with a progress event for each file being loaded
  13180. * @param pluginExtension the extension used to determine the plugin
  13181. * @returns The given scene
  13182. */
  13183. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13184. /**
  13185. * Load a scene into an asset container
  13186. * @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)
  13187. * @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)
  13188. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13189. * @param onSuccess a callback with the scene when import succeeds
  13190. * @param onProgress a callback with a progress event for each file being loaded
  13191. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13192. * @param pluginExtension the extension used to determine the plugin
  13193. * @returns The loaded plugin
  13194. */
  13195. 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>;
  13196. /**
  13197. * Load a scene into an asset container
  13198. * @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)
  13199. * @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)
  13200. * @param scene is the instance of BABYLON.Scene to append to
  13201. * @param onProgress a callback with a progress event for each file being loaded
  13202. * @param pluginExtension the extension used to determine the plugin
  13203. * @returns The loaded asset container
  13204. */
  13205. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13206. }
  13207. }
  13208. declare module BABYLON {
  13209. class Scalar {
  13210. /**
  13211. * Two pi constants convenient for computation.
  13212. */
  13213. static TwoPi: number;
  13214. /**
  13215. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  13216. */
  13217. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  13218. /**
  13219. * Returns a string : the upper case translation of the number i to hexadecimal.
  13220. */
  13221. static ToHex(i: number): string;
  13222. /**
  13223. * Returns -1 if value is negative and +1 is value is positive.
  13224. * Returns the value itself if it's equal to zero.
  13225. */
  13226. static Sign(value: number): number;
  13227. /**
  13228. * Returns the value itself if it's between min and max.
  13229. * Returns min if the value is lower than min.
  13230. * Returns max if the value is greater than max.
  13231. */
  13232. static Clamp(value: number, min?: number, max?: number): number;
  13233. /**
  13234. * Returns the log2 of value.
  13235. */
  13236. static Log2(value: number): number;
  13237. /**
  13238. * Loops the value, so that it is never larger than length and never smaller than 0.
  13239. *
  13240. * This is similar to the modulo operator but it works with floating point numbers.
  13241. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  13242. * With t = 5 and length = 2.5, the result would be 0.0.
  13243. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  13244. */
  13245. static Repeat(value: number, length: number): number;
  13246. /**
  13247. * Normalize the value between 0.0 and 1.0 using min and max values
  13248. */
  13249. static Normalize(value: number, min: number, max: number): number;
  13250. /**
  13251. * Denormalize the value from 0.0 and 1.0 using min and max values
  13252. */
  13253. static Denormalize(normalized: number, min: number, max: number): number;
  13254. /**
  13255. * Calculates the shortest difference between two given angles given in degrees.
  13256. */
  13257. static DeltaAngle(current: number, target: number): number;
  13258. /**
  13259. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  13260. *
  13261. * The returned value will move back and forth between 0 and length
  13262. */
  13263. static PingPong(tx: number, length: number): number;
  13264. /**
  13265. * Interpolates between min and max with smoothing at the limits.
  13266. *
  13267. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  13268. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  13269. */
  13270. static SmoothStep(from: number, to: number, tx: number): number;
  13271. /**
  13272. * Moves a value current towards target.
  13273. *
  13274. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  13275. * Negative values of maxDelta pushes the value away from target.
  13276. */
  13277. static MoveTowards(current: number, target: number, maxDelta: number): number;
  13278. /**
  13279. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13280. *
  13281. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  13282. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  13283. */
  13284. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  13285. /**
  13286. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  13287. */
  13288. static Lerp(start: number, end: number, amount: number): number;
  13289. /**
  13290. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13291. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  13292. */
  13293. static LerpAngle(start: number, end: number, amount: number): number;
  13294. /**
  13295. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  13296. */
  13297. static InverseLerp(a: number, b: number, value: number): number;
  13298. /**
  13299. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  13300. */
  13301. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  13302. /**
  13303. * Returns a random float number between and min and max values
  13304. */
  13305. static RandomRange(min: number, max: number): number;
  13306. /**
  13307. * This function returns percentage of a number in a given range.
  13308. *
  13309. * RangeToPercent(40,20,60) will return 0.5 (50%)
  13310. * RangeToPercent(34,0,100) will return 0.34 (34%)
  13311. */
  13312. static RangeToPercent(number: number, min: number, max: number): number;
  13313. /**
  13314. * This function returns number that corresponds to the percentage in a given range.
  13315. *
  13316. * PercentToRange(0.34,0,100) will return 34.
  13317. */
  13318. static PercentToRange(percent: number, min: number, max: number): number;
  13319. /**
  13320. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  13321. * @param angle The angle to normalize in radian.
  13322. * @return The converted angle.
  13323. */
  13324. static NormalizeRadians(angle: number): number;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. const ToGammaSpace: number;
  13329. const ToLinearSpace = 2.2;
  13330. const Epsilon = 0.001;
  13331. /**
  13332. * Class used to hold a RBG color
  13333. */
  13334. class Color3 {
  13335. /**
  13336. * Defines the red component (between 0 and 1, default is 0)
  13337. */
  13338. r: number;
  13339. /**
  13340. * Defines the green component (between 0 and 1, default is 0)
  13341. */
  13342. g: number;
  13343. /**
  13344. * Defines the blue component (between 0 and 1, default is 0)
  13345. */
  13346. b: number;
  13347. /**
  13348. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  13349. * @param r defines the red component (between 0 and 1, default is 0)
  13350. * @param g defines the green component (between 0 and 1, default is 0)
  13351. * @param b defines the blue component (between 0 and 1, default is 0)
  13352. */
  13353. constructor(
  13354. /**
  13355. * Defines the red component (between 0 and 1, default is 0)
  13356. */
  13357. r?: number,
  13358. /**
  13359. * Defines the green component (between 0 and 1, default is 0)
  13360. */
  13361. g?: number,
  13362. /**
  13363. * Defines the blue component (between 0 and 1, default is 0)
  13364. */
  13365. b?: number);
  13366. /**
  13367. * Creates a string with the Color3 current values
  13368. * @returns the string representation of the Color3 object
  13369. */
  13370. toString(): string;
  13371. /**
  13372. * Returns the string "Color3"
  13373. * @returns "Color3"
  13374. */
  13375. getClassName(): string;
  13376. /**
  13377. * Compute the Color3 hash code
  13378. * @returns an unique number that can be used to hash Color3 objects
  13379. */
  13380. getHashCode(): number;
  13381. /**
  13382. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  13383. * @param array defines the array where to store the r,g,b components
  13384. * @param index defines an optional index in the target array to define where to start storing values
  13385. * @returns the current Color3 object
  13386. */
  13387. toArray(array: FloatArray, index?: number): Color3;
  13388. /**
  13389. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  13390. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  13391. * @returns a new {BABYLON.Color4} object
  13392. */
  13393. toColor4(alpha?: number): Color4;
  13394. /**
  13395. * Returns a new array populated with 3 numeric elements : red, green and blue values
  13396. * @returns the new array
  13397. */
  13398. asArray(): number[];
  13399. /**
  13400. * Returns the luminance value
  13401. * @returns a float value
  13402. */
  13403. toLuminance(): number;
  13404. /**
  13405. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  13406. * @param otherColor defines the second operand
  13407. * @returns the new Color3 object
  13408. */
  13409. multiply(otherColor: Color3): Color3;
  13410. /**
  13411. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  13412. * @param otherColor defines the second operand
  13413. * @param result defines the Color3 object where to store the result
  13414. * @returns the current Color3
  13415. */
  13416. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  13417. /**
  13418. * Determines equality between Color3 objects
  13419. * @param otherColor defines the second operand
  13420. * @returns true if the rgb values are equal to the given ones
  13421. */
  13422. equals(otherColor: Color3): boolean;
  13423. /**
  13424. * Determines equality between the current Color3 object and a set of r,b,g values
  13425. * @param r defines the red component to check
  13426. * @param g defines the green component to check
  13427. * @param b defines the blue component to check
  13428. * @returns true if the rgb values are equal to the given ones
  13429. */
  13430. equalsFloats(r: number, g: number, b: number): boolean;
  13431. /**
  13432. * Multiplies in place each rgb value by scale
  13433. * @param scale defines the scaling factor
  13434. * @returns the updated Color3
  13435. */
  13436. scale(scale: number): Color3;
  13437. /**
  13438. * Multiplies the rgb values by scale and stores the result into "result"
  13439. * @param scale defines the scaling factor
  13440. * @param result defines the Color3 object where to store the result
  13441. * @returns the unmodified current Color3
  13442. */
  13443. scaleToRef(scale: number, result: Color3): Color3;
  13444. /**
  13445. * Scale the current Color3 values by a factor and add the result to a given Color3
  13446. * @param scale defines the scale factor
  13447. * @param result defines color to store the result into
  13448. * @returns the unmodified current Color3
  13449. */
  13450. scaleAndAddToRef(scale: number, result: Color3): Color3;
  13451. /**
  13452. * Clamps the rgb values by the min and max values and stores the result into "result"
  13453. * @param min defines minimum clamping value (default is 0)
  13454. * @param max defines maximum clamping value (default is 1)
  13455. * @param result defines color to store the result into
  13456. * @returns the original Color3
  13457. */
  13458. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  13459. /**
  13460. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  13461. * @param otherColor defines the second operand
  13462. * @returns the new Color3
  13463. */
  13464. add(otherColor: Color3): Color3;
  13465. /**
  13466. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  13467. * @param otherColor defines the second operand
  13468. * @param result defines Color3 object to store the result into
  13469. * @returns the unmodified current Color3
  13470. */
  13471. addToRef(otherColor: Color3, result: Color3): Color3;
  13472. /**
  13473. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  13474. * @param otherColor defines the second operand
  13475. * @returns the new Color3
  13476. */
  13477. subtract(otherColor: Color3): Color3;
  13478. /**
  13479. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  13480. * @param otherColor defines the second operand
  13481. * @param result defines Color3 object to store the result into
  13482. * @returns the unmodified current Color3
  13483. */
  13484. subtractToRef(otherColor: Color3, result: Color3): Color3;
  13485. /**
  13486. * Copy the current object
  13487. * @returns a new Color3 copied the current one
  13488. */
  13489. clone(): Color3;
  13490. /**
  13491. * Copies the rgb values from the source in the current Color3
  13492. * @param source defines the source Color3 object
  13493. * @returns the updated Color3 object
  13494. */
  13495. copyFrom(source: Color3): Color3;
  13496. /**
  13497. * Updates the Color3 rgb values from the given floats
  13498. * @param r defines the red component to read from
  13499. * @param g defines the green component to read from
  13500. * @param b defines the blue component to read from
  13501. * @returns the current Color3 object
  13502. */
  13503. copyFromFloats(r: number, g: number, b: number): Color3;
  13504. /**
  13505. * Updates the Color3 rgb values from the given floats
  13506. * @param r defines the red component to read from
  13507. * @param g defines the green component to read from
  13508. * @param b defines the blue component to read from
  13509. * @returns the current Color3 object
  13510. */
  13511. set(r: number, g: number, b: number): Color3;
  13512. /**
  13513. * Compute the Color3 hexadecimal code as a string
  13514. * @returns a string containing the hexadecimal representation of the Color3 object
  13515. */
  13516. toHexString(): string;
  13517. /**
  13518. * Computes a new Color3 converted from the current one to linear space
  13519. * @returns a new Color3 object
  13520. */
  13521. toLinearSpace(): Color3;
  13522. /**
  13523. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  13524. * @param convertedColor defines the Color3 object where to store the linear space version
  13525. * @returns the unmodified Color3
  13526. */
  13527. toLinearSpaceToRef(convertedColor: Color3): Color3;
  13528. /**
  13529. * Computes a new Color3 converted from the current one to gamma space
  13530. * @returns a new Color3 object
  13531. */
  13532. toGammaSpace(): Color3;
  13533. /**
  13534. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  13535. * @param convertedColor defines the Color3 object where to store the gamma space version
  13536. * @returns the unmodified Color3
  13537. */
  13538. toGammaSpaceToRef(convertedColor: Color3): Color3;
  13539. /**
  13540. * Creates a new Color3 from the string containing valid hexadecimal values
  13541. * @param hex defines a string containing valid hexadecimal values
  13542. * @returns a new Color3 object
  13543. */
  13544. static FromHexString(hex: string): Color3;
  13545. /**
  13546. * Creates a new Vector3 from the starting index of the given array
  13547. * @param array defines the source array
  13548. * @param offset defines an offset in the source array
  13549. * @returns a new Color3 object
  13550. */
  13551. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  13552. /**
  13553. * Creates a new Color3 from integer values (< 256)
  13554. * @param r defines the red component to read from (value between 0 and 255)
  13555. * @param g defines the green component to read from (value between 0 and 255)
  13556. * @param b defines the blue component to read from (value between 0 and 255)
  13557. * @returns a new Color3 object
  13558. */
  13559. static FromInts(r: number, g: number, b: number): Color3;
  13560. /**
  13561. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  13562. * @param start defines the start Color3 value
  13563. * @param end defines the end Color3 value
  13564. * @param amount defines the gradient value between start and end
  13565. * @returns a new Color3 object
  13566. */
  13567. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  13568. /**
  13569. * Returns a Color3 value containing a red color
  13570. * @returns a new Color3 object
  13571. */
  13572. static Red(): Color3;
  13573. /**
  13574. * Returns a Color3 value containing a green color
  13575. * @returns a new Color3 object
  13576. */
  13577. static Green(): Color3;
  13578. /**
  13579. * Returns a Color3 value containing a blue color
  13580. * @returns a new Color3 object
  13581. */
  13582. static Blue(): Color3;
  13583. /**
  13584. * Returns a Color3 value containing a black color
  13585. * @returns a new Color3 object
  13586. */
  13587. static Black(): Color3;
  13588. /**
  13589. * Returns a Color3 value containing a white color
  13590. * @returns a new Color3 object
  13591. */
  13592. static White(): Color3;
  13593. /**
  13594. * Returns a Color3 value containing a purple color
  13595. * @returns a new Color3 object
  13596. */
  13597. static Purple(): Color3;
  13598. /**
  13599. * Returns a Color3 value containing a magenta color
  13600. * @returns a new Color3 object
  13601. */
  13602. static Magenta(): Color3;
  13603. /**
  13604. * Returns a Color3 value containing a yellow color
  13605. * @returns a new Color3 object
  13606. */
  13607. static Yellow(): Color3;
  13608. /**
  13609. * Returns a Color3 value containing a gray color
  13610. * @returns a new Color3 object
  13611. */
  13612. static Gray(): Color3;
  13613. /**
  13614. * Returns a Color3 value containing a teal color
  13615. * @returns a new Color3 object
  13616. */
  13617. static Teal(): Color3;
  13618. /**
  13619. * Returns a Color3 value containing a random color
  13620. * @returns a new Color3 object
  13621. */
  13622. static Random(): Color3;
  13623. }
  13624. /**
  13625. * Class used to hold a RBGA color
  13626. */
  13627. class Color4 {
  13628. /**
  13629. * Defines the red component (between 0 and 1, default is 0)
  13630. */
  13631. r: number;
  13632. /**
  13633. * Defines the green component (between 0 and 1, default is 0)
  13634. */
  13635. g: number;
  13636. /**
  13637. * Defines the blue component (between 0 and 1, default is 0)
  13638. */
  13639. b: number;
  13640. /**
  13641. * Defines the alpha component (between 0 and 1, default is 1)
  13642. */
  13643. a: number;
  13644. /**
  13645. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  13646. * @param r defines the red component (between 0 and 1, default is 0)
  13647. * @param g defines the green component (between 0 and 1, default is 0)
  13648. * @param b defines the blue component (between 0 and 1, default is 0)
  13649. * @param a defines the alpha component (between 0 and 1, default is 1)
  13650. */
  13651. constructor(
  13652. /**
  13653. * Defines the red component (between 0 and 1, default is 0)
  13654. */
  13655. r?: number,
  13656. /**
  13657. * Defines the green component (between 0 and 1, default is 0)
  13658. */
  13659. g?: number,
  13660. /**
  13661. * Defines the blue component (between 0 and 1, default is 0)
  13662. */
  13663. b?: number,
  13664. /**
  13665. * Defines the alpha component (between 0 and 1, default is 1)
  13666. */
  13667. a?: number);
  13668. /**
  13669. * Adds in place the given Color4 values to the current Color4 object
  13670. * @param right defines the second operand
  13671. * @returns the current updated Color4 object
  13672. */
  13673. addInPlace(right: Color4): Color4;
  13674. /**
  13675. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  13676. * @returns the new array
  13677. */
  13678. asArray(): number[];
  13679. /**
  13680. * Stores from the starting index in the given array the Color4 successive values
  13681. * @param array defines the array where to store the r,g,b components
  13682. * @param index defines an optional index in the target array to define where to start storing values
  13683. * @returns the current Color4 object
  13684. */
  13685. toArray(array: number[], index?: number): Color4;
  13686. /**
  13687. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  13688. * @param right defines the second operand
  13689. * @returns a new Color4 object
  13690. */
  13691. add(right: Color4): Color4;
  13692. /**
  13693. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  13694. * @param right defines the second operand
  13695. * @returns a new Color4 object
  13696. */
  13697. subtract(right: Color4): Color4;
  13698. /**
  13699. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  13700. * @param right defines the second operand
  13701. * @param result defines the Color4 object where to store the result
  13702. * @returns the current Color4 object
  13703. */
  13704. subtractToRef(right: Color4, result: Color4): Color4;
  13705. /**
  13706. * Creates a new Color4 with the current Color4 values multiplied by scale
  13707. * @param scale defines the scaling factor to apply
  13708. * @returns a new Color4 object
  13709. */
  13710. scale(scale: number): Color4;
  13711. /**
  13712. * Multiplies the current Color4 values by scale and stores the result in "result"
  13713. * @param scale defines the scaling factor to apply
  13714. * @param result defines the Color4 object where to store the result
  13715. * @returns the current unmodified Color4
  13716. */
  13717. scaleToRef(scale: number, result: Color4): Color4;
  13718. /**
  13719. * Scale the current Color4 values by a factor and add the result to a given Color4
  13720. * @param scale defines the scale factor
  13721. * @param result defines the Color4 object where to store the result
  13722. * @returns the unmodified current Color4
  13723. */
  13724. scaleAndAddToRef(scale: number, result: Color4): Color4;
  13725. /**
  13726. * Clamps the rgb values by the min and max values and stores the result into "result"
  13727. * @param min defines minimum clamping value (default is 0)
  13728. * @param max defines maximum clamping value (default is 1)
  13729. * @param result defines color to store the result into.
  13730. * @returns the cuurent Color4
  13731. */
  13732. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  13733. /**
  13734. * Multipy an Color4 value by another and return a new Color4 object
  13735. * @param color defines the Color4 value to multiply by
  13736. * @returns a new Color4 object
  13737. */
  13738. multiply(color: Color4): Color4;
  13739. /**
  13740. * Multipy a Color4 value by another and push the result in a reference value
  13741. * @param color defines the Color4 value to multiply by
  13742. * @param result defines the Color4 to fill the result in
  13743. * @returns the result Color4
  13744. */
  13745. multiplyToRef(color: Color4, result: Color4): Color4;
  13746. /**
  13747. * Creates a string with the Color4 current values
  13748. * @returns the string representation of the Color4 object
  13749. */
  13750. toString(): string;
  13751. /**
  13752. * Returns the string "Color4"
  13753. * @returns "Color4"
  13754. */
  13755. getClassName(): string;
  13756. /**
  13757. * Compute the Color4 hash code
  13758. * @returns an unique number that can be used to hash Color4 objects
  13759. */
  13760. getHashCode(): number;
  13761. /**
  13762. * Creates a new Color4 copied from the current one
  13763. * @returns a new Color4 object
  13764. */
  13765. clone(): Color4;
  13766. /**
  13767. * Copies the given Color4 values into the current one
  13768. * @param source defines the source Color4 object
  13769. * @returns the current updated Color4 object
  13770. */
  13771. copyFrom(source: Color4): Color4;
  13772. /**
  13773. * Copies the given float values into the current one
  13774. * @param r defines the red component to read from
  13775. * @param g defines the green component to read from
  13776. * @param b defines the blue component to read from
  13777. * @param a defines the alpha component to read from
  13778. * @returns the current updated Color4 object
  13779. */
  13780. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  13781. /**
  13782. * Copies the given float values into the current one
  13783. * @param r defines the red component to read from
  13784. * @param g defines the green component to read from
  13785. * @param b defines the blue component to read from
  13786. * @param a defines the alpha component to read from
  13787. * @returns the current updated Color4 object
  13788. */
  13789. set(r: number, g: number, b: number, a: number): Color4;
  13790. /**
  13791. * Compute the Color4 hexadecimal code as a string
  13792. * @returns a string containing the hexadecimal representation of the Color4 object
  13793. */
  13794. toHexString(): string;
  13795. /**
  13796. * Computes a new Color4 converted from the current one to linear space
  13797. * @returns a new Color4 object
  13798. */
  13799. toLinearSpace(): Color4;
  13800. /**
  13801. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  13802. * @param convertedColor defines the Color4 object where to store the linear space version
  13803. * @returns the unmodified Color4
  13804. */
  13805. toLinearSpaceToRef(convertedColor: Color4): Color4;
  13806. /**
  13807. * Computes a new Color4 converted from the current one to gamma space
  13808. * @returns a new Color4 object
  13809. */
  13810. toGammaSpace(): Color4;
  13811. /**
  13812. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  13813. * @param convertedColor defines the Color4 object where to store the gamma space version
  13814. * @returns the unmodified Color4
  13815. */
  13816. toGammaSpaceToRef(convertedColor: Color4): Color4;
  13817. /**
  13818. * Creates a new Color4 from the string containing valid hexadecimal values
  13819. * @param hex defines a string containing valid hexadecimal values
  13820. * @returns a new Color4 object
  13821. */
  13822. static FromHexString(hex: string): Color4;
  13823. /**
  13824. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13825. * @param left defines the start value
  13826. * @param right defines the end value
  13827. * @param amount defines the gradient factor
  13828. * @returns a new Color4 object
  13829. */
  13830. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  13831. /**
  13832. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13833. * @param left defines the start value
  13834. * @param right defines the end value
  13835. * @param amount defines the gradient factor
  13836. * @param result defines the Color4 object where to store data
  13837. */
  13838. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  13839. /**
  13840. * Creates a new Color4 from the starting index element of the given array
  13841. * @param array defines the source array to read from
  13842. * @param offset defines the offset in the source array
  13843. * @returns a new Color4 object
  13844. */
  13845. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  13846. /**
  13847. * Creates a new Color3 from integer values (< 256)
  13848. * @param r defines the red component to read from (value between 0 and 255)
  13849. * @param g defines the green component to read from (value between 0 and 255)
  13850. * @param b defines the blue component to read from (value between 0 and 255)
  13851. * @param a defines the alpha component to read from (value between 0 and 255)
  13852. * @returns a new Color3 object
  13853. */
  13854. static FromInts(r: number, g: number, b: number, a: number): Color4;
  13855. /**
  13856. * Check the content of a given array and convert it to an array containing RGBA data
  13857. * If the original array was already containing count * 4 values then it is returned directly
  13858. * @param colors defines the array to check
  13859. * @param count defines the number of RGBA data to expect
  13860. * @returns an array containing count * 4 values (RGBA)
  13861. */
  13862. static CheckColors4(colors: number[], count: number): number[];
  13863. }
  13864. /**
  13865. * Class representing a vector containing 2 coordinates
  13866. */
  13867. class Vector2 {
  13868. /** defines the first coordinate */
  13869. x: number;
  13870. /** defines the second coordinate */
  13871. y: number;
  13872. /**
  13873. * Creates a new Vector2 from the given x and y coordinates
  13874. * @param x defines the first coordinate
  13875. * @param y defines the second coordinate
  13876. */
  13877. constructor(
  13878. /** defines the first coordinate */
  13879. x?: number,
  13880. /** defines the second coordinate */
  13881. y?: number);
  13882. /**
  13883. * Gets a string with the Vector2 coordinates
  13884. * @returns a string with the Vector2 coordinates
  13885. */
  13886. toString(): string;
  13887. /**
  13888. * Gets class name
  13889. * @returns the string "Vector2"
  13890. */
  13891. getClassName(): string;
  13892. /**
  13893. * Gets current vector hash code
  13894. * @returns the Vector2 hash code as a number
  13895. */
  13896. getHashCode(): number;
  13897. /**
  13898. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  13899. * @param array defines the source array
  13900. * @param index defines the offset in source array
  13901. * @returns the current Vector2
  13902. */
  13903. toArray(array: FloatArray, index?: number): Vector2;
  13904. /**
  13905. * Copy the current vector to an array
  13906. * @returns a new array with 2 elements: the Vector2 coordinates.
  13907. */
  13908. asArray(): number[];
  13909. /**
  13910. * Sets the Vector2 coordinates with the given Vector2 coordinates
  13911. * @param source defines the source Vector2
  13912. * @returns the current updated Vector2
  13913. */
  13914. copyFrom(source: Vector2): Vector2;
  13915. /**
  13916. * Sets the Vector2 coordinates with the given floats
  13917. * @param x defines the first coordinate
  13918. * @param y defines the second coordinate
  13919. * @returns the current updated Vector2
  13920. */
  13921. copyFromFloats(x: number, y: number): Vector2;
  13922. /**
  13923. * Sets the Vector2 coordinates with the given floats
  13924. * @param x defines the first coordinate
  13925. * @param y defines the second coordinate
  13926. * @returns the current updated Vector2
  13927. */
  13928. set(x: number, y: number): Vector2;
  13929. /**
  13930. * Add another vector with the current one
  13931. * @param otherVector defines the other vector
  13932. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  13933. */
  13934. add(otherVector: Vector2): Vector2;
  13935. /**
  13936. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  13937. * @param otherVector defines the other vector
  13938. * @param result defines the target vector
  13939. * @returns the unmodified current Vector2
  13940. */
  13941. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  13942. /**
  13943. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  13944. * @param otherVector defines the other vector
  13945. * @returns the current updated Vector2
  13946. */
  13947. addInPlace(otherVector: Vector2): Vector2;
  13948. /**
  13949. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  13950. * @param otherVector defines the other vector
  13951. * @returns a new Vector2
  13952. */
  13953. addVector3(otherVector: Vector3): Vector2;
  13954. /**
  13955. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  13956. * @param otherVector defines the other vector
  13957. * @returns a new Vector2
  13958. */
  13959. subtract(otherVector: Vector2): Vector2;
  13960. /**
  13961. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  13962. * @param otherVector defines the other vector
  13963. * @param result defines the target vector
  13964. * @returns the unmodified current Vector2
  13965. */
  13966. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  13967. /**
  13968. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  13969. * @param otherVector defines the other vector
  13970. * @returns the current updated Vector2
  13971. */
  13972. subtractInPlace(otherVector: Vector2): Vector2;
  13973. /**
  13974. * Multiplies in place the current Vector2 coordinates by the given ones
  13975. * @param otherVector defines the other vector
  13976. * @returns the current updated Vector2
  13977. */
  13978. multiplyInPlace(otherVector: Vector2): Vector2;
  13979. /**
  13980. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  13981. * @param otherVector defines the other vector
  13982. * @returns a new Vector2
  13983. */
  13984. multiply(otherVector: Vector2): Vector2;
  13985. /**
  13986. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  13987. * @param otherVector defines the other vector
  13988. * @param result defines the target vector
  13989. * @returns the unmodified current Vector2
  13990. */
  13991. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  13992. /**
  13993. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  13994. * @param x defines the first coordinate
  13995. * @param y defines the second coordinate
  13996. * @returns a new Vector2
  13997. */
  13998. multiplyByFloats(x: number, y: number): Vector2;
  13999. /**
  14000. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  14001. * @param otherVector defines the other vector
  14002. * @returns a new Vector2
  14003. */
  14004. divide(otherVector: Vector2): Vector2;
  14005. /**
  14006. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  14007. * @param otherVector defines the other vector
  14008. * @param result defines the target vector
  14009. * @returns the unmodified current Vector2
  14010. */
  14011. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  14012. /**
  14013. * Divides the current Vector2 coordinates by the given ones
  14014. * @param otherVector defines the other vector
  14015. * @returns the current updated Vector2
  14016. */
  14017. divideInPlace(otherVector: Vector2): Vector2;
  14018. /**
  14019. * Gets a new Vector2 with current Vector2 negated coordinates
  14020. * @returns a new Vector2
  14021. */
  14022. negate(): Vector2;
  14023. /**
  14024. * Multiply the Vector2 coordinates by scale
  14025. * @param scale defines the scaling factor
  14026. * @returns the current updated Vector2
  14027. */
  14028. scaleInPlace(scale: number): Vector2;
  14029. /**
  14030. * Returns a new Vector2 scaled by "scale" from the current Vector2
  14031. * @param scale defines the scaling factor
  14032. * @returns a new Vector2
  14033. */
  14034. scale(scale: number): Vector2;
  14035. /**
  14036. * Scale the current Vector2 values by a factor to a given Vector2
  14037. * @param scale defines the scale factor
  14038. * @param result defines the Vector2 object where to store the result
  14039. * @returns the unmodified current Vector2
  14040. */
  14041. scaleToRef(scale: number, result: Vector2): Vector2;
  14042. /**
  14043. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  14044. * @param scale defines the scale factor
  14045. * @param result defines the Vector2 object where to store the result
  14046. * @returns the unmodified current Vector2
  14047. */
  14048. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  14049. /**
  14050. * Gets a boolean if two vectors are equals
  14051. * @param otherVector defines the other vector
  14052. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  14053. */
  14054. equals(otherVector: Vector2): boolean;
  14055. /**
  14056. * Gets a boolean if two vectors are equals (using an epsilon value)
  14057. * @param otherVector defines the other vector
  14058. * @param epsilon defines the minimal distance to consider equality
  14059. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  14060. */
  14061. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  14062. /**
  14063. * Gets a new Vector2 from current Vector2 floored values
  14064. * @returns a new Vector2
  14065. */
  14066. floor(): Vector2;
  14067. /**
  14068. * Gets a new Vector2 from current Vector2 floored values
  14069. * @returns a new Vector2
  14070. */
  14071. fract(): Vector2;
  14072. /**
  14073. * Gets the length of the vector
  14074. * @returns the vector length (float)
  14075. */
  14076. length(): number;
  14077. /**
  14078. * Gets the vector squared length
  14079. * @returns the vector squared length (float)
  14080. */
  14081. lengthSquared(): number;
  14082. /**
  14083. * Normalize the vector
  14084. * @returns the current updated Vector2
  14085. */
  14086. normalize(): Vector2;
  14087. /**
  14088. * Gets a new Vector2 copied from the Vector2
  14089. * @returns a new Vector2
  14090. */
  14091. clone(): Vector2;
  14092. /**
  14093. * Gets a new Vector2(0, 0)
  14094. * @returns a new Vector2
  14095. */
  14096. static Zero(): Vector2;
  14097. /**
  14098. * Gets a new Vector2(1, 1)
  14099. * @returns a new Vector2
  14100. */
  14101. static One(): Vector2;
  14102. /**
  14103. * Gets a new Vector2 set from the given index element of the given array
  14104. * @param array defines the data source
  14105. * @param offset defines the offset in the data source
  14106. * @returns a new Vector2
  14107. */
  14108. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  14109. /**
  14110. * Sets "result" from the given index element of the given array
  14111. * @param array defines the data source
  14112. * @param offset defines the offset in the data source
  14113. * @param result defines the target vector
  14114. */
  14115. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  14116. /**
  14117. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  14118. * @param value1 defines 1st point of control
  14119. * @param value2 defines 2nd point of control
  14120. * @param value3 defines 3rd point of control
  14121. * @param value4 defines 4th point of control
  14122. * @param amount defines the interpolation factor
  14123. * @returns a new Vector2
  14124. */
  14125. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  14126. /**
  14127. * 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".
  14128. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  14129. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  14130. * @param value defines the value to clamp
  14131. * @param min defines the lower limit
  14132. * @param max defines the upper limit
  14133. * @returns a new Vector2
  14134. */
  14135. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  14136. /**
  14137. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  14138. * @param value1 defines the 1st control point
  14139. * @param tangent1 defines the outgoing tangent
  14140. * @param value2 defines the 2nd control point
  14141. * @param tangent2 defines the incoming tangent
  14142. * @param amount defines the interpolation factor
  14143. * @returns a new Vector2
  14144. */
  14145. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  14146. /**
  14147. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  14148. * @param start defines the start vector
  14149. * @param end defines the end vector
  14150. * @param amount defines the interpolation factor
  14151. * @returns a new Vector2
  14152. */
  14153. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  14154. /**
  14155. * Gets the dot product of the vector "left" and the vector "right"
  14156. * @param left defines first vector
  14157. * @param right defines second vector
  14158. * @returns the dot product (float)
  14159. */
  14160. static Dot(left: Vector2, right: Vector2): number;
  14161. /**
  14162. * Returns a new Vector2 equal to the normalized given vector
  14163. * @param vector defines the vector to normalize
  14164. * @returns a new Vector2
  14165. */
  14166. static Normalize(vector: Vector2): Vector2;
  14167. /**
  14168. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  14169. * @param left defines 1st vector
  14170. * @param right defines 2nd vector
  14171. * @returns a new Vector2
  14172. */
  14173. static Minimize(left: Vector2, right: Vector2): Vector2;
  14174. /**
  14175. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  14176. * @param left defines 1st vector
  14177. * @param right defines 2nd vector
  14178. * @returns a new Vector2
  14179. */
  14180. static Maximize(left: Vector2, right: Vector2): Vector2;
  14181. /**
  14182. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  14183. * @param vector defines the vector to transform
  14184. * @param transformation defines the matrix to apply
  14185. * @returns a new Vector2
  14186. */
  14187. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  14188. /**
  14189. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  14190. * @param vector defines the vector to transform
  14191. * @param transformation defines the matrix to apply
  14192. * @param result defines the target vector
  14193. */
  14194. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  14195. /**
  14196. * Determines if a given vector is included in a triangle
  14197. * @param p defines the vector to test
  14198. * @param p0 defines 1st triangle point
  14199. * @param p1 defines 2nd triangle point
  14200. * @param p2 defines 3rd triangle point
  14201. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  14202. */
  14203. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  14204. /**
  14205. * Gets the distance between the vectors "value1" and "value2"
  14206. * @param value1 defines first vector
  14207. * @param value2 defines second vector
  14208. * @returns the distance between vectors
  14209. */
  14210. static Distance(value1: Vector2, value2: Vector2): number;
  14211. /**
  14212. * Returns the squared distance between the vectors "value1" and "value2"
  14213. * @param value1 defines first vector
  14214. * @param value2 defines second vector
  14215. * @returns the squared distance between vectors
  14216. */
  14217. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  14218. /**
  14219. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  14220. * @param value1 defines first vector
  14221. * @param value2 defines second vector
  14222. * @returns a new Vector2
  14223. */
  14224. static Center(value1: Vector2, value2: Vector2): Vector2;
  14225. /**
  14226. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  14227. * @param p defines the middle point
  14228. * @param segA defines one point of the segment
  14229. * @param segB defines the other point of the segment
  14230. * @returns the shortest distance
  14231. */
  14232. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  14233. }
  14234. /**
  14235. * Classed used to store (x,y,z) vector representation
  14236. * A Vector3 is the main object used in 3D geometry
  14237. * It can represent etiher the coordinates of a point the space, either a direction
  14238. * Reminder: Babylon.js uses a left handed forward facing system
  14239. */
  14240. class Vector3 {
  14241. /**
  14242. * Defines the first coordinates (on X axis)
  14243. */
  14244. x: number;
  14245. /**
  14246. * Defines the second coordinates (on Y axis)
  14247. */
  14248. y: number;
  14249. /**
  14250. * Defines the third coordinates (on Z axis)
  14251. */
  14252. z: number;
  14253. /**
  14254. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  14255. * @param x defines the first coordinates (on X axis)
  14256. * @param y defines the second coordinates (on Y axis)
  14257. * @param z defines the third coordinates (on Z axis)
  14258. */
  14259. constructor(
  14260. /**
  14261. * Defines the first coordinates (on X axis)
  14262. */
  14263. x?: number,
  14264. /**
  14265. * Defines the second coordinates (on Y axis)
  14266. */
  14267. y?: number,
  14268. /**
  14269. * Defines the third coordinates (on Z axis)
  14270. */
  14271. z?: number);
  14272. /**
  14273. * Creates a string representation of the Vector3
  14274. * @returns a string with the Vector3 coordinates.
  14275. */
  14276. toString(): string;
  14277. /**
  14278. * Gets the class name
  14279. * @returns the string "Vector3"
  14280. */
  14281. getClassName(): string;
  14282. /**
  14283. * Creates the Vector3 hash code
  14284. * @returns a number which tends to be unique between Vector3 instances
  14285. */
  14286. getHashCode(): number;
  14287. /**
  14288. * Creates an array containing three elements : the coordinates of the Vector3
  14289. * @returns a new array of numbers
  14290. */
  14291. asArray(): number[];
  14292. /**
  14293. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  14294. * @param array defines the destination array
  14295. * @param index defines the offset in the destination array
  14296. * @returns the current Vector3
  14297. */
  14298. toArray(array: FloatArray, index?: number): Vector3;
  14299. /**
  14300. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  14301. * @returns a new Quaternion object, computed from the Vector3 coordinates
  14302. */
  14303. toQuaternion(): Quaternion;
  14304. /**
  14305. * Adds the given vector to the current Vector3
  14306. * @param otherVector defines the second operand
  14307. * @returns the current updated Vector3
  14308. */
  14309. addInPlace(otherVector: Vector3): Vector3;
  14310. /**
  14311. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  14312. * @param otherVector defines the second operand
  14313. * @returns the resulting Vector3
  14314. */
  14315. add(otherVector: Vector3): Vector3;
  14316. /**
  14317. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  14318. * @param otherVector defines the second operand
  14319. * @param result defines the Vector3 object where to store the result
  14320. * @returns the current Vector3
  14321. */
  14322. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  14323. /**
  14324. * Subtract the given vector from the current Vector3
  14325. * @param otherVector defines the second operand
  14326. * @returns the current updated Vector3
  14327. */
  14328. subtractInPlace(otherVector: Vector3): Vector3;
  14329. /**
  14330. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  14331. * @param otherVector defines the second operand
  14332. * @returns the resulting Vector3
  14333. */
  14334. subtract(otherVector: Vector3): Vector3;
  14335. /**
  14336. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  14337. * @param otherVector defines the second operand
  14338. * @param result defines the Vector3 object where to store the result
  14339. * @returns the current Vector3
  14340. */
  14341. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  14342. /**
  14343. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  14344. * @param x defines the x coordinate of the operand
  14345. * @param y defines the y coordinate of the operand
  14346. * @param z defines the z coordinate of the operand
  14347. * @returns the resulting Vector3
  14348. */
  14349. subtractFromFloats(x: number, y: number, z: number): Vector3;
  14350. /**
  14351. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  14352. * @param x defines the x coordinate of the operand
  14353. * @param y defines the y coordinate of the operand
  14354. * @param z defines the z coordinate of the operand
  14355. * @param result defines the Vector3 object where to store the result
  14356. * @returns the current Vector3
  14357. */
  14358. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  14359. /**
  14360. * Gets a new Vector3 set with the current Vector3 negated coordinates
  14361. * @returns a new Vector3
  14362. */
  14363. negate(): Vector3;
  14364. /**
  14365. * Multiplies the Vector3 coordinates by the float "scale"
  14366. * @param scale defines the multiplier factor
  14367. * @returns the current updated Vector3
  14368. */
  14369. scaleInPlace(scale: number): Vector3;
  14370. /**
  14371. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  14372. * @param scale defines the multiplier factor
  14373. * @returns a new Vector3
  14374. */
  14375. scale(scale: number): Vector3;
  14376. /**
  14377. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  14378. * @param scale defines the multiplier factor
  14379. * @param result defines the Vector3 object where to store the result
  14380. * @returns the current Vector3
  14381. */
  14382. scaleToRef(scale: number, result: Vector3): Vector3;
  14383. /**
  14384. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  14385. * @param scale defines the scale factor
  14386. * @param result defines the Vector3 object where to store the result
  14387. * @returns the unmodified current Vector3
  14388. */
  14389. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  14390. /**
  14391. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  14392. * @param otherVector defines the second operand
  14393. * @returns true if both vectors are equals
  14394. */
  14395. equals(otherVector: Vector3): boolean;
  14396. /**
  14397. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  14398. * @param otherVector defines the second operand
  14399. * @param epsilon defines the minimal distance to define values as equals
  14400. * @returns true if both vectors are distant less than epsilon
  14401. */
  14402. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  14403. /**
  14404. * Returns true if the current Vector3 coordinates equals the given floats
  14405. * @param x defines the x coordinate of the operand
  14406. * @param y defines the y coordinate of the operand
  14407. * @param z defines the z coordinate of the operand
  14408. * @returns true if both vectors are equals
  14409. */
  14410. equalsToFloats(x: number, y: number, z: number): boolean;
  14411. /**
  14412. * Multiplies the current Vector3 coordinates by the given ones
  14413. * @param otherVector defines the second operand
  14414. * @returns the current updated Vector3
  14415. */
  14416. multiplyInPlace(otherVector: Vector3): Vector3;
  14417. /**
  14418. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  14419. * @param otherVector defines the second operand
  14420. * @returns the new Vector3
  14421. */
  14422. multiply(otherVector: Vector3): Vector3;
  14423. /**
  14424. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  14425. * @param otherVector defines the second operand
  14426. * @param result defines the Vector3 object where to store the result
  14427. * @returns the current Vector3
  14428. */
  14429. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  14430. /**
  14431. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  14432. * @param x defines the x coordinate of the operand
  14433. * @param y defines the y coordinate of the operand
  14434. * @param z defines the z coordinate of the operand
  14435. * @returns the new Vector3
  14436. */
  14437. multiplyByFloats(x: number, y: number, z: number): Vector3;
  14438. /**
  14439. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  14440. * @param otherVector defines the second operand
  14441. * @returns the new Vector3
  14442. */
  14443. divide(otherVector: Vector3): Vector3;
  14444. /**
  14445. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  14446. * @param otherVector defines the second operand
  14447. * @param result defines the Vector3 object where to store the result
  14448. * @returns the current Vector3
  14449. */
  14450. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  14451. /**
  14452. * Divides the current Vector3 coordinates by the given ones.
  14453. * @param otherVector defines the second operand
  14454. * @returns the current updated Vector3
  14455. */
  14456. divideInPlace(otherVector: Vector3): Vector3;
  14457. /**
  14458. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  14459. * @param other defines the second operand
  14460. * @returns the current updated Vector3
  14461. */
  14462. minimizeInPlace(other: Vector3): Vector3;
  14463. /**
  14464. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  14465. * @param other defines the second operand
  14466. * @returns the current updated Vector3
  14467. */
  14468. maximizeInPlace(other: Vector3): Vector3;
  14469. /**
  14470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  14471. */
  14472. readonly isNonUniform: boolean;
  14473. /**
  14474. * Gets a new Vector3 from current Vector3 floored values
  14475. * @returns a new Vector3
  14476. */
  14477. floor(): Vector3;
  14478. /**
  14479. * Gets a new Vector3 from current Vector3 floored values
  14480. * @returns a new Vector3
  14481. */
  14482. fract(): Vector3;
  14483. /**
  14484. * Gets the length of the Vector3
  14485. * @returns the length of the Vecto3
  14486. */
  14487. length(): number;
  14488. /**
  14489. * Gets the squared length of the Vector3
  14490. * @returns squared length of the Vector3
  14491. */
  14492. lengthSquared(): number;
  14493. /**
  14494. * Normalize the current Vector3.
  14495. * Please note that this is an in place operation.
  14496. * @returns the current updated Vector3
  14497. */
  14498. normalize(): Vector3;
  14499. /**
  14500. * Normalize the current Vector3 to a new vector
  14501. * @returns the new Vector3
  14502. */
  14503. normalizeToNew(): Vector3;
  14504. /**
  14505. * Normalize the current Vector3 to the reference
  14506. * @param reference define the Vector3 to update
  14507. * @returns the updated Vector3
  14508. */
  14509. normalizeToRef(reference: Vector3): Vector3;
  14510. /**
  14511. * Creates a new Vector3 copied from the current Vector3
  14512. * @returns the new Vector3
  14513. */
  14514. clone(): Vector3;
  14515. /**
  14516. * Copies the given vector coordinates to the current Vector3 ones
  14517. * @param source defines the source Vector3
  14518. * @returns the current updated Vector3
  14519. */
  14520. copyFrom(source: Vector3): Vector3;
  14521. /**
  14522. * Copies the given floats to the current Vector3 coordinates
  14523. * @param x defines the x coordinate of the operand
  14524. * @param y defines the y coordinate of the operand
  14525. * @param z defines the z coordinate of the operand
  14526. * @returns the current updated Vector3
  14527. */
  14528. copyFromFloats(x: number, y: number, z: number): Vector3;
  14529. /**
  14530. * Copies the given floats to the current Vector3 coordinates
  14531. * @param x defines the x coordinate of the operand
  14532. * @param y defines the y coordinate of the operand
  14533. * @param z defines the z coordinate of the operand
  14534. * @returns the current updated Vector3
  14535. */
  14536. set(x: number, y: number, z: number): Vector3;
  14537. /**
  14538. * Get the clip factor between two vectors
  14539. * @param vector0 defines the first operand
  14540. * @param vector1 defines the second operand
  14541. * @param axis defines the axis to use
  14542. * @param size defines the size along the axis
  14543. * @returns the clip factor
  14544. */
  14545. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  14546. /**
  14547. * Get angle between two vectors
  14548. * @param vector0 angle between vector0 and vector1
  14549. * @param vector1 angle between vector0 and vector1
  14550. * @param normal direction of the normal
  14551. * @return the angle between vector0 and vector1
  14552. */
  14553. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  14554. /**
  14555. * Returns a new Vector3 set from the index "offset" of the given array
  14556. * @param array defines the source array
  14557. * @param offset defines the offset in the source array
  14558. * @returns the new Vector3
  14559. */
  14560. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  14561. /**
  14562. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  14563. * This function is deprecated. Use FromArray instead
  14564. * @param array defines the source array
  14565. * @param offset defines the offset in the source array
  14566. * @returns the new Vector3
  14567. */
  14568. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  14569. /**
  14570. * Sets the given vector "result" with the element values from the index "offset" of the given array
  14571. * @param array defines the source array
  14572. * @param offset defines the offset in the source array
  14573. * @param result defines the Vector3 where to store the result
  14574. */
  14575. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  14576. /**
  14577. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  14578. * This function is deprecated. Use FromArrayToRef instead.
  14579. * @param array defines the source array
  14580. * @param offset defines the offset in the source array
  14581. * @param result defines the Vector3 where to store the result
  14582. */
  14583. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  14584. /**
  14585. * Sets the given vector "result" with the given floats.
  14586. * @param x defines the x coordinate of the source
  14587. * @param y defines the y coordinate of the source
  14588. * @param z defines the z coordinate of the source
  14589. * @param result defines the Vector3 where to store the result
  14590. */
  14591. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  14592. /**
  14593. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  14594. * @returns a new empty Vector3
  14595. */
  14596. static Zero(): Vector3;
  14597. /**
  14598. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  14599. * @returns a new unit Vector3
  14600. */
  14601. static One(): Vector3;
  14602. /**
  14603. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  14604. * @returns a new up Vector3
  14605. */
  14606. static Up(): Vector3;
  14607. /**
  14608. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  14609. * @returns a new down Vector3
  14610. */
  14611. static Down(): Vector3;
  14612. /**
  14613. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  14614. * @returns a new forward Vector3
  14615. */
  14616. static Forward(): Vector3;
  14617. /**
  14618. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  14619. * @returns a new right Vector3
  14620. */
  14621. static Right(): Vector3;
  14622. /**
  14623. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  14624. * @returns a new left Vector3
  14625. */
  14626. static Left(): Vector3;
  14627. /**
  14628. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  14629. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14630. * @param vector defines the Vector3 to transform
  14631. * @param transformation defines the transformation matrix
  14632. * @returns the transformed Vector3
  14633. */
  14634. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  14635. /**
  14636. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  14637. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14638. * @param vector defines the Vector3 to transform
  14639. * @param transformation defines the transformation matrix
  14640. * @param result defines the Vector3 where to store the result
  14641. */
  14642. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14643. /**
  14644. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  14645. * This method computes tranformed coordinates only, not transformed direction vectors
  14646. * @param x define the x coordinate of the source vector
  14647. * @param y define the y coordinate of the source vector
  14648. * @param z define the z coordinate of the source vector
  14649. * @param transformation defines the transformation matrix
  14650. * @param result defines the Vector3 where to store the result
  14651. */
  14652. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14653. /**
  14654. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  14655. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14656. * @param vector defines the Vector3 to transform
  14657. * @param transformation defines the transformation matrix
  14658. * @returns the new Vector3
  14659. */
  14660. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  14661. /**
  14662. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  14663. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14664. * @param vector defines the Vector3 to transform
  14665. * @param transformation defines the transformation matrix
  14666. * @param result defines the Vector3 where to store the result
  14667. */
  14668. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14669. /**
  14670. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  14671. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14672. * @param x define the x coordinate of the source vector
  14673. * @param y define the y coordinate of the source vector
  14674. * @param z define the z coordinate of the source vector
  14675. * @param transformation defines the transformation matrix
  14676. * @param result defines the Vector3 where to store the result
  14677. */
  14678. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14679. /**
  14680. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  14681. * @param value1 defines the first control point
  14682. * @param value2 defines the second control point
  14683. * @param value3 defines the third control point
  14684. * @param value4 defines the fourth control point
  14685. * @param amount defines the amount on the spline to use
  14686. * @returns the new Vector3
  14687. */
  14688. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  14689. /**
  14690. * 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"
  14691. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  14692. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  14693. * @param value defines the current value
  14694. * @param min defines the lower range value
  14695. * @param max defines the upper range value
  14696. * @returns the new Vector3
  14697. */
  14698. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  14699. /**
  14700. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  14701. * @param value1 defines the first control point
  14702. * @param tangent1 defines the first tangent vector
  14703. * @param value2 defines the second control point
  14704. * @param tangent2 defines the second tangent vector
  14705. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  14706. * @returns the new Vector3
  14707. */
  14708. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  14709. /**
  14710. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  14711. * @param start defines the start value
  14712. * @param end defines the end value
  14713. * @param amount max defines amount between both (between 0 and 1)
  14714. * @returns the new Vector3
  14715. */
  14716. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  14717. /**
  14718. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  14719. * @param start defines the start value
  14720. * @param end defines the end value
  14721. * @param amount max defines amount between both (between 0 and 1)
  14722. * @param result defines the Vector3 where to store the result
  14723. */
  14724. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  14725. /**
  14726. * Returns the dot product (float) between the vectors "left" and "right"
  14727. * @param left defines the left operand
  14728. * @param right defines the right operand
  14729. * @returns the dot product
  14730. */
  14731. static Dot(left: Vector3, right: Vector3): number;
  14732. /**
  14733. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  14734. * The cross product is then orthogonal to both "left" and "right"
  14735. * @param left defines the left operand
  14736. * @param right defines the right operand
  14737. * @returns the cross product
  14738. */
  14739. static Cross(left: Vector3, right: Vector3): Vector3;
  14740. /**
  14741. * Sets the given vector "result" with the cross product of "left" and "right"
  14742. * The cross product is then orthogonal to both "left" and "right"
  14743. * @param left defines the left operand
  14744. * @param right defines the right operand
  14745. * @param result defines the Vector3 where to store the result
  14746. */
  14747. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  14748. /**
  14749. * Returns a new Vector3 as the normalization of the given vector
  14750. * @param vector defines the Vector3 to normalize
  14751. * @returns the new Vector3
  14752. */
  14753. static Normalize(vector: Vector3): Vector3;
  14754. /**
  14755. * Sets the given vector "result" with the normalization of the given first vector
  14756. * @param vector defines the Vector3 to normalize
  14757. * @param result defines the Vector3 where to store the result
  14758. */
  14759. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  14760. private static _viewportMatrixCache;
  14761. /**
  14762. * Project a Vector3 onto screen space
  14763. * @param vector defines the Vector3 to project
  14764. * @param world defines the world matrix to use
  14765. * @param transform defines the transform (view x projection) matrix to use
  14766. * @param viewport defines the screen viewport to use
  14767. * @returns the new Vector3
  14768. */
  14769. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  14770. /**
  14771. * Unproject from screen space to object space
  14772. * @param source defines the screen space Vector3 to use
  14773. * @param viewportWidth defines the current width of the viewport
  14774. * @param viewportHeight defines the current height of the viewport
  14775. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14776. * @param transform defines the transform (view x projection) matrix to use
  14777. * @returns the new Vector3
  14778. */
  14779. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  14780. /**
  14781. * Unproject from screen space to object space
  14782. * @param source defines the screen space Vector3 to use
  14783. * @param viewportWidth defines the current width of the viewport
  14784. * @param viewportHeight defines the current height of the viewport
  14785. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14786. * @param view defines the view matrix to use
  14787. * @param projection defines the projection matrix to use
  14788. * @returns the new Vector3
  14789. */
  14790. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  14791. /**
  14792. * Unproject from screen space to object space
  14793. * @param source defines the screen space Vector3 to use
  14794. * @param viewportWidth defines the current width of the viewport
  14795. * @param viewportHeight defines the current height of the viewport
  14796. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14797. * @param view defines the view matrix to use
  14798. * @param projection defines the projection matrix to use
  14799. * @param result defines the Vector3 where to store the result
  14800. */
  14801. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14802. /**
  14803. * Unproject from screen space to object space
  14804. * @param sourceX defines the screen space x coordinate to use
  14805. * @param sourceY defines the screen space y coordinate to use
  14806. * @param sourceZ defines the screen space z coordinate to use
  14807. * @param viewportWidth defines the current width of the viewport
  14808. * @param viewportHeight defines the current height of the viewport
  14809. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14810. * @param view defines the view matrix to use
  14811. * @param projection defines the projection matrix to use
  14812. * @param result defines the Vector3 where to store the result
  14813. */
  14814. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14815. /**
  14816. * Gets the minimal coordinate values between two Vector3
  14817. * @param left defines the first operand
  14818. * @param right defines the second operand
  14819. * @returns the new Vector3
  14820. */
  14821. static Minimize(left: Vector3, right: Vector3): Vector3;
  14822. /**
  14823. * Gets the maximal coordinate values between two Vector3
  14824. * @param left defines the first operand
  14825. * @param right defines the second operand
  14826. * @returns the new Vector3
  14827. */
  14828. static Maximize(left: Vector3, right: Vector3): Vector3;
  14829. /**
  14830. * Returns the distance between the vectors "value1" and "value2"
  14831. * @param value1 defines the first operand
  14832. * @param value2 defines the second operand
  14833. * @returns the distance
  14834. */
  14835. static Distance(value1: Vector3, value2: Vector3): number;
  14836. /**
  14837. * Returns the squared distance between the vectors "value1" and "value2"
  14838. * @param value1 defines the first operand
  14839. * @param value2 defines the second operand
  14840. * @returns the squared distance
  14841. */
  14842. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  14843. /**
  14844. * Returns a new Vector3 located at the center between "value1" and "value2"
  14845. * @param value1 defines the first operand
  14846. * @param value2 defines the second operand
  14847. * @returns the new Vector3
  14848. */
  14849. static Center(value1: Vector3, value2: Vector3): Vector3;
  14850. /**
  14851. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  14852. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  14853. * to something in order to rotate it from its local system to the given target system
  14854. * Note: axis1, axis2 and axis3 are normalized during this operation
  14855. * @param axis1 defines the first axis
  14856. * @param axis2 defines the second axis
  14857. * @param axis3 defines the third axis
  14858. * @returns a new Vector3
  14859. */
  14860. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  14861. /**
  14862. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  14863. * @param axis1 defines the first axis
  14864. * @param axis2 defines the second axis
  14865. * @param axis3 defines the third axis
  14866. * @param ref defines the Vector3 where to store the result
  14867. */
  14868. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  14869. }
  14870. class Vector4 {
  14871. x: number;
  14872. y: number;
  14873. z: number;
  14874. w: number;
  14875. /**
  14876. * Creates a Vector4 object from the given floats.
  14877. */
  14878. constructor(x: number, y: number, z: number, w: number);
  14879. /**
  14880. * Returns the string with the Vector4 coordinates.
  14881. */
  14882. toString(): string;
  14883. /**
  14884. * Returns the string "Vector4".
  14885. */
  14886. getClassName(): string;
  14887. /**
  14888. * Returns the Vector4 hash code.
  14889. */
  14890. getHashCode(): number;
  14891. /**
  14892. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  14893. */
  14894. asArray(): number[];
  14895. /**
  14896. * Populates the given array from the given index with the Vector4 coordinates.
  14897. * Returns the Vector4.
  14898. */
  14899. toArray(array: FloatArray, index?: number): Vector4;
  14900. /**
  14901. * Adds the given vector to the current Vector4.
  14902. * Returns the updated Vector4.
  14903. */
  14904. addInPlace(otherVector: Vector4): Vector4;
  14905. /**
  14906. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  14907. */
  14908. add(otherVector: Vector4): Vector4;
  14909. /**
  14910. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  14911. * Returns the current Vector4.
  14912. */
  14913. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14914. /**
  14915. * Subtract in place the given vector from the current Vector4.
  14916. * Returns the updated Vector4.
  14917. */
  14918. subtractInPlace(otherVector: Vector4): Vector4;
  14919. /**
  14920. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  14921. */
  14922. subtract(otherVector: Vector4): Vector4;
  14923. /**
  14924. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  14925. * Returns the current Vector4.
  14926. */
  14927. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14928. /**
  14929. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14930. */
  14931. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14932. /**
  14933. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14934. * Returns the current Vector4.
  14935. */
  14936. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14937. /**
  14938. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14939. */
  14940. negate(): Vector4;
  14941. /**
  14942. * Multiplies the current Vector4 coordinates by scale (float).
  14943. * Returns the updated Vector4.
  14944. */
  14945. scaleInPlace(scale: number): Vector4;
  14946. /**
  14947. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14948. */
  14949. scale(scale: number): Vector4;
  14950. /**
  14951. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14952. * Returns the current Vector4.
  14953. */
  14954. scaleToRef(scale: number, result: Vector4): Vector4;
  14955. /**
  14956. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  14957. * @param scale defines the scale factor
  14958. * @param result defines the Vector4 object where to store the result
  14959. * @returns the unmodified current Vector4
  14960. */
  14961. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  14962. /**
  14963. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  14964. */
  14965. equals(otherVector: Vector4): boolean;
  14966. /**
  14967. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  14968. */
  14969. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14970. /**
  14971. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  14972. */
  14973. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14974. /**
  14975. * Multiplies in place the current Vector4 by the given one.
  14976. * Returns the updated Vector4.
  14977. */
  14978. multiplyInPlace(otherVector: Vector4): Vector4;
  14979. /**
  14980. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  14981. */
  14982. multiply(otherVector: Vector4): Vector4;
  14983. /**
  14984. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  14985. * Returns the current Vector4.
  14986. */
  14987. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14988. /**
  14989. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  14990. */
  14991. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14992. /**
  14993. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  14994. */
  14995. divide(otherVector: Vector4): Vector4;
  14996. /**
  14997. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  14998. * Returns the current Vector4.
  14999. */
  15000. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  15001. /**
  15002. * Divides the current Vector3 coordinates by the given ones.
  15003. * @returns the updated Vector3.
  15004. */
  15005. divideInPlace(otherVector: Vector4): Vector4;
  15006. /**
  15007. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  15008. * @param other defines the second operand
  15009. * @returns the current updated Vector4
  15010. */
  15011. minimizeInPlace(other: Vector4): Vector4;
  15012. /**
  15013. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  15014. * @param other defines the second operand
  15015. * @returns the current updated Vector4
  15016. */
  15017. maximizeInPlace(other: Vector4): Vector4;
  15018. /**
  15019. * Gets a new Vector4 from current Vector4 floored values
  15020. * @returns a new Vector4
  15021. */
  15022. floor(): Vector4;
  15023. /**
  15024. * Gets a new Vector4 from current Vector3 floored values
  15025. * @returns a new Vector4
  15026. */
  15027. fract(): Vector4;
  15028. /**
  15029. * Returns the Vector4 length (float).
  15030. */
  15031. length(): number;
  15032. /**
  15033. * Returns the Vector4 squared length (float).
  15034. */
  15035. lengthSquared(): number;
  15036. /**
  15037. * Normalizes in place the Vector4.
  15038. * Returns the updated Vector4.
  15039. */
  15040. normalize(): Vector4;
  15041. /**
  15042. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  15043. */
  15044. toVector3(): Vector3;
  15045. /**
  15046. * Returns a new Vector4 copied from the current one.
  15047. */
  15048. clone(): Vector4;
  15049. /**
  15050. * Updates the current Vector4 with the given one coordinates.
  15051. * Returns the updated Vector4.
  15052. */
  15053. copyFrom(source: Vector4): Vector4;
  15054. /**
  15055. * Updates the current Vector4 coordinates with the given floats.
  15056. * Returns the updated Vector4.
  15057. */
  15058. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  15059. /**
  15060. * Updates the current Vector4 coordinates with the given floats.
  15061. * Returns the updated Vector4.
  15062. */
  15063. set(x: number, y: number, z: number, w: number): Vector4;
  15064. /**
  15065. * Returns a new Vector4 set from the starting index of the given array.
  15066. */
  15067. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  15068. /**
  15069. * Updates the given vector "result" from the starting index of the given array.
  15070. */
  15071. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  15072. /**
  15073. * Updates the given vector "result" from the starting index of the given Float32Array.
  15074. */
  15075. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  15076. /**
  15077. * Updates the given vector "result" coordinates from the given floats.
  15078. */
  15079. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  15080. /**
  15081. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  15082. */
  15083. static Zero(): Vector4;
  15084. /**
  15085. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  15086. */
  15087. static One(): Vector4;
  15088. /**
  15089. * Returns a new normalized Vector4 from the given one.
  15090. */
  15091. static Normalize(vector: Vector4): Vector4;
  15092. /**
  15093. * Updates the given vector "result" from the normalization of the given one.
  15094. */
  15095. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  15096. static Minimize(left: Vector4, right: Vector4): Vector4;
  15097. static Maximize(left: Vector4, right: Vector4): Vector4;
  15098. /**
  15099. * Returns the distance (float) between the vectors "value1" and "value2".
  15100. */
  15101. static Distance(value1: Vector4, value2: Vector4): number;
  15102. /**
  15103. * Returns the squared distance (float) between the vectors "value1" and "value2".
  15104. */
  15105. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  15106. /**
  15107. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  15108. */
  15109. static Center(value1: Vector4, value2: Vector4): Vector4;
  15110. /**
  15111. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  15112. * This methods computes transformed normalized direction vectors only.
  15113. */
  15114. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  15115. /**
  15116. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  15117. * This methods computes transformed normalized direction vectors only.
  15118. */
  15119. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  15120. /**
  15121. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  15122. * This methods computes transformed normalized direction vectors only.
  15123. */
  15124. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  15125. }
  15126. interface ISize {
  15127. width: number;
  15128. height: number;
  15129. }
  15130. class Size implements ISize {
  15131. width: number;
  15132. height: number;
  15133. /**
  15134. * Creates a Size object from the given width and height (floats).
  15135. */
  15136. constructor(width: number, height: number);
  15137. toString(): string;
  15138. /**
  15139. * Returns the string "Size"
  15140. */
  15141. getClassName(): string;
  15142. /**
  15143. * Returns the Size hash code.
  15144. */
  15145. getHashCode(): number;
  15146. /**
  15147. * Updates the current size from the given one.
  15148. * Returns the updated Size.
  15149. */
  15150. copyFrom(src: Size): void;
  15151. /**
  15152. * Updates in place the current Size from the given floats.
  15153. * Returns the updated Size.
  15154. */
  15155. copyFromFloats(width: number, height: number): Size;
  15156. /**
  15157. * Updates in place the current Size from the given floats.
  15158. * Returns the updated Size.
  15159. */
  15160. set(width: number, height: number): Size;
  15161. /**
  15162. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  15163. */
  15164. multiplyByFloats(w: number, h: number): Size;
  15165. /**
  15166. * Returns a new Size copied from the given one.
  15167. */
  15168. clone(): Size;
  15169. /**
  15170. * Boolean : True if the current Size and the given one width and height are strictly equal.
  15171. */
  15172. equals(other: Size): boolean;
  15173. /**
  15174. * Returns the surface of the Size : width * height (float).
  15175. */
  15176. readonly surface: number;
  15177. /**
  15178. * Returns a new Size set to (0.0, 0.0)
  15179. */
  15180. static Zero(): Size;
  15181. /**
  15182. * Returns a new Size set as the addition result of the current Size and the given one.
  15183. */
  15184. add(otherSize: Size): Size;
  15185. /**
  15186. * Returns a new Size set as the subtraction result of the given one from the current Size.
  15187. */
  15188. subtract(otherSize: Size): Size;
  15189. /**
  15190. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  15191. */
  15192. static Lerp(start: Size, end: Size, amount: number): Size;
  15193. }
  15194. /**
  15195. * Class used to store quaternion data
  15196. * @see https://en.wikipedia.org/wiki/Quaternion
  15197. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  15198. */
  15199. class Quaternion {
  15200. /** defines the first component (0 by default) */
  15201. x: number;
  15202. /** defines the second component (0 by default) */
  15203. y: number;
  15204. /** defines the third component (0 by default) */
  15205. z: number;
  15206. /** defines the fourth component (1.0 by default) */
  15207. w: number;
  15208. /**
  15209. * Creates a new Quaternion from the given floats
  15210. * @param x defines the first component (0 by default)
  15211. * @param y defines the second component (0 by default)
  15212. * @param z defines the third component (0 by default)
  15213. * @param w defines the fourth component (1.0 by default)
  15214. */
  15215. constructor(
  15216. /** defines the first component (0 by default) */
  15217. x?: number,
  15218. /** defines the second component (0 by default) */
  15219. y?: number,
  15220. /** defines the third component (0 by default) */
  15221. z?: number,
  15222. /** defines the fourth component (1.0 by default) */
  15223. w?: number);
  15224. /**
  15225. * Gets a string representation for the current quaternion
  15226. * @returns a string with the Quaternion coordinates
  15227. */
  15228. toString(): string;
  15229. /**
  15230. * Gets the class name of the quaternion
  15231. * @returns the string "Quaternion"
  15232. */
  15233. getClassName(): string;
  15234. /**
  15235. * Gets a hash code for this quaternion
  15236. * @returns the quaternion hash code
  15237. */
  15238. getHashCode(): number;
  15239. /**
  15240. * Copy the quaternion to an array
  15241. * @returns a new array populated with 4 elements from the quaternion coordinates
  15242. */
  15243. asArray(): number[];
  15244. /**
  15245. * Check if two quaternions are equals
  15246. * @param otherQuaternion defines the second operand
  15247. * @return true if the current quaternion and the given one coordinates are strictly equals
  15248. */
  15249. equals(otherQuaternion: Quaternion): boolean;
  15250. /**
  15251. * Clone the current quaternion
  15252. * @returns a new quaternion copied from the current one
  15253. */
  15254. clone(): Quaternion;
  15255. /**
  15256. * Copy a quaternion to the current one
  15257. * @param other defines the other quaternion
  15258. * @returns the updated current quaternion
  15259. */
  15260. copyFrom(other: Quaternion): Quaternion;
  15261. /**
  15262. * Updates the current quaternion with the given float coordinates
  15263. * @param x defines the x coordinate
  15264. * @param y defines the y coordinate
  15265. * @param z defines the z coordinate
  15266. * @param w defines the w coordinate
  15267. * @returns the updated current quaternion
  15268. */
  15269. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  15270. /**
  15271. * Updates the current quaternion from the given float coordinates
  15272. * @param x defines the x coordinate
  15273. * @param y defines the y coordinate
  15274. * @param z defines the z coordinate
  15275. * @param w defines the w coordinate
  15276. * @returns the updated current quaternion
  15277. */
  15278. set(x: number, y: number, z: number, w: number): Quaternion;
  15279. /**
  15280. * Adds two quaternions
  15281. * @param other defines the second operand
  15282. * @returns a new quaternion as the addition result of the given one and the current quaternion
  15283. */
  15284. add(other: Quaternion): Quaternion;
  15285. /**
  15286. * Add a quaternion to the current one
  15287. * @param other defines the quaternion to add
  15288. * @returns the current quaternion
  15289. */
  15290. addInPlace(other: Quaternion): Quaternion;
  15291. /**
  15292. * Subtract two quaternions
  15293. * @param other defines the second operand
  15294. * @returns a new quaternion as the subtraction result of the given one from the current one
  15295. */
  15296. subtract(other: Quaternion): Quaternion;
  15297. /**
  15298. * Multiplies the current quaternion by a scale factor
  15299. * @param value defines the scale factor
  15300. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  15301. */
  15302. scale(value: number): Quaternion;
  15303. /**
  15304. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  15305. * @param scale defines the scale factor
  15306. * @param result defines the Quaternion object where to store the result
  15307. * @returns the unmodified current quaternion
  15308. */
  15309. scaleToRef(scale: number, result: Quaternion): Quaternion;
  15310. /**
  15311. * Multiplies in place the current quaternion by a scale factor
  15312. * @param value defines the scale factor
  15313. * @returns the current modified quaternion
  15314. */
  15315. scaleInPlace(value: number): Quaternion;
  15316. /**
  15317. * Scale the current quaternion values by a factor and add the result to a given quaternion
  15318. * @param scale defines the scale factor
  15319. * @param result defines the Quaternion object where to store the result
  15320. * @returns the unmodified current quaternion
  15321. */
  15322. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  15323. /**
  15324. * Multiplies two quaternions
  15325. * @param q1 defines the second operand
  15326. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  15327. */
  15328. multiply(q1: Quaternion): Quaternion;
  15329. /**
  15330. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  15331. * @param q1 defines the second operand
  15332. * @param result defines the target quaternion
  15333. * @returns the current quaternion
  15334. */
  15335. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  15336. /**
  15337. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  15338. * @param q1 defines the second operand
  15339. * @returns the currentupdated quaternion
  15340. */
  15341. multiplyInPlace(q1: Quaternion): Quaternion;
  15342. /**
  15343. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  15344. * @param ref defines the target quaternion
  15345. * @returns the current quaternion
  15346. */
  15347. conjugateToRef(ref: Quaternion): Quaternion;
  15348. /**
  15349. * Conjugates in place (1-q) the current quaternion
  15350. * @returns the current updated quaternion
  15351. */
  15352. conjugateInPlace(): Quaternion;
  15353. /**
  15354. * Conjugates in place (1-q) the current quaternion
  15355. * @returns a new quaternion
  15356. */
  15357. conjugate(): Quaternion;
  15358. /**
  15359. * Gets length of current quaternion
  15360. * @returns the quaternion length (float)
  15361. */
  15362. length(): number;
  15363. /**
  15364. * Normalize in place the current quaternion
  15365. * @returns the current updated quaternion
  15366. */
  15367. normalize(): Quaternion;
  15368. /**
  15369. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  15370. * @param order is a reserved parameter and is ignore for now
  15371. * @returns a new Vector3 containing the Euler angles
  15372. */
  15373. toEulerAngles(order?: string): Vector3;
  15374. /**
  15375. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  15376. * @param result defines the vector which will be filled with the Euler angles
  15377. * @param order is a reserved parameter and is ignore for now
  15378. * @returns the current unchanged quaternion
  15379. */
  15380. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  15381. /**
  15382. * Updates the given rotation matrix with the current quaternion values
  15383. * @param result defines the target matrix
  15384. * @returns the current unchanged quaternion
  15385. */
  15386. toRotationMatrix(result: Matrix): Quaternion;
  15387. /**
  15388. * Updates the current quaternion from the given rotation matrix values
  15389. * @param matrix defines the source matrix
  15390. * @returns the current updated quaternion
  15391. */
  15392. fromRotationMatrix(matrix: Matrix): Quaternion;
  15393. /**
  15394. * Creates a new quaternion from a rotation matrix
  15395. * @param matrix defines the source matrix
  15396. * @returns a new quaternion created from the given rotation matrix values
  15397. */
  15398. static FromRotationMatrix(matrix: Matrix): Quaternion;
  15399. /**
  15400. * Updates the given quaternion with the given rotation matrix values
  15401. * @param matrix defines the source matrix
  15402. * @param result defines the target quaternion
  15403. */
  15404. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  15405. /**
  15406. * Returns the dot product (float) between the quaternions "left" and "right"
  15407. * @param left defines the left operand
  15408. * @param right defines the right operand
  15409. * @returns the dot product
  15410. */
  15411. static Dot(left: Quaternion, right: Quaternion): number;
  15412. /**
  15413. * Checks if the two quaternions are close to each other
  15414. * @param quat0 defines the first quaternion to check
  15415. * @param quat1 defines the second quaternion to check
  15416. * @returns true if the two quaternions are close to each other
  15417. */
  15418. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  15419. /**
  15420. * Creates an empty quaternion
  15421. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  15422. */
  15423. static Zero(): Quaternion;
  15424. /**
  15425. * Inverse a given quaternion
  15426. * @param q defines the source quaternion
  15427. * @returns a new quaternion as the inverted current quaternion
  15428. */
  15429. static Inverse(q: Quaternion): Quaternion;
  15430. /**
  15431. * Creates an identity quaternion
  15432. * @returns the identity quaternion
  15433. */
  15434. static Identity(): Quaternion;
  15435. /**
  15436. * Gets a boolean indicating if the given quaternion is identity
  15437. * @param quaternion defines the quaternion to check
  15438. * @returns true if the quaternion is identity
  15439. */
  15440. static IsIdentity(quaternion: Quaternion): boolean;
  15441. /**
  15442. * Creates a quaternion from a rotation around an axis
  15443. * @param axis defines the axis to use
  15444. * @param angle defines the angle to use
  15445. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  15446. */
  15447. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  15448. /**
  15449. * Creates a rotation around an axis and stores it into the given quaternion
  15450. * @param axis defines the axis to use
  15451. * @param angle defines the angle to use
  15452. * @param result defines the target quaternion
  15453. * @returns the target quaternion
  15454. */
  15455. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  15456. /**
  15457. * Creates a new quaternion from data stored into an array
  15458. * @param array defines the data source
  15459. * @param offset defines the offset in the source array where the data starts
  15460. * @returns a new quaternion
  15461. */
  15462. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  15463. /**
  15464. * Creates a new quaternion from the given Euler float angles (y, x, z)
  15465. * @param yaw defines the rotation around Y axis
  15466. * @param pitch defines the rotation around X axis
  15467. * @param roll defines the rotation around Z axis
  15468. * @returns the new quaternion
  15469. */
  15470. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  15471. /**
  15472. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  15473. * @param yaw defines the rotation around Y axis
  15474. * @param pitch defines the rotation around X axis
  15475. * @param roll defines the rotation around Z axis
  15476. * @param result defines the target quaternion
  15477. */
  15478. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  15479. /**
  15480. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  15481. * @param alpha defines the rotation around first axis
  15482. * @param beta defines the rotation around second axis
  15483. * @param gamma defines the rotation around third axis
  15484. * @returns the new quaternion
  15485. */
  15486. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  15487. /**
  15488. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  15489. * @param alpha defines the rotation around first axis
  15490. * @param beta defines the rotation around second axis
  15491. * @param gamma defines the rotation around third axis
  15492. * @param result defines the target quaternion
  15493. */
  15494. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  15495. /**
  15496. * 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)
  15497. * @param axis1 defines the first axis
  15498. * @param axis2 defines the second axis
  15499. * @param axis3 defines the third axis
  15500. * @returns the new quaternion
  15501. */
  15502. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  15503. /**
  15504. * 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
  15505. * @param axis1 defines the first axis
  15506. * @param axis2 defines the second axis
  15507. * @param axis3 defines the third axis
  15508. * @param ref defines the target quaternion
  15509. */
  15510. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  15511. /**
  15512. * Interpolates between two quaternions
  15513. * @param left defines first quaternion
  15514. * @param right defines second quaternion
  15515. * @param amount defines the gradient to use
  15516. * @returns the new interpolated quaternion
  15517. */
  15518. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  15519. /**
  15520. * Interpolates between two quaternions and stores it into a target quaternion
  15521. * @param left defines first quaternion
  15522. * @param right defines second quaternion
  15523. * @param amount defines the gradient to use
  15524. * @param result defines the target quaternion
  15525. */
  15526. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  15527. /**
  15528. * Interpolate between two quaternions using Hermite interpolation
  15529. * @param value1 defines first quaternion
  15530. * @param tangent1 defines the incoming tangent
  15531. * @param value2 defines second quaternion
  15532. * @param tangent2 defines the outgoing tangent
  15533. * @param amount defines the target quaternion
  15534. * @returns the new interpolated quaternion
  15535. */
  15536. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  15537. }
  15538. /**
  15539. * Class used to store matrix data (4x4)
  15540. */
  15541. class Matrix {
  15542. private static _tempQuaternion;
  15543. private static _xAxis;
  15544. private static _yAxis;
  15545. private static _zAxis;
  15546. private static _updateFlagSeed;
  15547. private static _identityReadOnly;
  15548. private _isIdentity;
  15549. private _isIdentityDirty;
  15550. /**
  15551. * Gets the update flag of the matrix which is an unique number for the matrix.
  15552. * It will be incremented every time the matrix data change.
  15553. * You can use it to speed the comparison between two versions of the same matrix.
  15554. */
  15555. updateFlag: number;
  15556. /**
  15557. * Gets or sets the internal data of the matrix
  15558. */
  15559. m: Float32Array;
  15560. /** @hidden */
  15561. _markAsUpdated(): void;
  15562. /**
  15563. * Creates an empty matrix (filled with zeros)
  15564. */
  15565. constructor();
  15566. /**
  15567. * Check if the current matrix is indentity
  15568. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  15569. * @returns true is the matrix is the identity matrix
  15570. */
  15571. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  15572. /**
  15573. * Gets the determinant of the matrix
  15574. * @returns the matrix determinant
  15575. */
  15576. determinant(): number;
  15577. /**
  15578. * Returns the matrix as a Float32Array
  15579. * @returns the matrix underlying array
  15580. */
  15581. toArray(): Float32Array;
  15582. /**
  15583. * Returns the matrix as a Float32Array
  15584. * @returns the matrix underlying array.
  15585. */
  15586. asArray(): Float32Array;
  15587. /**
  15588. * Inverts the current matrix in place
  15589. * @returns the current inverted matrix
  15590. */
  15591. invert(): Matrix;
  15592. /**
  15593. * Sets all the matrix elements to zero
  15594. * @returns the current matrix
  15595. */
  15596. reset(): Matrix;
  15597. /**
  15598. * Adds the current matrix with a second one
  15599. * @param other defines the matrix to add
  15600. * @returns a new matrix as the addition of the current matrix and the given one
  15601. */
  15602. add(other: Matrix): Matrix;
  15603. /**
  15604. * Sets the given matrix "result" to the addition of the current matrix and the given one
  15605. * @param other defines the matrix to add
  15606. * @param result defines the target matrix
  15607. * @returns the current matrix
  15608. */
  15609. addToRef(other: Matrix, result: Matrix): Matrix;
  15610. /**
  15611. * Adds in place the given matrix to the current matrix
  15612. * @param other defines the second operand
  15613. * @returns the current updated matrix
  15614. */
  15615. addToSelf(other: Matrix): Matrix;
  15616. /**
  15617. * Sets the given matrix to the current inverted Matrix
  15618. * @param other defines the target matrix
  15619. * @returns the unmodified current matrix
  15620. */
  15621. invertToRef(other: Matrix): Matrix;
  15622. /**
  15623. * Inserts the translation vector (using 3 floats) in the current matrix
  15624. * @param x defines the 1st component of the translation
  15625. * @param y defines the 2nd component of the translation
  15626. * @param z defines the 3rd component of the translation
  15627. * @returns the current updated matrix
  15628. */
  15629. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  15630. /**
  15631. * Inserts the translation vector in the current matrix
  15632. * @param vector3 defines the translation to insert
  15633. * @returns the current updated matrix
  15634. */
  15635. setTranslation(vector3: Vector3): Matrix;
  15636. /**
  15637. * Gets the translation value of the current matrix
  15638. * @returns a new Vector3 as the extracted translation from the matrix
  15639. */
  15640. getTranslation(): Vector3;
  15641. /**
  15642. * Fill a Vector3 with the extracted translation from the matrix
  15643. * @param result defines the Vector3 where to store the translation
  15644. * @returns the current matrix
  15645. */
  15646. getTranslationToRef(result: Vector3): Matrix;
  15647. /**
  15648. * Remove rotation and scaling part from the matrix
  15649. * @returns the updated matrix
  15650. */
  15651. removeRotationAndScaling(): Matrix;
  15652. /**
  15653. * Multiply two matrices
  15654. * @param other defines the second operand
  15655. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  15656. */
  15657. multiply(other: Matrix): Matrix;
  15658. /**
  15659. * Copy the current matrix from the given one
  15660. * @param other defines the source matrix
  15661. * @returns the current updated matrix
  15662. */
  15663. copyFrom(other: Matrix): Matrix;
  15664. /**
  15665. * Populates the given array from the starting index with the current matrix values
  15666. * @param array defines the target array
  15667. * @param offset defines the offset in the target array where to start storing values
  15668. * @returns the current matrix
  15669. */
  15670. copyToArray(array: Float32Array, offset?: number): Matrix;
  15671. /**
  15672. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  15673. * @param other defines the second operand
  15674. * @param result defines the matrix where to store the multiplication
  15675. * @returns the current matrix
  15676. */
  15677. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  15678. /**
  15679. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  15680. * @param other defines the second operand
  15681. * @param result defines the array where to store the multiplication
  15682. * @param offset defines the offset in the target array where to start storing values
  15683. * @returns the current matrix
  15684. */
  15685. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  15686. /**
  15687. * Check equality between this matrix and a second one
  15688. * @param value defines the second matrix to compare
  15689. * @returns true is the current matrix and the given one values are strictly equal
  15690. */
  15691. equals(value: Matrix): boolean;
  15692. /**
  15693. * Clone the current matrix
  15694. * @returns a new matrix from the current matrix
  15695. */
  15696. clone(): Matrix;
  15697. /**
  15698. * Returns the name of the current matrix class
  15699. * @returns the string "Matrix"
  15700. */
  15701. getClassName(): string;
  15702. /**
  15703. * Gets the hash code of the current matrix
  15704. * @returns the hash code
  15705. */
  15706. getHashCode(): number;
  15707. /**
  15708. * Decomposes the current Matrix into a translation, rotation and scaling components
  15709. * @param scale defines the scale vector3 given as a reference to update
  15710. * @param rotation defines the rotation quaternion given as a reference to update
  15711. * @param translation defines the translation vector3 given as a reference to update
  15712. * @returns true if operation was successful
  15713. */
  15714. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  15715. /**
  15716. * Gets specific row of the matrix
  15717. * @param index defines the number of the row to get
  15718. * @returns the index-th row of the current matrix as a new Vector4
  15719. */
  15720. getRow(index: number): Nullable<Vector4>;
  15721. /**
  15722. * Sets the index-th row of the current matrix to the vector4 values
  15723. * @param index defines the number of the row to set
  15724. * @param row defines the target vector4
  15725. * @returns the updated current matrix
  15726. */
  15727. setRow(index: number, row: Vector4): Matrix;
  15728. /**
  15729. * Compute the transpose of the matrix
  15730. * @returns the new transposed matrix
  15731. */
  15732. transpose(): Matrix;
  15733. /**
  15734. * Compute the transpose of the matrix and store it in a given matrix
  15735. * @param result defines the target matrix
  15736. * @returns the current matrix
  15737. */
  15738. transposeToRef(result: Matrix): Matrix;
  15739. /**
  15740. * Sets the index-th row of the current matrix with the given 4 x float values
  15741. * @param index defines the row index
  15742. * @param x defines the x component to set
  15743. * @param y defines the y component to set
  15744. * @param z defines the z component to set
  15745. * @param w defines the w component to set
  15746. * @returns the updated current matrix
  15747. */
  15748. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  15749. /**
  15750. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  15751. * @param scale defines the scale factor
  15752. * @returns a new matrix
  15753. */
  15754. scale(scale: number): Matrix;
  15755. /**
  15756. * Scale the current matrix values by a factor to a given result matrix
  15757. * @param scale defines the scale factor
  15758. * @param result defines the matrix to store the result
  15759. * @returns the current matrix
  15760. */
  15761. scaleToRef(scale: number, result: Matrix): Matrix;
  15762. /**
  15763. * Scale the current matrix values by a factor and add the result to a given matrix
  15764. * @param scale defines the scale factor
  15765. * @param result defines the Matrix to store the result
  15766. * @returns the current matrix
  15767. */
  15768. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  15769. /**
  15770. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  15771. * @param ref matrix to store the result
  15772. */
  15773. toNormalMatrix(ref: Matrix): void;
  15774. /**
  15775. * Gets only rotation part of the current matrix
  15776. * @returns a new matrix sets to the extracted rotation matrix from the current one
  15777. */
  15778. getRotationMatrix(): Matrix;
  15779. /**
  15780. * Extracts the rotation matrix from the current one and sets it as the given "result"
  15781. * @param result defines the target matrix to store data to
  15782. * @returns the current matrix
  15783. */
  15784. getRotationMatrixToRef(result: Matrix): Matrix;
  15785. /**
  15786. * Creates a matrix from an array
  15787. * @param array defines the source array
  15788. * @param offset defines an offset in the source array
  15789. * @returns a new Matrix set from the starting index of the given array
  15790. */
  15791. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  15792. /**
  15793. * Copy the content of an array into a given matrix
  15794. * @param array defines the source array
  15795. * @param offset defines an offset in the source array
  15796. * @param result defines the target matrix
  15797. */
  15798. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  15799. /**
  15800. * Stores an array into a matrix after having multiplied each component by a given factor
  15801. * @param array defines the source array
  15802. * @param offset defines the offset in the source array
  15803. * @param scale defines the scaling factor
  15804. * @param result defines the target matrix
  15805. */
  15806. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  15807. /**
  15808. * Stores a list of values (16) inside a given matrix
  15809. * @param initialM11 defines 1st value of 1st row
  15810. * @param initialM12 defines 2nd value of 1st row
  15811. * @param initialM13 defines 3rd value of 1st row
  15812. * @param initialM14 defines 4th value of 1st row
  15813. * @param initialM21 defines 1st value of 2nd row
  15814. * @param initialM22 defines 2nd value of 2nd row
  15815. * @param initialM23 defines 3rd value of 2nd row
  15816. * @param initialM24 defines 4th value of 2nd row
  15817. * @param initialM31 defines 1st value of 3rd row
  15818. * @param initialM32 defines 2nd value of 3rd row
  15819. * @param initialM33 defines 3rd value of 3rd row
  15820. * @param initialM34 defines 4th value of 3rd row
  15821. * @param initialM41 defines 1st value of 4th row
  15822. * @param initialM42 defines 2nd value of 4th row
  15823. * @param initialM43 defines 3rd value of 4th row
  15824. * @param initialM44 defines 4th value of 4th row
  15825. * @param result defines the target matrix
  15826. */
  15827. 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;
  15828. /**
  15829. * Gets an identity matrix that must not be updated
  15830. */
  15831. static readonly IdentityReadOnly: Matrix;
  15832. /**
  15833. * Creates new matrix from a list of values (16)
  15834. * @param initialM11 defines 1st value of 1st row
  15835. * @param initialM12 defines 2nd value of 1st row
  15836. * @param initialM13 defines 3rd value of 1st row
  15837. * @param initialM14 defines 4th value of 1st row
  15838. * @param initialM21 defines 1st value of 2nd row
  15839. * @param initialM22 defines 2nd value of 2nd row
  15840. * @param initialM23 defines 3rd value of 2nd row
  15841. * @param initialM24 defines 4th value of 2nd row
  15842. * @param initialM31 defines 1st value of 3rd row
  15843. * @param initialM32 defines 2nd value of 3rd row
  15844. * @param initialM33 defines 3rd value of 3rd row
  15845. * @param initialM34 defines 4th value of 3rd row
  15846. * @param initialM41 defines 1st value of 4th row
  15847. * @param initialM42 defines 2nd value of 4th row
  15848. * @param initialM43 defines 3rd value of 4th row
  15849. * @param initialM44 defines 4th value of 4th row
  15850. * @returns the new matrix
  15851. */
  15852. 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;
  15853. /**
  15854. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15855. * @param scale defines the scale vector3
  15856. * @param rotation defines the rotation quaternion
  15857. * @param translation defines the translation vector3
  15858. * @returns a new matrix
  15859. */
  15860. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  15861. /**
  15862. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15863. * @param scale defines the scale vector3
  15864. * @param rotation defines the rotation quaternion
  15865. * @param translation defines the translation vector3
  15866. * @param result defines the target matrix
  15867. */
  15868. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  15869. /**
  15870. * Creates a new identity matrix
  15871. * @returns a new identity matrix
  15872. */
  15873. static Identity(): Matrix;
  15874. /**
  15875. * Creates a new identity matrix and stores the result in a given matrix
  15876. * @param result defines the target matrix
  15877. */
  15878. static IdentityToRef(result: Matrix): void;
  15879. /**
  15880. * Creates a new zero matrix
  15881. * @returns a new zero matrix
  15882. */
  15883. static Zero(): Matrix;
  15884. /**
  15885. * Creates a new rotation matrix for "angle" radians around the X axis
  15886. * @param angle defines the angle (in radians) to use
  15887. * @return the new matrix
  15888. */
  15889. static RotationX(angle: number): Matrix;
  15890. /**
  15891. * Creates a new matrix as the invert of a given matrix
  15892. * @param source defines the source matrix
  15893. * @returns the new matrix
  15894. */
  15895. static Invert(source: Matrix): Matrix;
  15896. /**
  15897. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  15898. * @param angle defines the angle (in radians) to use
  15899. * @param result defines the target matrix
  15900. */
  15901. static RotationXToRef(angle: number, result: Matrix): void;
  15902. /**
  15903. * Creates a new rotation matrix for "angle" radians around the Y axis
  15904. * @param angle defines the angle (in radians) to use
  15905. * @return the new matrix
  15906. */
  15907. static RotationY(angle: number): Matrix;
  15908. /**
  15909. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  15910. * @param angle defines the angle (in radians) to use
  15911. * @param result defines the target matrix
  15912. */
  15913. static RotationYToRef(angle: number, result: Matrix): void;
  15914. /**
  15915. * Creates a new rotation matrix for "angle" radians around the Z axis
  15916. * @param angle defines the angle (in radians) to use
  15917. * @return the new matrix
  15918. */
  15919. static RotationZ(angle: number): Matrix;
  15920. /**
  15921. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  15922. * @param angle defines the angle (in radians) to use
  15923. * @param result defines the target matrix
  15924. */
  15925. static RotationZToRef(angle: number, result: Matrix): void;
  15926. /**
  15927. * Creates a new rotation matrix for "angle" radians around the given axis
  15928. * @param axis defines the axis to use
  15929. * @param angle defines the angle (in radians) to use
  15930. * @return the new matrix
  15931. */
  15932. static RotationAxis(axis: Vector3, angle: number): Matrix;
  15933. /**
  15934. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  15935. * @param axis defines the axis to use
  15936. * @param angle defines the angle (in radians) to use
  15937. * @param result defines the target matrix
  15938. */
  15939. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  15940. /**
  15941. * Creates a rotation matrix
  15942. * @param yaw defines the yaw angle in radians (Y axis)
  15943. * @param pitch defines the pitch angle in radians (X axis)
  15944. * @param roll defines the roll angle in radians (X axis)
  15945. * @returns the new rotation matrix
  15946. */
  15947. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  15948. /**
  15949. * Creates a rotation matrix and stores it in a given matrix
  15950. * @param yaw defines the yaw angle in radians (Y axis)
  15951. * @param pitch defines the pitch angle in radians (X axis)
  15952. * @param roll defines the roll angle in radians (X axis)
  15953. * @param result defines the target matrix
  15954. */
  15955. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  15956. /**
  15957. * Creates a scaling matrix
  15958. * @param x defines the scale factor on X axis
  15959. * @param y defines the scale factor on Y axis
  15960. * @param z defines the scale factor on Z axis
  15961. * @returns the new matrix
  15962. */
  15963. static Scaling(x: number, y: number, z: number): Matrix;
  15964. /**
  15965. * Creates a scaling matrix and stores it in a given matrix
  15966. * @param x defines the scale factor on X axis
  15967. * @param y defines the scale factor on Y axis
  15968. * @param z defines the scale factor on Z axis
  15969. * @param result defines the target matrix
  15970. */
  15971. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  15972. /**
  15973. * Creates a translation matrix
  15974. * @param x defines the translation on X axis
  15975. * @param y defines the translation on Y axis
  15976. * @param z defines the translationon Z axis
  15977. * @returns the new matrix
  15978. */
  15979. static Translation(x: number, y: number, z: number): Matrix;
  15980. /**
  15981. * Creates a translation matrix and stores it in a given matrix
  15982. * @param x defines the translation on X axis
  15983. * @param y defines the translation on Y axis
  15984. * @param z defines the translationon Z axis
  15985. * @param result defines the target matrix
  15986. */
  15987. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  15988. /**
  15989. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15990. * @param startValue defines the start value
  15991. * @param endValue defines the end value
  15992. * @param gradient defines the gradient factor
  15993. * @returns the new matrix
  15994. */
  15995. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15996. /**
  15997. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15998. * @param startValue defines the start value
  15999. * @param endValue defines the end value
  16000. * @param gradient defines the gradient factor
  16001. * @param result defines the Matrix object where to store data
  16002. */
  16003. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  16004. /**
  16005. * Builds a new matrix whose values are computed by:
  16006. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  16007. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  16008. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  16009. * @param startValue defines the first matrix
  16010. * @param endValue defines the second matrix
  16011. * @param gradient defines the gradient between the two matrices
  16012. * @returns the new matrix
  16013. */
  16014. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  16015. /**
  16016. * Update a matrix to values which are computed by:
  16017. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  16018. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  16019. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  16020. * @param startValue defines the first matrix
  16021. * @param endValue defines the second matrix
  16022. * @param gradient defines the gradient between the two matrices
  16023. * @param result defines the target matrix
  16024. */
  16025. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  16026. /**
  16027. * 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"
  16028. * This function works in left handed mode
  16029. * @param eye defines the final position of the entity
  16030. * @param target defines where the entity should look at
  16031. * @param up defines the up vector for the entity
  16032. * @returns the new matrix
  16033. */
  16034. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16035. /**
  16036. * 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".
  16037. * This function works in left handed mode
  16038. * @param eye defines the final position of the entity
  16039. * @param target defines where the entity should look at
  16040. * @param up defines the up vector for the entity
  16041. * @param result defines the target matrix
  16042. */
  16043. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16044. /**
  16045. * 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"
  16046. * This function works in right handed mode
  16047. * @param eye defines the final position of the entity
  16048. * @param target defines where the entity should look at
  16049. * @param up defines the up vector for the entity
  16050. * @returns the new matrix
  16051. */
  16052. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16053. /**
  16054. * 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".
  16055. * This function works in right handed mode
  16056. * @param eye defines the final position of the entity
  16057. * @param target defines where the entity should look at
  16058. * @param up defines the up vector for the entity
  16059. * @param result defines the target matrix
  16060. */
  16061. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16062. /**
  16063. * Create a left-handed orthographic projection matrix
  16064. * @param width defines the viewport width
  16065. * @param height defines the viewport height
  16066. * @param znear defines the near clip plane
  16067. * @param zfar defines the far clip plane
  16068. * @returns a new matrix as a left-handed orthographic projection matrix
  16069. */
  16070. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16071. /**
  16072. * Store a left-handed orthographic projection to a given matrix
  16073. * @param width defines the viewport width
  16074. * @param height defines the viewport height
  16075. * @param znear defines the near clip plane
  16076. * @param zfar defines the far clip plane
  16077. * @param result defines the target matrix
  16078. */
  16079. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  16080. /**
  16081. * Create a left-handed orthographic projection matrix
  16082. * @param left defines the viewport left coordinate
  16083. * @param right defines the viewport right coordinate
  16084. * @param bottom defines the viewport bottom coordinate
  16085. * @param top defines the viewport top coordinate
  16086. * @param znear defines the near clip plane
  16087. * @param zfar defines the far clip plane
  16088. * @returns a new matrix as a left-handed orthographic projection matrix
  16089. */
  16090. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16091. /**
  16092. * Stores a left-handed orthographic projection into a given matrix
  16093. * @param left defines the viewport left coordinate
  16094. * @param right defines the viewport right coordinate
  16095. * @param bottom defines the viewport bottom coordinate
  16096. * @param top defines the viewport top coordinate
  16097. * @param znear defines the near clip plane
  16098. * @param zfar defines the far clip plane
  16099. * @param result defines the target matrix
  16100. */
  16101. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16102. /**
  16103. * Creates a right-handed orthographic projection matrix
  16104. * @param left defines the viewport left coordinate
  16105. * @param right defines the viewport right coordinate
  16106. * @param bottom defines the viewport bottom coordinate
  16107. * @param top defines the viewport top coordinate
  16108. * @param znear defines the near clip plane
  16109. * @param zfar defines the far clip plane
  16110. * @returns a new matrix as a right-handed orthographic projection matrix
  16111. */
  16112. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16113. /**
  16114. * Stores a right-handed orthographic projection into a given matrix
  16115. * @param left defines the viewport left coordinate
  16116. * @param right defines the viewport right coordinate
  16117. * @param bottom defines the viewport bottom coordinate
  16118. * @param top defines the viewport top coordinate
  16119. * @param znear defines the near clip plane
  16120. * @param zfar defines the far clip plane
  16121. * @param result defines the target matrix
  16122. */
  16123. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16124. /**
  16125. * Creates a left-handed perspective projection matrix
  16126. * @param width defines the viewport width
  16127. * @param height defines the viewport height
  16128. * @param znear defines the near clip plane
  16129. * @param zfar defines the far clip plane
  16130. * @returns a new matrix as a left-handed perspective projection matrix
  16131. */
  16132. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16133. /**
  16134. * Creates a left-handed perspective projection matrix
  16135. * @param fov defines the horizontal field of view
  16136. * @param aspect defines the aspect ratio
  16137. * @param znear defines the near clip plane
  16138. * @param zfar defines the far clip plane
  16139. * @returns a new matrix as a left-handed perspective projection matrix
  16140. */
  16141. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16142. /**
  16143. * Stores a left-handed perspective projection into a given matrix
  16144. * @param fov defines the horizontal field of view
  16145. * @param aspect defines the aspect ratio
  16146. * @param znear defines the near clip plane
  16147. * @param zfar defines the far clip plane
  16148. * @param result defines the target matrix
  16149. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  16150. */
  16151. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16152. /**
  16153. * Creates a right-handed perspective projection matrix
  16154. * @param fov defines the horizontal field of view
  16155. * @param aspect defines the aspect ratio
  16156. * @param znear defines the near clip plane
  16157. * @param zfar defines the far clip plane
  16158. * @returns a new matrix as a right-handed perspective projection matrix
  16159. */
  16160. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16161. /**
  16162. * Stores a right-handed perspective projection into a given matrix
  16163. * @param fov defines the horizontal field of view
  16164. * @param aspect defines the aspect ratio
  16165. * @param znear defines the near clip plane
  16166. * @param zfar defines the far clip plane
  16167. * @param result defines the target matrix
  16168. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  16169. */
  16170. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16171. /**
  16172. * Stores a perspective projection for WebVR info a given matrix
  16173. * @param fov defines the field of view
  16174. * @param znear defines the near clip plane
  16175. * @param zfar defines the far clip plane
  16176. * @param result defines the target matrix
  16177. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  16178. */
  16179. static PerspectiveFovWebVRToRef(fov: {
  16180. upDegrees: number;
  16181. downDegrees: number;
  16182. leftDegrees: number;
  16183. rightDegrees: number;
  16184. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  16185. /**
  16186. * Computes a complete transformation matrix
  16187. * @param viewport defines the viewport to use
  16188. * @param world defines the world matrix
  16189. * @param view defines the view matrix
  16190. * @param projection defines the projection matrix
  16191. * @param zmin defines the near clip plane
  16192. * @param zmax defines the far clip plane
  16193. * @returns the transformation matrix
  16194. */
  16195. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  16196. /**
  16197. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  16198. * @param matrix defines the matrix to use
  16199. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  16200. */
  16201. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  16202. /**
  16203. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  16204. * @param matrix defines the matrix to use
  16205. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  16206. */
  16207. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  16208. /**
  16209. * Compute the transpose of a given matrix
  16210. * @param matrix defines the matrix to transpose
  16211. * @returns the new matrix
  16212. */
  16213. static Transpose(matrix: Matrix): Matrix;
  16214. /**
  16215. * Compute the transpose of a matrix and store it in a target matrix
  16216. * @param matrix defines the matrix to transpose
  16217. * @param result defines the target matrix
  16218. */
  16219. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  16220. /**
  16221. * Computes a reflection matrix from a plane
  16222. * @param plane defines the reflection plane
  16223. * @returns a new matrix
  16224. */
  16225. static Reflection(plane: Plane): Matrix;
  16226. /**
  16227. * Computes a reflection matrix from a plane
  16228. * @param plane defines the reflection plane
  16229. * @param result defines the target matrix
  16230. */
  16231. static ReflectionToRef(plane: Plane, result: Matrix): void;
  16232. /**
  16233. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  16234. * @param xaxis defines the value of the 1st axis
  16235. * @param yaxis defines the value of the 2nd axis
  16236. * @param zaxis defines the value of the 3rd axis
  16237. * @param result defines the target matrix
  16238. */
  16239. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  16240. /**
  16241. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  16242. * @param quat defines the quaternion to use
  16243. * @param result defines the target matrix
  16244. */
  16245. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  16246. }
  16247. class Plane {
  16248. normal: Vector3;
  16249. d: number;
  16250. /**
  16251. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  16252. */
  16253. constructor(a: number, b: number, c: number, d: number);
  16254. /**
  16255. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  16256. */
  16257. asArray(): number[];
  16258. /**
  16259. * Returns a new plane copied from the current Plane.
  16260. */
  16261. clone(): Plane;
  16262. /**
  16263. * Returns the string "Plane".
  16264. */
  16265. getClassName(): string;
  16266. /**
  16267. * Returns the Plane hash code.
  16268. */
  16269. getHashCode(): number;
  16270. /**
  16271. * Normalize the current Plane in place.
  16272. * Returns the updated Plane.
  16273. */
  16274. normalize(): Plane;
  16275. /**
  16276. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  16277. */
  16278. transform(transformation: Matrix): Plane;
  16279. /**
  16280. * Returns the dot product (float) of the point coordinates and the plane normal.
  16281. */
  16282. dotCoordinate(point: Vector3): number;
  16283. /**
  16284. * Updates the current Plane from the plane defined by the three given points.
  16285. * Returns the updated Plane.
  16286. */
  16287. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16288. /**
  16289. * Boolean : True is the vector "direction" is the same side than the plane normal.
  16290. */
  16291. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  16292. /**
  16293. * Returns the signed distance (float) from the given point to the Plane.
  16294. */
  16295. signedDistanceTo(point: Vector3): number;
  16296. /**
  16297. * Returns a new Plane from the given array.
  16298. */
  16299. static FromArray(array: ArrayLike<number>): Plane;
  16300. /**
  16301. * Returns a new Plane defined by the three given points.
  16302. */
  16303. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16304. /**
  16305. * Returns a new Plane the normal vector to this plane at the given origin point.
  16306. * Note : the vector "normal" is updated because normalized.
  16307. */
  16308. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  16309. /**
  16310. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  16311. */
  16312. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  16313. }
  16314. class Viewport {
  16315. x: number;
  16316. y: number;
  16317. width: number;
  16318. height: number;
  16319. /**
  16320. * Creates a Viewport object located at (x, y) and sized (width, height).
  16321. */
  16322. constructor(x: number, y: number, width: number, height: number);
  16323. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  16324. /**
  16325. * Returns a new Viewport copied from the current one.
  16326. */
  16327. clone(): Viewport;
  16328. }
  16329. class Frustum {
  16330. /**
  16331. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  16332. */
  16333. static GetPlanes(transform: Matrix): Plane[];
  16334. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16335. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16336. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16337. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16338. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16339. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16340. /**
  16341. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  16342. */
  16343. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  16344. }
  16345. /** Defines supported spaces */
  16346. enum Space {
  16347. /** Local (object) space */
  16348. LOCAL = 0,
  16349. /** World space */
  16350. WORLD = 1,
  16351. /** Bone space */
  16352. BONE = 2
  16353. }
  16354. /** Defines the 3 main axes */
  16355. class Axis {
  16356. /** X axis */
  16357. static X: Vector3;
  16358. /** Y axis */
  16359. static Y: Vector3;
  16360. /** Z axis */
  16361. static Z: Vector3;
  16362. }
  16363. class BezierCurve {
  16364. /**
  16365. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  16366. */
  16367. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  16368. }
  16369. /**
  16370. * Defines potential orientation for back face culling
  16371. */
  16372. enum Orientation {
  16373. /**
  16374. * Clockwise
  16375. */
  16376. CW = 0,
  16377. /** Counter clockwise */
  16378. CCW = 1
  16379. }
  16380. /**
  16381. * Defines angle representation
  16382. */
  16383. class Angle {
  16384. private _radians;
  16385. /**
  16386. * Creates an Angle object of "radians" radians (float).
  16387. */
  16388. constructor(radians: number);
  16389. /**
  16390. * Get value in degrees
  16391. * @returns the Angle value in degrees (float)
  16392. */
  16393. degrees(): number;
  16394. /**
  16395. * Get value in radians
  16396. * @returns the Angle value in radians (float)
  16397. */
  16398. radians(): number;
  16399. /**
  16400. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  16401. * @param a defines first vector
  16402. * @param b defines second vector
  16403. * @returns a new Angle
  16404. */
  16405. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  16406. /**
  16407. * Gets a new Angle object from the given float in radians
  16408. * @param radians defines the angle value in radians
  16409. * @returns a new Angle
  16410. */
  16411. static FromRadians(radians: number): Angle;
  16412. /**
  16413. * Gets a new Angle object from the given float in degrees
  16414. * @param degrees defines the angle value in degrees
  16415. * @returns a new Angle
  16416. */
  16417. static FromDegrees(degrees: number): Angle;
  16418. }
  16419. class Arc2 {
  16420. startPoint: Vector2;
  16421. midPoint: Vector2;
  16422. endPoint: Vector2;
  16423. centerPoint: Vector2;
  16424. radius: number;
  16425. angle: Angle;
  16426. startAngle: Angle;
  16427. orientation: Orientation;
  16428. /**
  16429. * Creates an Arc object from the three given points : start, middle and end.
  16430. */
  16431. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  16432. }
  16433. class Path2 {
  16434. private _points;
  16435. private _length;
  16436. closed: boolean;
  16437. /**
  16438. * Creates a Path2 object from the starting 2D coordinates x and y.
  16439. */
  16440. constructor(x: number, y: number);
  16441. /**
  16442. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  16443. * Returns the updated Path2.
  16444. */
  16445. addLineTo(x: number, y: number): Path2;
  16446. /**
  16447. * 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.
  16448. * Returns the updated Path2.
  16449. */
  16450. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  16451. /**
  16452. * Closes the Path2.
  16453. * Returns the Path2.
  16454. */
  16455. close(): Path2;
  16456. /**
  16457. * Returns the Path2 total length (float).
  16458. */
  16459. length(): number;
  16460. /**
  16461. * Returns the Path2 internal array of points.
  16462. */
  16463. getPoints(): Vector2[];
  16464. /**
  16465. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  16466. */
  16467. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  16468. /**
  16469. * Returns a new Path2 starting at the coordinates (x, y).
  16470. */
  16471. static StartingAt(x: number, y: number): Path2;
  16472. }
  16473. class Path3D {
  16474. path: Vector3[];
  16475. private _curve;
  16476. private _distances;
  16477. private _tangents;
  16478. private _normals;
  16479. private _binormals;
  16480. private _raw;
  16481. /**
  16482. * new Path3D(path, normal, raw)
  16483. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  16484. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  16485. * path : an array of Vector3, the curve axis of the Path3D
  16486. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  16487. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  16488. */
  16489. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  16490. /**
  16491. * Returns the Path3D array of successive Vector3 designing its curve.
  16492. */
  16493. getCurve(): Vector3[];
  16494. /**
  16495. * Returns an array populated with tangent vectors on each Path3D curve point.
  16496. */
  16497. getTangents(): Vector3[];
  16498. /**
  16499. * Returns an array populated with normal vectors on each Path3D curve point.
  16500. */
  16501. getNormals(): Vector3[];
  16502. /**
  16503. * Returns an array populated with binormal vectors on each Path3D curve point.
  16504. */
  16505. getBinormals(): Vector3[];
  16506. /**
  16507. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  16508. */
  16509. getDistances(): number[];
  16510. /**
  16511. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  16512. * Returns the same object updated.
  16513. */
  16514. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  16515. private _compute;
  16516. private _getFirstNonNullVector;
  16517. private _getLastNonNullVector;
  16518. private _normalVector;
  16519. }
  16520. class Curve3 {
  16521. private _points;
  16522. private _length;
  16523. /**
  16524. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  16525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  16526. * @param v1 (Vector3) the control point
  16527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  16528. * @param nbPoints (integer) the wanted number of points in the curve
  16529. */
  16530. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  16531. /**
  16532. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  16533. * @param v0 (Vector3) the origin point of the Cubic Bezier
  16534. * @param v1 (Vector3) the first control point
  16535. * @param v2 (Vector3) the second control point
  16536. * @param v3 (Vector3) the end point of the Cubic Bezier
  16537. * @param nbPoints (integer) the wanted number of points in the curve
  16538. */
  16539. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  16540. /**
  16541. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  16542. * @param p1 (Vector3) the origin point of the Hermite Spline
  16543. * @param t1 (Vector3) the tangent vector at the origin point
  16544. * @param p2 (Vector3) the end point of the Hermite Spline
  16545. * @param t2 (Vector3) the tangent vector at the end point
  16546. * @param nbPoints (integer) the wanted number of points in the curve
  16547. */
  16548. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  16549. /**
  16550. * Returns a Curve3 object along a CatmullRom Spline curve :
  16551. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  16552. * @param nbPoints (integer) the wanted number of points between each curve control points
  16553. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  16554. */
  16555. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  16556. /**
  16557. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  16558. * A Curve3 is designed from a series of successive Vector3.
  16559. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  16560. */
  16561. constructor(points: Vector3[]);
  16562. /**
  16563. * Returns the Curve3 stored array of successive Vector3
  16564. */
  16565. getPoints(): Vector3[];
  16566. /**
  16567. * Returns the computed length (float) of the curve.
  16568. */
  16569. length(): number;
  16570. /**
  16571. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  16572. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  16573. * curveA and curveB keep unchanged.
  16574. */
  16575. continue(curve: Curve3): Curve3;
  16576. private _computeLength;
  16577. }
  16578. class PositionNormalVertex {
  16579. position: Vector3;
  16580. normal: Vector3;
  16581. constructor(position?: Vector3, normal?: Vector3);
  16582. clone(): PositionNormalVertex;
  16583. }
  16584. class PositionNormalTextureVertex {
  16585. position: Vector3;
  16586. normal: Vector3;
  16587. uv: Vector2;
  16588. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  16589. clone(): PositionNormalTextureVertex;
  16590. }
  16591. class Tmp {
  16592. static Color3: Color3[];
  16593. static Color4: Color4[];
  16594. static Vector2: Vector2[];
  16595. static Vector3: Vector3[];
  16596. static Vector4: Vector4[];
  16597. static Quaternion: Quaternion[];
  16598. static Matrix: Matrix[];
  16599. }
  16600. }
  16601. declare module BABYLON {
  16602. /**
  16603. * Class representing spherical polynomial coefficients to the 3rd degree
  16604. */
  16605. class SphericalPolynomial {
  16606. /**
  16607. * The x coefficients of the spherical polynomial
  16608. */
  16609. x: Vector3;
  16610. /**
  16611. * The y coefficients of the spherical polynomial
  16612. */
  16613. y: Vector3;
  16614. /**
  16615. * The z coefficients of the spherical polynomial
  16616. */
  16617. z: Vector3;
  16618. /**
  16619. * The xx coefficients of the spherical polynomial
  16620. */
  16621. xx: Vector3;
  16622. /**
  16623. * The yy coefficients of the spherical polynomial
  16624. */
  16625. yy: Vector3;
  16626. /**
  16627. * The zz coefficients of the spherical polynomial
  16628. */
  16629. zz: Vector3;
  16630. /**
  16631. * The xy coefficients of the spherical polynomial
  16632. */
  16633. xy: Vector3;
  16634. /**
  16635. * The yz coefficients of the spherical polynomial
  16636. */
  16637. yz: Vector3;
  16638. /**
  16639. * The zx coefficients of the spherical polynomial
  16640. */
  16641. zx: Vector3;
  16642. /**
  16643. * Adds an ambient color to the spherical polynomial
  16644. * @param color the color to add
  16645. */
  16646. addAmbient(color: Color3): void;
  16647. /**
  16648. * Scales the spherical polynomial by the given amount
  16649. * @param scale the amount to scale
  16650. */
  16651. scale(scale: number): void;
  16652. /**
  16653. * Gets the spherical polynomial from harmonics
  16654. * @param harmonics the spherical harmonics
  16655. * @returns the spherical polynomial
  16656. */
  16657. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  16658. /**
  16659. * Constructs a spherical polynomial from an array.
  16660. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  16661. * @returns the spherical polynomial
  16662. */
  16663. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  16664. }
  16665. /**
  16666. * Class representing spherical harmonics coefficients to the 3rd degree
  16667. */
  16668. class SphericalHarmonics {
  16669. /**
  16670. * The l0,0 coefficients of the spherical harmonics
  16671. */
  16672. l00: Vector3;
  16673. /**
  16674. * The l1,-1 coefficients of the spherical harmonics
  16675. */
  16676. l1_1: Vector3;
  16677. /**
  16678. * The l1,0 coefficients of the spherical harmonics
  16679. */
  16680. l10: Vector3;
  16681. /**
  16682. * The l1,1 coefficients of the spherical harmonics
  16683. */
  16684. l11: Vector3;
  16685. /**
  16686. * The l2,-2 coefficients of the spherical harmonics
  16687. */
  16688. l2_2: Vector3;
  16689. /**
  16690. * The l2,-1 coefficients of the spherical harmonics
  16691. */
  16692. l2_1: Vector3;
  16693. /**
  16694. * The l2,0 coefficients of the spherical harmonics
  16695. */
  16696. l20: Vector3;
  16697. /**
  16698. * The l2,1 coefficients of the spherical harmonics
  16699. */
  16700. l21: Vector3;
  16701. /**
  16702. * The l2,2 coefficients of the spherical harmonics
  16703. */
  16704. lL22: Vector3;
  16705. /**
  16706. * Adds a light to the spherical harmonics
  16707. * @param direction the direction of the light
  16708. * @param color the color of the light
  16709. * @param deltaSolidAngle the delta solid angle of the light
  16710. */
  16711. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  16712. /**
  16713. * Scales the spherical harmonics by the given amount
  16714. * @param scale the amount to scale
  16715. */
  16716. scale(scale: number): void;
  16717. /**
  16718. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  16719. *
  16720. * ```
  16721. * E_lm = A_l * L_lm
  16722. * ```
  16723. *
  16724. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  16725. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  16726. * the scaling factors are given in equation 9.
  16727. */
  16728. convertIncidentRadianceToIrradiance(): void;
  16729. /**
  16730. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  16731. *
  16732. * ```
  16733. * L = (1/pi) * E * rho
  16734. * ```
  16735. *
  16736. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  16737. */
  16738. convertIrradianceToLambertianRadiance(): void;
  16739. /**
  16740. * Gets the spherical harmonics from polynomial
  16741. * @param polynomial the spherical polynomial
  16742. * @returns the spherical harmonics
  16743. */
  16744. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  16745. /**
  16746. * Constructs a spherical harmonics from an array.
  16747. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  16748. * @returns the spherical harmonics
  16749. */
  16750. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  16751. }
  16752. }
  16753. declare module BABYLON {
  16754. /**
  16755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16757. * 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;
  16758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16759. */
  16760. class ColorCurves {
  16761. private _dirty;
  16762. private _tempColor;
  16763. private _globalCurve;
  16764. private _highlightsCurve;
  16765. private _midtonesCurve;
  16766. private _shadowsCurve;
  16767. private _positiveCurve;
  16768. private _negativeCurve;
  16769. private _globalHue;
  16770. private _globalDensity;
  16771. private _globalSaturation;
  16772. private _globalExposure;
  16773. /**
  16774. * Gets the global Hue value.
  16775. * 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).
  16776. */
  16777. /**
  16778. * Sets the global Hue value.
  16779. * 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).
  16780. */
  16781. globalHue: number;
  16782. /**
  16783. * Gets the global Density value.
  16784. * 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.
  16785. * Values less than zero provide a filter of opposite hue.
  16786. */
  16787. /**
  16788. * Sets the global Density value.
  16789. * 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.
  16790. * Values less than zero provide a filter of opposite hue.
  16791. */
  16792. globalDensity: number;
  16793. /**
  16794. * Gets the global Saturation value.
  16795. * 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.
  16796. */
  16797. /**
  16798. * Sets the global Saturation value.
  16799. * 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.
  16800. */
  16801. globalSaturation: number;
  16802. /**
  16803. * Gets the global Exposure value.
  16804. * 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.
  16805. */
  16806. /**
  16807. * Sets the global Exposure value.
  16808. * 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.
  16809. */
  16810. globalExposure: number;
  16811. private _highlightsHue;
  16812. private _highlightsDensity;
  16813. private _highlightsSaturation;
  16814. private _highlightsExposure;
  16815. /**
  16816. * Gets the highlights Hue value.
  16817. * 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).
  16818. */
  16819. /**
  16820. * Sets the highlights Hue value.
  16821. * 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).
  16822. */
  16823. highlightsHue: number;
  16824. /**
  16825. * Gets the highlights Density value.
  16826. * 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.
  16827. * Values less than zero provide a filter of opposite hue.
  16828. */
  16829. /**
  16830. * Sets the highlights Density value.
  16831. * 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.
  16832. * Values less than zero provide a filter of opposite hue.
  16833. */
  16834. highlightsDensity: number;
  16835. /**
  16836. * Gets the highlights Saturation value.
  16837. * 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.
  16838. */
  16839. /**
  16840. * Sets the highlights Saturation value.
  16841. * 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.
  16842. */
  16843. highlightsSaturation: number;
  16844. /**
  16845. * Gets the highlights Exposure value.
  16846. * 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.
  16847. */
  16848. /**
  16849. * Sets the highlights Exposure value.
  16850. * 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.
  16851. */
  16852. highlightsExposure: number;
  16853. private _midtonesHue;
  16854. private _midtonesDensity;
  16855. private _midtonesSaturation;
  16856. private _midtonesExposure;
  16857. /**
  16858. * Gets the midtones Hue value.
  16859. * 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).
  16860. */
  16861. /**
  16862. * Sets the midtones Hue value.
  16863. * 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).
  16864. */
  16865. midtonesHue: number;
  16866. /**
  16867. * Gets the midtones Density value.
  16868. * 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.
  16869. * Values less than zero provide a filter of opposite hue.
  16870. */
  16871. /**
  16872. * Sets the midtones Density value.
  16873. * 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.
  16874. * Values less than zero provide a filter of opposite hue.
  16875. */
  16876. midtonesDensity: number;
  16877. /**
  16878. * Gets the midtones Saturation value.
  16879. * 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.
  16880. */
  16881. /**
  16882. * Sets the midtones Saturation value.
  16883. * 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.
  16884. */
  16885. midtonesSaturation: number;
  16886. /**
  16887. * Gets the midtones Exposure value.
  16888. * 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.
  16889. */
  16890. /**
  16891. * Sets the midtones Exposure value.
  16892. * 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.
  16893. */
  16894. midtonesExposure: number;
  16895. private _shadowsHue;
  16896. private _shadowsDensity;
  16897. private _shadowsSaturation;
  16898. private _shadowsExposure;
  16899. /**
  16900. * Gets the shadows Hue value.
  16901. * 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).
  16902. */
  16903. /**
  16904. * Sets the shadows Hue value.
  16905. * 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).
  16906. */
  16907. shadowsHue: number;
  16908. /**
  16909. * Gets the shadows Density value.
  16910. * 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.
  16911. * Values less than zero provide a filter of opposite hue.
  16912. */
  16913. /**
  16914. * Sets the shadows Density value.
  16915. * 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.
  16916. * Values less than zero provide a filter of opposite hue.
  16917. */
  16918. shadowsDensity: number;
  16919. /**
  16920. * Gets the shadows Saturation value.
  16921. * 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.
  16922. */
  16923. /**
  16924. * Sets the shadows Saturation value.
  16925. * 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.
  16926. */
  16927. shadowsSaturation: number;
  16928. /**
  16929. * Gets the shadows Exposure value.
  16930. * 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.
  16931. */
  16932. /**
  16933. * Sets the shadows Exposure value.
  16934. * 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.
  16935. */
  16936. shadowsExposure: number;
  16937. getClassName(): string;
  16938. /**
  16939. * Binds the color curves to the shader.
  16940. * @param colorCurves The color curve to bind
  16941. * @param effect The effect to bind to
  16942. */
  16943. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16944. /**
  16945. * Prepare the list of uniforms associated with the ColorCurves effects.
  16946. * @param uniformsList The list of uniforms used in the effect
  16947. */
  16948. static PrepareUniforms(uniformsList: string[]): void;
  16949. /**
  16950. * Returns color grading data based on a hue, density, saturation and exposure value.
  16951. * @param filterHue The hue of the color filter.
  16952. * @param filterDensity The density of the color filter.
  16953. * @param saturation The saturation.
  16954. * @param exposure The exposure.
  16955. * @param result The result data container.
  16956. */
  16957. private getColorGradingDataToRef;
  16958. /**
  16959. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16960. * @param value The input slider value in range [-100,100].
  16961. * @returns Adjusted value.
  16962. */
  16963. private static applyColorGradingSliderNonlinear;
  16964. /**
  16965. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16966. * @param hue The hue (H) input.
  16967. * @param saturation The saturation (S) input.
  16968. * @param brightness The brightness (B) input.
  16969. * @result An RGBA color represented as Vector4.
  16970. */
  16971. private static fromHSBToRef;
  16972. /**
  16973. * Returns a value clamped between min and max
  16974. * @param value The value to clamp
  16975. * @param min The minimum of value
  16976. * @param max The maximum of value
  16977. * @returns The clamped value.
  16978. */
  16979. private static clamp;
  16980. /**
  16981. * Clones the current color curve instance.
  16982. * @return The cloned curves
  16983. */
  16984. clone(): ColorCurves;
  16985. /**
  16986. * Serializes the current color curve instance to a json representation.
  16987. * @return a JSON representation
  16988. */
  16989. serialize(): any;
  16990. /**
  16991. * Parses the color curve from a json representation.
  16992. * @param source the JSON source to parse
  16993. * @return The parsed curves
  16994. */
  16995. static Parse(source: any): ColorCurves;
  16996. }
  16997. }
  16998. declare module BABYLON {
  16999. /**
  17000. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17001. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17002. */
  17003. class EffectFallbacks {
  17004. private _defines;
  17005. private _currentRank;
  17006. private _maxRank;
  17007. private _mesh;
  17008. /**
  17009. * Removes the fallback from the bound mesh.
  17010. */
  17011. unBindMesh(): void;
  17012. /**
  17013. * Adds a fallback on the specified property.
  17014. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17015. * @param define The name of the define in the shader
  17016. */
  17017. addFallback(rank: number, define: string): void;
  17018. /**
  17019. * Sets the mesh to use CPU skinning when needing to fallback.
  17020. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17021. * @param mesh The mesh to use the fallbacks.
  17022. */
  17023. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17024. /**
  17025. * Checks to see if more fallbacks are still availible.
  17026. */
  17027. readonly isMoreFallbacks: boolean;
  17028. /**
  17029. * Removes the defines that shoould be removed when falling back.
  17030. * @param currentDefines defines the current define statements for the shader.
  17031. * @param effect defines the current effect we try to compile
  17032. * @returns The resulting defines with defines of the current rank removed.
  17033. */
  17034. reduce(currentDefines: string, effect: Effect): string;
  17035. }
  17036. /**
  17037. * Options to be used when creating an effect.
  17038. */
  17039. class EffectCreationOptions {
  17040. /**
  17041. * Atrributes that will be used in the shader.
  17042. */
  17043. attributes: string[];
  17044. /**
  17045. * Uniform varible names that will be set in the shader.
  17046. */
  17047. uniformsNames: string[];
  17048. /**
  17049. * Uniform buffer varible names that will be set in the shader.
  17050. */
  17051. uniformBuffersNames: string[];
  17052. /**
  17053. * Sampler texture variable names that will be set in the shader.
  17054. */
  17055. samplers: string[];
  17056. /**
  17057. * Define statements that will be set in the shader.
  17058. */
  17059. defines: any;
  17060. /**
  17061. * Possible fallbacks for this effect to improve performance when needed.
  17062. */
  17063. fallbacks: Nullable<EffectFallbacks>;
  17064. /**
  17065. * Callback that will be called when the shader is compiled.
  17066. */
  17067. onCompiled: Nullable<(effect: Effect) => void>;
  17068. /**
  17069. * Callback that will be called if an error occurs during shader compilation.
  17070. */
  17071. onError: Nullable<(effect: Effect, errors: string) => void>;
  17072. /**
  17073. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17074. */
  17075. indexParameters: any;
  17076. /**
  17077. * Max number of lights that can be used in the shader.
  17078. */
  17079. maxSimultaneousLights: number;
  17080. /**
  17081. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17082. */
  17083. transformFeedbackVaryings: Nullable<string[]>;
  17084. }
  17085. /**
  17086. * Effect containing vertex and fragment shader that can be executed on an object.
  17087. */
  17088. class Effect {
  17089. /**
  17090. * Name of the effect.
  17091. */
  17092. name: any;
  17093. /**
  17094. * String container all the define statements that should be set on the shader.
  17095. */
  17096. defines: string;
  17097. /**
  17098. * Callback that will be called when the shader is compiled.
  17099. */
  17100. onCompiled: Nullable<(effect: Effect) => void>;
  17101. /**
  17102. * Callback that will be called if an error occurs during shader compilation.
  17103. */
  17104. onError: Nullable<(effect: Effect, errors: string) => void>;
  17105. /**
  17106. * Callback that will be called when effect is bound.
  17107. */
  17108. onBind: Nullable<(effect: Effect) => void>;
  17109. /**
  17110. * Unique ID of the effect.
  17111. */
  17112. uniqueId: number;
  17113. /**
  17114. * Observable that will be called when the shader is compiled.
  17115. */
  17116. onCompileObservable: Observable<Effect>;
  17117. /**
  17118. * Observable that will be called if an error occurs during shader compilation.
  17119. */
  17120. onErrorObservable: Observable<Effect>;
  17121. /** @hidden */
  17122. _onBindObservable: Nullable<Observable<Effect>>;
  17123. /**
  17124. * Observable that will be called when effect is bound.
  17125. */
  17126. readonly onBindObservable: Observable<Effect>;
  17127. /** @hidden */
  17128. _bonesComputationForcedToCPU: boolean;
  17129. private static _uniqueIdSeed;
  17130. private _engine;
  17131. private _uniformBuffersNames;
  17132. private _uniformsNames;
  17133. private _samplers;
  17134. private _isReady;
  17135. private _compilationError;
  17136. private _attributesNames;
  17137. private _attributes;
  17138. private _uniforms;
  17139. /**
  17140. * Key for the effect.
  17141. * @hidden
  17142. */
  17143. _key: string;
  17144. private _indexParameters;
  17145. private _fallbacks;
  17146. private _vertexSourceCode;
  17147. private _fragmentSourceCode;
  17148. private _vertexSourceCodeOverride;
  17149. private _fragmentSourceCodeOverride;
  17150. private _transformFeedbackVaryings;
  17151. /**
  17152. * Compiled shader to webGL program.
  17153. * @hidden
  17154. */
  17155. _program: WebGLProgram;
  17156. private _valueCache;
  17157. private static _baseCache;
  17158. /**
  17159. * Instantiates an effect.
  17160. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17161. * @param baseName Name of the effect.
  17162. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17163. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17164. * @param samplers List of sampler variables that will be passed to the shader.
  17165. * @param engine Engine to be used to render the effect
  17166. * @param defines Define statements to be added to the shader.
  17167. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17168. * @param onCompiled Callback that will be called when the shader is compiled.
  17169. * @param onError Callback that will be called if an error occurs during shader compilation.
  17170. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17171. */
  17172. 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);
  17173. /**
  17174. * Unique key for this effect
  17175. */
  17176. readonly key: string;
  17177. /**
  17178. * If the effect has been compiled and prepared.
  17179. * @returns if the effect is compiled and prepared.
  17180. */
  17181. isReady(): boolean;
  17182. /**
  17183. * The engine the effect was initialized with.
  17184. * @returns the engine.
  17185. */
  17186. getEngine(): Engine;
  17187. /**
  17188. * The compiled webGL program for the effect
  17189. * @returns the webGL program.
  17190. */
  17191. getProgram(): WebGLProgram;
  17192. /**
  17193. * The set of names of attribute variables for the shader.
  17194. * @returns An array of attribute names.
  17195. */
  17196. getAttributesNames(): string[];
  17197. /**
  17198. * Returns the attribute at the given index.
  17199. * @param index The index of the attribute.
  17200. * @returns The location of the attribute.
  17201. */
  17202. getAttributeLocation(index: number): number;
  17203. /**
  17204. * Returns the attribute based on the name of the variable.
  17205. * @param name of the attribute to look up.
  17206. * @returns the attribute location.
  17207. */
  17208. getAttributeLocationByName(name: string): number;
  17209. /**
  17210. * The number of attributes.
  17211. * @returns the numnber of attributes.
  17212. */
  17213. getAttributesCount(): number;
  17214. /**
  17215. * Gets the index of a uniform variable.
  17216. * @param uniformName of the uniform to look up.
  17217. * @returns the index.
  17218. */
  17219. getUniformIndex(uniformName: string): number;
  17220. /**
  17221. * Returns the attribute based on the name of the variable.
  17222. * @param uniformName of the uniform to look up.
  17223. * @returns the location of the uniform.
  17224. */
  17225. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17226. /**
  17227. * Returns an array of sampler variable names
  17228. * @returns The array of sampler variable neames.
  17229. */
  17230. getSamplers(): string[];
  17231. /**
  17232. * The error from the last compilation.
  17233. * @returns the error string.
  17234. */
  17235. getCompilationError(): string;
  17236. /**
  17237. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17238. * @param func The callback to be used.
  17239. */
  17240. executeWhenCompiled(func: (effect: Effect) => void): void;
  17241. /** @hidden */
  17242. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17243. /** @hidden */
  17244. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17245. /** @hidden */
  17246. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17247. private _processShaderConversion;
  17248. private _processIncludes;
  17249. private _processPrecision;
  17250. /**
  17251. * Recompiles the webGL program
  17252. * @param vertexSourceCode The source code for the vertex shader.
  17253. * @param fragmentSourceCode The source code for the fragment shader.
  17254. * @param onCompiled Callback called when completed.
  17255. * @param onError Callback called on error.
  17256. * @hidden
  17257. */
  17258. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17259. /**
  17260. * Gets the uniform locations of the the specified variable names
  17261. * @param names THe names of the variables to lookup.
  17262. * @returns Array of locations in the same order as variable names.
  17263. */
  17264. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17265. /**
  17266. * Prepares the effect
  17267. * @hidden
  17268. */
  17269. _prepareEffect(): void;
  17270. /**
  17271. * Checks if the effect is supported. (Must be called after compilation)
  17272. */
  17273. readonly isSupported: boolean;
  17274. /**
  17275. * Binds a texture to the engine to be used as output of the shader.
  17276. * @param channel Name of the output variable.
  17277. * @param texture Texture to bind.
  17278. * @hidden
  17279. */
  17280. _bindTexture(channel: string, texture: InternalTexture): void;
  17281. /**
  17282. * Sets a texture on the engine to be used in the shader.
  17283. * @param channel Name of the sampler variable.
  17284. * @param texture Texture to set.
  17285. */
  17286. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17287. /**
  17288. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17289. * @param channel Name of the sampler variable.
  17290. * @param texture Texture to set.
  17291. */
  17292. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17293. /**
  17294. * Sets an array of textures on the engine to be used in the shader.
  17295. * @param channel Name of the variable.
  17296. * @param textures Textures to set.
  17297. */
  17298. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17299. /**
  17300. * 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)
  17301. * @param channel Name of the sampler variable.
  17302. * @param postProcess Post process to get the input texture from.
  17303. */
  17304. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17305. /**
  17306. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17307. * 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)
  17308. * @param channel Name of the sampler variable.
  17309. * @param postProcess Post process to get the output texture from.
  17310. */
  17311. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17312. /** @hidden */
  17313. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17314. /** @hidden */
  17315. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17316. /** @hidden */
  17317. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17318. /** @hidden */
  17319. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17320. /**
  17321. * Binds a buffer to a uniform.
  17322. * @param buffer Buffer to bind.
  17323. * @param name Name of the uniform variable to bind to.
  17324. */
  17325. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17326. /**
  17327. * Binds block to a uniform.
  17328. * @param blockName Name of the block to bind.
  17329. * @param index Index to bind.
  17330. */
  17331. bindUniformBlock(blockName: string, index: number): void;
  17332. /**
  17333. * Sets an interger value on a uniform variable.
  17334. * @param uniformName Name of the variable.
  17335. * @param value Value to be set.
  17336. * @returns this effect.
  17337. */
  17338. setInt(uniformName: string, value: number): Effect;
  17339. /**
  17340. * Sets an int array on a uniform variable.
  17341. * @param uniformName Name of the variable.
  17342. * @param array array to be set.
  17343. * @returns this effect.
  17344. */
  17345. setIntArray(uniformName: string, array: Int32Array): Effect;
  17346. /**
  17347. * 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)
  17348. * @param uniformName Name of the variable.
  17349. * @param array array to be set.
  17350. * @returns this effect.
  17351. */
  17352. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17353. /**
  17354. * 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)
  17355. * @param uniformName Name of the variable.
  17356. * @param array array to be set.
  17357. * @returns this effect.
  17358. */
  17359. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17360. /**
  17361. * 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)
  17362. * @param uniformName Name of the variable.
  17363. * @param array array to be set.
  17364. * @returns this effect.
  17365. */
  17366. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17367. /**
  17368. * Sets an float array on a uniform variable.
  17369. * @param uniformName Name of the variable.
  17370. * @param array array to be set.
  17371. * @returns this effect.
  17372. */
  17373. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17374. /**
  17375. * 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)
  17376. * @param uniformName Name of the variable.
  17377. * @param array array to be set.
  17378. * @returns this effect.
  17379. */
  17380. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17381. /**
  17382. * 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)
  17383. * @param uniformName Name of the variable.
  17384. * @param array array to be set.
  17385. * @returns this effect.
  17386. */
  17387. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17388. /**
  17389. * 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)
  17390. * @param uniformName Name of the variable.
  17391. * @param array array to be set.
  17392. * @returns this effect.
  17393. */
  17394. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17395. /**
  17396. * Sets an array on a uniform variable.
  17397. * @param uniformName Name of the variable.
  17398. * @param array array to be set.
  17399. * @returns this effect.
  17400. */
  17401. setArray(uniformName: string, array: number[]): Effect;
  17402. /**
  17403. * 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)
  17404. * @param uniformName Name of the variable.
  17405. * @param array array to be set.
  17406. * @returns this effect.
  17407. */
  17408. setArray2(uniformName: string, array: number[]): Effect;
  17409. /**
  17410. * 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)
  17411. * @param uniformName Name of the variable.
  17412. * @param array array to be set.
  17413. * @returns this effect.
  17414. */
  17415. setArray3(uniformName: string, array: number[]): Effect;
  17416. /**
  17417. * 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)
  17418. * @param uniformName Name of the variable.
  17419. * @param array array to be set.
  17420. * @returns this effect.
  17421. */
  17422. setArray4(uniformName: string, array: number[]): Effect;
  17423. /**
  17424. * Sets matrices on a uniform variable.
  17425. * @param uniformName Name of the variable.
  17426. * @param matrices matrices to be set.
  17427. * @returns this effect.
  17428. */
  17429. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17430. /**
  17431. * Sets matrix on a uniform variable.
  17432. * @param uniformName Name of the variable.
  17433. * @param matrix matrix to be set.
  17434. * @returns this effect.
  17435. */
  17436. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17437. /**
  17438. * 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)
  17439. * @param uniformName Name of the variable.
  17440. * @param matrix matrix to be set.
  17441. * @returns this effect.
  17442. */
  17443. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17444. /**
  17445. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17446. * @param uniformName Name of the variable.
  17447. * @param matrix matrix to be set.
  17448. * @returns this effect.
  17449. */
  17450. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17451. /**
  17452. * Sets a float on a uniform variable.
  17453. * @param uniformName Name of the variable.
  17454. * @param value value to be set.
  17455. * @returns this effect.
  17456. */
  17457. setFloat(uniformName: string, value: number): Effect;
  17458. /**
  17459. * Sets a boolean on a uniform variable.
  17460. * @param uniformName Name of the variable.
  17461. * @param bool value to be set.
  17462. * @returns this effect.
  17463. */
  17464. setBool(uniformName: string, bool: boolean): Effect;
  17465. /**
  17466. * Sets a Vector2 on a uniform variable.
  17467. * @param uniformName Name of the variable.
  17468. * @param vector2 vector2 to be set.
  17469. * @returns this effect.
  17470. */
  17471. setVector2(uniformName: string, vector2: Vector2): Effect;
  17472. /**
  17473. * Sets a float2 on a uniform variable.
  17474. * @param uniformName Name of the variable.
  17475. * @param x First float in float2.
  17476. * @param y Second float in float2.
  17477. * @returns this effect.
  17478. */
  17479. setFloat2(uniformName: string, x: number, y: number): Effect;
  17480. /**
  17481. * Sets a Vector3 on a uniform variable.
  17482. * @param uniformName Name of the variable.
  17483. * @param vector3 Value to be set.
  17484. * @returns this effect.
  17485. */
  17486. setVector3(uniformName: string, vector3: Vector3): Effect;
  17487. /**
  17488. * Sets a float3 on a uniform variable.
  17489. * @param uniformName Name of the variable.
  17490. * @param x First float in float3.
  17491. * @param y Second float in float3.
  17492. * @param z Third float in float3.
  17493. * @returns this effect.
  17494. */
  17495. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17496. /**
  17497. * Sets a Vector4 on a uniform variable.
  17498. * @param uniformName Name of the variable.
  17499. * @param vector4 Value to be set.
  17500. * @returns this effect.
  17501. */
  17502. setVector4(uniformName: string, vector4: Vector4): Effect;
  17503. /**
  17504. * Sets a float4 on a uniform variable.
  17505. * @param uniformName Name of the variable.
  17506. * @param x First float in float4.
  17507. * @param y Second float in float4.
  17508. * @param z Third float in float4.
  17509. * @param w Fourth float in float4.
  17510. * @returns this effect.
  17511. */
  17512. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17513. /**
  17514. * Sets a Color3 on a uniform variable.
  17515. * @param uniformName Name of the variable.
  17516. * @param color3 Value to be set.
  17517. * @returns this effect.
  17518. */
  17519. setColor3(uniformName: string, color3: Color3): Effect;
  17520. /**
  17521. * Sets a Color4 on a uniform variable.
  17522. * @param uniformName Name of the variable.
  17523. * @param color3 Value to be set.
  17524. * @param alpha Alpha value to be set.
  17525. * @returns this effect.
  17526. */
  17527. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17528. /**
  17529. * Sets a Color4 on a uniform variable
  17530. * @param uniformName defines the name of the variable
  17531. * @param color4 defines the value to be set
  17532. * @returns this effect.
  17533. */
  17534. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17535. /**
  17536. * This function will add a new shader to the shader store
  17537. * @param name the name of the shader
  17538. * @param pixelShader optional pixel shader content
  17539. * @param vertexShader optional vertex shader content
  17540. */
  17541. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17542. /**
  17543. * Store of each shader (The can be looked up using effect.key)
  17544. */
  17545. static ShadersStore: {
  17546. [key: string]: string;
  17547. };
  17548. /**
  17549. * Store of each included file for a shader (The can be looked up using effect.key)
  17550. */
  17551. static IncludesShadersStore: {
  17552. [key: string]: string;
  17553. };
  17554. /**
  17555. * Resets the cache of effects.
  17556. */
  17557. static ResetCache(): void;
  17558. }
  17559. }
  17560. declare module BABYLON {
  17561. class FresnelParameters {
  17562. private _isEnabled;
  17563. isEnabled: boolean;
  17564. leftColor: Color3;
  17565. rightColor: Color3;
  17566. bias: number;
  17567. power: number;
  17568. clone(): FresnelParameters;
  17569. serialize(): any;
  17570. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17571. }
  17572. }
  17573. declare module BABYLON {
  17574. /**
  17575. * Interface to follow in your material defines to integrate easily the
  17576. * Image proccessing functions.
  17577. * @hidden
  17578. */
  17579. interface IImageProcessingConfigurationDefines {
  17580. IMAGEPROCESSING: boolean;
  17581. VIGNETTE: boolean;
  17582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17583. VIGNETTEBLENDMODEOPAQUE: boolean;
  17584. TONEMAPPING: boolean;
  17585. TONEMAPPING_ACES: boolean;
  17586. CONTRAST: boolean;
  17587. EXPOSURE: boolean;
  17588. COLORCURVES: boolean;
  17589. COLORGRADING: boolean;
  17590. COLORGRADING3D: boolean;
  17591. SAMPLER3DGREENDEPTH: boolean;
  17592. SAMPLER3DBGRMAP: boolean;
  17593. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17594. }
  17595. /**
  17596. * @hidden
  17597. */
  17598. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17599. IMAGEPROCESSING: boolean;
  17600. VIGNETTE: boolean;
  17601. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17602. VIGNETTEBLENDMODEOPAQUE: boolean;
  17603. TONEMAPPING: boolean;
  17604. TONEMAPPING_ACES: boolean;
  17605. CONTRAST: boolean;
  17606. COLORCURVES: boolean;
  17607. COLORGRADING: boolean;
  17608. COLORGRADING3D: boolean;
  17609. SAMPLER3DGREENDEPTH: boolean;
  17610. SAMPLER3DBGRMAP: boolean;
  17611. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17612. EXPOSURE: boolean;
  17613. constructor();
  17614. }
  17615. /**
  17616. * This groups together the common properties used for image processing either in direct forward pass
  17617. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17618. * or not.
  17619. */
  17620. class ImageProcessingConfiguration {
  17621. /**
  17622. * Default tone mapping applied in BabylonJS.
  17623. */
  17624. static readonly TONEMAPPING_STANDARD: number;
  17625. /**
  17626. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17627. * to other engines rendering to increase portability.
  17628. */
  17629. static readonly TONEMAPPING_ACES: number;
  17630. /**
  17631. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17632. */
  17633. colorCurves: Nullable<ColorCurves>;
  17634. private _colorCurvesEnabled;
  17635. /**
  17636. * Gets wether the color curves effect is enabled.
  17637. */
  17638. /**
  17639. * Sets wether the color curves effect is enabled.
  17640. */
  17641. colorCurvesEnabled: boolean;
  17642. /**
  17643. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17644. */
  17645. colorGradingTexture: Nullable<BaseTexture>;
  17646. private _colorGradingEnabled;
  17647. /**
  17648. * Gets wether the color grading effect is enabled.
  17649. */
  17650. /**
  17651. * Sets wether the color grading effect is enabled.
  17652. */
  17653. colorGradingEnabled: boolean;
  17654. private _colorGradingWithGreenDepth;
  17655. /**
  17656. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17657. */
  17658. /**
  17659. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17660. */
  17661. colorGradingWithGreenDepth: boolean;
  17662. private _colorGradingBGR;
  17663. /**
  17664. * Gets wether the color grading texture contains BGR values.
  17665. */
  17666. /**
  17667. * Sets wether the color grading texture contains BGR values.
  17668. */
  17669. colorGradingBGR: boolean;
  17670. /** @hidden */
  17671. _exposure: number;
  17672. /**
  17673. * Gets the Exposure used in the effect.
  17674. */
  17675. /**
  17676. * Sets the Exposure used in the effect.
  17677. */
  17678. exposure: number;
  17679. private _toneMappingEnabled;
  17680. /**
  17681. * Gets wether the tone mapping effect is enabled.
  17682. */
  17683. /**
  17684. * Sets wether the tone mapping effect is enabled.
  17685. */
  17686. toneMappingEnabled: boolean;
  17687. private _toneMappingType;
  17688. /**
  17689. * Gets the type of tone mapping effect.
  17690. */
  17691. /**
  17692. * Sets the type of tone mapping effect used in BabylonJS.
  17693. */
  17694. toneMappingType: number;
  17695. protected _contrast: number;
  17696. /**
  17697. * Gets the contrast used in the effect.
  17698. */
  17699. /**
  17700. * Sets the contrast used in the effect.
  17701. */
  17702. contrast: number;
  17703. /**
  17704. * Vignette stretch size.
  17705. */
  17706. vignetteStretch: number;
  17707. /**
  17708. * Vignette centre X Offset.
  17709. */
  17710. vignetteCentreX: number;
  17711. /**
  17712. * Vignette centre Y Offset.
  17713. */
  17714. vignetteCentreY: number;
  17715. /**
  17716. * Vignette weight or intensity of the vignette effect.
  17717. */
  17718. vignetteWeight: number;
  17719. /**
  17720. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17721. * if vignetteEnabled is set to true.
  17722. */
  17723. vignetteColor: Color4;
  17724. /**
  17725. * Camera field of view used by the Vignette effect.
  17726. */
  17727. vignetteCameraFov: number;
  17728. private _vignetteBlendMode;
  17729. /**
  17730. * Gets the vignette blend mode allowing different kind of effect.
  17731. */
  17732. /**
  17733. * Sets the vignette blend mode allowing different kind of effect.
  17734. */
  17735. vignetteBlendMode: number;
  17736. private _vignetteEnabled;
  17737. /**
  17738. * Gets wether the vignette effect is enabled.
  17739. */
  17740. /**
  17741. * Sets wether the vignette effect is enabled.
  17742. */
  17743. vignetteEnabled: boolean;
  17744. private _applyByPostProcess;
  17745. /**
  17746. * Gets wether the image processing is applied through a post process or not.
  17747. */
  17748. /**
  17749. * Sets wether the image processing is applied through a post process or not.
  17750. */
  17751. applyByPostProcess: boolean;
  17752. private _isEnabled;
  17753. /**
  17754. * Gets wether the image processing is enabled or not.
  17755. */
  17756. /**
  17757. * Sets wether the image processing is enabled or not.
  17758. */
  17759. isEnabled: boolean;
  17760. /**
  17761. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17762. */
  17763. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17764. /**
  17765. * Method called each time the image processing information changes requires to recompile the effect.
  17766. */
  17767. protected _updateParameters(): void;
  17768. getClassName(): string;
  17769. /**
  17770. * Prepare the list of uniforms associated with the Image Processing effects.
  17771. * @param uniformsList The list of uniforms used in the effect
  17772. * @param defines the list of defines currently in use
  17773. */
  17774. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17775. /**
  17776. * Prepare the list of samplers associated with the Image Processing effects.
  17777. * @param uniformsList The list of uniforms used in the effect
  17778. * @param defines the list of defines currently in use
  17779. */
  17780. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17781. /**
  17782. * Prepare the list of defines associated to the shader.
  17783. * @param defines the list of defines to complete
  17784. */
  17785. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17786. /**
  17787. * Returns true if all the image processing information are ready.
  17788. */
  17789. isReady(): boolean;
  17790. /**
  17791. * Binds the image processing to the shader.
  17792. * @param effect The effect to bind to
  17793. */
  17794. bind(effect: Effect, aspectRatio?: number): void;
  17795. /**
  17796. * Clones the current image processing instance.
  17797. * @return The cloned image processing
  17798. */
  17799. clone(): ImageProcessingConfiguration;
  17800. /**
  17801. * Serializes the current image processing instance to a json representation.
  17802. * @return a JSON representation
  17803. */
  17804. serialize(): any;
  17805. /**
  17806. * Parses the image processing from a json representation.
  17807. * @param source the JSON source to parse
  17808. * @return The parsed image processing
  17809. */
  17810. static Parse(source: any): ImageProcessingConfiguration;
  17811. private static _VIGNETTEMODE_MULTIPLY;
  17812. private static _VIGNETTEMODE_OPAQUE;
  17813. /**
  17814. * Used to apply the vignette as a mix with the pixel color.
  17815. */
  17816. static readonly VIGNETTEMODE_MULTIPLY: number;
  17817. /**
  17818. * Used to apply the vignette as a replacement of the pixel color.
  17819. */
  17820. static readonly VIGNETTEMODE_OPAQUE: number;
  17821. }
  17822. }
  17823. declare module BABYLON {
  17824. /**
  17825. * Manages the defines for the Material
  17826. */
  17827. class MaterialDefines {
  17828. private _keys;
  17829. private _isDirty;
  17830. /** @hidden */
  17831. _renderId: number;
  17832. /** @hidden */
  17833. _areLightsDirty: boolean;
  17834. /** @hidden */
  17835. _areAttributesDirty: boolean;
  17836. /** @hidden */
  17837. _areTexturesDirty: boolean;
  17838. /** @hidden */
  17839. _areFresnelDirty: boolean;
  17840. /** @hidden */
  17841. _areMiscDirty: boolean;
  17842. /** @hidden */
  17843. _areImageProcessingDirty: boolean;
  17844. /** @hidden */
  17845. _normals: boolean;
  17846. /** @hidden */
  17847. _uvs: boolean;
  17848. /** @hidden */
  17849. _needNormals: boolean;
  17850. /** @hidden */
  17851. _needUVs: boolean;
  17852. /**
  17853. * Specifies if the material needs to be re-calculated
  17854. */
  17855. readonly isDirty: boolean;
  17856. /**
  17857. * Marks the material to indicate that it has been re-calculated
  17858. */
  17859. markAsProcessed(): void;
  17860. /**
  17861. * Marks the material to indicate that it needs to be re-calculated
  17862. */
  17863. markAsUnprocessed(): void;
  17864. /**
  17865. * Marks the material to indicate all of its defines need to be re-calculated
  17866. */
  17867. markAllAsDirty(): void;
  17868. /**
  17869. * Marks the material to indicate that image processing needs to be re-calculated
  17870. */
  17871. markAsImageProcessingDirty(): void;
  17872. /**
  17873. * Marks the material to indicate the lights need to be re-calculated
  17874. */
  17875. markAsLightDirty(): void;
  17876. /**
  17877. * Marks the attribute state as changed
  17878. */
  17879. markAsAttributesDirty(): void;
  17880. /**
  17881. * Marks the texture state as changed
  17882. */
  17883. markAsTexturesDirty(): void;
  17884. /**
  17885. * Marks the fresnel state as changed
  17886. */
  17887. markAsFresnelDirty(): void;
  17888. /**
  17889. * Marks the misc state as changed
  17890. */
  17891. markAsMiscDirty(): void;
  17892. /**
  17893. * Rebuilds the material defines
  17894. */
  17895. rebuild(): void;
  17896. /**
  17897. * Specifies if two material defines are equal
  17898. * @param other - A material define instance to compare to
  17899. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17900. */
  17901. isEqual(other: MaterialDefines): boolean;
  17902. /**
  17903. * Clones this instance's defines to another instance
  17904. * @param other - material defines to clone values to
  17905. */
  17906. cloneTo(other: MaterialDefines): void;
  17907. /**
  17908. * Resets the material define values
  17909. */
  17910. reset(): void;
  17911. /**
  17912. * Converts the material define values to a string
  17913. * @returns - String of material define information
  17914. */
  17915. toString(): string;
  17916. }
  17917. /**
  17918. * Base class for the main features of a material in Babylon.js
  17919. */
  17920. class Material implements IAnimatable {
  17921. private static _TriangleFillMode;
  17922. private static _WireFrameFillMode;
  17923. private static _PointFillMode;
  17924. private static _PointListDrawMode;
  17925. private static _LineListDrawMode;
  17926. private static _LineLoopDrawMode;
  17927. private static _LineStripDrawMode;
  17928. private static _TriangleStripDrawMode;
  17929. private static _TriangleFanDrawMode;
  17930. /**
  17931. * Returns the triangle fill mode
  17932. */
  17933. static readonly TriangleFillMode: number;
  17934. /**
  17935. * Returns the wireframe mode
  17936. */
  17937. static readonly WireFrameFillMode: number;
  17938. /**
  17939. * Returns the point fill mode
  17940. */
  17941. static readonly PointFillMode: number;
  17942. /**
  17943. * Returns the point list draw mode
  17944. */
  17945. static readonly PointListDrawMode: number;
  17946. /**
  17947. * Returns the line list draw mode
  17948. */
  17949. static readonly LineListDrawMode: number;
  17950. /**
  17951. * Returns the line loop draw mode
  17952. */
  17953. static readonly LineLoopDrawMode: number;
  17954. /**
  17955. * Returns the line strip draw mode
  17956. */
  17957. static readonly LineStripDrawMode: number;
  17958. /**
  17959. * Returns the triangle strip draw mode
  17960. */
  17961. static readonly TriangleStripDrawMode: number;
  17962. /**
  17963. * Returns the triangle fan draw mode
  17964. */
  17965. static readonly TriangleFanDrawMode: number;
  17966. /**
  17967. * Stores the clock-wise side orientation
  17968. */
  17969. private static _ClockWiseSideOrientation;
  17970. /**
  17971. * Stores the counter clock-wise side orientation
  17972. */
  17973. private static _CounterClockWiseSideOrientation;
  17974. /**
  17975. * Returns the clock-wise side orientation
  17976. */
  17977. static readonly ClockWiseSideOrientation: number;
  17978. /**
  17979. * Returns the counter clock-wise side orientation
  17980. */
  17981. static readonly CounterClockWiseSideOrientation: number;
  17982. /**
  17983. * The dirty texture flag value
  17984. */
  17985. private static _TextureDirtyFlag;
  17986. /**
  17987. * The dirty light flag value
  17988. */
  17989. private static _LightDirtyFlag;
  17990. /**
  17991. * The dirty fresnel flag value
  17992. */
  17993. private static _FresnelDirtyFlag;
  17994. /**
  17995. * The dirty attribute flag value
  17996. */
  17997. private static _AttributesDirtyFlag;
  17998. /**
  17999. * The dirty misc flag value
  18000. */
  18001. private static _MiscDirtyFlag;
  18002. /**
  18003. * Returns the dirty texture flag value
  18004. */
  18005. static readonly TextureDirtyFlag: number;
  18006. /**
  18007. * Returns the dirty light flag value
  18008. */
  18009. static readonly LightDirtyFlag: number;
  18010. /**
  18011. * Returns the dirty fresnel flag value
  18012. */
  18013. static readonly FresnelDirtyFlag: number;
  18014. /**
  18015. * Returns the dirty attributes flag value
  18016. */
  18017. static readonly AttributesDirtyFlag: number;
  18018. /**
  18019. * Returns the dirty misc flag value
  18020. */
  18021. static readonly MiscDirtyFlag: number;
  18022. /**
  18023. * The ID of the material
  18024. */
  18025. id: string;
  18026. /**
  18027. * Gets or sets the unique id of the material
  18028. */
  18029. uniqueId: number;
  18030. /**
  18031. * The name of the material
  18032. */
  18033. name: string;
  18034. /**
  18035. * Specifies if the ready state should be checked on each call
  18036. */
  18037. checkReadyOnEveryCall: boolean;
  18038. /**
  18039. * Specifies if the ready state should be checked once
  18040. */
  18041. checkReadyOnlyOnce: boolean;
  18042. /**
  18043. * The state of the material
  18044. */
  18045. state: string;
  18046. /**
  18047. * The alpha value of the material
  18048. */
  18049. protected _alpha: number;
  18050. /**
  18051. * Sets the alpha value of the material
  18052. */
  18053. /**
  18054. * Gets the alpha value of the material
  18055. */
  18056. alpha: number;
  18057. /**
  18058. * Specifies if back face culling is enabled
  18059. */
  18060. protected _backFaceCulling: boolean;
  18061. /**
  18062. * Sets the back-face culling state
  18063. */
  18064. /**
  18065. * Gets the back-face culling state
  18066. */
  18067. backFaceCulling: boolean;
  18068. /**
  18069. * Stores the value for side orientation
  18070. */
  18071. sideOrientation: number;
  18072. /**
  18073. * Callback triggered when the material is compiled
  18074. */
  18075. onCompiled: (effect: Effect) => void;
  18076. /**
  18077. * Callback triggered when an error occurs
  18078. */
  18079. onError: (effect: Effect, errors: string) => void;
  18080. /**
  18081. * Callback triggered to get the render target textures
  18082. */
  18083. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18084. /**
  18085. * Gets a boolean indicating that current material needs to register RTT
  18086. */
  18087. hasRenderTargetTextures: boolean;
  18088. /**
  18089. * Specifies if the material should be serialized
  18090. */
  18091. doNotSerialize: boolean;
  18092. /**
  18093. * Specifies if the effect should be stored on sub meshes
  18094. */
  18095. storeEffectOnSubMeshes: boolean;
  18096. /**
  18097. * Stores the animations for the material
  18098. */
  18099. animations: Array<Animation>;
  18100. /**
  18101. * An event triggered when the material is disposed
  18102. */
  18103. onDisposeObservable: Observable<Material>;
  18104. /**
  18105. * An observer which watches for dispose events
  18106. */
  18107. private _onDisposeObserver;
  18108. private _onUnBindObservable;
  18109. /**
  18110. * Called during a dispose event
  18111. */
  18112. onDispose: () => void;
  18113. private _onBindObservable;
  18114. /**
  18115. * An event triggered when the material is bound
  18116. */
  18117. readonly onBindObservable: Observable<AbstractMesh>;
  18118. /**
  18119. * An observer which watches for bind events
  18120. */
  18121. private _onBindObserver;
  18122. /**
  18123. * Called during a bind event
  18124. */
  18125. onBind: (Mesh: AbstractMesh) => void;
  18126. /**
  18127. * An event triggered when the material is unbound
  18128. */
  18129. readonly onUnBindObservable: Observable<Material>;
  18130. /**
  18131. * Stores the value of the alpha mode
  18132. */
  18133. private _alphaMode;
  18134. /**
  18135. * Sets the value of the alpha mode.
  18136. *
  18137. * | Value | Type | Description |
  18138. * | --- | --- | --- |
  18139. * | 0 | ALPHA_DISABLE | |
  18140. * | 1 | ALPHA_ADD | |
  18141. * | 2 | ALPHA_COMBINE | |
  18142. * | 3 | ALPHA_SUBTRACT | |
  18143. * | 4 | ALPHA_MULTIPLY | |
  18144. * | 5 | ALPHA_MAXIMIZED | |
  18145. * | 6 | ALPHA_ONEONE | |
  18146. * | 7 | ALPHA_PREMULTIPLIED | |
  18147. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18148. * | 9 | ALPHA_INTERPOLATE | |
  18149. * | 10 | ALPHA_SCREENMODE | |
  18150. *
  18151. */
  18152. /**
  18153. * Gets the value of the alpha mode
  18154. */
  18155. alphaMode: number;
  18156. /**
  18157. * Stores the state of the need depth pre-pass value
  18158. */
  18159. private _needDepthPrePass;
  18160. /**
  18161. * Sets the need depth pre-pass value
  18162. */
  18163. /**
  18164. * Gets the depth pre-pass value
  18165. */
  18166. needDepthPrePass: boolean;
  18167. /**
  18168. * Specifies if depth writing should be disabled
  18169. */
  18170. disableDepthWrite: boolean;
  18171. /**
  18172. * Specifies if depth writing should be forced
  18173. */
  18174. forceDepthWrite: boolean;
  18175. /**
  18176. * Specifies if there should be a separate pass for culling
  18177. */
  18178. separateCullingPass: boolean;
  18179. /**
  18180. * Stores the state specifing if fog should be enabled
  18181. */
  18182. private _fogEnabled;
  18183. /**
  18184. * Sets the state for enabling fog
  18185. */
  18186. /**
  18187. * Gets the value of the fog enabled state
  18188. */
  18189. fogEnabled: boolean;
  18190. /**
  18191. * Stores the size of points
  18192. */
  18193. pointSize: number;
  18194. /**
  18195. * Stores the z offset value
  18196. */
  18197. zOffset: number;
  18198. /**
  18199. * Gets a value specifying if wireframe mode is enabled
  18200. */
  18201. /**
  18202. * Sets the state of wireframe mode
  18203. */
  18204. wireframe: boolean;
  18205. /**
  18206. * Gets the value specifying if point clouds are enabled
  18207. */
  18208. /**
  18209. * Sets the state of point cloud mode
  18210. */
  18211. pointsCloud: boolean;
  18212. /**
  18213. * Gets the material fill mode
  18214. */
  18215. /**
  18216. * Sets the material fill mode
  18217. */
  18218. fillMode: number;
  18219. /**
  18220. * @hidden
  18221. * Stores the effects for the material
  18222. */
  18223. _effect: Nullable<Effect>;
  18224. /**
  18225. * @hidden
  18226. * Specifies if the material was previously ready
  18227. */
  18228. _wasPreviouslyReady: boolean;
  18229. /**
  18230. * Specifies if uniform buffers should be used
  18231. */
  18232. private _useUBO;
  18233. /**
  18234. * Stores a reference to the scene
  18235. */
  18236. private _scene;
  18237. /**
  18238. * Stores the fill mode state
  18239. */
  18240. private _fillMode;
  18241. /**
  18242. * Specifies if the depth write state should be cached
  18243. */
  18244. private _cachedDepthWriteState;
  18245. /**
  18246. * Stores the uniform buffer
  18247. */
  18248. protected _uniformBuffer: UniformBuffer;
  18249. /**
  18250. * Creates a material instance
  18251. * @param name defines the name of the material
  18252. * @param scene defines the scene to reference
  18253. * @param doNotAdd specifies if the material should be added to the scene
  18254. */
  18255. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18256. /**
  18257. * Returns a string representation of the current material
  18258. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18259. * @returns a string with material information
  18260. */
  18261. toString(fullDetails?: boolean): string;
  18262. /**
  18263. * Gets the class name of the material
  18264. * @returns a string with the class name of the material
  18265. */
  18266. getClassName(): string;
  18267. /**
  18268. * Specifies if updates for the material been locked
  18269. */
  18270. readonly isFrozen: boolean;
  18271. /**
  18272. * Locks updates for the material
  18273. */
  18274. freeze(): void;
  18275. /**
  18276. * Unlocks updates for the material
  18277. */
  18278. unfreeze(): void;
  18279. /**
  18280. * Specifies if the material is ready to be used
  18281. * @param mesh defines the mesh to check
  18282. * @param useInstances specifies if instances should be used
  18283. * @returns a boolean indicating if the material is ready to be used
  18284. */
  18285. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18286. /**
  18287. * Specifies that the submesh is ready to be used
  18288. * @param mesh defines the mesh to check
  18289. * @param subMesh defines which submesh to check
  18290. * @param useInstances specifies that instances should be used
  18291. * @returns a boolean indicating that the submesh is ready or not
  18292. */
  18293. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18294. /**
  18295. * Returns the material effect
  18296. * @returns the effect associated with the material
  18297. */
  18298. getEffect(): Nullable<Effect>;
  18299. /**
  18300. * Returns the current scene
  18301. * @returns a Scene
  18302. */
  18303. getScene(): Scene;
  18304. /**
  18305. * Specifies if the material will require alpha blending
  18306. * @returns a boolean specifying if alpha blending is needed
  18307. */
  18308. needAlphaBlending(): boolean;
  18309. /**
  18310. * Specifies if the mesh will require alpha blending
  18311. * @param mesh defines the mesh to check
  18312. * @returns a boolean specifying if alpha blending is needed for the mesh
  18313. */
  18314. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18315. /**
  18316. * Specifies if this material should be rendered in alpha test mode
  18317. * @returns a boolean specifying if an alpha test is needed.
  18318. */
  18319. needAlphaTesting(): boolean;
  18320. /**
  18321. * Gets the texture used for the alpha test
  18322. * @returns the texture to use for alpha testing
  18323. */
  18324. getAlphaTestTexture(): Nullable<BaseTexture>;
  18325. /**
  18326. * Marks the material to indicate that it needs to be re-calculated
  18327. */
  18328. markDirty(): void;
  18329. /** @hidden */
  18330. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18331. /**
  18332. * Binds the material to the mesh
  18333. * @param world defines the world transformation matrix
  18334. * @param mesh defines the mesh to bind the material to
  18335. */
  18336. bind(world: Matrix, mesh?: Mesh): void;
  18337. /**
  18338. * Binds the submesh to the material
  18339. * @param world defines the world transformation matrix
  18340. * @param mesh defines the mesh containing the submesh
  18341. * @param subMesh defines the submesh to bind the material to
  18342. */
  18343. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18344. /**
  18345. * Binds the world matrix to the material
  18346. * @param world defines the world transformation matrix
  18347. */
  18348. bindOnlyWorldMatrix(world: Matrix): void;
  18349. /**
  18350. * Binds the scene's uniform buffer to the effect.
  18351. * @param effect defines the effect to bind to the scene uniform buffer
  18352. * @param sceneUbo defines the uniform buffer storing scene data
  18353. */
  18354. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18355. /**
  18356. * Binds the view matrix to the effect
  18357. * @param effect defines the effect to bind the view matrix to
  18358. */
  18359. bindView(effect: Effect): void;
  18360. /**
  18361. * Binds the view projection matrix to the effect
  18362. * @param effect defines the effect to bind the view projection matrix to
  18363. */
  18364. bindViewProjection(effect: Effect): void;
  18365. /**
  18366. * Specifies if material alpha testing should be turned on for the mesh
  18367. * @param mesh defines the mesh to check
  18368. */
  18369. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18370. /**
  18371. * Processes to execute after binding the material to a mesh
  18372. * @param mesh defines the rendered mesh
  18373. */
  18374. protected _afterBind(mesh?: Mesh): void;
  18375. /**
  18376. * Unbinds the material from the mesh
  18377. */
  18378. unbind(): void;
  18379. /**
  18380. * Gets the active textures from the material
  18381. * @returns an array of textures
  18382. */
  18383. getActiveTextures(): BaseTexture[];
  18384. /**
  18385. * Specifies if the material uses a texture
  18386. * @param texture defines the texture to check against the material
  18387. * @returns a boolean specifying if the material uses the texture
  18388. */
  18389. hasTexture(texture: BaseTexture): boolean;
  18390. /**
  18391. * Makes a duplicate of the material, and gives it a new name
  18392. * @param name defines the new name for the duplicated material
  18393. * @returns the cloned material
  18394. */
  18395. clone(name: string): Nullable<Material>;
  18396. /**
  18397. * Gets the meshes bound to the material
  18398. * @returns an array of meshes bound to the material
  18399. */
  18400. getBindedMeshes(): AbstractMesh[];
  18401. /**
  18402. * Force shader compilation
  18403. * @param mesh defines the mesh associated with this material
  18404. * @param onCompiled defines a function to execute once the material is compiled
  18405. * @param options defines the options to configure the compilation
  18406. */
  18407. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18408. clipPlane: boolean;
  18409. }>): void;
  18410. /**
  18411. * Force shader compilation
  18412. * @param mesh defines the mesh that will use this material
  18413. * @param options defines additional options for compiling the shaders
  18414. * @returns a promise that resolves when the compilation completes
  18415. */
  18416. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18417. clipPlane: boolean;
  18418. }>): Promise<void>;
  18419. /**
  18420. * Marks a define in the material to indicate that it needs to be re-computed
  18421. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18422. */
  18423. markAsDirty(flag: number): void;
  18424. /**
  18425. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18426. * @param func defines a function which checks material defines against the submeshes
  18427. */
  18428. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18429. /**
  18430. * Indicates that image processing needs to be re-calculated for all submeshes
  18431. */
  18432. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18433. /**
  18434. * Indicates that textures need to be re-calculated for all submeshes
  18435. */
  18436. protected _markAllSubMeshesAsTexturesDirty(): void;
  18437. /**
  18438. * Indicates that fresnel needs to be re-calculated for all submeshes
  18439. */
  18440. protected _markAllSubMeshesAsFresnelDirty(): void;
  18441. /**
  18442. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18443. */
  18444. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18445. /**
  18446. * Indicates that lights need to be re-calculated for all submeshes
  18447. */
  18448. protected _markAllSubMeshesAsLightsDirty(): void;
  18449. /**
  18450. * Indicates that attributes need to be re-calculated for all submeshes
  18451. */
  18452. protected _markAllSubMeshesAsAttributesDirty(): void;
  18453. /**
  18454. * Indicates that misc needs to be re-calculated for all submeshes
  18455. */
  18456. protected _markAllSubMeshesAsMiscDirty(): void;
  18457. /**
  18458. * Indicates that textures and misc need to be re-calculated for all submeshes
  18459. */
  18460. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18461. /**
  18462. * Disposes the material
  18463. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18464. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18465. */
  18466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18467. /**
  18468. * Serializes this material
  18469. * @returns the serialized material object
  18470. */
  18471. serialize(): any;
  18472. /**
  18473. * Creates a MultiMaterial from parsed MultiMaterial data.
  18474. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18475. * @param scene defines the hosting scene
  18476. * @returns a new MultiMaterial
  18477. */
  18478. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18479. /**
  18480. * Creates a material from parsed material data
  18481. * @param parsedMaterial defines parsed material data
  18482. * @param scene defines the hosting scene
  18483. * @param rootUrl defines the root URL to use to load textures
  18484. * @returns a new material
  18485. */
  18486. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18487. }
  18488. }
  18489. declare module BABYLON {
  18490. /**
  18491. * "Static Class" containing the most commonly used helper while dealing with material for
  18492. * rendering purpose.
  18493. *
  18494. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18495. *
  18496. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18497. */
  18498. class MaterialHelper {
  18499. /**
  18500. * Bind the current view position to an effect.
  18501. * @param effect The effect to be bound
  18502. * @param scene The scene the eyes position is used from
  18503. */
  18504. static BindEyePosition(effect: Effect, scene: Scene): void;
  18505. /**
  18506. * Helps preparing the defines values about the UVs in used in the effect.
  18507. * UVs are shared as much as we can accross chanels in the shaders.
  18508. * @param texture The texture we are preparing the UVs for
  18509. * @param defines The defines to update
  18510. * @param key The chanel key "diffuse", "specular"... used in the shader
  18511. */
  18512. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18513. /**
  18514. * Binds a texture matrix value to its corrsponding uniform
  18515. * @param texture The texture to bind the matrix for
  18516. * @param uniformBuffer The uniform buffer receivin the data
  18517. * @param key The chanel key "diffuse", "specular"... used in the shader
  18518. */
  18519. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18520. /**
  18521. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18522. * @param mesh defines the current mesh
  18523. * @param scene defines the current scene
  18524. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18525. * @param pointsCloud defines if point cloud rendering has to be turned on
  18526. * @param fogEnabled defines if fog has to be turned on
  18527. * @param alphaTest defines if alpha testing has to be turned on
  18528. * @param defines defines the current list of defines
  18529. */
  18530. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18531. /**
  18532. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18533. * @param scene defines the current scene
  18534. * @param engine defines the current engine
  18535. * @param defines specifies the list of active defines
  18536. * @param useInstances defines if instances have to be turned on
  18537. * @param useClipPlane defines if clip plane have to be turned on
  18538. */
  18539. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18540. /**
  18541. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18542. * @param mesh The mesh containing the geometry data we will draw
  18543. * @param defines The defines to update
  18544. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18545. * @param useBones Precise whether bones should be used or not (override mesh info)
  18546. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18547. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18548. * @returns false if defines are considered not dirty and have not been checked
  18549. */
  18550. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18551. /**
  18552. * Prepares the defines related to the light information passed in parameter
  18553. * @param scene The scene we are intending to draw
  18554. * @param mesh The mesh the effect is compiling for
  18555. * @param defines The defines to update
  18556. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18557. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18558. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18559. * @returns true if normals will be required for the rest of the effect
  18560. */
  18561. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18562. /**
  18563. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18564. * that won t be acctive due to defines being turned off.
  18565. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18566. * @param samplersList The samplers list
  18567. * @param defines The defines helping in the list generation
  18568. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18569. */
  18570. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18571. /**
  18572. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18573. * @param defines The defines to update while falling back
  18574. * @param fallbacks The authorized effect fallbacks
  18575. * @param maxSimultaneousLights The maximum number of lights allowed
  18576. * @param rank the current rank of the Effect
  18577. * @returns The newly affected rank
  18578. */
  18579. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18580. /**
  18581. * Prepares the list of attributes required for morph targets according to the effect defines.
  18582. * @param attribs The current list of supported attribs
  18583. * @param mesh The mesh to prepare the morph targets attributes for
  18584. * @param defines The current Defines of the effect
  18585. */
  18586. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18587. /**
  18588. * Prepares the list of attributes required for bones according to the effect defines.
  18589. * @param attribs The current list of supported attribs
  18590. * @param mesh The mesh to prepare the bones attributes for
  18591. * @param defines The current Defines of the effect
  18592. * @param fallbacks The current efffect fallback strategy
  18593. */
  18594. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18595. /**
  18596. * Prepares the list of attributes required for instances according to the effect defines.
  18597. * @param attribs The current list of supported attribs
  18598. * @param defines The current Defines of the effect
  18599. */
  18600. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18601. /**
  18602. * Binds the light shadow information to the effect for the given mesh.
  18603. * @param light The light containing the generator
  18604. * @param scene The scene the lights belongs to
  18605. * @param mesh The mesh we are binding the information to render
  18606. * @param lightIndex The light index in the effect used to render the mesh
  18607. * @param effect The effect we are binding the data to
  18608. */
  18609. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18610. /**
  18611. * Binds the light information to the effect.
  18612. * @param light The light containing the generator
  18613. * @param effect The effect we are binding the data to
  18614. * @param lightIndex The light index in the effect used to render
  18615. */
  18616. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18617. /**
  18618. * Binds the lights information from the scene to the effect for the given mesh.
  18619. * @param scene The scene the lights belongs to
  18620. * @param mesh The mesh we are binding the information to render
  18621. * @param effect The effect we are binding the data to
  18622. * @param defines The generated defines for the effect
  18623. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18624. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18625. */
  18626. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18627. /**
  18628. * Binds the fog information from the scene to the effect for the given mesh.
  18629. * @param scene The scene the lights belongs to
  18630. * @param mesh The mesh we are binding the information to render
  18631. * @param effect The effect we are binding the data to
  18632. */
  18633. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  18634. /**
  18635. * Binds the bones information from the mesh to the effect.
  18636. * @param mesh The mesh we are binding the information to render
  18637. * @param effect The effect we are binding the data to
  18638. */
  18639. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18640. /**
  18641. * Binds the morph targets information from the mesh to the effect.
  18642. * @param abstractMesh The mesh we are binding the information to render
  18643. * @param effect The effect we are binding the data to
  18644. */
  18645. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18646. /**
  18647. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18648. * @param defines The generated defines used in the effect
  18649. * @param effect The effect we are binding the data to
  18650. * @param scene The scene we are willing to render with logarithmic scale for
  18651. */
  18652. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18653. /**
  18654. * Binds the clip plane information from the scene to the effect.
  18655. * @param scene The scene the clip plane information are extracted from
  18656. * @param effect The effect we are binding the data to
  18657. */
  18658. static BindClipPlane(effect: Effect, scene: Scene): void;
  18659. }
  18660. }
  18661. declare module BABYLON {
  18662. class MultiMaterial extends Material {
  18663. private _subMaterials;
  18664. subMaterials: Nullable<Material>[];
  18665. constructor(name: string, scene: Scene);
  18666. private _hookArray;
  18667. getSubMaterial(index: number): Nullable<Material>;
  18668. getActiveTextures(): BaseTexture[];
  18669. getClassName(): string;
  18670. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18671. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18672. serialize(): any;
  18673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18674. }
  18675. }
  18676. declare module BABYLON {
  18677. class PushMaterial extends Material {
  18678. protected _activeEffect: Effect;
  18679. protected _normalMatrix: Matrix;
  18680. constructor(name: string, scene: Scene);
  18681. getEffect(): Effect;
  18682. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18683. /**
  18684. * Binds the given world matrix to the active effect
  18685. *
  18686. * @param world the matrix to bind
  18687. */
  18688. bindOnlyWorldMatrix(world: Matrix): void;
  18689. /**
  18690. * Binds the given normal matrix to the active effect
  18691. *
  18692. * @param normalMatrix the matrix to bind
  18693. */
  18694. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18695. bind(world: Matrix, mesh?: Mesh): void;
  18696. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18697. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18698. }
  18699. }
  18700. declare module BABYLON {
  18701. class ShaderMaterial extends Material {
  18702. private _shaderPath;
  18703. private _options;
  18704. private _textures;
  18705. private _textureArrays;
  18706. private _floats;
  18707. private _ints;
  18708. private _floatsArrays;
  18709. private _colors3;
  18710. private _colors3Arrays;
  18711. private _colors4;
  18712. private _vectors2;
  18713. private _vectors3;
  18714. private _vectors4;
  18715. private _matrices;
  18716. private _matrices3x3;
  18717. private _matrices2x2;
  18718. private _vectors2Arrays;
  18719. private _vectors3Arrays;
  18720. private _cachedWorldViewMatrix;
  18721. private _renderId;
  18722. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  18723. getClassName(): string;
  18724. needAlphaBlending(): boolean;
  18725. needAlphaTesting(): boolean;
  18726. private _checkUniform;
  18727. setTexture(name: string, texture: Texture): ShaderMaterial;
  18728. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18729. setFloat(name: string, value: number): ShaderMaterial;
  18730. setInt(name: string, value: number): ShaderMaterial;
  18731. setFloats(name: string, value: number[]): ShaderMaterial;
  18732. setColor3(name: string, value: Color3): ShaderMaterial;
  18733. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18734. setColor4(name: string, value: Color4): ShaderMaterial;
  18735. setVector2(name: string, value: Vector2): ShaderMaterial;
  18736. setVector3(name: string, value: Vector3): ShaderMaterial;
  18737. setVector4(name: string, value: Vector4): ShaderMaterial;
  18738. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18739. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18740. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18741. setArray2(name: string, value: number[]): ShaderMaterial;
  18742. setArray3(name: string, value: number[]): ShaderMaterial;
  18743. private _checkCache;
  18744. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18745. bindOnlyWorldMatrix(world: Matrix): void;
  18746. bind(world: Matrix, mesh?: Mesh): void;
  18747. getActiveTextures(): BaseTexture[];
  18748. hasTexture(texture: BaseTexture): boolean;
  18749. clone(name: string): ShaderMaterial;
  18750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18751. serialize(): any;
  18752. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18753. }
  18754. }
  18755. declare module BABYLON {
  18756. /** @hidden */
  18757. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18758. MAINUV1: boolean;
  18759. MAINUV2: boolean;
  18760. DIFFUSE: boolean;
  18761. DIFFUSEDIRECTUV: number;
  18762. AMBIENT: boolean;
  18763. AMBIENTDIRECTUV: number;
  18764. OPACITY: boolean;
  18765. OPACITYDIRECTUV: number;
  18766. OPACITYRGB: boolean;
  18767. REFLECTION: boolean;
  18768. EMISSIVE: boolean;
  18769. EMISSIVEDIRECTUV: number;
  18770. SPECULAR: boolean;
  18771. SPECULARDIRECTUV: number;
  18772. BUMP: boolean;
  18773. BUMPDIRECTUV: number;
  18774. PARALLAX: boolean;
  18775. PARALLAXOCCLUSION: boolean;
  18776. SPECULAROVERALPHA: boolean;
  18777. CLIPPLANE: boolean;
  18778. CLIPPLANE2: boolean;
  18779. CLIPPLANE3: boolean;
  18780. CLIPPLANE4: boolean;
  18781. ALPHATEST: boolean;
  18782. DEPTHPREPASS: boolean;
  18783. ALPHAFROMDIFFUSE: boolean;
  18784. POINTSIZE: boolean;
  18785. FOG: boolean;
  18786. SPECULARTERM: boolean;
  18787. DIFFUSEFRESNEL: boolean;
  18788. OPACITYFRESNEL: boolean;
  18789. REFLECTIONFRESNEL: boolean;
  18790. REFRACTIONFRESNEL: boolean;
  18791. EMISSIVEFRESNEL: boolean;
  18792. FRESNEL: boolean;
  18793. NORMAL: boolean;
  18794. UV1: boolean;
  18795. UV2: boolean;
  18796. VERTEXCOLOR: boolean;
  18797. VERTEXALPHA: boolean;
  18798. NUM_BONE_INFLUENCERS: number;
  18799. BonesPerMesh: number;
  18800. INSTANCES: boolean;
  18801. GLOSSINESS: boolean;
  18802. ROUGHNESS: boolean;
  18803. EMISSIVEASILLUMINATION: boolean;
  18804. LINKEMISSIVEWITHDIFFUSE: boolean;
  18805. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18806. LIGHTMAP: boolean;
  18807. LIGHTMAPDIRECTUV: number;
  18808. OBJECTSPACE_NORMALMAP: boolean;
  18809. USELIGHTMAPASSHADOWMAP: boolean;
  18810. REFLECTIONMAP_3D: boolean;
  18811. REFLECTIONMAP_SPHERICAL: boolean;
  18812. REFLECTIONMAP_PLANAR: boolean;
  18813. REFLECTIONMAP_CUBIC: boolean;
  18814. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18815. REFLECTIONMAP_PROJECTION: boolean;
  18816. REFLECTIONMAP_SKYBOX: boolean;
  18817. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18818. REFLECTIONMAP_EXPLICIT: boolean;
  18819. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18820. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18821. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18822. INVERTCUBICMAP: boolean;
  18823. LOGARITHMICDEPTH: boolean;
  18824. REFRACTION: boolean;
  18825. REFRACTIONMAP_3D: boolean;
  18826. REFLECTIONOVERALPHA: boolean;
  18827. TWOSIDEDLIGHTING: boolean;
  18828. SHADOWFLOAT: boolean;
  18829. MORPHTARGETS: boolean;
  18830. MORPHTARGETS_NORMAL: boolean;
  18831. MORPHTARGETS_TANGENT: boolean;
  18832. NUM_MORPH_INFLUENCERS: number;
  18833. NONUNIFORMSCALING: boolean;
  18834. PREMULTIPLYALPHA: boolean;
  18835. IMAGEPROCESSING: boolean;
  18836. VIGNETTE: boolean;
  18837. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18838. VIGNETTEBLENDMODEOPAQUE: boolean;
  18839. TONEMAPPING: boolean;
  18840. TONEMAPPING_ACES: boolean;
  18841. CONTRAST: boolean;
  18842. COLORCURVES: boolean;
  18843. COLORGRADING: boolean;
  18844. COLORGRADING3D: boolean;
  18845. SAMPLER3DGREENDEPTH: boolean;
  18846. SAMPLER3DBGRMAP: boolean;
  18847. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18848. /**
  18849. * If the reflection texture on this material is in linear color space
  18850. * @hidden
  18851. */
  18852. IS_REFLECTION_LINEAR: boolean;
  18853. /**
  18854. * If the refraction texture on this material is in linear color space
  18855. * @hidden
  18856. */
  18857. IS_REFRACTION_LINEAR: boolean;
  18858. EXPOSURE: boolean;
  18859. constructor();
  18860. setReflectionMode(modeToEnable: string): void;
  18861. }
  18862. class StandardMaterial extends PushMaterial {
  18863. private _diffuseTexture;
  18864. diffuseTexture: Nullable<BaseTexture>;
  18865. private _ambientTexture;
  18866. ambientTexture: Nullable<BaseTexture>;
  18867. private _opacityTexture;
  18868. opacityTexture: Nullable<BaseTexture>;
  18869. private _reflectionTexture;
  18870. reflectionTexture: Nullable<BaseTexture>;
  18871. private _emissiveTexture;
  18872. emissiveTexture: Nullable<BaseTexture>;
  18873. private _specularTexture;
  18874. specularTexture: Nullable<BaseTexture>;
  18875. private _bumpTexture;
  18876. bumpTexture: Nullable<BaseTexture>;
  18877. private _lightmapTexture;
  18878. lightmapTexture: Nullable<BaseTexture>;
  18879. private _refractionTexture;
  18880. refractionTexture: Nullable<BaseTexture>;
  18881. ambientColor: Color3;
  18882. diffuseColor: Color3;
  18883. specularColor: Color3;
  18884. emissiveColor: Color3;
  18885. specularPower: number;
  18886. private _useAlphaFromDiffuseTexture;
  18887. useAlphaFromDiffuseTexture: boolean;
  18888. private _useEmissiveAsIllumination;
  18889. useEmissiveAsIllumination: boolean;
  18890. private _linkEmissiveWithDiffuse;
  18891. linkEmissiveWithDiffuse: boolean;
  18892. private _useSpecularOverAlpha;
  18893. useSpecularOverAlpha: boolean;
  18894. private _useReflectionOverAlpha;
  18895. useReflectionOverAlpha: boolean;
  18896. private _disableLighting;
  18897. disableLighting: boolean;
  18898. private _useObjectSpaceNormalMap;
  18899. /**
  18900. * Allows using an object space normal map (instead of tangent space).
  18901. */
  18902. useObjectSpaceNormalMap: boolean;
  18903. private _useParallax;
  18904. useParallax: boolean;
  18905. private _useParallaxOcclusion;
  18906. useParallaxOcclusion: boolean;
  18907. parallaxScaleBias: number;
  18908. private _roughness;
  18909. roughness: number;
  18910. indexOfRefraction: number;
  18911. invertRefractionY: boolean;
  18912. /**
  18913. * Defines the alpha limits in alpha test mode
  18914. */
  18915. alphaCutOff: number;
  18916. private _useLightmapAsShadowmap;
  18917. useLightmapAsShadowmap: boolean;
  18918. private _diffuseFresnelParameters;
  18919. diffuseFresnelParameters: FresnelParameters;
  18920. private _opacityFresnelParameters;
  18921. opacityFresnelParameters: FresnelParameters;
  18922. private _reflectionFresnelParameters;
  18923. reflectionFresnelParameters: FresnelParameters;
  18924. private _refractionFresnelParameters;
  18925. refractionFresnelParameters: FresnelParameters;
  18926. private _emissiveFresnelParameters;
  18927. emissiveFresnelParameters: FresnelParameters;
  18928. private _useReflectionFresnelFromSpecular;
  18929. useReflectionFresnelFromSpecular: boolean;
  18930. private _useGlossinessFromSpecularMapAlpha;
  18931. useGlossinessFromSpecularMapAlpha: boolean;
  18932. private _maxSimultaneousLights;
  18933. maxSimultaneousLights: number;
  18934. /**
  18935. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18936. */
  18937. private _invertNormalMapX;
  18938. invertNormalMapX: boolean;
  18939. /**
  18940. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18941. */
  18942. private _invertNormalMapY;
  18943. invertNormalMapY: boolean;
  18944. /**
  18945. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18946. */
  18947. private _twoSidedLighting;
  18948. twoSidedLighting: boolean;
  18949. /**
  18950. * Default configuration related to image processing available in the standard Material.
  18951. */
  18952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18953. /**
  18954. * Gets the image processing configuration used either in this material.
  18955. */
  18956. /**
  18957. * Sets the Default image processing configuration used either in the this material.
  18958. *
  18959. * If sets to null, the scene one is in use.
  18960. */
  18961. imageProcessingConfiguration: ImageProcessingConfiguration;
  18962. /**
  18963. * Keep track of the image processing observer to allow dispose and replace.
  18964. */
  18965. private _imageProcessingObserver;
  18966. /**
  18967. * Attaches a new image processing configuration to the Standard Material.
  18968. * @param configuration
  18969. */
  18970. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18971. /**
  18972. * Gets wether the color curves effect is enabled.
  18973. */
  18974. /**
  18975. * Sets wether the color curves effect is enabled.
  18976. */
  18977. cameraColorCurvesEnabled: boolean;
  18978. /**
  18979. * Gets wether the color grading effect is enabled.
  18980. */
  18981. /**
  18982. * Gets wether the color grading effect is enabled.
  18983. */
  18984. cameraColorGradingEnabled: boolean;
  18985. /**
  18986. * Gets wether tonemapping is enabled or not.
  18987. */
  18988. /**
  18989. * Sets wether tonemapping is enabled or not
  18990. */
  18991. cameraToneMappingEnabled: boolean;
  18992. /**
  18993. * The camera exposure used on this material.
  18994. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18995. * This corresponds to a photographic exposure.
  18996. */
  18997. /**
  18998. * The camera exposure used on this material.
  18999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19000. * This corresponds to a photographic exposure.
  19001. */
  19002. cameraExposure: number;
  19003. /**
  19004. * Gets The camera contrast used on this material.
  19005. */
  19006. /**
  19007. * Sets The camera contrast used on this material.
  19008. */
  19009. cameraContrast: number;
  19010. /**
  19011. * Gets the Color Grading 2D Lookup Texture.
  19012. */
  19013. /**
  19014. * Sets the Color Grading 2D Lookup Texture.
  19015. */
  19016. cameraColorGradingTexture: Nullable<BaseTexture>;
  19017. /**
  19018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19020. * 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;
  19021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19022. */
  19023. /**
  19024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19026. * 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;
  19027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19028. */
  19029. cameraColorCurves: Nullable<ColorCurves>;
  19030. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19031. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19032. protected _worldViewProjectionMatrix: Matrix;
  19033. protected _globalAmbientColor: Color3;
  19034. protected _useLogarithmicDepth: boolean;
  19035. constructor(name: string, scene: Scene);
  19036. /**
  19037. * Gets a boolean indicating that current material needs to register RTT
  19038. */
  19039. readonly hasRenderTargetTextures: boolean;
  19040. getClassName(): string;
  19041. useLogarithmicDepth: boolean;
  19042. needAlphaBlending(): boolean;
  19043. needAlphaTesting(): boolean;
  19044. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19045. getAlphaTestTexture(): Nullable<BaseTexture>;
  19046. /**
  19047. * Child classes can use it to update shaders
  19048. */
  19049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19050. buildUniformLayout(): void;
  19051. unbind(): void;
  19052. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19053. getAnimatables(): IAnimatable[];
  19054. getActiveTextures(): BaseTexture[];
  19055. hasTexture(texture: BaseTexture): boolean;
  19056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19057. clone(name: string): StandardMaterial;
  19058. serialize(): any;
  19059. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19060. static _DiffuseTextureEnabled: boolean;
  19061. static DiffuseTextureEnabled: boolean;
  19062. static _AmbientTextureEnabled: boolean;
  19063. static AmbientTextureEnabled: boolean;
  19064. static _OpacityTextureEnabled: boolean;
  19065. static OpacityTextureEnabled: boolean;
  19066. static _ReflectionTextureEnabled: boolean;
  19067. static ReflectionTextureEnabled: boolean;
  19068. static _EmissiveTextureEnabled: boolean;
  19069. static EmissiveTextureEnabled: boolean;
  19070. static _SpecularTextureEnabled: boolean;
  19071. static SpecularTextureEnabled: boolean;
  19072. static _BumpTextureEnabled: boolean;
  19073. static BumpTextureEnabled: boolean;
  19074. static _LightmapTextureEnabled: boolean;
  19075. static LightmapTextureEnabled: boolean;
  19076. static _RefractionTextureEnabled: boolean;
  19077. static RefractionTextureEnabled: boolean;
  19078. static _ColorGradingTextureEnabled: boolean;
  19079. static ColorGradingTextureEnabled: boolean;
  19080. static _FresnelEnabled: boolean;
  19081. static FresnelEnabled: boolean;
  19082. }
  19083. }
  19084. declare module BABYLON {
  19085. class UniformBuffer {
  19086. private _engine;
  19087. private _buffer;
  19088. private _data;
  19089. private _bufferData;
  19090. private _dynamic?;
  19091. private _uniformLocations;
  19092. private _uniformSizes;
  19093. private _uniformLocationPointer;
  19094. private _needSync;
  19095. private _noUBO;
  19096. private _currentEffect;
  19097. private static _MAX_UNIFORM_SIZE;
  19098. private static _tempBuffer;
  19099. /**
  19100. * Wrapper for updateUniform.
  19101. * @method updateMatrix3x3
  19102. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19103. * @param {Float32Array} matrix
  19104. */
  19105. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19106. /**
  19107. * Wrapper for updateUniform.
  19108. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19109. * @param {Float32Array} matrix
  19110. */
  19111. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19112. /**
  19113. * Wrapper for updateUniform.
  19114. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19115. * @param {number} x
  19116. */
  19117. updateFloat: (name: string, x: number) => void;
  19118. /**
  19119. * Wrapper for updateUniform.
  19120. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19121. * @param {number} x
  19122. * @param {number} y
  19123. * @param {string} [suffix] Suffix to add to the uniform name.
  19124. */
  19125. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19126. /**
  19127. * Wrapper for updateUniform.
  19128. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19129. * @param {number} x
  19130. * @param {number} y
  19131. * @param {number} z
  19132. * @param {string} [suffix] Suffix to add to the uniform name.
  19133. */
  19134. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19135. /**
  19136. * Wrapper for updateUniform.
  19137. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19138. * @param {number} x
  19139. * @param {number} y
  19140. * @param {number} z
  19141. * @param {number} w
  19142. * @param {string} [suffix] Suffix to add to the uniform name.
  19143. */
  19144. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19145. /**
  19146. * Wrapper for updateUniform.
  19147. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19148. * @param {Matrix} A 4x4 matrix.
  19149. */
  19150. updateMatrix: (name: string, mat: Matrix) => void;
  19151. /**
  19152. * Wrapper for updateUniform.
  19153. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19154. * @param {Vector3} vector
  19155. */
  19156. updateVector3: (name: string, vector: Vector3) => void;
  19157. /**
  19158. * Wrapper for updateUniform.
  19159. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19160. * @param {Vector4} vector
  19161. */
  19162. updateVector4: (name: string, vector: Vector4) => void;
  19163. /**
  19164. * Wrapper for updateUniform.
  19165. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19166. * @param {Color3} color
  19167. * @param {string} [suffix] Suffix to add to the uniform name.
  19168. */
  19169. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19170. /**
  19171. * Wrapper for updateUniform.
  19172. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19173. * @param {Color3} color
  19174. * @param {number} alpha
  19175. * @param {string} [suffix] Suffix to add to the uniform name.
  19176. */
  19177. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19178. /**
  19179. * Uniform buffer objects.
  19180. *
  19181. * Handles blocks of uniform on the GPU.
  19182. *
  19183. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19184. *
  19185. * For more information, please refer to :
  19186. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19187. */
  19188. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19189. /**
  19190. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19191. * or just falling back on setUniformXXX calls.
  19192. */
  19193. readonly useUbo: boolean;
  19194. /**
  19195. * Indicates if the WebGL underlying uniform buffer is in sync
  19196. * with the javascript cache data.
  19197. */
  19198. readonly isSync: boolean;
  19199. /**
  19200. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19201. * Also, a dynamic UniformBuffer will disable cache verification and always
  19202. * update the underlying WebGL uniform buffer to the GPU.
  19203. */
  19204. isDynamic(): boolean;
  19205. /**
  19206. * The data cache on JS side.
  19207. */
  19208. getData(): Float32Array;
  19209. /**
  19210. * The underlying WebGL Uniform buffer.
  19211. */
  19212. getBuffer(): Nullable<WebGLBuffer>;
  19213. /**
  19214. * std140 layout specifies how to align data within an UBO structure.
  19215. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19216. * for specs.
  19217. */
  19218. private _fillAlignment;
  19219. /**
  19220. * Adds an uniform in the buffer.
  19221. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19222. * for the layout to be correct !
  19223. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19224. * @param {number|number[]} size Data size, or data directly.
  19225. */
  19226. addUniform(name: string, size: number | number[]): void;
  19227. /**
  19228. * Wrapper for addUniform.
  19229. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19230. * @param {Matrix} mat A 4x4 matrix.
  19231. */
  19232. addMatrix(name: string, mat: Matrix): void;
  19233. /**
  19234. * Wrapper for addUniform.
  19235. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19236. * @param {number} x
  19237. * @param {number} y
  19238. */
  19239. addFloat2(name: string, x: number, y: number): void;
  19240. /**
  19241. * Wrapper for addUniform.
  19242. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19243. * @param {number} x
  19244. * @param {number} y
  19245. * @param {number} z
  19246. */
  19247. addFloat3(name: string, x: number, y: number, z: number): void;
  19248. /**
  19249. * Wrapper for addUniform.
  19250. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19251. * @param {Color3} color
  19252. */
  19253. addColor3(name: string, color: Color3): void;
  19254. /**
  19255. * Wrapper for addUniform.
  19256. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19257. * @param {Color3} color
  19258. * @param {number} alpha
  19259. */
  19260. addColor4(name: string, color: Color3, alpha: number): void;
  19261. /**
  19262. * Wrapper for addUniform.
  19263. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19264. * @param {Vector3} vector
  19265. */
  19266. addVector3(name: string, vector: Vector3): void;
  19267. /**
  19268. * Wrapper for addUniform.
  19269. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19270. */
  19271. addMatrix3x3(name: string): void;
  19272. /**
  19273. * Wrapper for addUniform.
  19274. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  19275. */
  19276. addMatrix2x2(name: string): void;
  19277. /**
  19278. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19279. */
  19280. create(): void;
  19281. /** @hidden */
  19282. _rebuild(): void;
  19283. /**
  19284. * Updates the WebGL Uniform Buffer on the GPU.
  19285. * If the `dynamic` flag is set to true, no cache comparison is done.
  19286. * Otherwise, the buffer will be updated only if the cache differs.
  19287. */
  19288. update(): void;
  19289. /**
  19290. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19291. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  19292. * @param {number[]|Float32Array} data Flattened data
  19293. * @param {number} size Size of the data.
  19294. */
  19295. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19296. private _updateMatrix3x3ForUniform;
  19297. private _updateMatrix3x3ForEffect;
  19298. private _updateMatrix2x2ForEffect;
  19299. private _updateMatrix2x2ForUniform;
  19300. private _updateFloatForEffect;
  19301. private _updateFloatForUniform;
  19302. private _updateFloat2ForEffect;
  19303. private _updateFloat2ForUniform;
  19304. private _updateFloat3ForEffect;
  19305. private _updateFloat3ForUniform;
  19306. private _updateFloat4ForEffect;
  19307. private _updateFloat4ForUniform;
  19308. private _updateMatrixForEffect;
  19309. private _updateMatrixForUniform;
  19310. private _updateVector3ForEffect;
  19311. private _updateVector3ForUniform;
  19312. private _updateVector4ForEffect;
  19313. private _updateVector4ForUniform;
  19314. private _updateColor3ForEffect;
  19315. private _updateColor3ForUniform;
  19316. private _updateColor4ForEffect;
  19317. private _updateColor4ForUniform;
  19318. /**
  19319. * Sets a sampler uniform on the effect.
  19320. * @param {string} name Name of the sampler.
  19321. * @param {Texture} texture
  19322. */
  19323. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19324. /**
  19325. * Directly updates the value of the uniform in the cache AND on the GPU.
  19326. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  19327. * @param {number[]|Float32Array} data Flattened data
  19328. */
  19329. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19330. /**
  19331. * Binds this uniform buffer to an effect.
  19332. * @param {Effect} effect
  19333. * @param {string} name Name of the uniform block in the shader.
  19334. */
  19335. bindToEffect(effect: Effect, name: string): void;
  19336. /**
  19337. * Disposes the uniform buffer.
  19338. */
  19339. dispose(): void;
  19340. }
  19341. }
  19342. declare module BABYLON {
  19343. /**
  19344. * Defines a target to use with MorphTargetManager
  19345. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19346. */
  19347. class MorphTarget implements IAnimatable {
  19348. /** defines the name of the target */
  19349. name: string;
  19350. /**
  19351. * Gets or sets the list of animations
  19352. */
  19353. animations: Animation[];
  19354. private _scene;
  19355. private _positions;
  19356. private _normals;
  19357. private _tangents;
  19358. private _influence;
  19359. /**
  19360. * Observable raised when the influence changes
  19361. */
  19362. onInfluenceChanged: Observable<boolean>;
  19363. /**
  19364. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19365. */
  19366. influence: number;
  19367. private _animationPropertiesOverride;
  19368. /**
  19369. * Gets or sets the animation properties override
  19370. */
  19371. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19372. /**
  19373. * Creates a new MorphTarget
  19374. * @param name defines the name of the target
  19375. * @param influence defines the influence to use
  19376. */
  19377. constructor(
  19378. /** defines the name of the target */
  19379. name: string, influence?: number, scene?: Nullable<Scene>);
  19380. /**
  19381. * Gets a boolean defining if the target contains position data
  19382. */
  19383. readonly hasPositions: boolean;
  19384. /**
  19385. * Gets a boolean defining if the target contains normal data
  19386. */
  19387. readonly hasNormals: boolean;
  19388. /**
  19389. * Gets a boolean defining if the target contains tangent data
  19390. */
  19391. readonly hasTangents: boolean;
  19392. /**
  19393. * Affects position data to this target
  19394. * @param data defines the position data to use
  19395. */
  19396. setPositions(data: Nullable<FloatArray>): void;
  19397. /**
  19398. * Gets the position data stored in this target
  19399. * @returns a FloatArray containing the position data (or null if not present)
  19400. */
  19401. getPositions(): Nullable<FloatArray>;
  19402. /**
  19403. * Affects normal data to this target
  19404. * @param data defines the normal data to use
  19405. */
  19406. setNormals(data: Nullable<FloatArray>): void;
  19407. /**
  19408. * Gets the normal data stored in this target
  19409. * @returns a FloatArray containing the normal data (or null if not present)
  19410. */
  19411. getNormals(): Nullable<FloatArray>;
  19412. /**
  19413. * Affects tangent data to this target
  19414. * @param data defines the tangent data to use
  19415. */
  19416. setTangents(data: Nullable<FloatArray>): void;
  19417. /**
  19418. * Gets the tangent data stored in this target
  19419. * @returns a FloatArray containing the tangent data (or null if not present)
  19420. */
  19421. getTangents(): Nullable<FloatArray>;
  19422. /**
  19423. * Serializes the current target into a Serialization object
  19424. * @returns the serialized object
  19425. */
  19426. serialize(): any;
  19427. /**
  19428. * Creates a new target from serialized data
  19429. * @param serializationObject defines the serialized data to use
  19430. * @returns a new MorphTarget
  19431. */
  19432. static Parse(serializationObject: any): MorphTarget;
  19433. /**
  19434. * Creates a MorphTarget from mesh data
  19435. * @param mesh defines the source mesh
  19436. * @param name defines the name to use for the new target
  19437. * @param influence defines the influence to attach to the target
  19438. * @returns a new MorphTarget
  19439. */
  19440. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19441. }
  19442. }
  19443. declare module BABYLON {
  19444. /**
  19445. * This class is used to deform meshes using morphing between different targets
  19446. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19447. */
  19448. class MorphTargetManager {
  19449. private _targets;
  19450. private _targetObservable;
  19451. private _activeTargets;
  19452. private _scene;
  19453. private _influences;
  19454. private _supportsNormals;
  19455. private _supportsTangents;
  19456. private _vertexCount;
  19457. private _uniqueId;
  19458. private _tempInfluences;
  19459. /**
  19460. * Creates a new MorphTargetManager
  19461. * @param scene defines the current scene
  19462. */
  19463. constructor(scene?: Nullable<Scene>);
  19464. /**
  19465. * Gets the unique ID of this manager
  19466. */
  19467. readonly uniqueId: number;
  19468. /**
  19469. * Gets the number of vertices handled by this manager
  19470. */
  19471. readonly vertexCount: number;
  19472. /**
  19473. * Gets a boolean indicating if this manager supports morphing of normals
  19474. */
  19475. readonly supportsNormals: boolean;
  19476. /**
  19477. * Gets a boolean indicating if this manager supports morphing of tangents
  19478. */
  19479. readonly supportsTangents: boolean;
  19480. /**
  19481. * Gets the number of targets stored in this manager
  19482. */
  19483. readonly numTargets: number;
  19484. /**
  19485. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19486. */
  19487. readonly numInfluencers: number;
  19488. /**
  19489. * Gets the list of influences (one per target)
  19490. */
  19491. readonly influences: Float32Array;
  19492. /**
  19493. * Gets the active target at specified index. An active target is a target with an influence > 0
  19494. * @param index defines the index to check
  19495. * @returns the requested target
  19496. */
  19497. getActiveTarget(index: number): MorphTarget;
  19498. /**
  19499. * Gets the target at specified index
  19500. * @param index defines the index to check
  19501. * @returns the requested target
  19502. */
  19503. getTarget(index: number): MorphTarget;
  19504. /**
  19505. * Add a new target to this manager
  19506. * @param target defines the target to add
  19507. */
  19508. addTarget(target: MorphTarget): void;
  19509. /**
  19510. * Removes a target from the manager
  19511. * @param target defines the target to remove
  19512. */
  19513. removeTarget(target: MorphTarget): void;
  19514. /**
  19515. * Serializes the current manager into a Serialization object
  19516. * @returns the serialized object
  19517. */
  19518. serialize(): any;
  19519. private _syncActiveTargets;
  19520. /**
  19521. * Syncrhonize the targets with all the meshes using this morph target manager
  19522. */
  19523. synchronize(): void;
  19524. /**
  19525. * Creates a new MorphTargetManager from serialized data
  19526. * @param serializationObject defines the serialized data
  19527. * @param scene defines the hosting scene
  19528. * @returns the new MorphTargetManager
  19529. */
  19530. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19531. }
  19532. }
  19533. declare module BABYLON {
  19534. /**
  19535. * Class used to store all common mesh properties
  19536. */
  19537. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19538. /** No occlusion */
  19539. static OCCLUSION_TYPE_NONE: number;
  19540. /** Occlusion set to optimisitic */
  19541. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19542. /** Occlusion set to strict */
  19543. static OCCLUSION_TYPE_STRICT: number;
  19544. /** Use an accurante occlusion algorithm */
  19545. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19546. /** Use a conservative occlusion algorithm */
  19547. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19548. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19549. static readonly CULLINGSTRATEGY_STANDARD: number;
  19550. /** Culling strategy with bounding sphere only and then frustum culling */
  19551. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19552. /**
  19553. * No billboard
  19554. */
  19555. static readonly BILLBOARDMODE_NONE: number;
  19556. /** Billboard on X axis */
  19557. static readonly BILLBOARDMODE_X: number;
  19558. /** Billboard on Y axis */
  19559. static readonly BILLBOARDMODE_Y: number;
  19560. /** Billboard on Z axis */
  19561. static readonly BILLBOARDMODE_Z: number;
  19562. /** Billboard on all axes */
  19563. static readonly BILLBOARDMODE_ALL: number;
  19564. private _facetPositions;
  19565. private _facetNormals;
  19566. private _facetPartitioning;
  19567. private _facetNb;
  19568. private _partitioningSubdivisions;
  19569. private _partitioningBBoxRatio;
  19570. private _facetDataEnabled;
  19571. private _facetParameters;
  19572. private _bbSize;
  19573. private _subDiv;
  19574. private _facetDepthSort;
  19575. private _facetDepthSortEnabled;
  19576. private _depthSortedIndices;
  19577. private _depthSortedFacets;
  19578. private _facetDepthSortFunction;
  19579. private _facetDepthSortFrom;
  19580. private _facetDepthSortOrigin;
  19581. private _invertedMatrix;
  19582. /** Gets ot sets the culling strategy to use to find visible meshes */
  19583. cullingStrategy: number;
  19584. /**
  19585. * Gets the number of facets in the mesh
  19586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19587. */
  19588. readonly facetNb: number;
  19589. /**
  19590. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19592. */
  19593. partitioningSubdivisions: number;
  19594. /**
  19595. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19596. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19598. */
  19599. partitioningBBoxRatio: number;
  19600. /**
  19601. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19602. * Works only for updatable meshes.
  19603. * Doesn't work with multi-materials
  19604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19605. */
  19606. mustDepthSortFacets: boolean;
  19607. /**
  19608. * The location (Vector3) where the facet depth sort must be computed from.
  19609. * By default, the active camera position.
  19610. * Used only when facet depth sort is enabled
  19611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19612. */
  19613. facetDepthSortFrom: Vector3;
  19614. /**
  19615. * gets a boolean indicating if facetData is enabled
  19616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19617. */
  19618. readonly isFacetDataEnabled: boolean;
  19619. /** @hidden */
  19620. _updateNonUniformScalingState(value: boolean): boolean;
  19621. /**
  19622. * An event triggered when this mesh collides with another one
  19623. */
  19624. onCollideObservable: Observable<AbstractMesh>;
  19625. private _onCollideObserver;
  19626. /** Set a function to call when this mesh collides with another one */
  19627. onCollide: () => void;
  19628. /**
  19629. * An event triggered when the collision's position changes
  19630. */
  19631. onCollisionPositionChangeObservable: Observable<Vector3>;
  19632. private _onCollisionPositionChangeObserver;
  19633. /** Set a function to call when the collision's position changes */
  19634. onCollisionPositionChange: () => void;
  19635. /**
  19636. * An event triggered when material is changed
  19637. */
  19638. onMaterialChangedObservable: Observable<AbstractMesh>;
  19639. /**
  19640. * Gets or sets the orientation for POV movement & rotation
  19641. */
  19642. definedFacingForward: boolean;
  19643. /**
  19644. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19645. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19646. * * 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.
  19647. * @see http://doc.babylonjs.com/features/occlusionquery
  19648. */
  19649. occlusionQueryAlgorithmType: number;
  19650. /**
  19651. * 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:
  19652. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19653. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19654. * * 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.
  19655. * @see http://doc.babylonjs.com/features/occlusionquery
  19656. */
  19657. occlusionType: number;
  19658. /**
  19659. * 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.
  19660. * The default value is -1 which means don't break the query and wait till the result
  19661. * @see http://doc.babylonjs.com/features/occlusionquery
  19662. */
  19663. occlusionRetryCount: number;
  19664. /** @hidden */
  19665. _occlusionInternalRetryCounter: number;
  19666. /** @hidden */
  19667. _isOccluded: boolean;
  19668. /**
  19669. * 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
  19670. * @see http://doc.babylonjs.com/features/occlusionquery
  19671. */
  19672. isOccluded: boolean;
  19673. /** @hidden */
  19674. _isOcclusionQueryInProgress: boolean;
  19675. /**
  19676. * Flag to check the progress status of the query
  19677. * @see http://doc.babylonjs.com/features/occlusionquery
  19678. */
  19679. readonly isOcclusionQueryInProgress: boolean;
  19680. /** @hidden */
  19681. _occlusionQuery: Nullable<WebGLQuery>;
  19682. private _visibility;
  19683. /**
  19684. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19685. */
  19686. /**
  19687. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19688. */
  19689. visibility: number;
  19690. /** Gets or sets the alpha index used to sort transparent meshes
  19691. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19692. */
  19693. alphaIndex: number;
  19694. /**
  19695. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19696. */
  19697. isVisible: boolean;
  19698. /**
  19699. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19700. */
  19701. isPickable: boolean;
  19702. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19703. showSubMeshesBoundingBox: boolean;
  19704. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19706. */
  19707. isBlocker: boolean;
  19708. /**
  19709. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19710. */
  19711. enablePointerMoveEvents: boolean;
  19712. /**
  19713. * Specifies the rendering group id for this mesh (0 by default)
  19714. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19715. */
  19716. renderingGroupId: number;
  19717. private _material;
  19718. /** Gets or sets current material */
  19719. material: Nullable<Material>;
  19720. private _receiveShadows;
  19721. /**
  19722. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19723. * @see http://doc.babylonjs.com/babylon101/shadows
  19724. */
  19725. receiveShadows: boolean;
  19726. /** Defines color to use when rendering outline */
  19727. outlineColor: Color3;
  19728. /** Define width to use when rendering outline */
  19729. outlineWidth: number;
  19730. /** Defines color to use when rendering overlay */
  19731. overlayColor: Color3;
  19732. /** Defines alpha to use when rendering overlay */
  19733. overlayAlpha: number;
  19734. private _hasVertexAlpha;
  19735. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19736. hasVertexAlpha: boolean;
  19737. private _useVertexColors;
  19738. /** 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) */
  19739. useVertexColors: boolean;
  19740. private _computeBonesUsingShaders;
  19741. /**
  19742. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19743. */
  19744. computeBonesUsingShaders: boolean;
  19745. private _numBoneInfluencers;
  19746. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19747. numBoneInfluencers: number;
  19748. private _applyFog;
  19749. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19750. applyFog: boolean;
  19751. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19752. useOctreeForRenderingSelection: boolean;
  19753. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19754. useOctreeForPicking: boolean;
  19755. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19756. useOctreeForCollisions: boolean;
  19757. private _layerMask;
  19758. /**
  19759. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19760. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19761. */
  19762. layerMask: number;
  19763. /**
  19764. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19765. */
  19766. alwaysSelectAsActiveMesh: boolean;
  19767. /**
  19768. * Gets or sets the current action manager
  19769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19770. */
  19771. actionManager: Nullable<ActionManager>;
  19772. /**
  19773. * Gets or sets impostor used for physic simulation
  19774. * @see http://doc.babylonjs.com/features/physics_engine
  19775. */
  19776. physicsImpostor: Nullable<PhysicsImpostor>;
  19777. private _checkCollisions;
  19778. private _collisionMask;
  19779. private _collisionGroup;
  19780. /**
  19781. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19783. */
  19784. ellipsoid: Vector3;
  19785. /**
  19786. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19788. */
  19789. ellipsoidOffset: Vector3;
  19790. private _collider;
  19791. private _oldPositionForCollisions;
  19792. private _diffPositionForCollisions;
  19793. /**
  19794. * Gets or sets a collision mask used to mask collisions (default is -1).
  19795. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19796. */
  19797. collisionMask: number;
  19798. /**
  19799. * Gets or sets the current collision group mask (-1 by default).
  19800. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19801. */
  19802. collisionGroup: number;
  19803. /**
  19804. * Defines edge width used when edgesRenderer is enabled
  19805. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19806. */
  19807. edgesWidth: number;
  19808. /**
  19809. * Defines edge color used when edgesRenderer is enabled
  19810. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19811. */
  19812. edgesColor: Color4;
  19813. /** @hidden */
  19814. _edgesRenderer: Nullable<IEdgesRenderer>;
  19815. private _collisionsTransformMatrix;
  19816. private _collisionsScalingMatrix;
  19817. /** @hidden */
  19818. _masterMesh: Nullable<AbstractMesh>;
  19819. /** @hidden */
  19820. _boundingInfo: Nullable<BoundingInfo>;
  19821. /** @hidden */
  19822. _renderId: number;
  19823. /**
  19824. * Gets or sets the list of subMeshes
  19825. * @see http://doc.babylonjs.com/how_to/multi_materials
  19826. */
  19827. subMeshes: SubMesh[];
  19828. /** @hidden */
  19829. _intersectionsInProgress: AbstractMesh[];
  19830. /** @hidden */
  19831. _unIndexed: boolean;
  19832. /** @hidden */
  19833. _lightSources: Light[];
  19834. /** @hidden */
  19835. readonly _positions: Nullable<Vector3[]>;
  19836. /** @hidden */
  19837. _waitingActions: any;
  19838. /** @hidden */
  19839. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19840. private _skeleton;
  19841. /** @hidden */
  19842. _bonesTransformMatrices: Nullable<Float32Array>;
  19843. /**
  19844. * Gets or sets a skeleton to apply skining transformations
  19845. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19846. */
  19847. skeleton: Nullable<Skeleton>;
  19848. /**
  19849. * An event triggered when the mesh is rebuilt.
  19850. */
  19851. onRebuildObservable: Observable<AbstractMesh>;
  19852. /**
  19853. * Creates a new AbstractMesh
  19854. * @param name defines the name of the mesh
  19855. * @param scene defines the hosting scene
  19856. */
  19857. constructor(name: string, scene?: Nullable<Scene>);
  19858. /**
  19859. * Returns the string "AbstractMesh"
  19860. * @returns "AbstractMesh"
  19861. */
  19862. getClassName(): string;
  19863. /**
  19864. * Gets a string representation of the current mesh
  19865. * @param fullDetails defines a boolean indicating if full details must be included
  19866. * @returns a string representation of the current mesh
  19867. */
  19868. toString(fullDetails?: boolean): string;
  19869. /** @hidden */
  19870. _rebuild(): void;
  19871. /** @hidden */
  19872. _resyncLightSources(): void;
  19873. /** @hidden */
  19874. _resyncLighSource(light: Light): void;
  19875. /** @hidden */
  19876. _unBindEffect(): void;
  19877. /** @hidden */
  19878. _removeLightSource(light: Light): void;
  19879. private _markSubMeshesAsDirty;
  19880. /** @hidden */
  19881. _markSubMeshesAsLightDirty(): void;
  19882. /** @hidden */
  19883. _markSubMeshesAsAttributesDirty(): void;
  19884. /** @hidden */
  19885. _markSubMeshesAsMiscDirty(): void;
  19886. /**
  19887. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19888. */
  19889. scaling: Vector3;
  19890. /**
  19891. * Returns true if the mesh is blocked. Implemented by child classes
  19892. */
  19893. readonly isBlocked: boolean;
  19894. /**
  19895. * Returns the mesh itself by default. Implemented by child classes
  19896. * @param camera defines the camera to use to pick the right LOD level
  19897. * @returns the currentAbstractMesh
  19898. */
  19899. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19900. /**
  19901. * Returns 0 by default. Implemented by child classes
  19902. * @returns an integer
  19903. */
  19904. getTotalVertices(): number;
  19905. /**
  19906. * Returns null by default. Implemented by child classes
  19907. * @returns null
  19908. */
  19909. getIndices(): Nullable<IndicesArray>;
  19910. /**
  19911. * Returns the array of the requested vertex data kind. Implemented by child classes
  19912. * @param kind defines the vertex data kind to use
  19913. * @returns null
  19914. */
  19915. getVerticesData(kind: string): Nullable<FloatArray>;
  19916. /**
  19917. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19918. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19919. * Note that a new underlying VertexBuffer object is created each call.
  19920. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19921. * @param kind defines vertex data kind:
  19922. * * BABYLON.VertexBuffer.PositionKind
  19923. * * BABYLON.VertexBuffer.UVKind
  19924. * * BABYLON.VertexBuffer.UV2Kind
  19925. * * BABYLON.VertexBuffer.UV3Kind
  19926. * * BABYLON.VertexBuffer.UV4Kind
  19927. * * BABYLON.VertexBuffer.UV5Kind
  19928. * * BABYLON.VertexBuffer.UV6Kind
  19929. * * BABYLON.VertexBuffer.ColorKind
  19930. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19931. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19932. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19933. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19934. * @param data defines the data source
  19935. * @param updatable defines if the data must be flagged as updatable (or static)
  19936. * @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
  19937. * @returns the current mesh
  19938. */
  19939. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19940. /**
  19941. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19942. * If the mesh has no geometry, it is simply returned as it is.
  19943. * @param kind defines vertex data kind:
  19944. * * BABYLON.VertexBuffer.PositionKind
  19945. * * BABYLON.VertexBuffer.UVKind
  19946. * * BABYLON.VertexBuffer.UV2Kind
  19947. * * BABYLON.VertexBuffer.UV3Kind
  19948. * * BABYLON.VertexBuffer.UV4Kind
  19949. * * BABYLON.VertexBuffer.UV5Kind
  19950. * * BABYLON.VertexBuffer.UV6Kind
  19951. * * BABYLON.VertexBuffer.ColorKind
  19952. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19953. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19954. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19955. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19956. * @param data defines the data source
  19957. * @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
  19958. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19959. * @returns the current mesh
  19960. */
  19961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19962. /**
  19963. * Sets the mesh indices,
  19964. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19965. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19966. * @param totalVertices Defines the total number of vertices
  19967. * @returns the current mesh
  19968. */
  19969. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19970. /**
  19971. * Gets a boolean indicating if specific vertex data is present
  19972. * @param kind defines the vertex data kind to use
  19973. * @returns true is data kind is present
  19974. */
  19975. isVerticesDataPresent(kind: string): boolean;
  19976. /**
  19977. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19978. * @returns a BoundingInfo
  19979. */
  19980. getBoundingInfo(): BoundingInfo;
  19981. /**
  19982. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19983. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19984. * @returns the current mesh
  19985. */
  19986. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19987. /**
  19988. * Overwrite the current bounding info
  19989. * @param boundingInfo defines the new bounding info
  19990. * @returns the current mesh
  19991. */
  19992. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19993. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19994. readonly useBones: boolean;
  19995. /** @hidden */
  19996. _preActivate(): void;
  19997. /** @hidden */
  19998. _preActivateForIntermediateRendering(renderId: number): void;
  19999. /** @hidden */
  20000. _activate(renderId: number): void;
  20001. /**
  20002. * Gets the current world matrix
  20003. * @returns a Matrix
  20004. */
  20005. getWorldMatrix(): Matrix;
  20006. /** @hidden */
  20007. _getWorldMatrixDeterminant(): number;
  20008. /**
  20009. * Perform relative position change from the point of view of behind the front of the mesh.
  20010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20011. * Supports definition of mesh facing forward or backward
  20012. * @param amountRight defines the distance on the right axis
  20013. * @param amountUp defines the distance on the up axis
  20014. * @param amountForward defines the distance on the forward axis
  20015. * @returns the current mesh
  20016. */
  20017. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  20018. /**
  20019. * Calculate relative position change from the point of view of behind the front of the mesh.
  20020. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20021. * Supports definition of mesh facing forward or backward
  20022. * @param amountRight defines the distance on the right axis
  20023. * @param amountUp defines the distance on the up axis
  20024. * @param amountForward defines the distance on the forward axis
  20025. * @returns the new displacement vector
  20026. */
  20027. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20028. /**
  20029. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20030. * Supports definition of mesh facing forward or backward
  20031. * @param flipBack defines the flip
  20032. * @param twirlClockwise defines the twirl
  20033. * @param tiltRight defines the tilt
  20034. * @returns the current mesh
  20035. */
  20036. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20037. /**
  20038. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20039. * Supports definition of mesh facing forward or backward.
  20040. * @param flipBack defines the flip
  20041. * @param twirlClockwise defines the twirl
  20042. * @param tiltRight defines the tilt
  20043. * @returns the new rotation vector
  20044. */
  20045. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  20046. /**
  20047. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  20048. * @param includeDescendants Include bounding info from descendants as well (true by default)
  20049. * @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
  20050. * @returns the new bounding vectors
  20051. */
  20052. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  20053. min: Vector3;
  20054. max: Vector3;
  20055. };
  20056. /** @hidden */
  20057. _updateBoundingInfo(): AbstractMesh;
  20058. /** @hidden */
  20059. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  20060. /** @hidden */
  20061. protected _afterComputeWorldMatrix(): void;
  20062. /**
  20063. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20064. * A mesh is in the frustum if its bounding box intersects the frustum
  20065. * @param frustumPlanes defines the frustum to test
  20066. * @returns true if the mesh is in the frustum planes
  20067. */
  20068. isInFrustum(frustumPlanes: Plane[]): boolean;
  20069. /**
  20070. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  20071. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  20072. * @param frustumPlanes defines the frustum to test
  20073. * @returns true if the mesh is completely in the frustum planes
  20074. */
  20075. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20076. /**
  20077. * True if the mesh intersects another mesh or a SolidParticle object
  20078. * @param mesh defines a target mesh or SolidParticle to test
  20079. * @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)
  20080. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  20081. * @returns true if there is an intersection
  20082. */
  20083. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  20084. /**
  20085. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  20086. * @param point defines the point to test
  20087. * @returns true if there is an intersection
  20088. */
  20089. intersectsPoint(point: Vector3): boolean;
  20090. /**
  20091. * Gets the current physics impostor
  20092. * @see http://doc.babylonjs.com/features/physics_engine
  20093. * @returns a physics impostor or null
  20094. */
  20095. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  20096. /**
  20097. * Gets the position of the current mesh in camera space
  20098. * @param camera defines the camera to use
  20099. * @returns a position
  20100. */
  20101. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20102. /**
  20103. * Returns the distance from the mesh to the active camera
  20104. * @param camera defines the camera to use
  20105. * @returns the distance
  20106. */
  20107. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20108. /**
  20109. * Apply a physic impulse to the mesh
  20110. * @param force defines the force to apply
  20111. * @param contactPoint defines where to apply the force
  20112. * @returns the current mesh
  20113. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20114. */
  20115. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  20116. /**
  20117. * Creates a physic joint between two meshes
  20118. * @param otherMesh defines the other mesh to use
  20119. * @param pivot1 defines the pivot to use on this mesh
  20120. * @param pivot2 defines the pivot to use on the other mesh
  20121. * @param options defines additional options (can be plugin dependent)
  20122. * @returns the current mesh
  20123. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  20124. */
  20125. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  20126. /**
  20127. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  20128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20129. */
  20130. checkCollisions: boolean;
  20131. /**
  20132. * Gets Collider object used to compute collisions (not physics)
  20133. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20134. */
  20135. readonly collider: Collider;
  20136. /**
  20137. * Move the mesh using collision engine
  20138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20139. * @param displacement defines the requested displacement vector
  20140. * @returns the current mesh
  20141. */
  20142. moveWithCollisions(displacement: Vector3): AbstractMesh;
  20143. private _onCollisionPositionChange;
  20144. /** @hidden */
  20145. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  20146. /** @hidden */
  20147. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  20148. /** @hidden */
  20149. _checkCollision(collider: Collider): AbstractMesh;
  20150. /** @hidden */
  20151. _generatePointsArray(): boolean;
  20152. /**
  20153. * Checks if the passed Ray intersects with the mesh
  20154. * @param ray defines the ray to use
  20155. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20156. * @returns the picking info
  20157. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20158. */
  20159. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20160. /**
  20161. * Clones the current mesh
  20162. * @param name defines the mesh name
  20163. * @param newParent defines the new mesh parent
  20164. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20165. * @returns the new mesh
  20166. */
  20167. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20168. /**
  20169. * Disposes all the submeshes of the current meshnp
  20170. * @returns the current mesh
  20171. */
  20172. releaseSubMeshes(): AbstractMesh;
  20173. /**
  20174. * Releases resources associated with this abstract mesh.
  20175. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20176. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20177. */
  20178. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20179. /**
  20180. * Adds the passed mesh as a child to the current mesh
  20181. * @param mesh defines the child mesh
  20182. * @returns the current mesh
  20183. */
  20184. addChild(mesh: AbstractMesh): AbstractMesh;
  20185. /**
  20186. * Removes the passed mesh from the current mesh children list
  20187. * @param mesh defines the child mesh
  20188. * @returns the current mesh
  20189. */
  20190. removeChild(mesh: AbstractMesh): AbstractMesh;
  20191. /** @hidden */
  20192. private _initFacetData;
  20193. /**
  20194. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20195. * This method can be called within the render loop.
  20196. * 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
  20197. * @returns the current mesh
  20198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20199. */
  20200. updateFacetData(): AbstractMesh;
  20201. /**
  20202. * Returns the facetLocalNormals array.
  20203. * The normals are expressed in the mesh local spac
  20204. * @returns an array of Vector3
  20205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20206. */
  20207. getFacetLocalNormals(): Vector3[];
  20208. /**
  20209. * Returns the facetLocalPositions array.
  20210. * The facet positions are expressed in the mesh local space
  20211. * @returns an array of Vector3
  20212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20213. */
  20214. getFacetLocalPositions(): Vector3[];
  20215. /**
  20216. * Returns the facetLocalPartioning array
  20217. * @returns an array of array of numbers
  20218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20219. */
  20220. getFacetLocalPartitioning(): number[][];
  20221. /**
  20222. * Returns the i-th facet position in the world system.
  20223. * This method allocates a new Vector3 per call
  20224. * @param i defines the facet index
  20225. * @returns a new Vector3
  20226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20227. */
  20228. getFacetPosition(i: number): Vector3;
  20229. /**
  20230. * Sets the reference Vector3 with the i-th facet position in the world system
  20231. * @param i defines the facet index
  20232. * @param ref defines the target vector
  20233. * @returns the current mesh
  20234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20235. */
  20236. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20237. /**
  20238. * Returns the i-th facet normal in the world system.
  20239. * This method allocates a new Vector3 per call
  20240. * @param i defines the facet index
  20241. * @returns a new Vector3
  20242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20243. */
  20244. getFacetNormal(i: number): Vector3;
  20245. /**
  20246. * Sets the reference Vector3 with the i-th facet normal in the world system
  20247. * @param i defines the facet index
  20248. * @param ref defines the target vector
  20249. * @returns the current mesh
  20250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20251. */
  20252. getFacetNormalToRef(i: number, ref: Vector3): this;
  20253. /**
  20254. * 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)
  20255. * @param x defines x coordinate
  20256. * @param y defines y coordinate
  20257. * @param z defines z coordinate
  20258. * @returns the array of facet indexes
  20259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20260. */
  20261. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20262. /**
  20263. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20264. * @param projected sets as the (x,y,z) world projection on the facet
  20265. * @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
  20266. * @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
  20267. * @param x defines x coordinate
  20268. * @param y defines y coordinate
  20269. * @param z defines z coordinate
  20270. * @returns the face index if found (or null instead)
  20271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20272. */
  20273. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20274. /**
  20275. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20276. * @param projected sets as the (x,y,z) local projection on the facet
  20277. * @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
  20278. * @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
  20279. * @param x defines x coordinate
  20280. * @param y defines y coordinate
  20281. * @param z defines z coordinate
  20282. * @returns the face index if found (or null instead)
  20283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20284. */
  20285. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20286. /**
  20287. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20288. * @returns the parameters
  20289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20290. */
  20291. getFacetDataParameters(): any;
  20292. /**
  20293. * Disables the feature FacetData and frees the related memory
  20294. * @returns the current mesh
  20295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20296. */
  20297. disableFacetData(): AbstractMesh;
  20298. /**
  20299. * Updates the AbstractMesh indices array
  20300. * @param indices defines the data source
  20301. * @returns the current mesh
  20302. */
  20303. updateIndices(indices: IndicesArray): AbstractMesh;
  20304. /**
  20305. * Creates new normals data for the mesh
  20306. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20307. * @returns the current mesh
  20308. */
  20309. createNormals(updatable: boolean): AbstractMesh;
  20310. /**
  20311. * Align the mesh with a normal
  20312. * @param normal defines the normal to use
  20313. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20314. * @returns the current mesh
  20315. */
  20316. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20317. /** @hidden */
  20318. _checkOcclusionQuery(): void;
  20319. }
  20320. }
  20321. declare module BABYLON {
  20322. class Buffer {
  20323. private _engine;
  20324. private _buffer;
  20325. /** @hidden */
  20326. _data: Nullable<DataArray>;
  20327. private _updatable;
  20328. private _instanced;
  20329. /**
  20330. * Gets the byte stride.
  20331. */
  20332. readonly byteStride: number;
  20333. /**
  20334. * Constructor
  20335. * @param engine the engine
  20336. * @param data the data to use for this buffer
  20337. * @param updatable whether the data is updatable
  20338. * @param stride the stride (optional)
  20339. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20340. * @param instanced whether the buffer is instanced (optional)
  20341. * @param useBytes set to true if the stride in in bytes (optional)
  20342. */
  20343. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20344. /**
  20345. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20346. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20347. * @param offset defines offset in the buffer (0 by default)
  20348. * @param size defines the size in floats of attributes (position is 3 for instance)
  20349. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20350. * @param instanced defines if the vertex buffer contains indexed data
  20351. * @param useBytes defines if the offset and stride are in bytes
  20352. * @returns the new vertex buffer
  20353. */
  20354. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20355. isUpdatable(): boolean;
  20356. getData(): Nullable<DataArray>;
  20357. getBuffer(): Nullable<WebGLBuffer>;
  20358. /**
  20359. * Gets the stride in float32 units (i.e. byte stride / 4).
  20360. * May not be an integer if the byte stride is not divisible by 4.
  20361. * DEPRECATED. Use byteStride instead.
  20362. * @returns the stride in float32 units
  20363. */
  20364. getStrideSize(): number;
  20365. create(data?: Nullable<DataArray>): void;
  20366. /** @hidden */
  20367. _rebuild(): void;
  20368. update(data: DataArray): void;
  20369. /**
  20370. * Updates the data directly.
  20371. * @param data the new data
  20372. * @param offset the new offset
  20373. * @param vertexCount the vertex count (optional)
  20374. * @param useBytes set to true if the offset is in bytes
  20375. */
  20376. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20377. dispose(): void;
  20378. }
  20379. }
  20380. declare module BABYLON {
  20381. class CSG {
  20382. private polygons;
  20383. matrix: Matrix;
  20384. position: Vector3;
  20385. rotation: Vector3;
  20386. rotationQuaternion: Nullable<Quaternion>;
  20387. scaling: Vector3;
  20388. static FromMesh(mesh: Mesh): CSG;
  20389. private static FromPolygons;
  20390. clone(): CSG;
  20391. union(csg: CSG): CSG;
  20392. unionInPlace(csg: CSG): void;
  20393. subtract(csg: CSG): CSG;
  20394. subtractInPlace(csg: CSG): void;
  20395. intersect(csg: CSG): CSG;
  20396. intersectInPlace(csg: CSG): void;
  20397. inverse(): CSG;
  20398. inverseInPlace(): void;
  20399. copyTransformAttributes(csg: CSG): CSG;
  20400. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20401. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20402. }
  20403. }
  20404. declare module BABYLON {
  20405. /**
  20406. * Class used to store geometry data (vertex buffers + index buffer)
  20407. */
  20408. class Geometry implements IGetSetVerticesData {
  20409. /**
  20410. * Gets or sets the unique ID of the geometry
  20411. */
  20412. id: string;
  20413. /**
  20414. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20415. */
  20416. delayLoadState: number;
  20417. /**
  20418. * Gets the file containing the data to load when running in delay load state
  20419. */
  20420. delayLoadingFile: Nullable<string>;
  20421. /**
  20422. * Callback called when the geometry is updated
  20423. */
  20424. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20425. private _scene;
  20426. private _engine;
  20427. private _meshes;
  20428. private _totalVertices;
  20429. /** @hidden */
  20430. _indices: IndicesArray;
  20431. /** @hidden */
  20432. _vertexBuffers: {
  20433. [key: string]: VertexBuffer;
  20434. };
  20435. private _isDisposed;
  20436. private _extend;
  20437. private _boundingBias;
  20438. /** @hidden */
  20439. _delayInfo: Array<string>;
  20440. private _indexBuffer;
  20441. private _indexBufferIsUpdatable;
  20442. /** @hidden */
  20443. _boundingInfo: Nullable<BoundingInfo>;
  20444. /** @hidden */
  20445. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20446. /** @hidden */
  20447. _softwareSkinningFrameId: number;
  20448. private _vertexArrayObjects;
  20449. private _updatable;
  20450. /** @hidden */
  20451. _positions: Nullable<Vector3[]>;
  20452. /**
  20453. * 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
  20454. */
  20455. /**
  20456. * 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
  20457. */
  20458. boundingBias: Vector2;
  20459. /**
  20460. * Static function used to attach a new empty geometry to a mesh
  20461. * @param mesh defines the mesh to attach the geometry to
  20462. * @returns the new {BABYLON.Geometry}
  20463. */
  20464. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20465. /**
  20466. * Creates a new geometry
  20467. * @param id defines the unique ID
  20468. * @param scene defines the hosting scene
  20469. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20470. * @param updatable defines if geometry must be updatable (false by default)
  20471. * @param mesh defines the mesh that will be associated with the geometry
  20472. */
  20473. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20474. /**
  20475. * Gets the current extend of the geometry
  20476. */
  20477. readonly extend: {
  20478. minimum: Vector3;
  20479. maximum: Vector3;
  20480. };
  20481. /**
  20482. * Gets the hosting scene
  20483. * @returns the hosting {BABYLON.Scene}
  20484. */
  20485. getScene(): Scene;
  20486. /**
  20487. * Gets the hosting engine
  20488. * @returns the hosting {BABYLON.Engine}
  20489. */
  20490. getEngine(): Engine;
  20491. /**
  20492. * Defines if the geometry is ready to use
  20493. * @returns true if the geometry is ready to be used
  20494. */
  20495. isReady(): boolean;
  20496. /**
  20497. * Gets a value indicating that the geometry should not be serialized
  20498. */
  20499. readonly doNotSerialize: boolean;
  20500. /** @hidden */
  20501. _rebuild(): void;
  20502. /**
  20503. * Affects all geometry data in one call
  20504. * @param vertexData defines the geometry data
  20505. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20506. */
  20507. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20508. /**
  20509. * Set specific vertex data
  20510. * @param kind defines the data kind (Position, normal, etc...)
  20511. * @param data defines the vertex data to use
  20512. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20513. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20514. */
  20515. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20516. /**
  20517. * Removes a specific vertex data
  20518. * @param kind defines the data kind (Position, normal, etc...)
  20519. */
  20520. removeVerticesData(kind: string): void;
  20521. /**
  20522. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20523. * @param buffer defines the vertex buffer to use
  20524. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20525. */
  20526. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20527. /**
  20528. * Update a specific vertex buffer
  20529. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20530. * It will do nothing if the buffer is not updatable
  20531. * @param kind defines the data kind (Position, normal, etc...)
  20532. * @param data defines the data to use
  20533. * @param offset defines the offset in the target buffer where to store the data
  20534. * @param useBytes set to true if the offset is in bytes
  20535. */
  20536. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20537. /**
  20538. * Update a specific vertex buffer
  20539. * This function will create a new buffer if the current one is not updatable
  20540. * @param kind defines the data kind (Position, normal, etc...)
  20541. * @param data defines the data to use
  20542. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20543. */
  20544. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20545. private _updateBoundingInfo;
  20546. /** @hidden */
  20547. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20548. /**
  20549. * Gets total number of vertices
  20550. * @returns the total number of vertices
  20551. */
  20552. getTotalVertices(): number;
  20553. /**
  20554. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20555. * @param kind defines the data kind (Position, normal, etc...)
  20556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20558. * @returns a float array containing vertex data
  20559. */
  20560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20561. /**
  20562. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20563. * @param kind defines the data kind (Position, normal, etc...)
  20564. * @returns true if the vertex buffer with the specified kind is updatable
  20565. */
  20566. isVertexBufferUpdatable(kind: string): boolean;
  20567. /**
  20568. * Gets a specific vertex buffer
  20569. * @param kind defines the data kind (Position, normal, etc...)
  20570. * @returns a {BABYLON.VertexBuffer}
  20571. */
  20572. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20573. /**
  20574. * Returns all vertex buffers
  20575. * @return an object holding all vertex buffers indexed by kind
  20576. */
  20577. getVertexBuffers(): Nullable<{
  20578. [key: string]: VertexBuffer;
  20579. }>;
  20580. /**
  20581. * Gets a boolean indicating if specific vertex buffer is present
  20582. * @param kind defines the data kind (Position, normal, etc...)
  20583. * @returns true if data is present
  20584. */
  20585. isVerticesDataPresent(kind: string): boolean;
  20586. /**
  20587. * Gets a list of all attached data kinds (Position, normal, etc...)
  20588. * @returns a list of string containing all kinds
  20589. */
  20590. getVerticesDataKinds(): string[];
  20591. /**
  20592. * Update index buffer
  20593. * @param indices defines the indices to store in the index buffer
  20594. * @param offset defines the offset in the target buffer where to store the data
  20595. */
  20596. updateIndices(indices: IndicesArray, offset?: number): void;
  20597. /**
  20598. * Creates a new index buffer
  20599. * @param indices defines the indices to store in the index buffer
  20600. * @param totalVertices defines the total number of vertices (could be null)
  20601. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20602. */
  20603. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20604. /**
  20605. * Return the total number of indices
  20606. * @returns the total number of indices
  20607. */
  20608. getTotalIndices(): number;
  20609. /**
  20610. * Gets the index buffer array
  20611. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20613. * @returns the index buffer array
  20614. */
  20615. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20616. /**
  20617. * Gets the index buffer
  20618. * @return the index buffer
  20619. */
  20620. getIndexBuffer(): Nullable<WebGLBuffer>;
  20621. /** @hidden */
  20622. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20623. /**
  20624. * Release the associated resources for a specific mesh
  20625. * @param mesh defines the source mesh
  20626. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20627. */
  20628. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20629. /**
  20630. * Apply current geometry to a given mesh
  20631. * @param mesh defines the mesh to apply geometry to
  20632. */
  20633. applyToMesh(mesh: Mesh): void;
  20634. private _updateExtend;
  20635. private _applyToMesh;
  20636. private notifyUpdate;
  20637. /**
  20638. * Load the geometry if it was flagged as delay loaded
  20639. * @param scene defines the hosting scene
  20640. * @param onLoaded defines a callback called when the geometry is loaded
  20641. */
  20642. load(scene: Scene, onLoaded?: () => void): void;
  20643. private _queueLoad;
  20644. /**
  20645. * Invert the geometry to move from a right handed system to a left handed one.
  20646. */
  20647. toLeftHanded(): void;
  20648. /** @hidden */
  20649. _resetPointsArrayCache(): void;
  20650. /** @hidden */
  20651. _generatePointsArray(): boolean;
  20652. /**
  20653. * Gets a value indicating if the geometry is disposed
  20654. * @returns true if the geometry was disposed
  20655. */
  20656. isDisposed(): boolean;
  20657. private _disposeVertexArrayObjects;
  20658. /**
  20659. * Free all associated resources
  20660. */
  20661. dispose(): void;
  20662. /**
  20663. * Clone the current geometry into a new geometry
  20664. * @param id defines the unique ID of the new geometry
  20665. * @returns a new geometry object
  20666. */
  20667. copy(id: string): Geometry;
  20668. /**
  20669. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20670. * @return a JSON representation of the current geometry data (without the vertices data)
  20671. */
  20672. serialize(): any;
  20673. private toNumberArray;
  20674. /**
  20675. * Serialize all vertices data into a JSON oject
  20676. * @returns a JSON representation of the current geometry data
  20677. */
  20678. serializeVerticeData(): any;
  20679. /**
  20680. * Extracts a clone of a mesh geometry
  20681. * @param mesh defines the source mesh
  20682. * @param id defines the unique ID of the new geometry object
  20683. * @returns the new geometry object
  20684. */
  20685. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20686. /**
  20687. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20688. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20689. * Be aware Math.random() could cause collisions, but:
  20690. * "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"
  20691. * @returns a string containing a new GUID
  20692. */
  20693. static RandomId(): string;
  20694. /** @hidden */
  20695. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20696. private static _CleanMatricesWeights;
  20697. /**
  20698. * Create a new geometry from persisted data (Using .babylon file format)
  20699. * @param parsedVertexData defines the persisted data
  20700. * @param scene defines the hosting scene
  20701. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20702. * @returns the new geometry object
  20703. */
  20704. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20705. }
  20706. /**
  20707. * Abstract class used to provide common services for all typed geometries
  20708. * @hidden
  20709. */
  20710. class _PrimitiveGeometry extends Geometry {
  20711. private _canBeRegenerated;
  20712. private _beingRegenerated;
  20713. /**
  20714. * Creates a new typed geometry
  20715. * @param id defines the unique ID of the geometry
  20716. * @param scene defines the hosting scene
  20717. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20718. * @param mesh defines the hosting mesh (can be null)
  20719. */
  20720. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20721. /**
  20722. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20723. * @returns true if the geometry can be regenerated
  20724. */
  20725. canBeRegenerated(): boolean;
  20726. /**
  20727. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20728. */
  20729. regenerate(): void;
  20730. /**
  20731. * Clone the geometry
  20732. * @param id defines the unique ID of the new geometry
  20733. * @returns the new geometry
  20734. */
  20735. asNewGeometry(id: string): Geometry;
  20736. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20738. /** @hidden */
  20739. _regenerateVertexData(): VertexData;
  20740. copy(id: string): Geometry;
  20741. serialize(): any;
  20742. }
  20743. /**
  20744. * Creates a ribbon geometry
  20745. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20746. */
  20747. class RibbonGeometry extends _PrimitiveGeometry {
  20748. /**
  20749. * Defines the array of paths to use
  20750. */
  20751. pathArray: Vector3[][];
  20752. /**
  20753. * Defines if the last and first points of each path in your pathArray must be joined
  20754. */
  20755. closeArray: boolean;
  20756. /**
  20757. * Defines if the last and first points of each path in your pathArray must be joined
  20758. */
  20759. closePath: boolean;
  20760. /**
  20761. * Defines the offset between points
  20762. */
  20763. offset: number;
  20764. /**
  20765. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20766. */
  20767. side: number;
  20768. /**
  20769. * Creates a ribbon geometry
  20770. * @param id defines the unique ID of the geometry
  20771. * @param scene defines the hosting scene
  20772. * @param pathArray defines the array of paths to use
  20773. * @param closeArray defines if the last path and the first path must be joined
  20774. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20775. * @param offset defines the offset between points
  20776. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20777. * @param mesh defines the hosting mesh (can be null)
  20778. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20779. */
  20780. constructor(id: string, scene: Scene,
  20781. /**
  20782. * Defines the array of paths to use
  20783. */
  20784. pathArray: Vector3[][],
  20785. /**
  20786. * Defines if the last and first points of each path in your pathArray must be joined
  20787. */
  20788. closeArray: boolean,
  20789. /**
  20790. * Defines if the last and first points of each path in your pathArray must be joined
  20791. */
  20792. closePath: boolean,
  20793. /**
  20794. * Defines the offset between points
  20795. */
  20796. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20797. /**
  20798. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20799. */
  20800. side?: number);
  20801. /** @hidden */
  20802. _regenerateVertexData(): VertexData;
  20803. copy(id: string): Geometry;
  20804. }
  20805. /**
  20806. * Creates a box geometry
  20807. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20808. */
  20809. class BoxGeometry extends _PrimitiveGeometry {
  20810. /**
  20811. * Defines the zise of the box (width, height and depth are the same)
  20812. */
  20813. size: number;
  20814. /**
  20815. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20816. */
  20817. side: number;
  20818. /**
  20819. * Creates a box geometry
  20820. * @param id defines the unique ID of the geometry
  20821. * @param scene defines the hosting scene
  20822. * @param size defines the zise of the box (width, height and depth are the same)
  20823. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20824. * @param mesh defines the hosting mesh (can be null)
  20825. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20826. */
  20827. constructor(id: string, scene: Scene,
  20828. /**
  20829. * Defines the zise of the box (width, height and depth are the same)
  20830. */
  20831. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20832. /**
  20833. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20834. */
  20835. side?: number);
  20836. /** @hidden */
  20837. _regenerateVertexData(): VertexData;
  20838. copy(id: string): Geometry;
  20839. serialize(): any;
  20840. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20841. }
  20842. /**
  20843. * Creates a sphere geometry
  20844. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20845. */
  20846. class SphereGeometry extends _PrimitiveGeometry {
  20847. /**
  20848. * Defines the number of segments to use to create the sphere
  20849. */
  20850. segments: number;
  20851. /**
  20852. * Defines the diameter of the sphere
  20853. */
  20854. diameter: number;
  20855. /**
  20856. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20857. */
  20858. side: number;
  20859. /**
  20860. * Create a new sphere geometry
  20861. * @param id defines the unique ID of the geometry
  20862. * @param scene defines the hosting scene
  20863. * @param segments defines the number of segments to use to create the sphere
  20864. * @param diameter defines the diameter of the sphere
  20865. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20866. * @param mesh defines the hosting mesh (can be null)
  20867. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20868. */
  20869. constructor(id: string, scene: Scene,
  20870. /**
  20871. * Defines the number of segments to use to create the sphere
  20872. */
  20873. segments: number,
  20874. /**
  20875. * Defines the diameter of the sphere
  20876. */
  20877. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20878. /**
  20879. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20880. */
  20881. side?: number);
  20882. /** @hidden */
  20883. _regenerateVertexData(): VertexData;
  20884. copy(id: string): Geometry;
  20885. serialize(): any;
  20886. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20887. }
  20888. /**
  20889. * Creates a disc geometry
  20890. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20891. */
  20892. class DiscGeometry extends _PrimitiveGeometry {
  20893. /**
  20894. * Defines the radius of the disc
  20895. */
  20896. radius: number;
  20897. /**
  20898. * Defines the tesselation factor to apply to the disc
  20899. */
  20900. tessellation: number;
  20901. /**
  20902. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20903. */
  20904. side: number;
  20905. /**
  20906. * Creates a new disc geometry
  20907. * @param id defines the unique ID of the geometry
  20908. * @param scene defines the hosting scene
  20909. * @param radius defines the radius of the disc
  20910. * @param tessellation defines the tesselation factor to apply to the disc
  20911. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20912. * @param mesh defines the hosting mesh (can be null)
  20913. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20914. */
  20915. constructor(id: string, scene: Scene,
  20916. /**
  20917. * Defines the radius of the disc
  20918. */
  20919. radius: number,
  20920. /**
  20921. * Defines the tesselation factor to apply to the disc
  20922. */
  20923. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20924. /**
  20925. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20926. */
  20927. side?: number);
  20928. /** @hidden */
  20929. _regenerateVertexData(): VertexData;
  20930. copy(id: string): Geometry;
  20931. }
  20932. /**
  20933. * Creates a new cylinder geometry
  20934. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20935. */
  20936. class CylinderGeometry extends _PrimitiveGeometry {
  20937. /**
  20938. * Defines the height of the cylinder
  20939. */
  20940. height: number;
  20941. /**
  20942. * Defines the diameter of the cylinder's top cap
  20943. */
  20944. diameterTop: number;
  20945. /**
  20946. * Defines the diameter of the cylinder's bottom cap
  20947. */
  20948. diameterBottom: number;
  20949. /**
  20950. * Defines the tessellation factor to apply to the cylinder
  20951. */
  20952. tessellation: number;
  20953. /**
  20954. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20955. */
  20956. subdivisions: number;
  20957. /**
  20958. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20959. */
  20960. side: number;
  20961. /**
  20962. * Creates a new cylinder geometry
  20963. * @param id defines the unique ID of the geometry
  20964. * @param scene defines the hosting scene
  20965. * @param height defines the height of the cylinder
  20966. * @param diameterTop defines the diameter of the cylinder's top cap
  20967. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20968. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20969. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20970. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20971. * @param mesh defines the hosting mesh (can be null)
  20972. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20973. */
  20974. constructor(id: string, scene: Scene,
  20975. /**
  20976. * Defines the height of the cylinder
  20977. */
  20978. height: number,
  20979. /**
  20980. * Defines the diameter of the cylinder's top cap
  20981. */
  20982. diameterTop: number,
  20983. /**
  20984. * Defines the diameter of the cylinder's bottom cap
  20985. */
  20986. diameterBottom: number,
  20987. /**
  20988. * Defines the tessellation factor to apply to the cylinder
  20989. */
  20990. tessellation: number,
  20991. /**
  20992. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20993. */
  20994. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20995. /**
  20996. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20997. */
  20998. side?: number);
  20999. /** @hidden */
  21000. _regenerateVertexData(): VertexData;
  21001. copy(id: string): Geometry;
  21002. serialize(): any;
  21003. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  21004. }
  21005. /**
  21006. * Creates a new torus geometry
  21007. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  21008. */
  21009. class TorusGeometry extends _PrimitiveGeometry {
  21010. /**
  21011. * Defines the diameter of the torus
  21012. */
  21013. diameter: number;
  21014. /**
  21015. * Defines the thickness of the torus (ie. internal diameter)
  21016. */
  21017. thickness: number;
  21018. /**
  21019. * Defines the tesselation factor to apply to the torus
  21020. */
  21021. tessellation: number;
  21022. /**
  21023. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21024. */
  21025. side: number;
  21026. /**
  21027. * Creates a new torus geometry
  21028. * @param id defines the unique ID of the geometry
  21029. * @param scene defines the hosting scene
  21030. * @param diameter defines the diameter of the torus
  21031. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21032. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21033. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21034. * @param mesh defines the hosting mesh (can be null)
  21035. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21036. */
  21037. constructor(id: string, scene: Scene,
  21038. /**
  21039. * Defines the diameter of the torus
  21040. */
  21041. diameter: number,
  21042. /**
  21043. * Defines the thickness of the torus (ie. internal diameter)
  21044. */
  21045. thickness: number,
  21046. /**
  21047. * Defines the tesselation factor to apply to the torus
  21048. */
  21049. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21050. /**
  21051. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21052. */
  21053. side?: number);
  21054. /** @hidden */
  21055. _regenerateVertexData(): VertexData;
  21056. copy(id: string): Geometry;
  21057. serialize(): any;
  21058. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  21059. }
  21060. /**
  21061. * Creates a new ground geometry
  21062. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  21063. */
  21064. class GroundGeometry extends _PrimitiveGeometry {
  21065. /**
  21066. * Defines the width of the ground
  21067. */
  21068. width: number;
  21069. /**
  21070. * Defines the height of the ground
  21071. */
  21072. height: number;
  21073. /**
  21074. * Defines the subdivisions to apply to the ground
  21075. */
  21076. subdivisions: number;
  21077. /**
  21078. * Creates a new ground geometry
  21079. * @param id defines the unique ID of the geometry
  21080. * @param scene defines the hosting scene
  21081. * @param width defines the width of the ground
  21082. * @param height defines the height of the ground
  21083. * @param subdivisions defines the subdivisions to apply to the ground
  21084. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21085. * @param mesh defines the hosting mesh (can be null)
  21086. */
  21087. constructor(id: string, scene: Scene,
  21088. /**
  21089. * Defines the width of the ground
  21090. */
  21091. width: number,
  21092. /**
  21093. * Defines the height of the ground
  21094. */
  21095. height: number,
  21096. /**
  21097. * Defines the subdivisions to apply to the ground
  21098. */
  21099. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21100. /** @hidden */
  21101. _regenerateVertexData(): VertexData;
  21102. copy(id: string): Geometry;
  21103. serialize(): any;
  21104. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  21105. }
  21106. /**
  21107. * Creates a tiled ground geometry
  21108. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  21109. */
  21110. class TiledGroundGeometry extends _PrimitiveGeometry {
  21111. /**
  21112. * Defines the minimum value on X axis
  21113. */
  21114. xmin: number;
  21115. /**
  21116. * Defines the minimum value on Z axis
  21117. */
  21118. zmin: number;
  21119. /**
  21120. * Defines the maximum value on X axis
  21121. */
  21122. xmax: number;
  21123. /**
  21124. * Defines the maximum value on Z axis
  21125. */
  21126. zmax: number;
  21127. /**
  21128. * Defines the subdivisions to apply to the ground
  21129. */
  21130. subdivisions: {
  21131. w: number;
  21132. h: number;
  21133. };
  21134. /**
  21135. * Defines the precision to use when computing the tiles
  21136. */
  21137. precision: {
  21138. w: number;
  21139. h: number;
  21140. };
  21141. /**
  21142. * Creates a tiled ground geometry
  21143. * @param id defines the unique ID of the geometry
  21144. * @param scene defines the hosting scene
  21145. * @param xmin defines the minimum value on X axis
  21146. * @param zmin defines the minimum value on Z axis
  21147. * @param xmax defines the maximum value on X axis
  21148. * @param zmax defines the maximum value on Z axis
  21149. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  21150. * @param precision defines the precision to use when computing the tiles
  21151. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21152. * @param mesh defines the hosting mesh (can be null)
  21153. */
  21154. constructor(id: string, scene: Scene,
  21155. /**
  21156. * Defines the minimum value on X axis
  21157. */
  21158. xmin: number,
  21159. /**
  21160. * Defines the minimum value on Z axis
  21161. */
  21162. zmin: number,
  21163. /**
  21164. * Defines the maximum value on X axis
  21165. */
  21166. xmax: number,
  21167. /**
  21168. * Defines the maximum value on Z axis
  21169. */
  21170. zmax: number,
  21171. /**
  21172. * Defines the subdivisions to apply to the ground
  21173. */
  21174. subdivisions: {
  21175. w: number;
  21176. h: number;
  21177. },
  21178. /**
  21179. * Defines the precision to use when computing the tiles
  21180. */
  21181. precision: {
  21182. w: number;
  21183. h: number;
  21184. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21185. /** @hidden */
  21186. _regenerateVertexData(): VertexData;
  21187. copy(id: string): Geometry;
  21188. }
  21189. /**
  21190. * Creates a plane geometry
  21191. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21192. */
  21193. class PlaneGeometry extends _PrimitiveGeometry {
  21194. /**
  21195. * Defines the size of the plane (width === height)
  21196. */
  21197. size: number;
  21198. /**
  21199. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21200. */
  21201. side: number;
  21202. /**
  21203. * Creates a plane geometry
  21204. * @param id defines the unique ID of the geometry
  21205. * @param scene defines the hosting scene
  21206. * @param size defines the size of the plane (width === height)
  21207. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21208. * @param mesh defines the hosting mesh (can be null)
  21209. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21210. */
  21211. constructor(id: string, scene: Scene,
  21212. /**
  21213. * Defines the size of the plane (width === height)
  21214. */
  21215. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21216. /**
  21217. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21218. */
  21219. side?: number);
  21220. /** @hidden */
  21221. _regenerateVertexData(): VertexData;
  21222. copy(id: string): Geometry;
  21223. serialize(): any;
  21224. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21225. }
  21226. /**
  21227. * Creates a torus knot geometry
  21228. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21229. */
  21230. class TorusKnotGeometry extends _PrimitiveGeometry {
  21231. /**
  21232. * Defines the radius of the torus knot
  21233. */
  21234. radius: number;
  21235. /**
  21236. * Defines the thickness of the torus knot tube
  21237. */
  21238. tube: number;
  21239. /**
  21240. * Defines the number of radial segments
  21241. */
  21242. radialSegments: number;
  21243. /**
  21244. * Defines the number of tubular segments
  21245. */
  21246. tubularSegments: number;
  21247. /**
  21248. * Defines the first number of windings
  21249. */
  21250. p: number;
  21251. /**
  21252. * Defines the second number of windings
  21253. */
  21254. q: number;
  21255. /**
  21256. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21257. */
  21258. side: number;
  21259. /**
  21260. * Creates a torus knot geometry
  21261. * @param id defines the unique ID of the geometry
  21262. * @param scene defines the hosting scene
  21263. * @param radius defines the radius of the torus knot
  21264. * @param tube defines the thickness of the torus knot tube
  21265. * @param radialSegments defines the number of radial segments
  21266. * @param tubularSegments defines the number of tubular segments
  21267. * @param p defines the first number of windings
  21268. * @param q defines the second number of windings
  21269. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21270. * @param mesh defines the hosting mesh (can be null)
  21271. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21272. */
  21273. constructor(id: string, scene: Scene,
  21274. /**
  21275. * Defines the radius of the torus knot
  21276. */
  21277. radius: number,
  21278. /**
  21279. * Defines the thickness of the torus knot tube
  21280. */
  21281. tube: number,
  21282. /**
  21283. * Defines the number of radial segments
  21284. */
  21285. radialSegments: number,
  21286. /**
  21287. * Defines the number of tubular segments
  21288. */
  21289. tubularSegments: number,
  21290. /**
  21291. * Defines the first number of windings
  21292. */
  21293. p: number,
  21294. /**
  21295. * Defines the second number of windings
  21296. */
  21297. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21298. /**
  21299. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21300. */
  21301. side?: number);
  21302. /** @hidden */
  21303. _regenerateVertexData(): VertexData;
  21304. copy(id: string): Geometry;
  21305. serialize(): any;
  21306. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21307. }
  21308. }
  21309. declare module BABYLON {
  21310. class GroundMesh extends Mesh {
  21311. generateOctree: boolean;
  21312. private _heightQuads;
  21313. /** @hidden */
  21314. _subdivisionsX: number;
  21315. /** @hidden */
  21316. _subdivisionsY: number;
  21317. /** @hidden */
  21318. _width: number;
  21319. /** @hidden */
  21320. _height: number;
  21321. /** @hidden */
  21322. _minX: number;
  21323. /** @hidden */
  21324. _maxX: number;
  21325. /** @hidden */
  21326. _minZ: number;
  21327. /** @hidden */
  21328. _maxZ: number;
  21329. constructor(name: string, scene: Scene);
  21330. getClassName(): string;
  21331. readonly subdivisions: number;
  21332. readonly subdivisionsX: number;
  21333. readonly subdivisionsY: number;
  21334. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21335. /**
  21336. * Returns a height (y) value in the Worl system :
  21337. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21338. * Returns the ground y position if (x, z) are outside the ground surface.
  21339. */
  21340. getHeightAtCoordinates(x: number, z: number): number;
  21341. /**
  21342. * Returns a normalized vector (Vector3) orthogonal to the ground
  21343. * at the ground coordinates (x, z) expressed in the World system.
  21344. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21345. */
  21346. getNormalAtCoordinates(x: number, z: number): Vector3;
  21347. /**
  21348. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21349. * at the ground coordinates (x, z) expressed in the World system.
  21350. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21351. * Returns the GroundMesh.
  21352. */
  21353. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21354. /**
  21355. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21356. * if the ground has been updated.
  21357. * This can be used in the render loop.
  21358. * Returns the GroundMesh.
  21359. */
  21360. updateCoordinateHeights(): GroundMesh;
  21361. private _getFacetAt;
  21362. private _initHeightQuads;
  21363. private _computeHeightQuads;
  21364. serialize(serializationObject: any): void;
  21365. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21366. }
  21367. }
  21368. declare module BABYLON {
  21369. /**
  21370. * Creates an instance based on a source mesh.
  21371. */
  21372. class InstancedMesh extends AbstractMesh {
  21373. private _sourceMesh;
  21374. private _currentLOD;
  21375. constructor(name: string, source: Mesh);
  21376. /**
  21377. * Returns the string "InstancedMesh".
  21378. */
  21379. getClassName(): string;
  21380. readonly receiveShadows: boolean;
  21381. readonly material: Nullable<Material>;
  21382. readonly visibility: number;
  21383. readonly skeleton: Nullable<Skeleton>;
  21384. renderingGroupId: number;
  21385. /**
  21386. * Returns the total number of vertices (integer).
  21387. */
  21388. getTotalVertices(): number;
  21389. readonly sourceMesh: Mesh;
  21390. /**
  21391. * Is this node ready to be used/rendered
  21392. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21393. * @return {boolean} is it ready
  21394. */
  21395. isReady(completeCheck?: boolean): boolean;
  21396. /**
  21397. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21398. */
  21399. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21400. /**
  21401. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21402. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21403. * The `data` are either a numeric array either a Float32Array.
  21404. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21405. * 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).
  21406. * Note that a new underlying VertexBuffer object is created each call.
  21407. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21408. *
  21409. * Possible `kind` values :
  21410. * - BABYLON.VertexBuffer.PositionKind
  21411. * - BABYLON.VertexBuffer.UVKind
  21412. * - BABYLON.VertexBuffer.UV2Kind
  21413. * - BABYLON.VertexBuffer.UV3Kind
  21414. * - BABYLON.VertexBuffer.UV4Kind
  21415. * - BABYLON.VertexBuffer.UV5Kind
  21416. * - BABYLON.VertexBuffer.UV6Kind
  21417. * - BABYLON.VertexBuffer.ColorKind
  21418. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21419. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21420. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21421. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21422. *
  21423. * Returns the Mesh.
  21424. */
  21425. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21426. /**
  21427. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21428. * If the mesh has no geometry, it is simply returned as it is.
  21429. * The `data` are either a numeric array either a Float32Array.
  21430. * No new underlying VertexBuffer object is created.
  21431. * 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.
  21432. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21433. *
  21434. * Possible `kind` values :
  21435. * - BABYLON.VertexBuffer.PositionKind
  21436. * - BABYLON.VertexBuffer.UVKind
  21437. * - BABYLON.VertexBuffer.UV2Kind
  21438. * - BABYLON.VertexBuffer.UV3Kind
  21439. * - BABYLON.VertexBuffer.UV4Kind
  21440. * - BABYLON.VertexBuffer.UV5Kind
  21441. * - BABYLON.VertexBuffer.UV6Kind
  21442. * - BABYLON.VertexBuffer.ColorKind
  21443. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21444. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21445. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21446. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21447. *
  21448. * Returns the Mesh.
  21449. */
  21450. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21451. /**
  21452. * Sets the mesh indices.
  21453. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21454. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21455. * This method creates a new index buffer each call.
  21456. * Returns the Mesh.
  21457. */
  21458. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21459. /**
  21460. * Boolean : True if the mesh owns the requested kind of data.
  21461. */
  21462. isVerticesDataPresent(kind: string): boolean;
  21463. /**
  21464. * Returns an array of indices (IndicesArray).
  21465. */
  21466. getIndices(): Nullable<IndicesArray>;
  21467. readonly _positions: Nullable<Vector3[]>;
  21468. /**
  21469. * Sets a new updated BoundingInfo to the mesh.
  21470. * Returns the mesh.
  21471. */
  21472. refreshBoundingInfo(): InstancedMesh;
  21473. /** @hidden */
  21474. _preActivate(): InstancedMesh;
  21475. /** @hidden */
  21476. _activate(renderId: number): InstancedMesh;
  21477. /**
  21478. * Returns the current associated LOD AbstractMesh.
  21479. */
  21480. getLOD(camera: Camera): AbstractMesh;
  21481. /** @hidden */
  21482. _syncSubMeshes(): InstancedMesh;
  21483. /** @hidden */
  21484. _generatePointsArray(): boolean;
  21485. /**
  21486. * Creates a new InstancedMesh from the current mesh.
  21487. * - name (string) : the cloned mesh name
  21488. * - newParent (optional Node) : the optional Node to parent the clone to.
  21489. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21490. *
  21491. * Returns the clone.
  21492. */
  21493. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21494. /**
  21495. * Disposes the InstancedMesh.
  21496. * Returns nothing.
  21497. */
  21498. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21499. }
  21500. }
  21501. declare module BABYLON {
  21502. class LinesMesh extends Mesh {
  21503. useVertexColor?: boolean | undefined;
  21504. useVertexAlpha?: boolean | undefined;
  21505. color: Color3;
  21506. alpha: number;
  21507. /**
  21508. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21509. * This margin is expressed in world space coordinates, so its value may vary.
  21510. * Default value is 0.1
  21511. * @returns the intersection Threshold value.
  21512. */
  21513. /**
  21514. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21515. * This margin is expressed in world space coordinates, so its value may vary.
  21516. * @param value the new threshold to apply
  21517. */
  21518. intersectionThreshold: number;
  21519. private _intersectionThreshold;
  21520. private _colorShader;
  21521. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21522. /**
  21523. * Returns the string "LineMesh"
  21524. */
  21525. getClassName(): string;
  21526. /**
  21527. * @hidden
  21528. */
  21529. /**
  21530. * @hidden
  21531. */
  21532. material: Material;
  21533. /**
  21534. * @hidden
  21535. */
  21536. readonly checkCollisions: boolean;
  21537. createInstance(name: string): InstancedMesh;
  21538. /** @hidden */
  21539. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21540. /** @hidden */
  21541. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21542. dispose(doNotRecurse?: boolean): void;
  21543. /**
  21544. * Returns a new LineMesh object cloned from the current one.
  21545. */
  21546. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21547. }
  21548. }
  21549. declare module BABYLON {
  21550. /**
  21551. * @hidden
  21552. **/
  21553. class _InstancesBatch {
  21554. mustReturn: boolean;
  21555. visibleInstances: Nullable<InstancedMesh[]>[];
  21556. renderSelf: boolean[];
  21557. }
  21558. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21559. static _FRONTSIDE: number;
  21560. static _BACKSIDE: number;
  21561. static _DOUBLESIDE: number;
  21562. static _DEFAULTSIDE: number;
  21563. static _NO_CAP: number;
  21564. static _CAP_START: number;
  21565. static _CAP_END: number;
  21566. static _CAP_ALL: number;
  21567. /**
  21568. * Mesh side orientation : usually the external or front surface
  21569. */
  21570. static readonly FRONTSIDE: number;
  21571. /**
  21572. * Mesh side orientation : usually the internal or back surface
  21573. */
  21574. static readonly BACKSIDE: number;
  21575. /**
  21576. * Mesh side orientation : both internal and external or front and back surfaces
  21577. */
  21578. static readonly DOUBLESIDE: number;
  21579. /**
  21580. * Mesh side orientation : by default, `FRONTSIDE`
  21581. */
  21582. static readonly DEFAULTSIDE: number;
  21583. /**
  21584. * Mesh cap setting : no cap
  21585. */
  21586. static readonly NO_CAP: number;
  21587. /**
  21588. * Mesh cap setting : one cap at the beginning of the mesh
  21589. */
  21590. static readonly CAP_START: number;
  21591. /**
  21592. * Mesh cap setting : one cap at the end of the mesh
  21593. */
  21594. static readonly CAP_END: number;
  21595. /**
  21596. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21597. */
  21598. static readonly CAP_ALL: number;
  21599. private _onBeforeRenderObservable;
  21600. private _onAfterRenderObservable;
  21601. private _onBeforeDrawObservable;
  21602. /**
  21603. * An event triggered before rendering the mesh
  21604. */
  21605. readonly onBeforeRenderObservable: Observable<Mesh>;
  21606. /**
  21607. * An event triggered after rendering the mesh
  21608. */
  21609. readonly onAfterRenderObservable: Observable<Mesh>;
  21610. /**
  21611. * An event triggered before drawing the mesh
  21612. */
  21613. readonly onBeforeDrawObservable: Observable<Mesh>;
  21614. private _onBeforeDrawObserver;
  21615. onBeforeDraw: () => void;
  21616. delayLoadState: number;
  21617. instances: InstancedMesh[];
  21618. delayLoadingFile: string;
  21619. /** @hidden */
  21620. _binaryInfo: any;
  21621. private _LODLevels;
  21622. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21623. private _morphTargetManager;
  21624. morphTargetManager: Nullable<MorphTargetManager>;
  21625. /** @hidden */
  21626. _geometry: Nullable<Geometry>;
  21627. /** @hidden */
  21628. _delayInfo: Array<string>;
  21629. /** @hidden */
  21630. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21631. /** @hidden */
  21632. _visibleInstances: any;
  21633. private _renderIdForInstances;
  21634. private _batchCache;
  21635. private _instancesBufferSize;
  21636. private _instancesBuffer;
  21637. private _instancesData;
  21638. private _overridenInstanceCount;
  21639. private _effectiveMaterial;
  21640. /** @hidden */
  21641. _shouldGenerateFlatShading: boolean;
  21642. private _preActivateId;
  21643. /** @hidden */
  21644. _originalBuilderSideOrientation: number;
  21645. overrideMaterialSideOrientation: Nullable<number>;
  21646. private _areNormalsFrozen;
  21647. private _sourcePositions;
  21648. private _sourceNormals;
  21649. private _source;
  21650. readonly source: Nullable<Mesh>;
  21651. isUnIndexed: boolean;
  21652. /**
  21653. * @constructor
  21654. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21655. * @param {Scene} scene The scene to add this mesh to.
  21656. * @param {Node} parent The parent of this mesh, if it has one
  21657. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21658. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21659. * When false, achieved by calling a clone(), also passing False.
  21660. * This will make creation of children, recursive.
  21661. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21662. */
  21663. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21664. /**
  21665. * Returns the string "Mesh".
  21666. */
  21667. getClassName(): string;
  21668. /**
  21669. * Returns a string.
  21670. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21671. */
  21672. toString(fullDetails?: boolean): string;
  21673. /** @hidden */
  21674. _unBindEffect(): void;
  21675. /**
  21676. * True if the mesh has some Levels Of Details (LOD).
  21677. * Returns a boolean.
  21678. */
  21679. readonly hasLODLevels: boolean;
  21680. /**
  21681. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21682. * @returns an array of {BABYLON.MeshLODLevel}
  21683. */
  21684. getLODLevels(): MeshLODLevel[];
  21685. private _sortLODLevels;
  21686. /**
  21687. * Add a mesh as LOD level triggered at the given distance.
  21688. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21689. * @param distance The distance from the center of the object to show this level
  21690. * @param mesh The mesh to be added as LOD level (can be null)
  21691. * @return This mesh (for chaining)
  21692. */
  21693. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21694. /**
  21695. * Returns the LOD level mesh at the passed distance or null if not found.
  21696. * It is related to the method `addLODLevel(distance, mesh)`.
  21697. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21698. * Returns an object Mesh or `null`.
  21699. */
  21700. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21701. /**
  21702. * Remove a mesh from the LOD array
  21703. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21704. * @param {Mesh} mesh The mesh to be removed.
  21705. * @return {Mesh} This mesh (for chaining)
  21706. */
  21707. removeLODLevel(mesh: Mesh): Mesh;
  21708. /**
  21709. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21710. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21711. */
  21712. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21713. /**
  21714. * Returns the mesh internal Geometry object.
  21715. */
  21716. readonly geometry: Nullable<Geometry>;
  21717. /**
  21718. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21719. */
  21720. getTotalVertices(): number;
  21721. /**
  21722. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21723. * 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.
  21724. * You can force the copy with forceCopy === true
  21725. * Returns null if the mesh has no geometry or no vertex buffer.
  21726. * Possible `kind` values :
  21727. * - BABYLON.VertexBuffer.PositionKind
  21728. * - BABYLON.VertexBuffer.UVKind
  21729. * - BABYLON.VertexBuffer.UV2Kind
  21730. * - BABYLON.VertexBuffer.UV3Kind
  21731. * - BABYLON.VertexBuffer.UV4Kind
  21732. * - BABYLON.VertexBuffer.UV5Kind
  21733. * - BABYLON.VertexBuffer.UV6Kind
  21734. * - BABYLON.VertexBuffer.ColorKind
  21735. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21736. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21737. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21738. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21739. */
  21740. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21741. /**
  21742. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21743. * Returns `null` if the mesh has no geometry.
  21744. * Possible `kind` values :
  21745. * - BABYLON.VertexBuffer.PositionKind
  21746. * - BABYLON.VertexBuffer.UVKind
  21747. * - BABYLON.VertexBuffer.UV2Kind
  21748. * - BABYLON.VertexBuffer.UV3Kind
  21749. * - BABYLON.VertexBuffer.UV4Kind
  21750. * - BABYLON.VertexBuffer.UV5Kind
  21751. * - BABYLON.VertexBuffer.UV6Kind
  21752. * - BABYLON.VertexBuffer.ColorKind
  21753. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21754. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21755. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21756. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21757. */
  21758. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21759. isVerticesDataPresent(kind: string): boolean;
  21760. /**
  21761. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21762. * Possible `kind` values :
  21763. * - BABYLON.VertexBuffer.PositionKind
  21764. * - BABYLON.VertexBuffer.UVKind
  21765. * - BABYLON.VertexBuffer.UV2Kind
  21766. * - BABYLON.VertexBuffer.UV3Kind
  21767. * - BABYLON.VertexBuffer.UV4Kind
  21768. * - BABYLON.VertexBuffer.UV5Kind
  21769. * - BABYLON.VertexBuffer.UV6Kind
  21770. * - BABYLON.VertexBuffer.ColorKind
  21771. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21772. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21773. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21774. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21775. */
  21776. isVertexBufferUpdatable(kind: string): boolean;
  21777. /**
  21778. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21779. * Possible `kind` values :
  21780. * - BABYLON.VertexBuffer.PositionKind
  21781. * - BABYLON.VertexBuffer.UVKind
  21782. * - BABYLON.VertexBuffer.UV2Kind
  21783. * - BABYLON.VertexBuffer.UV3Kind
  21784. * - BABYLON.VertexBuffer.UV4Kind
  21785. * - BABYLON.VertexBuffer.UV5Kind
  21786. * - BABYLON.VertexBuffer.UV6Kind
  21787. * - BABYLON.VertexBuffer.ColorKind
  21788. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21789. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21790. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21791. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21792. */
  21793. getVerticesDataKinds(): string[];
  21794. /**
  21795. * Returns a positive integer : the total number of indices in this mesh geometry.
  21796. * Returns zero if the mesh has no geometry.
  21797. */
  21798. getTotalIndices(): number;
  21799. /**
  21800. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21801. * @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.
  21802. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21803. * @returns the indices array or an empty array if the mesh has no geometry
  21804. */
  21805. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21806. readonly isBlocked: boolean;
  21807. /**
  21808. * Determine if the current mesh is ready to be rendered
  21809. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21810. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21811. * @returns true if all associated assets are ready (material, textures, shaders)
  21812. */
  21813. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21814. /**
  21815. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21816. * This property is pertinent only for updatable parametric shapes.
  21817. */
  21818. readonly areNormalsFrozen: boolean;
  21819. /**
  21820. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21821. * It has no effect at all on other shapes.
  21822. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21823. * Returns the Mesh.
  21824. */
  21825. freezeNormals(): Mesh;
  21826. /**
  21827. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21828. * It has no effect at all on other shapes.
  21829. * It reactivates the mesh normals computation if it was previously frozen.
  21830. * Returns the Mesh.
  21831. */
  21832. unfreezeNormals(): Mesh;
  21833. /**
  21834. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21835. */
  21836. overridenInstanceCount: number;
  21837. /** @hidden */
  21838. _preActivate(): Mesh;
  21839. /** @hidden */
  21840. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21841. /** @hidden */
  21842. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21843. /**
  21844. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21845. * This means the mesh underlying bounding box and sphere are recomputed.
  21846. * Returns the Mesh.
  21847. */
  21848. refreshBoundingInfo(): Mesh;
  21849. /** @hidden */
  21850. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21851. private _getPositionData;
  21852. /** @hidden */
  21853. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21854. subdivide(count: number): void;
  21855. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21856. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21857. /**
  21858. * Sets the mesh VertexBuffer.
  21859. * Returns the Mesh.
  21860. */
  21861. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21863. /**
  21864. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21865. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21866. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21867. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21868. * Returns the Mesh.
  21869. */
  21870. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21871. /**
  21872. * Creates a un-shared specific occurence of the geometry for the mesh.
  21873. * Returns the Mesh.
  21874. */
  21875. makeGeometryUnique(): Mesh;
  21876. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21877. /**
  21878. * Update the current index buffer
  21879. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21880. * Returns the Mesh.
  21881. */
  21882. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21883. /**
  21884. * Invert the geometry to move from a right handed system to a left handed one.
  21885. * Returns the Mesh.
  21886. */
  21887. toLeftHanded(): Mesh;
  21888. /** @hidden */
  21889. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21890. /** @hidden */
  21891. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21892. /**
  21893. * Registers for this mesh a javascript function called just before the rendering process.
  21894. * This function is passed the current mesh.
  21895. * Return the Mesh.
  21896. */
  21897. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21898. /**
  21899. * Disposes a previously registered javascript function called before the rendering.
  21900. * This function is passed the current mesh.
  21901. * Returns the Mesh.
  21902. */
  21903. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21904. /**
  21905. * Registers for this mesh a javascript function called just after the rendering is complete.
  21906. * This function is passed the current mesh.
  21907. * Returns the Mesh.
  21908. */
  21909. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21910. /**
  21911. * Disposes a previously registered javascript function called after the rendering.
  21912. * This function is passed the current mesh.
  21913. * Return the Mesh.
  21914. */
  21915. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21916. /** @hidden */
  21917. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21918. /** @hidden */
  21919. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21920. /** @hidden */
  21921. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21922. /**
  21923. * 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
  21924. * @param subMesh defines the subMesh to render
  21925. * @param enableAlphaMode defines if alpha mode can be changed
  21926. * @returns the current mesh
  21927. */
  21928. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21929. private _onBeforeDraw;
  21930. /**
  21931. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21932. */
  21933. getEmittedParticleSystems(): IParticleSystem[];
  21934. /**
  21935. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21936. */
  21937. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21938. /**
  21939. * Normalize matrix weights so that all vertices have a total weight set to 1
  21940. */
  21941. cleanMatrixWeights(): void;
  21942. /** @hidden */
  21943. _checkDelayState(): Mesh;
  21944. private _queueLoad;
  21945. /**
  21946. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21947. * A mesh is in the frustum if its bounding box intersects the frustum
  21948. * @param frustumPlanes defines the frustum to test
  21949. * @returns true if the mesh is in the frustum planes
  21950. */
  21951. isInFrustum(frustumPlanes: Plane[]): boolean;
  21952. /**
  21953. * Sets the mesh material by the material or multiMaterial `id` property.
  21954. * The material `id` is a string identifying the material or the multiMaterial.
  21955. * This method returns the Mesh.
  21956. */
  21957. setMaterialByID(id: string): Mesh;
  21958. /**
  21959. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21960. */
  21961. getAnimatables(): IAnimatable[];
  21962. /**
  21963. * Modifies the mesh geometry according to the passed transformation matrix.
  21964. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21965. * The mesh normals are modified using the same transformation.
  21966. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21967. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21968. * Returns the Mesh.
  21969. */
  21970. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21971. /**
  21972. * Modifies the mesh geometry according to its own current World Matrix.
  21973. * The mesh World Matrix is then reset.
  21974. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21975. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21976. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21977. * Returns the Mesh.
  21978. */
  21979. bakeCurrentTransformIntoVertices(): Mesh;
  21980. readonly _positions: Nullable<Vector3[]>;
  21981. /** @hidden */
  21982. _resetPointsArrayCache(): Mesh;
  21983. /** @hidden */
  21984. _generatePointsArray(): boolean;
  21985. /**
  21986. * Returns a new Mesh object generated from the current mesh properties.
  21987. * This method must not get confused with createInstance().
  21988. * The parameter `name` is a string, the name given to the new mesh.
  21989. * The optional parameter `newParent` can be any Node object (default `null`).
  21990. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21991. * 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.
  21992. */
  21993. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21994. /**
  21995. * Releases resources associated with this mesh.
  21996. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21997. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21998. */
  21999. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22000. /**
  22001. * Modifies the mesh geometry according to a displacement map.
  22002. * 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.
  22003. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22004. * This method returns nothing.
  22005. * @param url is a string, the URL from the image file is to be downloaded.
  22006. * @param minHeight is the lower limit of the displacement.
  22007. * @param maxHeight is the upper limit of the displacement.
  22008. * @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.
  22009. * @param uvOffset is an optional vector2 used to offset UV.
  22010. * @param uvScale is an optional vector2 used to scale UV.
  22011. * @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.
  22012. * @returns the Mesh.
  22013. */
  22014. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22015. /**
  22016. * Modifies the mesh geometry according to a displacementMap buffer.
  22017. * 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.
  22018. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22019. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22020. * @param heightMapWidth is the width of the buffer image.
  22021. * @param heightMapHeight is the height of the buffer image.
  22022. * @param minHeight is the lower limit of the displacement.
  22023. * @param maxHeight is the upper limit of the displacement.
  22024. * @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.
  22025. * @param uvOffset is an optional vector2 used to offset UV.
  22026. * @param uvScale is an optional vector2 used to scale UV.
  22027. * @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.
  22028. * @returns the Mesh.
  22029. */
  22030. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22031. /**
  22032. * Modify the mesh to get a flat shading rendering.
  22033. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22034. * This method returns the Mesh.
  22035. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22036. */
  22037. convertToFlatShadedMesh(): Mesh;
  22038. /**
  22039. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22040. * In other words, more vertices, no more indices and a single bigger VBO.
  22041. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22042. * Returns the Mesh.
  22043. */
  22044. convertToUnIndexedMesh(): Mesh;
  22045. /**
  22046. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  22047. * This method returns the Mesh.
  22048. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22049. */
  22050. flipFaces(flipNormals?: boolean): Mesh;
  22051. /**
  22052. * Creates a new InstancedMesh object from the mesh model.
  22053. * An instance shares the same properties and the same material than its model.
  22054. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  22055. * Only these properties of each instance can then be set individually :
  22056. * - position
  22057. * - rotation
  22058. * - rotationQuaternion
  22059. * - setPivotMatrix
  22060. * - scaling
  22061. *
  22062. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22063. * Warning : this method is not supported for Line mesh and LineSystem
  22064. */
  22065. createInstance(name: string): InstancedMesh;
  22066. /**
  22067. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22068. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22069. * This method returns the Mesh.
  22070. */
  22071. synchronizeInstances(): Mesh;
  22072. /**
  22073. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22074. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22075. * This should be used together with the simplification to avoid disappearing triangles.
  22076. * Returns the Mesh.
  22077. * @param successCallback an optional success callback to be called after the optimization finished.
  22078. */
  22079. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22080. serialize(serializationObject: any): void;
  22081. /** @hidden */
  22082. _syncGeometryWithMorphTargetManager(): void;
  22083. /**
  22084. * Returns a new Mesh object parsed from the source provided.
  22085. * The parameter `parsedMesh` is the source.
  22086. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22087. */
  22088. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22089. /**
  22090. * Creates a ribbon mesh.
  22091. * Please consider using the same method from the MeshBuilder class instead.
  22092. * 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.
  22093. *
  22094. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22095. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22096. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  22097. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  22098. * 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.
  22099. * 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.
  22100. * 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
  22101. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22102. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22103. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22104. */
  22105. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22106. /**
  22107. * Creates a plane polygonal mesh. By default, this is a disc.
  22108. * Please consider using the same method from the MeshBuilder class instead.
  22109. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  22110. * 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.
  22111. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22112. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22113. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22114. */
  22115. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22116. /**
  22117. * Creates a box mesh.
  22118. * Please consider using the same method from the MeshBuilder class instead.
  22119. * The parameter `size` sets the size (float) of each box side (default 1).
  22120. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22121. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22122. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22123. */
  22124. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22125. /**
  22126. * Creates a sphere mesh.
  22127. * Please consider using the same method from the MeshBuilder class instead.
  22128. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  22129. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  22130. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22131. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22132. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22133. */
  22134. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22135. /**
  22136. * Creates a cylinder or a cone mesh.
  22137. * Please consider using the same method from the MeshBuilder class instead.
  22138. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22139. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22140. * 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.
  22141. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22142. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22143. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22144. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22145. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22146. */
  22147. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22148. /**
  22149. * Creates a torus mesh.
  22150. * Please consider using the same method from the MeshBuilder class instead.
  22151. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  22152. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22153. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22154. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22155. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22156. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22157. */
  22158. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22159. /**
  22160. * Creates a torus knot mesh.
  22161. * Please consider using the same method from the MeshBuilder class instead.
  22162. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22163. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22164. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22165. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22166. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22167. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22168. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22169. */
  22170. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22171. /**
  22172. * Creates a line mesh.
  22173. * Please consider using the same method from the MeshBuilder class instead.
  22174. * 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.
  22175. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22176. * The parameter `points` is an array successive Vector3.
  22177. * 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
  22178. * When updating an instance, remember that only point positions can change, not the number of points.
  22179. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22180. */
  22181. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22182. /**
  22183. * Creates a dashed line mesh.
  22184. * Please consider using the same method from the MeshBuilder class instead.
  22185. * 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.
  22186. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22187. * The parameter `points` is an array successive Vector3.
  22188. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22189. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22190. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22191. * 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
  22192. * When updating an instance, remember that only point positions can change, not the number of points.
  22193. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22194. */
  22195. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22196. /**
  22197. * Creates a polygon mesh.
  22198. * Please consider using the same method from the MeshBuilder class instead.
  22199. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22200. * 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.
  22201. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22202. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22203. * Remember you can only change the shape positions, not their number when updating a polygon.
  22204. */
  22205. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22206. /**
  22207. * Creates an extruded polygon mesh, with depth in the Y direction.
  22208. * Please consider using the same method from the MeshBuilder class instead.
  22209. */
  22210. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22211. /**
  22212. * Creates an extruded shape mesh.
  22213. * 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.
  22214. * Please consider using the same method from the MeshBuilder class instead.
  22215. *
  22216. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22217. * 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
  22218. * extruded along the Z axis.
  22219. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22220. * 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.
  22221. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22222. * 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
  22223. * 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
  22224. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22225. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22226. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22227. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22228. */
  22229. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22230. /**
  22231. * Creates an custom extruded shape mesh.
  22232. * 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.
  22233. * Please consider using the same method from the MeshBuilder class instead.
  22234. *
  22235. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22236. * 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
  22237. * extruded along the Z axis.
  22238. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22239. * 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
  22240. * and the distance of this point from the begining of the path :
  22241. * ```javascript
  22242. * var rotationFunction = function(i, distance) {
  22243. * // do things
  22244. * return rotationValue; }
  22245. * ```
  22246. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22247. * 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
  22248. * and the distance of this point from the begining of the path :
  22249. * ```javascript
  22250. * var scaleFunction = function(i, distance) {
  22251. * // do things
  22252. * return scaleValue;}
  22253. * ```
  22254. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22255. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22256. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22257. * 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
  22258. * 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
  22259. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22260. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22261. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22262. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22263. */
  22264. 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;
  22265. /**
  22266. * Creates lathe mesh.
  22267. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22268. * Please consider using the same method from the MeshBuilder class instead.
  22269. * 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
  22270. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22271. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22272. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22273. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22274. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22275. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22276. */
  22277. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22278. /**
  22279. * Creates a plane mesh.
  22280. * Please consider using the same method from the MeshBuilder class instead.
  22281. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22282. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22283. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22284. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22285. */
  22286. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22287. /**
  22288. * Creates a ground mesh.
  22289. * Please consider using the same method from the MeshBuilder class instead.
  22290. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22291. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22292. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22293. */
  22294. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22295. /**
  22296. * Creates a tiled ground mesh.
  22297. * Please consider using the same method from the MeshBuilder class instead.
  22298. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22299. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22300. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22301. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22302. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22303. * numbers of subdivisions on the ground width and height of each tile.
  22304. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22305. */
  22306. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22307. w: number;
  22308. h: number;
  22309. }, precision: {
  22310. w: number;
  22311. h: number;
  22312. }, scene: Scene, updatable?: boolean): Mesh;
  22313. /**
  22314. * Creates a ground mesh from a height map.
  22315. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22316. * Please consider using the same method from the MeshBuilder class instead.
  22317. * The parameter `url` sets the URL of the height map image resource.
  22318. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22319. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22320. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22321. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22322. * 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).
  22323. * This function is passed the newly built mesh :
  22324. * ```javascript
  22325. * function(mesh) { // do things
  22326. * return; }
  22327. * ```
  22328. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22329. */
  22330. 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;
  22331. /**
  22332. * Creates a tube mesh.
  22333. * 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.
  22334. * Please consider using the same method from the MeshBuilder class instead.
  22335. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22336. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22337. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22338. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22339. * 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.
  22340. * It must return a radius value (positive float) :
  22341. * ```javascript
  22342. * var radiusFunction = function(i, distance) {
  22343. * // do things
  22344. * return radius; }
  22345. * ```
  22346. * 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
  22347. * 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
  22348. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22349. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22350. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22351. */
  22352. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22353. (i: number, distance: number): number;
  22354. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22355. /**
  22356. * Creates a polyhedron mesh.
  22357. * Please consider using the same method from the MeshBuilder class instead.
  22358. * 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
  22359. * to choose the wanted type.
  22360. * The parameter `size` (positive float, default 1) sets the polygon size.
  22361. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22362. * 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`.
  22363. * 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
  22364. * 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)`).
  22365. * 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
  22366. * 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.
  22367. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22368. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22369. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22370. */
  22371. static CreatePolyhedron(name: string, options: {
  22372. type?: number;
  22373. size?: number;
  22374. sizeX?: number;
  22375. sizeY?: number;
  22376. sizeZ?: number;
  22377. custom?: any;
  22378. faceUV?: Vector4[];
  22379. faceColors?: Color4[];
  22380. updatable?: boolean;
  22381. sideOrientation?: number;
  22382. }, scene: Scene): Mesh;
  22383. /**
  22384. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22385. * Please consider using the same method from the MeshBuilder class instead.
  22386. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22387. * 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`).
  22388. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22389. * 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.
  22390. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22391. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22392. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22393. */
  22394. static CreateIcoSphere(name: string, options: {
  22395. radius?: number;
  22396. flat?: boolean;
  22397. subdivisions?: number;
  22398. sideOrientation?: number;
  22399. updatable?: boolean;
  22400. }, scene: Scene): Mesh;
  22401. /**
  22402. * Creates a decal mesh.
  22403. * Please consider using the same method from the MeshBuilder class instead.
  22404. * 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.
  22405. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22406. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22407. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22408. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22409. */
  22410. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22411. /**
  22412. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22413. */
  22414. setPositionsForCPUSkinning(): Float32Array;
  22415. /**
  22416. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22417. */
  22418. setNormalsForCPUSkinning(): Float32Array;
  22419. /**
  22420. * Updates the vertex buffer by applying transformation from the bones.
  22421. * Returns the Mesh.
  22422. *
  22423. * @param {skeleton} skeleton to apply
  22424. */
  22425. applySkeleton(skeleton: Skeleton): Mesh;
  22426. /**
  22427. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22428. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22429. */
  22430. static MinMax(meshes: AbstractMesh[]): {
  22431. min: Vector3;
  22432. max: Vector3;
  22433. };
  22434. /**
  22435. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22436. */
  22437. static Center(meshesOrMinMaxVector: {
  22438. min: Vector3;
  22439. max: Vector3;
  22440. } | AbstractMesh[]): Vector3;
  22441. /**
  22442. * Merge the array of meshes into a single mesh for performance reasons.
  22443. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22444. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22445. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22446. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22447. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22448. */
  22449. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22450. }
  22451. }
  22452. declare module BABYLON {
  22453. /**
  22454. * Define an interface for all classes that will get and set the data on vertices
  22455. */
  22456. interface IGetSetVerticesData {
  22457. isVerticesDataPresent(kind: string): boolean;
  22458. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22459. /**
  22460. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22461. * @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.
  22462. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22463. * @returns the indices array or an empty array if the mesh has no geometry
  22464. */
  22465. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22466. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22467. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22468. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22469. }
  22470. /**
  22471. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22472. */
  22473. class VertexData {
  22474. /**
  22475. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22476. */
  22477. positions: Nullable<FloatArray>;
  22478. /**
  22479. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22480. */
  22481. normals: Nullable<FloatArray>;
  22482. /**
  22483. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22484. */
  22485. tangents: Nullable<FloatArray>;
  22486. /**
  22487. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22488. */
  22489. uvs: Nullable<FloatArray>;
  22490. /**
  22491. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22492. */
  22493. uvs2: Nullable<FloatArray>;
  22494. /**
  22495. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22496. */
  22497. uvs3: Nullable<FloatArray>;
  22498. /**
  22499. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22500. */
  22501. uvs4: Nullable<FloatArray>;
  22502. /**
  22503. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22504. */
  22505. uvs5: Nullable<FloatArray>;
  22506. /**
  22507. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22508. */
  22509. uvs6: Nullable<FloatArray>;
  22510. /**
  22511. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22512. */
  22513. colors: Nullable<FloatArray>;
  22514. /**
  22515. * 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).
  22516. */
  22517. matricesIndices: Nullable<FloatArray>;
  22518. /**
  22519. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22520. */
  22521. matricesWeights: Nullable<FloatArray>;
  22522. /**
  22523. * An array extending the number of possible indices
  22524. */
  22525. matricesIndicesExtra: Nullable<FloatArray>;
  22526. /**
  22527. * An array extending the number of possible weights when the number of indices is extended
  22528. */
  22529. matricesWeightsExtra: Nullable<FloatArray>;
  22530. /**
  22531. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22532. */
  22533. indices: Nullable<IndicesArray>;
  22534. /**
  22535. * Uses the passed data array to set the set the values for the specified kind of data
  22536. * @param data a linear array of floating numbers
  22537. * @param kind the type of data that is being set, eg positions, colors etc
  22538. */
  22539. set(data: FloatArray, kind: string): void;
  22540. /**
  22541. * Associates the vertexData to the passed Mesh.
  22542. * Sets it as updatable or not (default `false`)
  22543. * @param mesh the mesh the vertexData is applied to
  22544. * @param updatable when used and having the value true allows new data to update the vertexData
  22545. * @returns the VertexData
  22546. */
  22547. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22548. /**
  22549. * Associates the vertexData to the passed Geometry.
  22550. * Sets it as updatable or not (default `false`)
  22551. * @param geometry the geometry the vertexData is applied to
  22552. * @param updatable when used and having the value true allows new data to update the vertexData
  22553. * @returns VertexData
  22554. */
  22555. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22556. /**
  22557. * Updates the associated mesh
  22558. * @param mesh the mesh to be updated
  22559. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22560. * @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
  22561. * @returns VertexData
  22562. */
  22563. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22564. /**
  22565. * Updates the associated geometry
  22566. * @param geometry the geometry to be updated
  22567. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22568. * @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
  22569. * @returns VertexData.
  22570. */
  22571. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22572. private _applyTo;
  22573. private _update;
  22574. /**
  22575. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22576. * @param matrix the transforming matrix
  22577. * @returns the VertexData
  22578. */
  22579. transform(matrix: Matrix): VertexData;
  22580. /**
  22581. * Merges the passed VertexData into the current one
  22582. * @param other the VertexData to be merged into the current one
  22583. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22584. * @returns the modified VertexData
  22585. */
  22586. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22587. private _mergeElement;
  22588. private _validate;
  22589. /**
  22590. * Serializes the VertexData
  22591. * @returns a serialized object
  22592. */
  22593. serialize(): any;
  22594. /**
  22595. * Extracts the vertexData from a mesh
  22596. * @param mesh the mesh from which to extract the VertexData
  22597. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22598. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22599. * @returns the object VertexData associated to the passed mesh
  22600. */
  22601. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22602. /**
  22603. * Extracts the vertexData from the geometry
  22604. * @param geometry the geometry from which to extract the VertexData
  22605. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22606. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22607. * @returns the object VertexData associated to the passed mesh
  22608. */
  22609. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22610. private static _ExtractFrom;
  22611. /**
  22612. * Creates the VertexData for a Ribbon
  22613. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22614. * * pathArray array of paths, each of which an array of successive Vector3
  22615. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22616. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22617. * * 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
  22618. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22619. * * 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)
  22620. * * 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)
  22621. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22622. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22623. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22624. * @returns the VertexData of the ribbon
  22625. */
  22626. static CreateRibbon(options: {
  22627. pathArray: Vector3[][];
  22628. closeArray?: boolean;
  22629. closePath?: boolean;
  22630. offset?: number;
  22631. sideOrientation?: number;
  22632. frontUVs?: Vector4;
  22633. backUVs?: Vector4;
  22634. invertUV?: boolean;
  22635. uvs?: Vector2[];
  22636. colors?: Color4[];
  22637. }): VertexData;
  22638. /**
  22639. * Creates the VertexData for a box
  22640. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22641. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22642. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22643. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22644. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22645. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22646. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22647. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22648. * * 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)
  22649. * * 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)
  22650. * @returns the VertexData of the box
  22651. */
  22652. static CreateBox(options: {
  22653. size?: number;
  22654. width?: number;
  22655. height?: number;
  22656. depth?: number;
  22657. faceUV?: Vector4[];
  22658. faceColors?: Color4[];
  22659. sideOrientation?: number;
  22660. frontUVs?: Vector4;
  22661. backUVs?: Vector4;
  22662. }): VertexData;
  22663. /**
  22664. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22666. * * segments sets the number of horizontal strips optional, default 32
  22667. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22668. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22669. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22670. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22671. * * 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
  22672. * * 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
  22673. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22674. * * 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)
  22675. * * 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)
  22676. * @returns the VertexData of the ellipsoid
  22677. */
  22678. static CreateSphere(options: {
  22679. segments?: number;
  22680. diameter?: number;
  22681. diameterX?: number;
  22682. diameterY?: number;
  22683. diameterZ?: number;
  22684. arc?: number;
  22685. slice?: number;
  22686. sideOrientation?: number;
  22687. frontUVs?: Vector4;
  22688. backUVs?: Vector4;
  22689. }): VertexData;
  22690. /**
  22691. * Creates the VertexData for a cylinder, cone or prism
  22692. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22693. * * height sets the height (y direction) of the cylinder, optional, default 2
  22694. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22695. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22696. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22697. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22698. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22699. * * 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
  22700. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22701. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22702. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22703. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22704. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22705. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22706. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22707. * @returns the VertexData of the cylinder, cone or prism
  22708. */
  22709. static CreateCylinder(options: {
  22710. height?: number;
  22711. diameterTop?: number;
  22712. diameterBottom?: number;
  22713. diameter?: number;
  22714. tessellation?: number;
  22715. subdivisions?: number;
  22716. arc?: number;
  22717. faceColors?: Color4[];
  22718. faceUV?: Vector4[];
  22719. hasRings?: boolean;
  22720. enclose?: boolean;
  22721. sideOrientation?: number;
  22722. frontUVs?: Vector4;
  22723. backUVs?: Vector4;
  22724. }): VertexData;
  22725. /**
  22726. * Creates the VertexData for a torus
  22727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22728. * * diameter the diameter of the torus, optional default 1
  22729. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22730. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22731. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22732. * * 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)
  22733. * * 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)
  22734. * @returns the VertexData of the torus
  22735. */
  22736. static CreateTorus(options: {
  22737. diameter?: number;
  22738. thickness?: number;
  22739. tessellation?: number;
  22740. sideOrientation?: number;
  22741. frontUVs?: Vector4;
  22742. backUVs?: Vector4;
  22743. }): VertexData;
  22744. /**
  22745. * Creates the VertexData of the LineSystem
  22746. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22747. * - lines an array of lines, each line being an array of successive Vector3
  22748. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22749. * @returns the VertexData of the LineSystem
  22750. */
  22751. static CreateLineSystem(options: {
  22752. lines: Vector3[][];
  22753. colors?: Nullable<Color4[][]>;
  22754. }): VertexData;
  22755. /**
  22756. * Create the VertexData for a DashedLines
  22757. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22758. * - points an array successive Vector3
  22759. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22760. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22761. * - dashNb the intended total number of dashes, optional, default 200
  22762. * @returns the VertexData for the DashedLines
  22763. */
  22764. static CreateDashedLines(options: {
  22765. points: Vector3[];
  22766. dashSize?: number;
  22767. gapSize?: number;
  22768. dashNb?: number;
  22769. }): VertexData;
  22770. /**
  22771. * Creates the VertexData for a Ground
  22772. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22773. * - width the width (x direction) of the ground, optional, default 1
  22774. * - height the height (z direction) of the ground, optional, default 1
  22775. * - subdivisions the number of subdivisions per side, optional, default 1
  22776. * @returns the VertexData of the Ground
  22777. */
  22778. static CreateGround(options: {
  22779. width?: number;
  22780. height?: number;
  22781. subdivisions?: number;
  22782. subdivisionsX?: number;
  22783. subdivisionsY?: number;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22787. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22788. * * xmin the ground minimum X coordinate, optional, default -1
  22789. * * zmin the ground minimum Z coordinate, optional, default -1
  22790. * * xmax the ground maximum X coordinate, optional, default 1
  22791. * * zmax the ground maximum Z coordinate, optional, default 1
  22792. * * 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}
  22793. * * 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}
  22794. * @returns the VertexData of the TiledGround
  22795. */
  22796. static CreateTiledGround(options: {
  22797. xmin: number;
  22798. zmin: number;
  22799. xmax: number;
  22800. zmax: number;
  22801. subdivisions?: {
  22802. w: number;
  22803. h: number;
  22804. };
  22805. precision?: {
  22806. w: number;
  22807. h: number;
  22808. };
  22809. }): VertexData;
  22810. /**
  22811. * Creates the VertexData of the Ground designed from a heightmap
  22812. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22813. * * width the width (x direction) of the ground
  22814. * * height the height (z direction) of the ground
  22815. * * subdivisions the number of subdivisions per side
  22816. * * minHeight the minimum altitude on the ground, optional, default 0
  22817. * * maxHeight the maximum altitude on the ground, optional default 1
  22818. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22819. * * buffer the array holding the image color data
  22820. * * bufferWidth the width of image
  22821. * * bufferHeight the height of image
  22822. * @returns the VertexData of the Ground designed from a heightmap
  22823. */
  22824. static CreateGroundFromHeightMap(options: {
  22825. width: number;
  22826. height: number;
  22827. subdivisions: number;
  22828. minHeight: number;
  22829. maxHeight: number;
  22830. colorFilter: Color3;
  22831. buffer: Uint8Array;
  22832. bufferWidth: number;
  22833. bufferHeight: number;
  22834. }): VertexData;
  22835. /**
  22836. * Creates the VertexData for a Plane
  22837. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22838. * * size sets the width and height of the plane to the value of size, optional default 1
  22839. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22840. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22841. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22842. * * 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)
  22843. * * 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)
  22844. * @returns the VertexData of the box
  22845. */
  22846. static CreatePlane(options: {
  22847. size?: number;
  22848. width?: number;
  22849. height?: number;
  22850. sideOrientation?: number;
  22851. frontUVs?: Vector4;
  22852. backUVs?: Vector4;
  22853. }): VertexData;
  22854. /**
  22855. * Creates the VertexData of the Disc or regular Polygon
  22856. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22857. * * radius the radius of the disc, optional default 0.5
  22858. * * tessellation the number of polygon sides, optional, default 64
  22859. * * 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
  22860. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22861. * * 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)
  22862. * * 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)
  22863. * @returns the VertexData of the box
  22864. */
  22865. static CreateDisc(options: {
  22866. radius?: number;
  22867. tessellation?: number;
  22868. arc?: number;
  22869. sideOrientation?: number;
  22870. frontUVs?: Vector4;
  22871. backUVs?: Vector4;
  22872. }): VertexData;
  22873. /**
  22874. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22875. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22876. * @param polygon a mesh built from polygonTriangulation.build()
  22877. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22878. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22879. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22880. * @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)
  22881. * @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)
  22882. * @returns the VertexData of the Polygon
  22883. */
  22884. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22885. /**
  22886. * Creates the VertexData of the IcoSphere
  22887. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22888. * * radius the radius of the IcoSphere, optional default 1
  22889. * * radiusX allows stretching in the x direction, optional, default radius
  22890. * * radiusY allows stretching in the y direction, optional, default radius
  22891. * * radiusZ allows stretching in the z direction, optional, default radius
  22892. * * flat when true creates a flat shaded mesh, optional, default true
  22893. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22894. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22895. * * 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)
  22896. * * 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)
  22897. * @returns the VertexData of the IcoSphere
  22898. */
  22899. static CreateIcoSphere(options: {
  22900. radius?: number;
  22901. radiusX?: number;
  22902. radiusY?: number;
  22903. radiusZ?: number;
  22904. flat?: boolean;
  22905. subdivisions?: number;
  22906. sideOrientation?: number;
  22907. frontUVs?: Vector4;
  22908. backUVs?: Vector4;
  22909. }): VertexData;
  22910. /**
  22911. * Creates the VertexData for a Polyhedron
  22912. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22913. * * type provided types are:
  22914. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22915. * * 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)
  22916. * * size the size of the IcoSphere, optional default 1
  22917. * * sizeX allows stretching in the x direction, optional, default size
  22918. * * sizeY allows stretching in the y direction, optional, default size
  22919. * * sizeZ allows stretching in the z direction, optional, default size
  22920. * * 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
  22921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22922. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22923. * * flat when true creates a flat shaded mesh, optional, default true
  22924. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22925. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22926. * * 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)
  22927. * * 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)
  22928. * @returns the VertexData of the Polyhedron
  22929. */
  22930. static CreatePolyhedron(options: {
  22931. type?: number;
  22932. size?: number;
  22933. sizeX?: number;
  22934. sizeY?: number;
  22935. sizeZ?: number;
  22936. custom?: any;
  22937. faceUV?: Vector4[];
  22938. faceColors?: Color4[];
  22939. flat?: boolean;
  22940. sideOrientation?: number;
  22941. frontUVs?: Vector4;
  22942. backUVs?: Vector4;
  22943. }): VertexData;
  22944. /**
  22945. * Creates the VertexData for a TorusKnot
  22946. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22947. * * radius the radius of the torus knot, optional, default 2
  22948. * * tube the thickness of the tube, optional, default 0.5
  22949. * * radialSegments the number of sides on each tube segments, optional, default 32
  22950. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22951. * * p the number of windings around the z axis, optional, default 2
  22952. * * q the number of windings around the x axis, optional, default 3
  22953. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22954. * * 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)
  22955. * * 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)
  22956. * @returns the VertexData of the Torus Knot
  22957. */
  22958. static CreateTorusKnot(options: {
  22959. radius?: number;
  22960. tube?: number;
  22961. radialSegments?: number;
  22962. tubularSegments?: number;
  22963. p?: number;
  22964. q?: number;
  22965. sideOrientation?: number;
  22966. frontUVs?: Vector4;
  22967. backUVs?: Vector4;
  22968. }): VertexData;
  22969. /**
  22970. * Compute normals for given positions and indices
  22971. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22972. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22973. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22974. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22975. * * facetNormals : optional array of facet normals (vector3)
  22976. * * facetPositions : optional array of facet positions (vector3)
  22977. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22978. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22979. * * bInfo : optional bounding info, required for facetPartitioning computation
  22980. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22981. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22982. * * useRightHandedSystem: optional boolean to for right handed system computation
  22983. * * depthSort : optional boolean to enable the facet depth sort computation
  22984. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22985. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22986. */
  22987. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22988. facetNormals?: any;
  22989. facetPositions?: any;
  22990. facetPartitioning?: any;
  22991. ratio?: number;
  22992. bInfo?: any;
  22993. bbSize?: Vector3;
  22994. subDiv?: any;
  22995. useRightHandedSystem?: boolean;
  22996. depthSort?: boolean;
  22997. distanceTo?: Vector3;
  22998. depthSortedFacets?: any;
  22999. }): void;
  23000. private static _ComputeSides;
  23001. /**
  23002. * Applies VertexData created from the imported parameters to the geometry
  23003. * @param parsedVertexData the parsed data from an imported file
  23004. * @param geometry the geometry to apply the VertexData to
  23005. */
  23006. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23007. }
  23008. }
  23009. declare module BABYLON {
  23010. /**
  23011. * Class containing static functions to help procedurally build meshes
  23012. */
  23013. class MeshBuilder {
  23014. private static updateSideOrientation;
  23015. /**
  23016. * Creates a box mesh
  23017. * * The parameter `size` sets the size (float) of each box side (default 1)
  23018. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  23019. * * 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)
  23020. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23022. * * 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
  23023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23024. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  23025. * @param name defines the name of the mesh
  23026. * @param options defines the options used to create the mesh
  23027. * @param scene defines the hosting scene
  23028. * @returns the box mesh
  23029. */
  23030. static CreateBox(name: string, options: {
  23031. size?: number;
  23032. width?: number;
  23033. height?: number;
  23034. depth?: number;
  23035. faceUV?: Vector4[];
  23036. faceColors?: Color4[];
  23037. sideOrientation?: number;
  23038. frontUVs?: Vector4;
  23039. backUVs?: Vector4;
  23040. updatable?: boolean;
  23041. }, scene?: Nullable<Scene>): Mesh;
  23042. /**
  23043. * Creates a sphere mesh
  23044. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23045. * * 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`)
  23046. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23047. * * 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
  23048. * * 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)
  23049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23050. * * 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
  23051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23052. * @param name defines the name of the mesh
  23053. * @param options defines the options used to create the mesh
  23054. * @param scene defines the hosting scene
  23055. * @returns the sphere mesh
  23056. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  23057. */
  23058. static CreateSphere(name: string, options: {
  23059. segments?: number;
  23060. diameter?: number;
  23061. diameterX?: number;
  23062. diameterY?: number;
  23063. diameterZ?: number;
  23064. arc?: number;
  23065. slice?: number;
  23066. sideOrientation?: number;
  23067. frontUVs?: Vector4;
  23068. backUVs?: Vector4;
  23069. updatable?: boolean;
  23070. }, scene: any): Mesh;
  23071. /**
  23072. * Creates a plane polygonal mesh. By default, this is a disc
  23073. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23074. * * 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
  23075. * * 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
  23076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23077. * * 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
  23078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23079. * @param name defines the name of the mesh
  23080. * @param options defines the options used to create the mesh
  23081. * @param scene defines the hosting scene
  23082. * @returns the plane polygonal mesh
  23083. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23084. */
  23085. static CreateDisc(name: string, options: {
  23086. radius?: number;
  23087. tessellation?: number;
  23088. arc?: number;
  23089. updatable?: boolean;
  23090. sideOrientation?: number;
  23091. frontUVs?: Vector4;
  23092. backUVs?: Vector4;
  23093. }, scene?: Nullable<Scene>): Mesh;
  23094. /**
  23095. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23096. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23097. * * 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`)
  23098. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23099. * * 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
  23100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23101. * * 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
  23102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23103. * @param name defines the name of the mesh
  23104. * @param options defines the options used to create the mesh
  23105. * @param scene defines the hosting scene
  23106. * @returns the icosahedron mesh
  23107. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23108. */
  23109. static CreateIcoSphere(name: string, options: {
  23110. radius?: number;
  23111. radiusX?: number;
  23112. radiusY?: number;
  23113. radiusZ?: number;
  23114. flat?: boolean;
  23115. subdivisions?: number;
  23116. sideOrientation?: number;
  23117. frontUVs?: Vector4;
  23118. backUVs?: Vector4;
  23119. updatable?: boolean;
  23120. }, scene: Scene): Mesh;
  23121. /**
  23122. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23123. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23124. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23125. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23126. * * 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
  23127. * * 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
  23128. * * 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
  23129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23130. * * 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
  23131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23132. * * 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
  23133. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23134. * * 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
  23135. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23137. * @param name defines the name of the mesh
  23138. * @param options defines the options used to create the mesh
  23139. * @param scene defines the hosting scene
  23140. * @returns the ribbon mesh
  23141. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23142. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23143. */
  23144. static CreateRibbon(name: string, options: {
  23145. pathArray: Vector3[][];
  23146. closeArray?: boolean;
  23147. closePath?: boolean;
  23148. offset?: number;
  23149. updatable?: boolean;
  23150. sideOrientation?: number;
  23151. frontUVs?: Vector4;
  23152. backUVs?: Vector4;
  23153. instance?: Mesh;
  23154. invertUV?: boolean;
  23155. uvs?: Vector2[];
  23156. colors?: Color4[];
  23157. }, scene?: Nullable<Scene>): Mesh;
  23158. /**
  23159. * Creates a cylinder or a cone mesh
  23160. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23161. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23162. * * 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.
  23163. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23164. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23165. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23166. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23167. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23168. * * 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).
  23169. * * 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
  23170. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23171. * * 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
  23172. * * 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.
  23173. * * If `enclose` is false, a ring surface is one element.
  23174. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23175. * * 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
  23176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23177. * * 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
  23178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23179. * @param name defines the name of the mesh
  23180. * @param options defines the options used to create the mesh
  23181. * @param scene defines the hosting scene
  23182. * @returns the cylinder mesh
  23183. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23184. */
  23185. static CreateCylinder(name: string, options: {
  23186. height?: number;
  23187. diameterTop?: number;
  23188. diameterBottom?: number;
  23189. diameter?: number;
  23190. tessellation?: number;
  23191. subdivisions?: number;
  23192. arc?: number;
  23193. faceColors?: Color4[];
  23194. faceUV?: Vector4[];
  23195. updatable?: boolean;
  23196. hasRings?: boolean;
  23197. enclose?: boolean;
  23198. sideOrientation?: number;
  23199. frontUVs?: Vector4;
  23200. backUVs?: Vector4;
  23201. }, scene: any): Mesh;
  23202. /**
  23203. * Creates a torus mesh
  23204. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23205. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23206. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23208. * * 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
  23209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23210. * @param name defines the name of the mesh
  23211. * @param options defines the options used to create the mesh
  23212. * @param scene defines the hosting scene
  23213. * @returns the torus mesh
  23214. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23215. */
  23216. static CreateTorus(name: string, options: {
  23217. diameter?: number;
  23218. thickness?: number;
  23219. tessellation?: number;
  23220. updatable?: boolean;
  23221. sideOrientation?: number;
  23222. frontUVs?: Vector4;
  23223. backUVs?: Vector4;
  23224. }, scene: any): Mesh;
  23225. /**
  23226. * Creates a torus knot mesh
  23227. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23228. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23229. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23230. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23232. * * 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
  23233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23234. * @param name defines the name of the mesh
  23235. * @param options defines the options used to create the mesh
  23236. * @param scene defines the hosting scene
  23237. * @returns the torus knot mesh
  23238. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23239. */
  23240. static CreateTorusKnot(name: string, options: {
  23241. radius?: number;
  23242. tube?: number;
  23243. radialSegments?: number;
  23244. tubularSegments?: number;
  23245. p?: number;
  23246. q?: number;
  23247. updatable?: boolean;
  23248. sideOrientation?: number;
  23249. frontUVs?: Vector4;
  23250. backUVs?: Vector4;
  23251. }, scene: any): Mesh;
  23252. /**
  23253. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23254. * * 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
  23255. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23256. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23257. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23258. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23259. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23260. * * 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
  23261. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23263. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23264. * @param name defines the name of the new line system
  23265. * @param options defines the options used to create the line system
  23266. * @param scene defines the hosting scene
  23267. * @returns a new line system mesh
  23268. */
  23269. static CreateLineSystem(name: string, options: {
  23270. lines: Vector3[][];
  23271. updatable?: boolean;
  23272. instance?: Nullable<LinesMesh>;
  23273. colors?: Nullable<Color4[][]>;
  23274. useVertexAlpha?: boolean;
  23275. }, scene: Nullable<Scene>): LinesMesh;
  23276. /**
  23277. * Creates a line mesh
  23278. * 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
  23279. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23280. * * The parameter `points` is an array successive Vector3
  23281. * * 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
  23282. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23283. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23284. * * When updating an instance, remember that only point positions can change, not the number of points
  23285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23286. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23287. * @param name defines the name of the new line system
  23288. * @param options defines the options used to create the line system
  23289. * @param scene defines the hosting scene
  23290. * @returns a new line mesh
  23291. */
  23292. static CreateLines(name: string, options: {
  23293. points: Vector3[];
  23294. updatable?: boolean;
  23295. instance?: Nullable<LinesMesh>;
  23296. colors?: Color4[];
  23297. useVertexAlpha?: boolean;
  23298. }, scene?: Nullable<Scene>): LinesMesh;
  23299. /**
  23300. * Creates a dashed line mesh
  23301. * * 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
  23302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23303. * * The parameter `points` is an array successive Vector3
  23304. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23305. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23306. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23307. * * 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
  23308. * * When updating an instance, remember that only point positions can change, not the number of points
  23309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23310. * @param name defines the name of the mesh
  23311. * @param options defines the options used to create the mesh
  23312. * @param scene defines the hosting scene
  23313. * @returns the dashed line mesh
  23314. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23315. */
  23316. static CreateDashedLines(name: string, options: {
  23317. points: Vector3[];
  23318. dashSize?: number;
  23319. gapSize?: number;
  23320. dashNb?: number;
  23321. updatable?: boolean;
  23322. instance?: LinesMesh;
  23323. }, scene?: Nullable<Scene>): LinesMesh;
  23324. /**
  23325. * 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.
  23326. * * 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.
  23327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23328. * * 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.
  23329. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23330. * * 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
  23331. * * 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
  23332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23334. * * 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
  23335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23337. * @param name defines the name of the mesh
  23338. * @param options defines the options used to create the mesh
  23339. * @param scene defines the hosting scene
  23340. * @returns the extruded shape mesh
  23341. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23342. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23343. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23344. */
  23345. static ExtrudeShape(name: string, options: {
  23346. shape: Vector3[];
  23347. path: Vector3[];
  23348. scale?: number;
  23349. rotation?: number;
  23350. cap?: number;
  23351. updatable?: boolean;
  23352. sideOrientation?: number;
  23353. frontUVs?: Vector4;
  23354. backUVs?: Vector4;
  23355. instance?: Mesh;
  23356. invertUV?: boolean;
  23357. }, scene?: Nullable<Scene>): Mesh;
  23358. /**
  23359. * Creates an custom extruded shape mesh.
  23360. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23361. * * 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.
  23362. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23363. * * 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
  23364. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23365. * * 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
  23366. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23367. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23368. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23369. * * 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
  23370. * * 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
  23371. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23373. * * 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
  23374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23376. * @param name defines the name of the mesh
  23377. * @param options defines the options used to create the mesh
  23378. * @param scene defines the hosting scene
  23379. * @returns the custom extruded shape mesh
  23380. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23381. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23382. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23383. */
  23384. static ExtrudeShapeCustom(name: string, options: {
  23385. shape: Vector3[];
  23386. path: Vector3[];
  23387. scaleFunction?: any;
  23388. rotationFunction?: any;
  23389. ribbonCloseArray?: boolean;
  23390. ribbonClosePath?: boolean;
  23391. cap?: number;
  23392. updatable?: boolean;
  23393. sideOrientation?: number;
  23394. frontUVs?: Vector4;
  23395. backUVs?: Vector4;
  23396. instance?: Mesh;
  23397. invertUV?: boolean;
  23398. }, scene: Scene): Mesh;
  23399. /**
  23400. * Creates lathe mesh.
  23401. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23402. * * 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
  23403. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23404. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23405. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23406. * * 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
  23407. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23408. * * 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
  23409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23410. * * 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
  23411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23413. * @param name defines the name of the mesh
  23414. * @param options defines the options used to create the mesh
  23415. * @param scene defines the hosting scene
  23416. * @returns the lathe mesh
  23417. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23418. */
  23419. static CreateLathe(name: string, options: {
  23420. shape: Vector3[];
  23421. radius?: number;
  23422. tessellation?: number;
  23423. clip?: number;
  23424. arc?: number;
  23425. closed?: boolean;
  23426. updatable?: boolean;
  23427. sideOrientation?: number;
  23428. frontUVs?: Vector4;
  23429. backUVs?: Vector4;
  23430. cap?: number;
  23431. invertUV?: boolean;
  23432. }, scene: Scene): Mesh;
  23433. /**
  23434. * Creates a plane mesh
  23435. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23436. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23437. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23439. * * 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
  23440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23441. * @param name defines the name of the mesh
  23442. * @param options defines the options used to create the mesh
  23443. * @param scene defines the hosting scene
  23444. * @returns the plane mesh
  23445. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23446. */
  23447. static CreatePlane(name: string, options: {
  23448. size?: number;
  23449. width?: number;
  23450. height?: number;
  23451. sideOrientation?: number;
  23452. frontUVs?: Vector4;
  23453. backUVs?: Vector4;
  23454. updatable?: boolean;
  23455. sourcePlane?: Plane;
  23456. }, scene: Scene): Mesh;
  23457. /**
  23458. * Creates a ground mesh
  23459. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23460. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23462. * @param name defines the name of the mesh
  23463. * @param options defines the options used to create the mesh
  23464. * @param scene defines the hosting scene
  23465. * @returns the ground mesh
  23466. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23467. */
  23468. static CreateGround(name: string, options: {
  23469. width?: number;
  23470. height?: number;
  23471. subdivisions?: number;
  23472. subdivisionsX?: number;
  23473. subdivisionsY?: number;
  23474. updatable?: boolean;
  23475. }, scene: any): Mesh;
  23476. /**
  23477. * Creates a tiled ground mesh
  23478. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23479. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23480. * * 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
  23481. * * 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
  23482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23483. * @param name defines the name of the mesh
  23484. * @param options defines the options used to create the mesh
  23485. * @param scene defines the hosting scene
  23486. * @returns the tiled ground mesh
  23487. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23488. */
  23489. static CreateTiledGround(name: string, options: {
  23490. xmin: number;
  23491. zmin: number;
  23492. xmax: number;
  23493. zmax: number;
  23494. subdivisions?: {
  23495. w: number;
  23496. h: number;
  23497. };
  23498. precision?: {
  23499. w: number;
  23500. h: number;
  23501. };
  23502. updatable?: boolean;
  23503. }, scene: Scene): Mesh;
  23504. /**
  23505. * Creates a ground mesh from a height map
  23506. * * The parameter `url` sets the URL of the height map image resource.
  23507. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23508. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23509. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23510. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23511. * * 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.
  23512. * * 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).
  23513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23514. * @param name defines the name of the mesh
  23515. * @param url defines the url to the height map
  23516. * @param options defines the options used to create the mesh
  23517. * @param scene defines the hosting scene
  23518. * @returns the ground mesh
  23519. * @see http://doc.babylonjs.com/babylon101/height_map
  23520. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23521. */
  23522. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23523. width?: number;
  23524. height?: number;
  23525. subdivisions?: number;
  23526. minHeight?: number;
  23527. maxHeight?: number;
  23528. colorFilter?: Color3;
  23529. updatable?: boolean;
  23530. onReady?: (mesh: GroundMesh) => void;
  23531. }, scene: Scene): GroundMesh;
  23532. /**
  23533. * Creates a polygon mesh
  23534. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23535. * * 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
  23536. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23538. * * 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)
  23539. * * Remember you can only change the shape positions, not their number when updating a polygon
  23540. * @param name defines the name of the mesh
  23541. * @param options defines the options used to create the mesh
  23542. * @param scene defines the hosting scene
  23543. * @returns the polygon mesh
  23544. */
  23545. static CreatePolygon(name: string, options: {
  23546. shape: Vector3[];
  23547. holes?: Vector3[][];
  23548. depth?: number;
  23549. faceUV?: Vector4[];
  23550. faceColors?: Color4[];
  23551. updatable?: boolean;
  23552. sideOrientation?: number;
  23553. frontUVs?: Vector4;
  23554. backUVs?: Vector4;
  23555. }, scene: Scene): Mesh;
  23556. /**
  23557. * Creates an extruded polygon mesh, with depth in the Y direction.
  23558. * * 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)
  23559. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23560. * @param name defines the name of the mesh
  23561. * @param options defines the options used to create the mesh
  23562. * @param scene defines the hosting scene
  23563. * @returns the polygon mesh
  23564. */
  23565. static ExtrudePolygon(name: string, options: {
  23566. shape: Vector3[];
  23567. holes?: Vector3[][];
  23568. depth?: number;
  23569. faceUV?: Vector4[];
  23570. faceColors?: Color4[];
  23571. updatable?: boolean;
  23572. sideOrientation?: number;
  23573. frontUVs?: Vector4;
  23574. backUVs?: Vector4;
  23575. }, scene: Scene): Mesh;
  23576. /**
  23577. * Creates a tube mesh.
  23578. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23579. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23580. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23581. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23582. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23583. * * 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)
  23584. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23585. * * 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
  23586. * * 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
  23587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23588. * * 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
  23589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23591. * @param name defines the name of the mesh
  23592. * @param options defines the options used to create the mesh
  23593. * @param scene defines the hosting scene
  23594. * @returns the tube mesh
  23595. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23596. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23597. */
  23598. static CreateTube(name: string, options: {
  23599. path: Vector3[];
  23600. radius?: number;
  23601. tessellation?: number;
  23602. radiusFunction?: {
  23603. (i: number, distance: number): number;
  23604. };
  23605. cap?: number;
  23606. arc?: number;
  23607. updatable?: boolean;
  23608. sideOrientation?: number;
  23609. frontUVs?: Vector4;
  23610. backUVs?: Vector4;
  23611. instance?: Mesh;
  23612. invertUV?: boolean;
  23613. }, scene: Scene): Mesh;
  23614. /**
  23615. * Creates a polyhedron mesh
  23616. * * 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
  23617. * * The parameter `size` (positive float, default 1) sets the polygon size
  23618. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23619. * * 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`
  23620. * * 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
  23621. * * 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)`)
  23622. * * 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
  23623. * * 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
  23624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23625. * * 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
  23626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23627. * @param name defines the name of the mesh
  23628. * @param options defines the options used to create the mesh
  23629. * @param scene defines the hosting scene
  23630. * @returns the polyhedron mesh
  23631. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23632. */
  23633. static CreatePolyhedron(name: string, options: {
  23634. type?: number;
  23635. size?: number;
  23636. sizeX?: number;
  23637. sizeY?: number;
  23638. sizeZ?: number;
  23639. custom?: any;
  23640. faceUV?: Vector4[];
  23641. faceColors?: Color4[];
  23642. flat?: boolean;
  23643. updatable?: boolean;
  23644. sideOrientation?: number;
  23645. frontUVs?: Vector4;
  23646. backUVs?: Vector4;
  23647. }, scene: Scene): Mesh;
  23648. /**
  23649. * Creates a decal mesh.
  23650. * 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
  23651. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23652. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23653. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23654. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23655. * @param name defines the name of the mesh
  23656. * @param sourceMesh defines the mesh where the decal must be applied
  23657. * @param options defines the options used to create the mesh
  23658. * @param scene defines the hosting scene
  23659. * @returns the decal mesh
  23660. * @see http://doc.babylonjs.com/how_to/decals
  23661. */
  23662. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23663. position?: Vector3;
  23664. normal?: Vector3;
  23665. size?: Vector3;
  23666. angle?: number;
  23667. }): Mesh;
  23668. private static _ExtrudeShapeGeneric;
  23669. }
  23670. }
  23671. declare module BABYLON {
  23672. class MeshLODLevel {
  23673. distance: number;
  23674. mesh: Nullable<Mesh>;
  23675. constructor(distance: number, mesh: Nullable<Mesh>);
  23676. }
  23677. }
  23678. declare module BABYLON {
  23679. /**
  23680. * A simplifier interface for future simplification implementations.
  23681. */
  23682. interface ISimplifier {
  23683. /**
  23684. * Simplification of a given mesh according to the given settings.
  23685. * Since this requires computation, it is assumed that the function runs async.
  23686. * @param settings The settings of the simplification, including quality and distance
  23687. * @param successCallback A callback that will be called after the mesh was simplified.
  23688. * @param errorCallback in case of an error, this callback will be called. optional.
  23689. */
  23690. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23691. }
  23692. /**
  23693. * Expected simplification settings.
  23694. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23695. */
  23696. interface ISimplificationSettings {
  23697. quality: number;
  23698. distance: number;
  23699. optimizeMesh?: boolean;
  23700. }
  23701. class SimplificationSettings implements ISimplificationSettings {
  23702. quality: number;
  23703. distance: number;
  23704. optimizeMesh?: boolean | undefined;
  23705. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23706. }
  23707. interface ISimplificationTask {
  23708. settings: Array<ISimplificationSettings>;
  23709. simplificationType: SimplificationType;
  23710. mesh: Mesh;
  23711. successCallback?: () => void;
  23712. parallelProcessing: boolean;
  23713. }
  23714. class SimplificationQueue {
  23715. private _simplificationArray;
  23716. running: boolean;
  23717. constructor();
  23718. addTask(task: ISimplificationTask): void;
  23719. executeNext(): void;
  23720. runSimplification(task: ISimplificationTask): void;
  23721. private getSimplifier;
  23722. }
  23723. /**
  23724. * The implemented types of simplification
  23725. * At the moment only Quadratic Error Decimation is implemented
  23726. */
  23727. enum SimplificationType {
  23728. /** Quadratic error decimation */
  23729. QUADRATIC = 0
  23730. }
  23731. class DecimationTriangle {
  23732. vertices: Array<DecimationVertex>;
  23733. normal: Vector3;
  23734. error: Array<number>;
  23735. deleted: boolean;
  23736. isDirty: boolean;
  23737. borderFactor: number;
  23738. deletePending: boolean;
  23739. originalOffset: number;
  23740. constructor(vertices: Array<DecimationVertex>);
  23741. }
  23742. class DecimationVertex {
  23743. position: Vector3;
  23744. id: number;
  23745. q: QuadraticMatrix;
  23746. isBorder: boolean;
  23747. triangleStart: number;
  23748. triangleCount: number;
  23749. originalOffsets: Array<number>;
  23750. constructor(position: Vector3, id: number);
  23751. updatePosition(newPosition: Vector3): void;
  23752. }
  23753. class QuadraticMatrix {
  23754. data: Array<number>;
  23755. constructor(data?: Array<number>);
  23756. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23757. addInPlace(matrix: QuadraticMatrix): void;
  23758. addArrayInPlace(data: Array<number>): void;
  23759. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23760. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23761. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23762. }
  23763. class Reference {
  23764. vertexId: number;
  23765. triangleId: number;
  23766. constructor(vertexId: number, triangleId: number);
  23767. }
  23768. /**
  23769. * An implementation of the Quadratic Error simplification algorithm.
  23770. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23771. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23772. * @author RaananW
  23773. */
  23774. class QuadraticErrorSimplification implements ISimplifier {
  23775. private _mesh;
  23776. private triangles;
  23777. private vertices;
  23778. private references;
  23779. private _reconstructedMesh;
  23780. syncIterations: number;
  23781. aggressiveness: number;
  23782. decimationIterations: number;
  23783. boundingBoxEpsilon: number;
  23784. constructor(_mesh: Mesh);
  23785. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23786. private runDecimation;
  23787. private initWithMesh;
  23788. private init;
  23789. private reconstructMesh;
  23790. private initDecimatedMesh;
  23791. private isFlipped;
  23792. private updateTriangles;
  23793. private identifyBorder;
  23794. private updateMesh;
  23795. private vertexError;
  23796. private calculateError;
  23797. }
  23798. }
  23799. declare module BABYLON {
  23800. interface Scene {
  23801. /** @hidden (Backing field) */
  23802. _simplificationQueue: SimplificationQueue;
  23803. /**
  23804. * Gets or sets the simplification queue attached to the scene
  23805. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23806. */
  23807. simplificationQueue: SimplificationQueue;
  23808. }
  23809. interface Mesh {
  23810. /**
  23811. * Simplify the mesh according to the given array of settings.
  23812. * Function will return immediately and will simplify async. It returns the Mesh.
  23813. * @param settings a collection of simplification settings.
  23814. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23815. * @param type the type of simplification to run.
  23816. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23817. */
  23818. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23819. }
  23820. /**
  23821. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23822. * created in a scene
  23823. */
  23824. class SimplicationQueueSceneComponent implements ISceneComponent {
  23825. /**
  23826. * The component name helpfull to identify the component in the list of scene components.
  23827. */
  23828. readonly name: string;
  23829. /**
  23830. * The scene the component belongs to.
  23831. */
  23832. scene: Scene;
  23833. /**
  23834. * Creates a new instance of the component for the given scene
  23835. * @param scene Defines the scene to register the component in
  23836. */
  23837. constructor(scene: Scene);
  23838. /**
  23839. * Registers the component in a given scene
  23840. */
  23841. register(): void;
  23842. /**
  23843. * Rebuilds the elements related to this component in case of
  23844. * context lost for instance.
  23845. */
  23846. rebuild(): void;
  23847. /**
  23848. * Disposes the component and the associated ressources
  23849. */
  23850. dispose(): void;
  23851. private _beforeCameraUpdate;
  23852. }
  23853. }
  23854. declare module BABYLON {
  23855. class Polygon {
  23856. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23857. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23858. static Parse(input: string): Vector2[];
  23859. static StartingAt(x: number, y: number): Path2;
  23860. }
  23861. class PolygonMeshBuilder {
  23862. private _points;
  23863. private _outlinepoints;
  23864. private _holes;
  23865. private _name;
  23866. private _scene;
  23867. private _epoints;
  23868. private _eholes;
  23869. private _addToepoint;
  23870. constructor(name: string, contours: Path2, scene: Scene);
  23871. constructor(name: string, contours: Vector2[], scene: Scene);
  23872. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23873. build(updatable?: boolean, depth?: number): Mesh;
  23874. private addSide;
  23875. }
  23876. }
  23877. declare module BABYLON {
  23878. class BaseSubMesh {
  23879. /** @hidden */
  23880. _materialDefines: Nullable<MaterialDefines>;
  23881. /** @hidden */
  23882. _materialEffect: Nullable<Effect>;
  23883. readonly effect: Nullable<Effect>;
  23884. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23885. }
  23886. class SubMesh extends BaseSubMesh implements ICullable {
  23887. materialIndex: number;
  23888. verticesStart: number;
  23889. verticesCount: number;
  23890. indexStart: number;
  23891. indexCount: number;
  23892. linesIndexCount: number;
  23893. private _mesh;
  23894. private _renderingMesh;
  23895. private _boundingInfo;
  23896. private _linesIndexBuffer;
  23897. /** @hidden */
  23898. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23899. /** @hidden */
  23900. _trianglePlanes: Plane[];
  23901. /** @hidden */
  23902. _lastColliderTransformMatrix: Matrix;
  23903. /** @hidden */
  23904. _renderId: number;
  23905. /** @hidden */
  23906. _alphaIndex: number;
  23907. /** @hidden */
  23908. _distanceToCamera: number;
  23909. /** @hidden */
  23910. _id: number;
  23911. private _currentMaterial;
  23912. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23913. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23914. readonly IsGlobal: boolean;
  23915. /**
  23916. * Returns the submesh BoudingInfo object.
  23917. */
  23918. getBoundingInfo(): BoundingInfo;
  23919. /**
  23920. * Sets the submesh BoundingInfo.
  23921. * Return the SubMesh.
  23922. */
  23923. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23924. /**
  23925. * Returns the mesh of the current submesh.
  23926. */
  23927. getMesh(): AbstractMesh;
  23928. /**
  23929. * Returns the rendering mesh of the submesh.
  23930. */
  23931. getRenderingMesh(): Mesh;
  23932. /**
  23933. * Returns the submesh material.
  23934. */
  23935. getMaterial(): Nullable<Material>;
  23936. /**
  23937. * Sets a new updated BoundingInfo object to the submesh.
  23938. * Returns the SubMesh.
  23939. */
  23940. refreshBoundingInfo(): SubMesh;
  23941. /** @hidden */
  23942. _checkCollision(collider: Collider): boolean;
  23943. /**
  23944. * Updates the submesh BoundingInfo.
  23945. * Returns the Submesh.
  23946. */
  23947. updateBoundingInfo(world: Matrix): SubMesh;
  23948. /**
  23949. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23950. * Boolean returned.
  23951. */
  23952. isInFrustum(frustumPlanes: Plane[]): boolean;
  23953. /**
  23954. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23955. * Boolean returned.
  23956. */
  23957. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23958. /**
  23959. * Renders the submesh.
  23960. * Returns it.
  23961. */
  23962. render(enableAlphaMode: boolean): SubMesh;
  23963. /**
  23964. * Returns a new Index Buffer.
  23965. * Type returned : WebGLBuffer.
  23966. */
  23967. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23968. /**
  23969. * True is the passed Ray intersects the submesh bounding box.
  23970. * Boolean returned.
  23971. */
  23972. canIntersects(ray: Ray): boolean;
  23973. /**
  23974. * Returns an object IntersectionInfo.
  23975. */
  23976. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23977. /** @hidden */
  23978. _rebuild(): void;
  23979. /**
  23980. * Creates a new Submesh from the passed Mesh.
  23981. */
  23982. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23983. /**
  23984. * Disposes the Submesh.
  23985. * Returns nothing.
  23986. */
  23987. dispose(): void;
  23988. /**
  23989. * Creates a new Submesh from the passed parameters :
  23990. * - materialIndex (integer) : the index of the main mesh material.
  23991. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23992. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23993. * - mesh (Mesh) : the main mesh to create the submesh from.
  23994. * - renderingMesh (optional Mesh) : rendering mesh.
  23995. */
  23996. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23997. }
  23998. }
  23999. declare module BABYLON {
  24000. class TransformNode extends Node {
  24001. static BILLBOARDMODE_NONE: number;
  24002. static BILLBOARDMODE_X: number;
  24003. static BILLBOARDMODE_Y: number;
  24004. static BILLBOARDMODE_Z: number;
  24005. static BILLBOARDMODE_ALL: number;
  24006. private _forward;
  24007. private _forwardInverted;
  24008. private _up;
  24009. private _right;
  24010. private _rightInverted;
  24011. private _position;
  24012. private _rotation;
  24013. private _rotationQuaternion;
  24014. protected _scaling: Vector3;
  24015. protected _isDirty: boolean;
  24016. private _transformToBoneReferal;
  24017. /**
  24018. * Set the billboard mode. Default is 0.
  24019. *
  24020. * | Value | Type | Description |
  24021. * | --- | --- | --- |
  24022. * | 0 | BILLBOARDMODE_NONE | |
  24023. * | 1 | BILLBOARDMODE_X | |
  24024. * | 2 | BILLBOARDMODE_Y | |
  24025. * | 4 | BILLBOARDMODE_Z | |
  24026. * | 7 | BILLBOARDMODE_ALL | |
  24027. *
  24028. */
  24029. billboardMode: number;
  24030. scalingDeterminant: number;
  24031. infiniteDistance: boolean;
  24032. /**
  24033. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  24034. * By default the system will update normals to compensate
  24035. */
  24036. ignoreNonUniformScaling: boolean;
  24037. /** @hidden */
  24038. _poseMatrix: Matrix;
  24039. private _localWorld;
  24040. private _absolutePosition;
  24041. private _pivotMatrix;
  24042. private _pivotMatrixInverse;
  24043. private _postMultiplyPivotMatrix;
  24044. protected _isWorldMatrixFrozen: boolean;
  24045. /**
  24046. * An event triggered after the world matrix is updated
  24047. */
  24048. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  24049. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  24050. /**
  24051. * Gets a string identifying the name of the class
  24052. * @returns "TransformNode" string
  24053. */
  24054. getClassName(): string;
  24055. /**
  24056. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  24057. */
  24058. position: Vector3;
  24059. /**
  24060. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  24061. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  24062. */
  24063. rotation: Vector3;
  24064. /**
  24065. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  24066. */
  24067. scaling: Vector3;
  24068. /**
  24069. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  24070. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  24071. */
  24072. rotationQuaternion: Nullable<Quaternion>;
  24073. /**
  24074. * The forward direction of that transform in world space.
  24075. */
  24076. readonly forward: Vector3;
  24077. /**
  24078. * The up direction of that transform in world space.
  24079. */
  24080. readonly up: Vector3;
  24081. /**
  24082. * The right direction of that transform in world space.
  24083. */
  24084. readonly right: Vector3;
  24085. /**
  24086. * Copies the parameter passed Matrix into the mesh Pose matrix.
  24087. * Returns the TransformNode.
  24088. */
  24089. updatePoseMatrix(matrix: Matrix): TransformNode;
  24090. /**
  24091. * Returns the mesh Pose matrix.
  24092. * Returned object : Matrix
  24093. */
  24094. getPoseMatrix(): Matrix;
  24095. /** @hidden */
  24096. _isSynchronized(): boolean;
  24097. /** @hidden */
  24098. _initCache(): void;
  24099. markAsDirty(property: string): TransformNode;
  24100. /**
  24101. * Returns the current mesh absolute position.
  24102. * Returns a Vector3.
  24103. */
  24104. readonly absolutePosition: Vector3;
  24105. /**
  24106. * Sets a new matrix to apply before all other transformation
  24107. * @param matrix defines the transform matrix
  24108. * @returns the current TransformNode
  24109. */
  24110. setPreTransformMatrix(matrix: Matrix): TransformNode;
  24111. /**
  24112. * Sets a new pivot matrix to the current node
  24113. * @param matrix defines the new pivot matrix to use
  24114. * @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
  24115. * @returns the current TransformNode
  24116. */
  24117. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  24118. /**
  24119. * Returns the mesh pivot matrix.
  24120. * Default : Identity.
  24121. * A Matrix is returned.
  24122. */
  24123. getPivotMatrix(): Matrix;
  24124. /**
  24125. * Prevents the World matrix to be computed any longer.
  24126. * Returns the TransformNode.
  24127. */
  24128. freezeWorldMatrix(): TransformNode;
  24129. /**
  24130. * Allows back the World matrix computation.
  24131. * Returns the TransformNode.
  24132. */
  24133. unfreezeWorldMatrix(): this;
  24134. /**
  24135. * True if the World matrix has been frozen.
  24136. * Returns a boolean.
  24137. */
  24138. readonly isWorldMatrixFrozen: boolean;
  24139. /**
  24140. * Retuns the mesh absolute position in the World.
  24141. * Returns a Vector3.
  24142. */
  24143. getAbsolutePosition(): Vector3;
  24144. /**
  24145. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  24146. * Returns the TransformNode.
  24147. */
  24148. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24149. /**
  24150. * Sets the mesh position in its local space.
  24151. * Returns the TransformNode.
  24152. */
  24153. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24154. /**
  24155. * Returns the mesh position in the local space from the current World matrix values.
  24156. * Returns a new Vector3.
  24157. */
  24158. getPositionExpressedInLocalSpace(): Vector3;
  24159. /**
  24160. * Translates the mesh along the passed Vector3 in its local space.
  24161. * Returns the TransformNode.
  24162. */
  24163. locallyTranslate(vector3: Vector3): TransformNode;
  24164. private static _lookAtVectorCache;
  24165. /**
  24166. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24167. * @param targetPoint the position (must be in same space as current mesh) to look at
  24168. * @param yawCor optional yaw (y-axis) correction in radians
  24169. * @param pitchCor optional pitch (x-axis) correction in radians
  24170. * @param rollCor optional roll (z-axis) correction in radians
  24171. * @param space the choosen space of the target
  24172. * @returns the TransformNode.
  24173. */
  24174. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24175. /**
  24176. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24177. * This Vector3 is expressed in the World space.
  24178. */
  24179. getDirection(localAxis: Vector3): Vector3;
  24180. /**
  24181. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24182. * localAxis is expressed in the mesh local space.
  24183. * result is computed in the Wordl space from the mesh World matrix.
  24184. * Returns the TransformNode.
  24185. */
  24186. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24187. /**
  24188. * Sets a new pivot point to the current node
  24189. * @param point defines the new pivot point to use
  24190. * @param space defines if the point is in world or local space (local by default)
  24191. * @returns the current TransformNode
  24192. */
  24193. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24194. /**
  24195. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24196. */
  24197. getPivotPoint(): Vector3;
  24198. /**
  24199. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24200. * Returns the TransformNode.
  24201. */
  24202. getPivotPointToRef(result: Vector3): TransformNode;
  24203. /**
  24204. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24205. */
  24206. getAbsolutePivotPoint(): Vector3;
  24207. /**
  24208. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24209. * Returns the TransformNode.
  24210. */
  24211. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24212. /**
  24213. * Defines the passed node as the parent of the current node.
  24214. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24215. * Returns the TransformNode.
  24216. */
  24217. setParent(node: Nullable<Node>): TransformNode;
  24218. private _nonUniformScaling;
  24219. readonly nonUniformScaling: boolean;
  24220. /** @hidden */
  24221. _updateNonUniformScalingState(value: boolean): boolean;
  24222. /**
  24223. * Attach the current TransformNode to another TransformNode associated with a bone
  24224. * @param bone Bone affecting the TransformNode
  24225. * @param affectedTransformNode TransformNode associated with the bone
  24226. */
  24227. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24228. detachFromBone(): TransformNode;
  24229. private static _rotationAxisCache;
  24230. /**
  24231. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24232. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24233. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24234. * The passed axis is also normalized.
  24235. * Returns the TransformNode.
  24236. */
  24237. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24238. /**
  24239. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24240. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24241. * The passed axis is also normalized.
  24242. * Returns the TransformNode.
  24243. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24244. */
  24245. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24246. /**
  24247. * Translates the mesh along the axis vector for the passed distance in the given space.
  24248. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24249. * Returns the TransformNode.
  24250. */
  24251. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24252. /**
  24253. * Adds a rotation step to the mesh current rotation.
  24254. * x, y, z are Euler angles expressed in radians.
  24255. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24256. * This means this rotation is made in the mesh local space only.
  24257. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24258. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24259. * ```javascript
  24260. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24261. * ```
  24262. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24263. * 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.
  24264. * Returns the TransformNode.
  24265. */
  24266. addRotation(x: number, y: number, z: number): TransformNode;
  24267. /**
  24268. * Computes the world matrix of the node
  24269. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24270. * @returns the world matrix
  24271. */
  24272. computeWorldMatrix(force?: boolean): Matrix;
  24273. protected _afterComputeWorldMatrix(): void;
  24274. /**
  24275. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24276. * @param func: callback function to add
  24277. *
  24278. * Returns the TransformNode.
  24279. */
  24280. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24281. /**
  24282. * Removes a registered callback function.
  24283. * Returns the TransformNode.
  24284. */
  24285. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24286. /**
  24287. * Clone the current transform node
  24288. * Returns the new transform node
  24289. * @param name Name of the new clone
  24290. * @param newParent New parent for the clone
  24291. * @param doNotCloneChildren Do not clone children hierarchy
  24292. */
  24293. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24294. serialize(currentSerializationObject?: any): any;
  24295. /**
  24296. * Returns a new TransformNode object parsed from the source provided.
  24297. * The parameter `parsedMesh` is the source.
  24298. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24299. */
  24300. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24301. /**
  24302. * Releases resources associated with this transform node.
  24303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24305. */
  24306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24307. }
  24308. }
  24309. declare module BABYLON {
  24310. class VertexBuffer {
  24311. /** @hidden */
  24312. _buffer: Buffer;
  24313. private _kind;
  24314. private _size;
  24315. private _ownsBuffer;
  24316. private _instanced;
  24317. private _instanceDivisor;
  24318. /**
  24319. * The byte type.
  24320. */
  24321. static readonly BYTE: number;
  24322. /**
  24323. * The unsigned byte type.
  24324. */
  24325. static readonly UNSIGNED_BYTE: number;
  24326. /**
  24327. * The short type.
  24328. */
  24329. static readonly SHORT: number;
  24330. /**
  24331. * The unsigned short type.
  24332. */
  24333. static readonly UNSIGNED_SHORT: number;
  24334. /**
  24335. * The integer type.
  24336. */
  24337. static readonly INT: number;
  24338. /**
  24339. * The unsigned integer type.
  24340. */
  24341. static readonly UNSIGNED_INT: number;
  24342. /**
  24343. * The float type.
  24344. */
  24345. static readonly FLOAT: number;
  24346. /**
  24347. * Gets or sets the instance divisor when in instanced mode
  24348. */
  24349. instanceDivisor: number;
  24350. /**
  24351. * Gets the byte stride.
  24352. */
  24353. readonly byteStride: number;
  24354. /**
  24355. * Gets the byte offset.
  24356. */
  24357. readonly byteOffset: number;
  24358. /**
  24359. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24360. */
  24361. readonly normalized: boolean;
  24362. /**
  24363. * Gets the data type of each component in the array.
  24364. */
  24365. readonly type: number;
  24366. /**
  24367. * Constructor
  24368. * @param engine the engine
  24369. * @param data the data to use for this vertex buffer
  24370. * @param kind the vertex buffer kind
  24371. * @param updatable whether the data is updatable
  24372. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24373. * @param stride the stride (optional)
  24374. * @param instanced whether the buffer is instanced (optional)
  24375. * @param offset the offset of the data (optional)
  24376. * @param size the number of components (optional)
  24377. * @param type the type of the component (optional)
  24378. * @param normalized whether the data contains normalized data (optional)
  24379. * @param useBytes set to true if stride and offset are in bytes (optional)
  24380. */
  24381. 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);
  24382. /** @hidden */
  24383. _rebuild(): void;
  24384. /**
  24385. * Returns the kind of the VertexBuffer (string).
  24386. */
  24387. getKind(): string;
  24388. /**
  24389. * Boolean : is the VertexBuffer updatable ?
  24390. */
  24391. isUpdatable(): boolean;
  24392. /**
  24393. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24394. */
  24395. getData(): Nullable<DataArray>;
  24396. /**
  24397. * Returns the WebGLBuffer associated to the VertexBuffer.
  24398. */
  24399. getBuffer(): Nullable<WebGLBuffer>;
  24400. /**
  24401. * Returns the stride as a multiple of the type byte length.
  24402. * DEPRECATED. Use byteStride instead.
  24403. */
  24404. getStrideSize(): number;
  24405. /**
  24406. * Returns the offset as a multiple of the type byte length.
  24407. * DEPRECATED. Use byteOffset instead.
  24408. */
  24409. getOffset(): number;
  24410. /**
  24411. * Returns the number of components per vertex attribute (integer).
  24412. */
  24413. getSize(): number;
  24414. /**
  24415. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24416. */
  24417. getIsInstanced(): boolean;
  24418. /**
  24419. * Returns the instancing divisor, zero for non-instanced (integer).
  24420. */
  24421. getInstanceDivisor(): number;
  24422. /**
  24423. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24424. * Returns the created WebGLBuffer.
  24425. */
  24426. create(data?: DataArray): void;
  24427. /**
  24428. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24429. * This function will create a new buffer if the current one is not updatable
  24430. * Returns the updated WebGLBuffer.
  24431. */
  24432. update(data: DataArray): void;
  24433. /**
  24434. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24435. * Returns the directly updated WebGLBuffer.
  24436. * @param data the new data
  24437. * @param offset the new offset
  24438. * @param useBytes set to true if the offset is in bytes
  24439. */
  24440. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24441. /**
  24442. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24443. */
  24444. dispose(): void;
  24445. /**
  24446. * Enumerates each value of this vertex buffer as numbers.
  24447. * @param count the number of values to enumerate
  24448. * @param callback the callback function called for each value
  24449. */
  24450. forEach(count: number, callback: (value: number, index: number) => void): void;
  24451. private static _PositionKind;
  24452. private static _NormalKind;
  24453. private static _TangentKind;
  24454. private static _UVKind;
  24455. private static _UV2Kind;
  24456. private static _UV3Kind;
  24457. private static _UV4Kind;
  24458. private static _UV5Kind;
  24459. private static _UV6Kind;
  24460. private static _ColorKind;
  24461. private static _MatricesIndicesKind;
  24462. private static _MatricesWeightsKind;
  24463. private static _MatricesIndicesExtraKind;
  24464. private static _MatricesWeightsExtraKind;
  24465. static readonly PositionKind: string;
  24466. static readonly NormalKind: string;
  24467. static readonly TangentKind: string;
  24468. static readonly UVKind: string;
  24469. static readonly UV2Kind: string;
  24470. static readonly UV3Kind: string;
  24471. static readonly UV4Kind: string;
  24472. static readonly UV5Kind: string;
  24473. static readonly UV6Kind: string;
  24474. static readonly ColorKind: string;
  24475. static readonly MatricesIndicesKind: string;
  24476. static readonly MatricesWeightsKind: string;
  24477. static readonly MatricesIndicesExtraKind: string;
  24478. static readonly MatricesWeightsExtraKind: string;
  24479. /**
  24480. * Deduces the stride given a kind.
  24481. * @param kind The kind string to deduce
  24482. * @returns The deduced stride
  24483. */
  24484. static DeduceStride(kind: string): number;
  24485. /**
  24486. * Gets the byte length of the given type.
  24487. * @param type the type
  24488. * @returns the number of bytes
  24489. */
  24490. static GetTypeByteLength(type: number): number;
  24491. /**
  24492. * Enumerates each value of the given parameters as numbers.
  24493. * @param data the data to enumerate
  24494. * @param byteOffset the byte offset of the data
  24495. * @param byteStride the byte stride of the data
  24496. * @param componentCount the number of components per element
  24497. * @param componentType the type of the component
  24498. * @param count the total number of components
  24499. * @param normalized whether the data is normalized
  24500. * @param callback the callback function called for each value
  24501. */
  24502. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24503. private static _GetFloatValue;
  24504. }
  24505. }
  24506. declare module BABYLON {
  24507. /**
  24508. * This represents the base class for particle system in Babylon.
  24509. * 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.
  24510. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24511. * @example https://doc.babylonjs.com/babylon101/particles
  24512. */
  24513. class BaseParticleSystem {
  24514. /**
  24515. * Source color is added to the destination color without alpha affecting the result.
  24516. */
  24517. static BLENDMODE_ONEONE: number;
  24518. /**
  24519. * Blend current color and particle color using particle’s alpha.
  24520. */
  24521. static BLENDMODE_STANDARD: number;
  24522. /**
  24523. * Add current color and particle color multiplied by particle’s alpha.
  24524. */
  24525. static BLENDMODE_ADD: number;
  24526. /**
  24527. * Multiply current color with particle color
  24528. */
  24529. static BLENDMODE_MULTIPLY: number;
  24530. /**
  24531. * List of animations used by the particle system.
  24532. */
  24533. animations: Animation[];
  24534. /**
  24535. * The id of the Particle system.
  24536. */
  24537. id: string;
  24538. /**
  24539. * The friendly name of the Particle system.
  24540. */
  24541. name: string;
  24542. /**
  24543. * The rendering group used by the Particle system to chose when to render.
  24544. */
  24545. renderingGroupId: number;
  24546. /**
  24547. * The emitter represents the Mesh or position we are attaching the particle system to.
  24548. */
  24549. emitter: Nullable<AbstractMesh | Vector3>;
  24550. /**
  24551. * The maximum number of particles to emit per frame
  24552. */
  24553. emitRate: number;
  24554. /**
  24555. * If you want to launch only a few particles at once, that can be done, as well.
  24556. */
  24557. manualEmitCount: number;
  24558. /**
  24559. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24560. */
  24561. updateSpeed: number;
  24562. /**
  24563. * The amount of time the particle system is running (depends of the overall update speed).
  24564. */
  24565. targetStopDuration: number;
  24566. /**
  24567. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24568. */
  24569. disposeOnStop: boolean;
  24570. /**
  24571. * Minimum power of emitting particles.
  24572. */
  24573. minEmitPower: number;
  24574. /**
  24575. * Maximum power of emitting particles.
  24576. */
  24577. maxEmitPower: number;
  24578. /**
  24579. * Minimum life time of emitting particles.
  24580. */
  24581. minLifeTime: number;
  24582. /**
  24583. * Maximum life time of emitting particles.
  24584. */
  24585. maxLifeTime: number;
  24586. /**
  24587. * Minimum Size of emitting particles.
  24588. */
  24589. minSize: number;
  24590. /**
  24591. * Maximum Size of emitting particles.
  24592. */
  24593. maxSize: number;
  24594. /**
  24595. * Minimum scale of emitting particles on X axis.
  24596. */
  24597. minScaleX: number;
  24598. /**
  24599. * Maximum scale of emitting particles on X axis.
  24600. */
  24601. maxScaleX: number;
  24602. /**
  24603. * Minimum scale of emitting particles on Y axis.
  24604. */
  24605. minScaleY: number;
  24606. /**
  24607. * Maximum scale of emitting particles on Y axis.
  24608. */
  24609. maxScaleY: number;
  24610. /**
  24611. * Gets or sets the minimal initial rotation in radians.
  24612. */
  24613. minInitialRotation: number;
  24614. /**
  24615. * Gets or sets the maximal initial rotation in radians.
  24616. */
  24617. maxInitialRotation: number;
  24618. /**
  24619. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24620. */
  24621. minAngularSpeed: number;
  24622. /**
  24623. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24624. */
  24625. maxAngularSpeed: number;
  24626. /**
  24627. * The texture used to render each particle. (this can be a spritesheet)
  24628. */
  24629. particleTexture: Nullable<Texture>;
  24630. /**
  24631. * The layer mask we are rendering the particles through.
  24632. */
  24633. layerMask: number;
  24634. /**
  24635. * This can help using your own shader to render the particle system.
  24636. * The according effect will be created
  24637. */
  24638. customShader: any;
  24639. /**
  24640. * By default particle system starts as soon as they are created. This prevents the
  24641. * automatic start to happen and let you decide when to start emitting particles.
  24642. */
  24643. preventAutoStart: boolean;
  24644. /**
  24645. * Gets or sets a texture used to add random noise to particle positions
  24646. */
  24647. noiseTexture: Nullable<BaseTexture>;
  24648. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24649. noiseStrength: Vector3;
  24650. /**
  24651. * Callback triggered when the particle animation is ending.
  24652. */
  24653. onAnimationEnd: Nullable<() => void>;
  24654. /**
  24655. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24656. */
  24657. blendMode: number;
  24658. /**
  24659. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24660. * to override the particles.
  24661. */
  24662. forceDepthWrite: boolean;
  24663. /** 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 */
  24664. preWarmCycles: number;
  24665. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24666. preWarmStepOffset: number;
  24667. /**
  24668. * 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)
  24669. */
  24670. spriteCellChangeSpeed: number;
  24671. /**
  24672. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24673. */
  24674. startSpriteCellID: number;
  24675. /**
  24676. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24677. */
  24678. endSpriteCellID: number;
  24679. /**
  24680. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24681. */
  24682. spriteCellWidth: number;
  24683. /**
  24684. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24685. */
  24686. spriteCellHeight: number;
  24687. /**
  24688. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  24689. */
  24690. spriteRandomStartCell: boolean;
  24691. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24692. translationPivot: Vector2;
  24693. /** @hidden */
  24694. protected _isAnimationSheetEnabled: boolean;
  24695. /**
  24696. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24697. */
  24698. isAnimationSheetEnabled: boolean;
  24699. /**
  24700. * Get hosting scene
  24701. * @returns the scene
  24702. */
  24703. getScene(): Scene;
  24704. /**
  24705. * You can use gravity if you want to give an orientation to your particles.
  24706. */
  24707. gravity: Vector3;
  24708. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24709. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24710. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24711. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24712. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24713. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24714. protected _dragGradients: Nullable<Array<FactorGradient>>;
  24715. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  24716. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  24717. protected _rampGradients: Nullable<Array<ColorGradient>>;
  24718. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  24719. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  24720. /**
  24721. * Gets the current list of drag gradients.
  24722. * You must use addDragGradient and removeDragGradient to udpate this list
  24723. * @returns the list of drag gradients
  24724. */
  24725. getDragGradients(): Nullable<Array<FactorGradient>>;
  24726. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24727. limitVelocityDamping: number;
  24728. /**
  24729. * Gets the current list of limit velocity gradients.
  24730. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24731. * @returns the list of limit velocity gradients
  24732. */
  24733. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24734. /**
  24735. * Gets the current list of color gradients.
  24736. * You must use addColorGradient and removeColorGradient to udpate this list
  24737. * @returns the list of color gradients
  24738. */
  24739. getColorGradients(): Nullable<Array<ColorGradient>>;
  24740. /**
  24741. * Gets the current list of size gradients.
  24742. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24743. * @returns the list of size gradients
  24744. */
  24745. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24746. /**
  24747. * Gets the current list of color remap gradients.
  24748. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  24749. * @returns the list of color remap gradients
  24750. */
  24751. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  24752. /**
  24753. * Gets the current list of alpha remap gradients.
  24754. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  24755. * @returns the list of alpha remap gradients
  24756. */
  24757. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  24758. /**
  24759. * Gets the current list of life time gradients.
  24760. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24761. * @returns the list of life time gradients
  24762. */
  24763. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24764. /**
  24765. * Gets the current list of angular speed gradients.
  24766. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24767. * @returns the list of angular speed gradients
  24768. */
  24769. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24770. /**
  24771. * Gets the current list of velocity gradients.
  24772. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24773. * @returns the list of velocity gradients
  24774. */
  24775. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24776. /**
  24777. * Gets the current list of start size gradients.
  24778. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  24779. * @returns the list of start size gradients
  24780. */
  24781. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  24782. /**
  24783. * Gets the current list of emit rate gradients.
  24784. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  24785. * @returns the list of emit rate gradients
  24786. */
  24787. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  24788. /**
  24789. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24790. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24791. */
  24792. direction1: Vector3;
  24793. /**
  24794. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24795. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24796. */
  24797. direction2: Vector3;
  24798. /**
  24799. * 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.
  24800. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24801. */
  24802. minEmitBox: Vector3;
  24803. /**
  24804. * 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.
  24805. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24806. */
  24807. maxEmitBox: Vector3;
  24808. /**
  24809. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24810. */
  24811. color1: Color4;
  24812. /**
  24813. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24814. */
  24815. color2: Color4;
  24816. /**
  24817. * Color the particle will have at the end of its lifetime
  24818. */
  24819. colorDead: Color4;
  24820. /**
  24821. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24822. */
  24823. textureMask: Color4;
  24824. /**
  24825. * The particle emitter type defines the emitter used by the particle system.
  24826. * It can be for example box, sphere, or cone...
  24827. */
  24828. particleEmitterType: IParticleEmitterType;
  24829. /**
  24830. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24831. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24832. */
  24833. billboardMode: number;
  24834. protected _isBillboardBased: boolean;
  24835. /**
  24836. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24837. */
  24838. isBillboardBased: boolean;
  24839. /**
  24840. * The scene the particle system belongs to.
  24841. */
  24842. protected _scene: Scene;
  24843. /**
  24844. * Local cache of defines for image processing.
  24845. */
  24846. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  24847. /**
  24848. * Default configuration related to image processing available in the standard Material.
  24849. */
  24850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24851. /**
  24852. * Gets the image processing configuration used either in this material.
  24853. */
  24854. /**
  24855. * Sets the Default image processing configuration used either in the this material.
  24856. *
  24857. * If sets to null, the scene one is in use.
  24858. */
  24859. imageProcessingConfiguration: ImageProcessingConfiguration;
  24860. /**
  24861. * Attaches a new image processing configuration to the Standard Material.
  24862. * @param configuration
  24863. */
  24864. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24865. /** @hidden */
  24866. protected _reset(): void;
  24867. /** @hidden */
  24868. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  24869. /**
  24870. * Instantiates a particle system.
  24871. * 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.
  24872. * @param name The name of the particle system
  24873. */
  24874. constructor(name: string);
  24875. /**
  24876. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  24877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24879. * @returns the emitter
  24880. */
  24881. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  24882. /**
  24883. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  24884. * @param radius The radius of the hemisphere to emit from
  24885. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24886. * @returns the emitter
  24887. */
  24888. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  24889. /**
  24890. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  24891. * @param radius The radius of the sphere to emit from
  24892. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24893. * @returns the emitter
  24894. */
  24895. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  24896. /**
  24897. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  24898. * @param radius The radius of the sphere to emit from
  24899. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24900. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24901. * @returns the emitter
  24902. */
  24903. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24904. /**
  24905. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  24906. * @param radius The radius of the emission cylinder
  24907. * @param height The height of the emission cylinder
  24908. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  24909. * @param directionRandomizer How much to randomize the particle direction [0-1]
  24910. * @returns the emitter
  24911. */
  24912. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  24913. /**
  24914. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  24915. * @param radius The radius of the cylinder to emit from
  24916. * @param height The height of the emission cylinder
  24917. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  24918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  24919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  24920. * @returns the emitter
  24921. */
  24922. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  24923. /**
  24924. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  24925. * @param radius The radius of the cone to emit from
  24926. * @param angle The base angle of the cone
  24927. * @returns the emitter
  24928. */
  24929. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24930. /**
  24931. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24934. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24935. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24936. * @returns the emitter
  24937. */
  24938. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24939. }
  24940. }
  24941. declare module BABYLON {
  24942. /**
  24943. * This represents a GPU particle system in Babylon
  24944. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24945. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24946. */
  24947. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24948. /**
  24949. * The layer mask we are rendering the particles through.
  24950. */
  24951. layerMask: number;
  24952. private _capacity;
  24953. private _activeCount;
  24954. private _currentActiveCount;
  24955. private _accumulatedCount;
  24956. private _renderEffect;
  24957. private _updateEffect;
  24958. private _buffer0;
  24959. private _buffer1;
  24960. private _spriteBuffer;
  24961. private _updateVAO;
  24962. private _renderVAO;
  24963. private _targetIndex;
  24964. private _sourceBuffer;
  24965. private _targetBuffer;
  24966. private _engine;
  24967. private _currentRenderId;
  24968. private _started;
  24969. private _stopped;
  24970. private _timeDelta;
  24971. private _randomTexture;
  24972. private _randomTexture2;
  24973. private _attributesStrideSize;
  24974. private _updateEffectOptions;
  24975. private _randomTextureSize;
  24976. private _actualFrame;
  24977. private readonly _rawTextureWidth;
  24978. /**
  24979. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24980. */
  24981. static readonly IsSupported: boolean;
  24982. /**
  24983. * An event triggered when the system is disposed.
  24984. */
  24985. onDisposeObservable: Observable<GPUParticleSystem>;
  24986. /**
  24987. * Gets the maximum number of particles active at the same time.
  24988. * @returns The max number of active particles.
  24989. */
  24990. getCapacity(): number;
  24991. /**
  24992. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24993. * to override the particles.
  24994. */
  24995. forceDepthWrite: boolean;
  24996. /**
  24997. * Gets or set the number of active particles
  24998. */
  24999. activeParticleCount: number;
  25000. private _preWarmDone;
  25001. /**
  25002. * Is this system ready to be used/rendered
  25003. * @return true if the system is ready
  25004. */
  25005. isReady(): boolean;
  25006. /**
  25007. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25008. * @returns True if it has been started, otherwise false.
  25009. */
  25010. isStarted(): boolean;
  25011. /**
  25012. * Starts the particle system and begins to emit
  25013. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25014. */
  25015. start(delay?: number): void;
  25016. /**
  25017. * Stops the particle system.
  25018. */
  25019. stop(): void;
  25020. /**
  25021. * Remove all active particles
  25022. */
  25023. reset(): void;
  25024. /**
  25025. * Returns the string "GPUParticleSystem"
  25026. * @returns a string containing the class name
  25027. */
  25028. getClassName(): string;
  25029. private _colorGradientsTexture;
  25030. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  25031. /**
  25032. * Adds a new color gradient
  25033. * @param gradient defines the gradient to use (between 0 and 1)
  25034. * @param color defines the color to affect to the specified gradient
  25035. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25036. * @returns the current particle system
  25037. */
  25038. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  25039. /**
  25040. * Remove a specific color gradient
  25041. * @param gradient defines the gradient to remove
  25042. * @returns the current particle system
  25043. */
  25044. removeColorGradient(gradient: number): GPUParticleSystem;
  25045. private _angularSpeedGradientsTexture;
  25046. private _sizeGradientsTexture;
  25047. private _velocityGradientsTexture;
  25048. private _limitVelocityGradientsTexture;
  25049. private _dragGradientsTexture;
  25050. private _addFactorGradient;
  25051. /**
  25052. * Adds a new size gradient
  25053. * @param gradient defines the gradient to use (between 0 and 1)
  25054. * @param factor defines the size factor to affect to the specified gradient
  25055. * @returns the current particle system
  25056. */
  25057. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  25058. /**
  25059. * Remove a specific size gradient
  25060. * @param gradient defines the gradient to remove
  25061. * @returns the current particle system
  25062. */
  25063. removeSizeGradient(gradient: number): GPUParticleSystem;
  25064. /**
  25065. * Adds a new angular speed gradient
  25066. * @param gradient defines the gradient to use (between 0 and 1)
  25067. * @param factor defines the angular speed to affect to the specified gradient
  25068. * @returns the current particle system
  25069. */
  25070. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25071. /**
  25072. * Remove a specific angular speed gradient
  25073. * @param gradient defines the gradient to remove
  25074. * @returns the current particle system
  25075. */
  25076. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25077. /**
  25078. * Adds a new velocity gradient
  25079. * @param gradient defines the gradient to use (between 0 and 1)
  25080. * @param factor defines the velocity to affect to the specified gradient
  25081. * @returns the current particle system
  25082. */
  25083. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25084. /**
  25085. * Remove a specific velocity gradient
  25086. * @param gradient defines the gradient to remove
  25087. * @returns the current particle system
  25088. */
  25089. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25090. /**
  25091. * Adds a new limit velocity gradient
  25092. * @param gradient defines the gradient to use (between 0 and 1)
  25093. * @param factor defines the limit velocity value to affect to the specified gradient
  25094. * @returns the current particle system
  25095. */
  25096. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25097. /**
  25098. * Remove a specific limit velocity gradient
  25099. * @param gradient defines the gradient to remove
  25100. * @returns the current particle system
  25101. */
  25102. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25103. /**
  25104. * Adds a new drag gradient
  25105. * @param gradient defines the gradient to use (between 0 and 1)
  25106. * @param factor defines the drag value to affect to the specified gradient
  25107. * @returns the current particle system
  25108. */
  25109. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  25110. /**
  25111. * Remove a specific drag gradient
  25112. * @param gradient defines the gradient to remove
  25113. * @returns the current particle system
  25114. */
  25115. removeDragGradient(gradient: number): GPUParticleSystem;
  25116. /**
  25117. * Not supported by GPUParticleSystem
  25118. * @param gradient defines the gradient to use (between 0 and 1)
  25119. * @param factor defines the emit rate value to affect to the specified gradient
  25120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25121. * @returns the current particle system
  25122. */
  25123. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25124. /**
  25125. * Not supported by GPUParticleSystem
  25126. * @param gradient defines the gradient to remove
  25127. * @returns the current particle system
  25128. */
  25129. removeEmitRateGradient(gradient: number): IParticleSystem;
  25130. /**
  25131. * Not supported by GPUParticleSystem
  25132. * @param gradient defines the gradient to use (between 0 and 1)
  25133. * @param factor defines the start size value to affect to the specified gradient
  25134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25135. * @returns the current particle system
  25136. */
  25137. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25138. /**
  25139. * Not supported by GPUParticleSystem
  25140. * @param gradient defines the gradient to remove
  25141. * @returns the current particle system
  25142. */
  25143. removeStartSizeGradient(gradient: number): IParticleSystem;
  25144. /**
  25145. * Not supported by GPUParticleSystem
  25146. * @param gradient defines the gradient to use (between 0 and 1)
  25147. * @param min defines the color remap minimal range
  25148. * @param max defines the color remap maximal range
  25149. * @returns the current particle system
  25150. */
  25151. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25152. /**
  25153. * Not supported by GPUParticleSystem
  25154. * @param gradient defines the gradient to remove
  25155. * @returns the current particle system
  25156. */
  25157. removeColorRemapGradient(gradient: number): IParticleSystem;
  25158. /**
  25159. * Not supported by GPUParticleSystem
  25160. * @param gradient defines the gradient to use (between 0 and 1)
  25161. * @param min defines the alpha remap minimal range
  25162. * @param max defines the alpha remap maximal range
  25163. * @returns the current particle system
  25164. */
  25165. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25166. /**
  25167. * Not supported by GPUParticleSystem
  25168. * @param gradient defines the gradient to remove
  25169. * @returns the current particle system
  25170. */
  25171. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  25172. /**
  25173. * Not supported by GPUParticleSystem
  25174. * @param gradient defines the gradient to use (between 0 and 1)
  25175. * @param color defines the color to affect to the specified gradient
  25176. * @returns the current particle system
  25177. */
  25178. addRampGradient(gradient: number, color: Color4): IParticleSystem;
  25179. /**
  25180. * Not supported by GPUParticleSystem
  25181. * @param gradient defines the gradient to remove
  25182. * @returns the current particle system
  25183. */
  25184. removeRampGradient(gradient: number): IParticleSystem;
  25185. /**
  25186. * Not supported by GPUParticleSystem
  25187. * @returns the list of ramp gradients
  25188. */
  25189. getRampGradients(): Nullable<Array<ColorGradient>>;
  25190. /**
  25191. * Instantiates a GPU particle system.
  25192. * 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.
  25193. * @param name The name of the particle system
  25194. * @param options The options used to create the system
  25195. * @param scene The scene the particle system belongs to
  25196. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25197. */
  25198. constructor(name: string, options: Partial<{
  25199. capacity: number;
  25200. randomTextureSize: number;
  25201. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25202. protected _reset(): void;
  25203. private _createUpdateVAO;
  25204. private _createRenderVAO;
  25205. private _initialize;
  25206. /** @hidden */
  25207. _recreateUpdateEffect(): void;
  25208. /** @hidden */
  25209. _recreateRenderEffect(): void;
  25210. /**
  25211. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25212. * @param preWarm defines if we are in the pre-warmimg phase
  25213. */
  25214. animate(preWarm?: boolean): void;
  25215. private _createFactorGradientTexture;
  25216. private _createSizeGradientTexture;
  25217. private _createAngularSpeedGradientTexture;
  25218. private _createVelocityGradientTexture;
  25219. private _createLimitVelocityGradientTexture;
  25220. private _createDragGradientTexture;
  25221. private _createColorGradientTexture;
  25222. /**
  25223. * Renders the particle system in its current state
  25224. * @param preWarm defines if the system should only update the particles but not render them
  25225. * @returns the current number of particles
  25226. */
  25227. render(preWarm?: boolean): number;
  25228. /**
  25229. * Rebuilds the particle system
  25230. */
  25231. rebuild(): void;
  25232. private _releaseBuffers;
  25233. private _releaseVAOs;
  25234. /**
  25235. * Disposes the particle system and free the associated resources
  25236. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25237. */
  25238. dispose(disposeTexture?: boolean): void;
  25239. /**
  25240. * Clones the particle system.
  25241. * @param name The name of the cloned object
  25242. * @param newEmitter The new emitter to use
  25243. * @returns the cloned particle system
  25244. */
  25245. clone(name: string, newEmitter: any): GPUParticleSystem;
  25246. /**
  25247. * Serializes the particle system to a JSON object.
  25248. * @returns the JSON object
  25249. */
  25250. serialize(): any;
  25251. /**
  25252. * Parses a JSON object to create a GPU particle system.
  25253. * @param parsedParticleSystem The JSON object to parse
  25254. * @param scene The scene to create the particle system in
  25255. * @param rootUrl The root url to use to load external dependencies like texture
  25256. * @returns the parsed GPU particle system
  25257. */
  25258. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25259. }
  25260. }
  25261. declare module BABYLON {
  25262. /**
  25263. * Interface representing a particle system in Babylon.js.
  25264. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25265. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25266. */
  25267. interface IParticleSystem {
  25268. /**
  25269. * List of animations used by the particle system.
  25270. */
  25271. animations: Animation[];
  25272. /**
  25273. * The id of the Particle system.
  25274. */
  25275. id: string;
  25276. /**
  25277. * The name of the Particle system.
  25278. */
  25279. name: string;
  25280. /**
  25281. * The emitter represents the Mesh or position we are attaching the particle system to.
  25282. */
  25283. emitter: Nullable<AbstractMesh | Vector3>;
  25284. /**
  25285. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25286. */
  25287. isBillboardBased: boolean;
  25288. /**
  25289. * The rendering group used by the Particle system to chose when to render.
  25290. */
  25291. renderingGroupId: number;
  25292. /**
  25293. * The layer mask we are rendering the particles through.
  25294. */
  25295. layerMask: number;
  25296. /**
  25297. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25298. */
  25299. updateSpeed: number;
  25300. /**
  25301. * The amount of time the particle system is running (depends of the overall update speed).
  25302. */
  25303. targetStopDuration: number;
  25304. /**
  25305. * The texture used to render each particle. (this can be a spritesheet)
  25306. */
  25307. particleTexture: Nullable<Texture>;
  25308. /**
  25309. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25310. */
  25311. blendMode: number;
  25312. /**
  25313. * Minimum life time of emitting particles.
  25314. */
  25315. minLifeTime: number;
  25316. /**
  25317. * Maximum life time of emitting particles.
  25318. */
  25319. maxLifeTime: number;
  25320. /**
  25321. * Minimum Size of emitting particles.
  25322. */
  25323. minSize: number;
  25324. /**
  25325. * Maximum Size of emitting particles.
  25326. */
  25327. maxSize: number;
  25328. /**
  25329. * Minimum scale of emitting particles on X axis.
  25330. */
  25331. minScaleX: number;
  25332. /**
  25333. * Maximum scale of emitting particles on X axis.
  25334. */
  25335. maxScaleX: number;
  25336. /**
  25337. * Minimum scale of emitting particles on Y axis.
  25338. */
  25339. minScaleY: number;
  25340. /**
  25341. * Maximum scale of emitting particles on Y axis.
  25342. */
  25343. maxScaleY: number;
  25344. /**
  25345. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25346. */
  25347. color1: Color4;
  25348. /**
  25349. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25350. */
  25351. color2: Color4;
  25352. /**
  25353. * Color the particle will have at the end of its lifetime.
  25354. */
  25355. colorDead: Color4;
  25356. /**
  25357. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25358. */
  25359. emitRate: number;
  25360. /**
  25361. * You can use gravity if you want to give an orientation to your particles.
  25362. */
  25363. gravity: Vector3;
  25364. /**
  25365. * Minimum power of emitting particles.
  25366. */
  25367. minEmitPower: number;
  25368. /**
  25369. * Maximum power of emitting particles.
  25370. */
  25371. maxEmitPower: number;
  25372. /**
  25373. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25374. */
  25375. minAngularSpeed: number;
  25376. /**
  25377. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25378. */
  25379. maxAngularSpeed: number;
  25380. /**
  25381. * Gets or sets the minimal initial rotation in radians.
  25382. */
  25383. minInitialRotation: number;
  25384. /**
  25385. * Gets or sets the maximal initial rotation in radians.
  25386. */
  25387. maxInitialRotation: number;
  25388. /**
  25389. * The particle emitter type defines the emitter used by the particle system.
  25390. * It can be for example box, sphere, or cone...
  25391. */
  25392. particleEmitterType: Nullable<IParticleEmitterType>;
  25393. /**
  25394. * 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
  25395. */
  25396. preWarmCycles: number;
  25397. /**
  25398. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25399. */
  25400. preWarmStepOffset: number;
  25401. /**
  25402. * 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)
  25403. */
  25404. spriteCellChangeSpeed: number;
  25405. /**
  25406. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25407. */
  25408. startSpriteCellID: number;
  25409. /**
  25410. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25411. */
  25412. endSpriteCellID: number;
  25413. /**
  25414. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25415. */
  25416. spriteCellWidth: number;
  25417. /**
  25418. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25419. */
  25420. spriteCellHeight: number;
  25421. /**
  25422. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  25423. */
  25424. spriteRandomStartCell: boolean;
  25425. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25426. translationPivot: Vector2;
  25427. /**
  25428. * Gets or sets a texture used to add random noise to particle positions
  25429. */
  25430. noiseTexture: Nullable<BaseTexture>;
  25431. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25432. noiseStrength: Vector3;
  25433. /**
  25434. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25435. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25436. */
  25437. billboardMode: number;
  25438. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25439. limitVelocityDamping: number;
  25440. /**
  25441. * Gets the maximum number of particles active at the same time.
  25442. * @returns The max number of active particles.
  25443. */
  25444. getCapacity(): number;
  25445. /**
  25446. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25447. * @returns True if it has been started, otherwise false.
  25448. */
  25449. isStarted(): boolean;
  25450. /**
  25451. * Animates the particle system for this frame.
  25452. */
  25453. animate(): void;
  25454. /**
  25455. * Renders the particle system in its current state.
  25456. * @returns the current number of particles
  25457. */
  25458. render(): number;
  25459. /**
  25460. * Dispose the particle system and frees its associated resources.
  25461. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25462. */
  25463. dispose(disposeTexture?: boolean): void;
  25464. /**
  25465. * Clones the particle system.
  25466. * @param name The name of the cloned object
  25467. * @param newEmitter The new emitter to use
  25468. * @returns the cloned particle system
  25469. */
  25470. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25471. /**
  25472. * Serializes the particle system to a JSON object.
  25473. * @returns the JSON object
  25474. */
  25475. serialize(): any;
  25476. /**
  25477. * Rebuild the particle system
  25478. */
  25479. rebuild(): void;
  25480. /**
  25481. * Starts the particle system and begins to emit
  25482. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25483. */
  25484. start(delay?: number): void;
  25485. /**
  25486. * Stops the particle system.
  25487. */
  25488. stop(): void;
  25489. /**
  25490. * Remove all active particles
  25491. */
  25492. reset(): void;
  25493. /**
  25494. * Is this system ready to be used/rendered
  25495. * @return true if the system is ready
  25496. */
  25497. isReady(): boolean;
  25498. /**
  25499. * Adds a new color gradient
  25500. * @param gradient defines the gradient to use (between 0 and 1)
  25501. * @param color defines the color to affect to the specified gradient
  25502. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25503. * @returns the current particle system
  25504. */
  25505. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25506. /**
  25507. * Remove a specific color gradient
  25508. * @param gradient defines the gradient to remove
  25509. * @returns the current particle system
  25510. */
  25511. removeColorGradient(gradient: number): IParticleSystem;
  25512. /**
  25513. * Adds a new size gradient
  25514. * @param gradient defines the gradient to use (between 0 and 1)
  25515. * @param factor defines the size factor to affect to the specified gradient
  25516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25517. * @returns the current particle system
  25518. */
  25519. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25520. /**
  25521. * Remove a specific size gradient
  25522. * @param gradient defines the gradient to remove
  25523. * @returns the current particle system
  25524. */
  25525. removeSizeGradient(gradient: number): IParticleSystem;
  25526. /**
  25527. * Gets the current list of color gradients.
  25528. * You must use addColorGradient and removeColorGradient to udpate this list
  25529. * @returns the list of color gradients
  25530. */
  25531. getColorGradients(): Nullable<Array<ColorGradient>>;
  25532. /**
  25533. * Gets the current list of size gradients.
  25534. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25535. * @returns the list of size gradients
  25536. */
  25537. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25538. /**
  25539. * Gets the current list of angular speed gradients.
  25540. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25541. * @returns the list of angular speed gradients
  25542. */
  25543. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25544. /**
  25545. * Adds a new angular speed gradient
  25546. * @param gradient defines the gradient to use (between 0 and 1)
  25547. * @param factor defines the angular speed to affect to the specified gradient
  25548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25549. * @returns the current particle system
  25550. */
  25551. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25552. /**
  25553. * Remove a specific angular speed gradient
  25554. * @param gradient defines the gradient to remove
  25555. * @returns the current particle system
  25556. */
  25557. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25558. /**
  25559. * Gets the current list of velocity gradients.
  25560. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25561. * @returns the list of velocity gradients
  25562. */
  25563. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25564. /**
  25565. * Adds a new velocity gradient
  25566. * @param gradient defines the gradient to use (between 0 and 1)
  25567. * @param factor defines the velocity to affect to the specified gradient
  25568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25569. * @returns the current particle system
  25570. */
  25571. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25572. /**
  25573. * Remove a specific velocity gradient
  25574. * @param gradient defines the gradient to remove
  25575. * @returns the current particle system
  25576. */
  25577. removeVelocityGradient(gradient: number): IParticleSystem;
  25578. /**
  25579. * Gets the current list of limit velocity gradients.
  25580. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25581. * @returns the list of limit velocity gradients
  25582. */
  25583. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25584. /**
  25585. * Adds a new limit velocity gradient
  25586. * @param gradient defines the gradient to use (between 0 and 1)
  25587. * @param factor defines the limit velocity to affect to the specified gradient
  25588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25589. * @returns the current particle system
  25590. */
  25591. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25592. /**
  25593. * Remove a specific limit velocity gradient
  25594. * @param gradient defines the gradient to remove
  25595. * @returns the current particle system
  25596. */
  25597. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25598. /**
  25599. * Adds a new drag gradient
  25600. * @param gradient defines the gradient to use (between 0 and 1)
  25601. * @param factor defines the drag to affect to the specified gradient
  25602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25603. * @returns the current particle system
  25604. */
  25605. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25606. /**
  25607. * Remove a specific drag gradient
  25608. * @param gradient defines the gradient to remove
  25609. * @returns the current particle system
  25610. */
  25611. removeDragGradient(gradient: number): IParticleSystem;
  25612. /**
  25613. * Gets the current list of drag gradients.
  25614. * You must use addDragGradient and removeDragGradient to udpate this list
  25615. * @returns the list of drag gradients
  25616. */
  25617. getDragGradients(): Nullable<Array<FactorGradient>>;
  25618. /**
  25619. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  25620. * @param gradient defines the gradient to use (between 0 and 1)
  25621. * @param factor defines the emit rate to affect to the specified gradient
  25622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25623. * @returns the current particle system
  25624. */
  25625. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25626. /**
  25627. * Remove a specific emit rate gradient
  25628. * @param gradient defines the gradient to remove
  25629. * @returns the current particle system
  25630. */
  25631. removeEmitRateGradient(gradient: number): IParticleSystem;
  25632. /**
  25633. * Gets the current list of emit rate gradients.
  25634. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  25635. * @returns the list of emit rate gradients
  25636. */
  25637. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  25638. /**
  25639. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  25640. * @param gradient defines the gradient to use (between 0 and 1)
  25641. * @param factor defines the start size to affect to the specified gradient
  25642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25643. * @returns the current particle system
  25644. */
  25645. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25646. /**
  25647. * Remove a specific start size gradient
  25648. * @param gradient defines the gradient to remove
  25649. * @returns the current particle system
  25650. */
  25651. removeStartSizeGradient(gradient: number): IParticleSystem;
  25652. /**
  25653. * Gets the current list of start size gradients.
  25654. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  25655. * @returns the list of start size gradients
  25656. */
  25657. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  25658. /**
  25659. * Gets the current list of color gradients.
  25660. * You must use addColorGradient and removeColorGradient to udpate this list
  25661. * @returns the list of color gradients
  25662. */
  25663. getColorGradients(): Nullable<Array<ColorGradient>>;
  25664. /**
  25665. * Adds a new ramp gradient used to remap particle colors
  25666. * @param gradient defines the gradient to use (between 0 and 1)
  25667. * @param color defines the color to affect to the specified gradient
  25668. * @returns the current particle system
  25669. */
  25670. addRampGradient(gradient: number, color: Color4): IParticleSystem;
  25671. /**
  25672. * Gets the current list of ramp gradients.
  25673. * You must use addRampGradient and removeRampGradient to udpate this list
  25674. * @returns the list of ramp gradients
  25675. */
  25676. getRampGradients(): Nullable<Array<ColorGradient>>;
  25677. /**
  25678. * Adds a new color remap gradient
  25679. * @param gradient defines the gradient to use (between 0 and 1)
  25680. * @param min defines the color remap minimal range
  25681. * @param max defines the color remap maximal range
  25682. * @returns the current particle system
  25683. */
  25684. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25685. /**
  25686. * Gets the current list of color remap gradients.
  25687. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  25688. * @returns the list of color remap gradients
  25689. */
  25690. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  25691. /**
  25692. * Adds a new alpha remap gradient
  25693. * @param gradient defines the gradient to use (between 0 and 1)
  25694. * @param min defines the alpha remap minimal range
  25695. * @param max defines the alpha remap maximal range
  25696. * @returns the current particle system
  25697. */
  25698. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25699. /**
  25700. * Gets the current list of alpha remap gradients.
  25701. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  25702. * @returns the list of alpha remap gradients
  25703. */
  25704. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  25705. /**
  25706. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25709. * @returns the emitter
  25710. */
  25711. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25712. /**
  25713. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25714. * @param radius The radius of the hemisphere to emit from
  25715. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25716. * @returns the emitter
  25717. */
  25718. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  25719. /**
  25720. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25721. * @param radius The radius of the sphere to emit from
  25722. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25723. * @returns the emitter
  25724. */
  25725. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  25726. /**
  25727. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25728. * @param radius The radius of the sphere to emit from
  25729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25731. * @returns the emitter
  25732. */
  25733. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25734. /**
  25735. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  25736. * @param radius The radius of the emission cylinder
  25737. * @param height The height of the emission cylinder
  25738. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  25739. * @param directionRandomizer How much to randomize the particle direction [0-1]
  25740. * @returns the emitter
  25741. */
  25742. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  25743. /**
  25744. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  25745. * @param radius The radius of the cylinder to emit from
  25746. * @param height The height of the emission cylinder
  25747. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  25748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  25749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  25750. * @returns the emitter
  25751. */
  25752. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25753. /**
  25754. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25755. * @param radius The radius of the cone to emit from
  25756. * @param angle The base angle of the cone
  25757. * @returns the emitter
  25758. */
  25759. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  25760. /**
  25761. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25764. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25765. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25766. * @returns the emitter
  25767. */
  25768. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25769. /**
  25770. * Get hosting scene
  25771. * @returns the scene
  25772. */
  25773. getScene(): Scene;
  25774. }
  25775. }
  25776. declare module BABYLON {
  25777. /**
  25778. * A particle represents one of the element emitted by a particle system.
  25779. * This is mainly define by its coordinates, direction, velocity and age.
  25780. */
  25781. class Particle {
  25782. /**
  25783. * The particle system the particle belongs to.
  25784. */
  25785. particleSystem: ParticleSystem;
  25786. private static _Count;
  25787. /**
  25788. * Unique ID of the particle
  25789. */
  25790. id: number;
  25791. /**
  25792. * The world position of the particle in the scene.
  25793. */
  25794. position: Vector3;
  25795. /**
  25796. * The world direction of the particle in the scene.
  25797. */
  25798. direction: Vector3;
  25799. /**
  25800. * The color of the particle.
  25801. */
  25802. color: Color4;
  25803. /**
  25804. * The color change of the particle per step.
  25805. */
  25806. colorStep: Color4;
  25807. /**
  25808. * Defines how long will the life of the particle be.
  25809. */
  25810. lifeTime: number;
  25811. /**
  25812. * The current age of the particle.
  25813. */
  25814. age: number;
  25815. /**
  25816. * The current size of the particle.
  25817. */
  25818. size: number;
  25819. /**
  25820. * The current scale of the particle.
  25821. */
  25822. scale: Vector2;
  25823. /**
  25824. * The current angle of the particle.
  25825. */
  25826. angle: number;
  25827. /**
  25828. * Defines how fast is the angle changing.
  25829. */
  25830. angularSpeed: number;
  25831. /**
  25832. * Defines the cell index used by the particle to be rendered from a sprite.
  25833. */
  25834. cellIndex: number;
  25835. /**
  25836. * The information required to support color remapping
  25837. */
  25838. remapData: Vector4;
  25839. /** @hidden */
  25840. _randomCellOffset?: number;
  25841. /** @hidden */
  25842. _initialDirection: Nullable<Vector3>;
  25843. /** @hidden */
  25844. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  25845. /** @hidden */
  25846. _initialStartSpriteCellID: number;
  25847. _initialEndSpriteCellID: number;
  25848. /** @hidden */
  25849. _currentColorGradient: Nullable<ColorGradient>;
  25850. /** @hidden */
  25851. _currentColor1: Color4;
  25852. /** @hidden */
  25853. _currentColor2: Color4;
  25854. /** @hidden */
  25855. _currentSizeGradient: Nullable<FactorGradient>;
  25856. /** @hidden */
  25857. _currentSize1: number;
  25858. /** @hidden */
  25859. _currentSize2: number;
  25860. /** @hidden */
  25861. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25862. /** @hidden */
  25863. _currentAngularSpeed1: number;
  25864. /** @hidden */
  25865. _currentAngularSpeed2: number;
  25866. /** @hidden */
  25867. _currentVelocityGradient: Nullable<FactorGradient>;
  25868. /** @hidden */
  25869. _currentVelocity1: number;
  25870. /** @hidden */
  25871. _currentVelocity2: number;
  25872. /** @hidden */
  25873. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  25874. /** @hidden */
  25875. _currentLimitVelocity1: number;
  25876. /** @hidden */
  25877. _currentLimitVelocity2: number;
  25878. /** @hidden */
  25879. _currentDragGradient: Nullable<FactorGradient>;
  25880. /** @hidden */
  25881. _currentDrag1: number;
  25882. /** @hidden */
  25883. _currentDrag2: number;
  25884. /**
  25885. * Creates a new instance Particle
  25886. * @param particleSystem the particle system the particle belongs to
  25887. */
  25888. constructor(
  25889. /**
  25890. * The particle system the particle belongs to.
  25891. */
  25892. particleSystem: ParticleSystem);
  25893. private updateCellInfoFromSystem;
  25894. /**
  25895. * Defines how the sprite cell index is updated for the particle
  25896. */
  25897. updateCellIndex(): void;
  25898. /** @hidden */
  25899. _reset(): void;
  25900. /**
  25901. * Copy the properties of particle to another one.
  25902. * @param other the particle to copy the information to.
  25903. */
  25904. copyTo(other: Particle): void;
  25905. }
  25906. }
  25907. declare module BABYLON {
  25908. /**
  25909. * This class is made for on one-liner static method to help creating particle system set.
  25910. */
  25911. class ParticleHelper {
  25912. /**
  25913. * Gets or sets base Assets URL
  25914. */
  25915. static BaseAssetsUrl: string;
  25916. /**
  25917. * Create a default particle system that you can tweak
  25918. * @param emitter defines the emitter to use
  25919. * @param capacity defines the system capacity (default is 500 particles)
  25920. * @param scene defines the hosting scene
  25921. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  25922. * @returns the new Particle system
  25923. */
  25924. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  25925. /**
  25926. * This is the main static method (one-liner) of this helper to create different particle systems
  25927. * @param type This string represents the type to the particle system to create
  25928. * @param scene The scene where the particle system should live
  25929. * @param gpu If the system will use gpu
  25930. * @returns the ParticleSystemSet created
  25931. */
  25932. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25933. /**
  25934. * Static function used to export a particle system to a ParticleSystemSet variable.
  25935. * Please note that the emitter shape is not exported
  25936. * @param system defines the particle systems to export
  25937. */
  25938. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25939. }
  25940. }
  25941. declare module BABYLON {
  25942. /**
  25943. * This represents a particle system in Babylon.
  25944. * 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.
  25945. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25946. * @example https://doc.babylonjs.com/babylon101/particles
  25947. */
  25948. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25949. /**
  25950. * This function can be defined to provide custom update for active particles.
  25951. * This function will be called instead of regular update (age, position, color, etc.).
  25952. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25953. */
  25954. updateFunction: (particles: Particle[]) => void;
  25955. private _emitterWorldMatrix;
  25956. /**
  25957. * This function can be defined to specify initial direction for every new particle.
  25958. * It by default use the emitterType defined function
  25959. */
  25960. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25961. /**
  25962. * This function can be defined to specify initial position for every new particle.
  25963. * It by default use the emitterType defined function
  25964. */
  25965. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25966. /**
  25967. * @hidden
  25968. */
  25969. _inheritedVelocityOffset: Vector3;
  25970. /**
  25971. * An event triggered when the system is disposed
  25972. */
  25973. onDisposeObservable: Observable<ParticleSystem>;
  25974. private _onDisposeObserver;
  25975. /**
  25976. * Sets a callback that will be triggered when the system is disposed
  25977. */
  25978. onDispose: () => void;
  25979. private _particles;
  25980. private _epsilon;
  25981. private _capacity;
  25982. private _stockParticles;
  25983. private _newPartsExcess;
  25984. private _vertexData;
  25985. private _vertexBuffer;
  25986. private _vertexBuffers;
  25987. private _spriteBuffer;
  25988. private _indexBuffer;
  25989. private _effect;
  25990. private _customEffect;
  25991. private _cachedDefines;
  25992. private _scaledColorStep;
  25993. private _colorDiff;
  25994. private _scaledDirection;
  25995. private _scaledGravity;
  25996. private _currentRenderId;
  25997. private _alive;
  25998. private _useInstancing;
  25999. private _started;
  26000. private _stopped;
  26001. private _actualFrame;
  26002. private _scaledUpdateSpeed;
  26003. private _vertexBufferSize;
  26004. /** @hidden */
  26005. _currentEmitRateGradient: Nullable<FactorGradient>;
  26006. /** @hidden */
  26007. _currentEmitRate1: number;
  26008. /** @hidden */
  26009. _currentEmitRate2: number;
  26010. /** @hidden */
  26011. _currentStartSizeGradient: Nullable<FactorGradient>;
  26012. /** @hidden */
  26013. _currentStartSize1: number;
  26014. /** @hidden */
  26015. _currentStartSize2: number;
  26016. private readonly _rawTextureWidth;
  26017. private _rampGradientsTexture;
  26018. private _useRampGradients;
  26019. /** Gets or sets a boolean indicating that ramp gradients must be used
  26020. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  26021. */
  26022. useRampGradients: boolean;
  26023. /**
  26024. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  26025. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  26026. */
  26027. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  26028. private _subEmitters;
  26029. /**
  26030. * @hidden
  26031. * If the particle systems emitter should be disposed when the particle system is disposed
  26032. */
  26033. _disposeEmitterOnDispose: boolean;
  26034. /**
  26035. * The current active Sub-systems, this property is used by the root particle system only.
  26036. */
  26037. activeSubSystems: Array<ParticleSystem>;
  26038. private _rootParticleSystem;
  26039. /**
  26040. * Gets the current list of active particles
  26041. */
  26042. readonly particles: Particle[];
  26043. /**
  26044. * Returns the string "ParticleSystem"
  26045. * @returns a string containing the class name
  26046. */
  26047. getClassName(): string;
  26048. /**
  26049. * Instantiates a particle system.
  26050. * 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.
  26051. * @param name The name of the particle system
  26052. * @param capacity The max number of particles alive at the same time
  26053. * @param scene The scene the particle system belongs to
  26054. * @param customEffect a custom effect used to change the way particles are rendered by default
  26055. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  26056. * @param epsilon Offset used to render the particles
  26057. */
  26058. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  26059. private static _InheritParticleInfoToSubEmitter;
  26060. private _addFactorGradient;
  26061. private _removeFactorGradient;
  26062. /**
  26063. * Adds a new life time gradient
  26064. * @param gradient defines the gradient to use (between 0 and 1)
  26065. * @param factor defines the life time factor to affect to the specified gradient
  26066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26067. * @returns the current particle system
  26068. */
  26069. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26070. /**
  26071. * Remove a specific life time gradient
  26072. * @param gradient defines the gradient to remove
  26073. * @returns the current particle system
  26074. */
  26075. removeLifeTimeGradient(gradient: number): IParticleSystem;
  26076. /**
  26077. * Adds a new size gradient
  26078. * @param gradient defines the gradient to use (between 0 and 1)
  26079. * @param factor defines the size factor to affect to the specified gradient
  26080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26081. * @returns the current particle system
  26082. */
  26083. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26084. /**
  26085. * Remove a specific size gradient
  26086. * @param gradient defines the gradient to remove
  26087. * @returns the current particle system
  26088. */
  26089. removeSizeGradient(gradient: number): IParticleSystem;
  26090. /**
  26091. * Adds a new color remap gradient
  26092. * @param gradient defines the gradient to use (between 0 and 1)
  26093. * @param min defines the color remap minimal range
  26094. * @param max defines the color remap maximal range
  26095. * @returns the current particle system
  26096. */
  26097. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  26098. /**
  26099. * Remove a specific color remap gradient
  26100. * @param gradient defines the gradient to remove
  26101. * @returns the current particle system
  26102. */
  26103. removeColorRemapGradient(gradient: number): IParticleSystem;
  26104. /**
  26105. * Adds a new alpha remap gradient
  26106. * @param gradient defines the gradient to use (between 0 and 1)
  26107. * @param min defines the alpha remap minimal range
  26108. * @param max defines the alpha remap maximal range
  26109. * @returns the current particle system
  26110. */
  26111. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  26112. /**
  26113. * Remove a specific alpha remap gradient
  26114. * @param gradient defines the gradient to remove
  26115. * @returns the current particle system
  26116. */
  26117. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  26118. /**
  26119. * Adds a new angular speed gradient
  26120. * @param gradient defines the gradient to use (between 0 and 1)
  26121. * @param factor defines the angular speed to affect to the specified gradient
  26122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26123. * @returns the current particle system
  26124. */
  26125. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26126. /**
  26127. * Remove a specific angular speed gradient
  26128. * @param gradient defines the gradient to remove
  26129. * @returns the current particle system
  26130. */
  26131. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  26132. /**
  26133. * Adds a new velocity gradient
  26134. * @param gradient defines the gradient to use (between 0 and 1)
  26135. * @param factor defines the velocity to affect to the specified gradient
  26136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26137. * @returns the current particle system
  26138. */
  26139. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26140. /**
  26141. * Remove a specific velocity gradient
  26142. * @param gradient defines the gradient to remove
  26143. * @returns the current particle system
  26144. */
  26145. removeVelocityGradient(gradient: number): IParticleSystem;
  26146. /**
  26147. * Adds a new limit velocity gradient
  26148. * @param gradient defines the gradient to use (between 0 and 1)
  26149. * @param factor defines the limit velocity value to affect to the specified gradient
  26150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26151. * @returns the current particle system
  26152. */
  26153. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26154. /**
  26155. * Remove a specific limit velocity gradient
  26156. * @param gradient defines the gradient to remove
  26157. * @returns the current particle system
  26158. */
  26159. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  26160. /**
  26161. * Adds a new drag gradient
  26162. * @param gradient defines the gradient to use (between 0 and 1)
  26163. * @param factor defines the drag value to affect to the specified gradient
  26164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26165. * @returns the current particle system
  26166. */
  26167. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26168. /**
  26169. * Remove a specific drag gradient
  26170. * @param gradient defines the gradient to remove
  26171. * @returns the current particle system
  26172. */
  26173. removeDragGradient(gradient: number): IParticleSystem;
  26174. /**
  26175. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  26176. * @param gradient defines the gradient to use (between 0 and 1)
  26177. * @param factor defines the emit rate value to affect to the specified gradient
  26178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26179. * @returns the current particle system
  26180. */
  26181. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26182. /**
  26183. * Remove a specific emit rate gradient
  26184. * @param gradient defines the gradient to remove
  26185. * @returns the current particle system
  26186. */
  26187. removeEmitRateGradient(gradient: number): IParticleSystem;
  26188. /**
  26189. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  26190. * @param gradient defines the gradient to use (between 0 and 1)
  26191. * @param factor defines the start size value to affect to the specified gradient
  26192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26193. * @returns the current particle system
  26194. */
  26195. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26196. /**
  26197. * Remove a specific start size gradient
  26198. * @param gradient defines the gradient to remove
  26199. * @returns the current particle system
  26200. */
  26201. removeStartSizeGradient(gradient: number): IParticleSystem;
  26202. private _createRampGradientTexture;
  26203. /**
  26204. * Gets the current list of ramp gradients.
  26205. * You must use addRampGradient and removeRampGradient to udpate this list
  26206. * @returns the list of ramp gradients
  26207. */
  26208. getRampGradients(): Nullable<Array<ColorGradient>>;
  26209. /**
  26210. * Adds a new ramp gradient used to remap particle colors
  26211. * @param gradient defines the gradient to use (between 0 and 1)
  26212. * @param color defines the color to affect to the specified gradient
  26213. * @returns the current particle system
  26214. */
  26215. addRampGradient(gradient: number, color: Color4): ParticleSystem;
  26216. /**
  26217. * Remove a specific ramp gradient
  26218. * @param gradient defines the gradient to remove
  26219. * @returns the current particle system
  26220. */
  26221. removeRampGradient(gradient: number): ParticleSystem;
  26222. /**
  26223. * Adds a new color gradient
  26224. * @param gradient defines the gradient to use (between 0 and 1)
  26225. * @param color defines the color to affect to the specified gradient
  26226. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  26227. */
  26228. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  26229. /**
  26230. * Remove a specific color gradient
  26231. * @param gradient defines the gradient to remove
  26232. */
  26233. removeColorGradient(gradient: number): IParticleSystem;
  26234. private _fetchR;
  26235. protected _reset(): void;
  26236. private _resetEffect;
  26237. private _createVertexBuffers;
  26238. private _createIndexBuffer;
  26239. /**
  26240. * Gets the maximum number of particles active at the same time.
  26241. * @returns The max number of active particles.
  26242. */
  26243. getCapacity(): number;
  26244. /**
  26245. * Gets whether there are still active particles in the system.
  26246. * @returns True if it is alive, otherwise false.
  26247. */
  26248. isAlive(): boolean;
  26249. /**
  26250. * Gets if the system has been started. (Note: this will still be true after stop is called)
  26251. * @returns True if it has been started, otherwise false.
  26252. */
  26253. isStarted(): boolean;
  26254. /**
  26255. * Starts the particle system and begins to emit
  26256. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  26257. */
  26258. start(delay?: number): void;
  26259. /**
  26260. * Stops the particle system.
  26261. * @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.
  26262. */
  26263. stop(stopSubEmitters?: boolean): void;
  26264. /**
  26265. * Remove all active particles
  26266. */
  26267. reset(): void;
  26268. /**
  26269. * @hidden (for internal use only)
  26270. */
  26271. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  26272. /**
  26273. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  26274. * Its lifetime will start back at 0.
  26275. */
  26276. recycleParticle: (particle: Particle) => void;
  26277. private _stopSubEmitters;
  26278. private _createParticle;
  26279. private _removeFromRoot;
  26280. private _emitFromParticle;
  26281. private _update;
  26282. /** @hidden */
  26283. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  26284. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  26285. private _getEffect;
  26286. /**
  26287. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  26288. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  26289. */
  26290. animate(preWarmOnly?: boolean): void;
  26291. private _appendParticleVertices;
  26292. /**
  26293. * Rebuilds the particle system.
  26294. */
  26295. rebuild(): void;
  26296. /**
  26297. * Is this system ready to be used/rendered
  26298. * @return true if the system is ready
  26299. */
  26300. isReady(): boolean;
  26301. /**
  26302. * Renders the particle system in its current state.
  26303. * @returns the current number of particles
  26304. */
  26305. render(): number;
  26306. /**
  26307. * Disposes the particle system and free the associated resources
  26308. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  26309. */
  26310. dispose(disposeTexture?: boolean): void;
  26311. /**
  26312. * Clones the particle system.
  26313. * @param name The name of the cloned object
  26314. * @param newEmitter The new emitter to use
  26315. * @returns the cloned particle system
  26316. */
  26317. clone(name: string, newEmitter: any): ParticleSystem;
  26318. /**
  26319. * Serializes the particle system to a JSON object.
  26320. * @returns the JSON object
  26321. */
  26322. serialize(): any;
  26323. /** @hidden */
  26324. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  26325. /** @hidden */
  26326. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  26327. /**
  26328. * Parses a JSON object to create a particle system.
  26329. * @param parsedParticleSystem The JSON object to parse
  26330. * @param scene The scene to create the particle system in
  26331. * @param rootUrl The root url to use to load external dependencies like texture
  26332. * @returns the Parsed particle system
  26333. */
  26334. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  26335. }
  26336. }
  26337. declare module BABYLON {
  26338. interface Engine {
  26339. /**
  26340. * Create an effect to use with particle systems.
  26341. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  26342. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  26343. * @param uniformsNames defines a list of attribute names
  26344. * @param samplers defines an array of string used to represent textures
  26345. * @param defines defines the string containing the defines to use to compile the shaders
  26346. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26347. * @param onCompiled defines a function to call when the effect creation is successful
  26348. * @param onError defines a function to call when the effect creation has failed
  26349. * @returns the new Effect
  26350. */
  26351. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  26352. }
  26353. }
  26354. declare module BABYLON {
  26355. /**
  26356. * Represents a set of particle systems working together to create a specific effect
  26357. */
  26358. class ParticleSystemSet implements IDisposable {
  26359. private _emitterCreationOptions;
  26360. private _emitterNode;
  26361. /**
  26362. * Gets the particle system list
  26363. */
  26364. systems: IParticleSystem[];
  26365. /**
  26366. * Gets the emitter node used with this set
  26367. */
  26368. readonly emitterNode: Nullable<TransformNode>;
  26369. /**
  26370. * Creates a new emitter mesh as a sphere
  26371. * @param options defines the options used to create the sphere
  26372. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  26373. * @param scene defines the hosting scene
  26374. */
  26375. setEmitterAsSphere(options: {
  26376. diameter: number;
  26377. segments: number;
  26378. color: Color3;
  26379. }, renderingGroupId: number, scene: Scene): void;
  26380. /**
  26381. * Starts all particle systems of the set
  26382. * @param emitter defines an optional mesh to use as emitter for the particle systems
  26383. */
  26384. start(emitter?: AbstractMesh): void;
  26385. /**
  26386. * Release all associated resources
  26387. */
  26388. dispose(): void;
  26389. /**
  26390. * Serialize the set into a JSON compatible object
  26391. * @returns a JSON compatible representation of the set
  26392. */
  26393. serialize(): any;
  26394. /**
  26395. * Parse a new ParticleSystemSet from a serialized source
  26396. * @param data defines a JSON compatible representation of the set
  26397. * @param scene defines the hosting scene
  26398. * @param gpu defines if we want GPU particles or CPU particles
  26399. * @returns a new ParticleSystemSet
  26400. */
  26401. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  26402. }
  26403. }
  26404. declare module BABYLON {
  26405. /**
  26406. * Represents one particle of a solid particle system.
  26407. */
  26408. class SolidParticle {
  26409. /**
  26410. * particle global index
  26411. */
  26412. idx: number;
  26413. /**
  26414. * The color of the particle
  26415. */
  26416. color: Nullable<Color4>;
  26417. /**
  26418. * The world space position of the particle.
  26419. */
  26420. position: Vector3;
  26421. /**
  26422. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26423. */
  26424. rotation: Vector3;
  26425. /**
  26426. * The world space rotation quaternion of the particle.
  26427. */
  26428. rotationQuaternion: Nullable<Quaternion>;
  26429. /**
  26430. * The scaling of the particle.
  26431. */
  26432. scaling: Vector3;
  26433. /**
  26434. * The uvs of the particle.
  26435. */
  26436. uvs: Vector4;
  26437. /**
  26438. * The current speed of the particle.
  26439. */
  26440. velocity: Vector3;
  26441. /**
  26442. * The pivot point in the particle local space.
  26443. */
  26444. pivot: Vector3;
  26445. /**
  26446. * Must the particle be translated from its pivot point in its local space ?
  26447. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26448. * Default : false
  26449. */
  26450. translateFromPivot: boolean;
  26451. /**
  26452. * Is the particle active or not ?
  26453. */
  26454. alive: boolean;
  26455. /**
  26456. * Is the particle visible or not ?
  26457. */
  26458. isVisible: boolean;
  26459. /**
  26460. * Index of this particle in the global "positions" array (Internal use)
  26461. * @hidden
  26462. */
  26463. _pos: number;
  26464. /**
  26465. * @hidden Index of this particle in the global "indices" array (Internal use)
  26466. */
  26467. _ind: number;
  26468. /**
  26469. * @hidden ModelShape of this particle (Internal use)
  26470. */
  26471. _model: ModelShape;
  26472. /**
  26473. * ModelShape id of this particle
  26474. */
  26475. shapeId: number;
  26476. /**
  26477. * Index of the particle in its shape id (Internal use)
  26478. */
  26479. idxInShape: number;
  26480. /**
  26481. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26482. */
  26483. _modelBoundingInfo: BoundingInfo;
  26484. /**
  26485. * @hidden Particle BoundingInfo object (Internal use)
  26486. */
  26487. _boundingInfo: BoundingInfo;
  26488. /**
  26489. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26490. */
  26491. _sps: SolidParticleSystem;
  26492. /**
  26493. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26494. */
  26495. _stillInvisible: boolean;
  26496. /**
  26497. * @hidden Last computed particle rotation matrix
  26498. */
  26499. _rotationMatrix: number[];
  26500. /**
  26501. * Parent particle Id, if any.
  26502. * Default null.
  26503. */
  26504. parentId: Nullable<number>;
  26505. /**
  26506. * @hidden Internal global position in the SPS.
  26507. */
  26508. _globalPosition: Vector3;
  26509. /**
  26510. * Creates a Solid Particle object.
  26511. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26512. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26513. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26514. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26515. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26516. * @param shapeId (integer) is the model shape identifier in the SPS.
  26517. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26518. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26519. */
  26520. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26521. /**
  26522. * Legacy support, changed scale to scaling
  26523. */
  26524. /**
  26525. * Legacy support, changed scale to scaling
  26526. */
  26527. scale: Vector3;
  26528. /**
  26529. * Legacy support, changed quaternion to rotationQuaternion
  26530. */
  26531. /**
  26532. * Legacy support, changed quaternion to rotationQuaternion
  26533. */
  26534. quaternion: Nullable<Quaternion>;
  26535. /**
  26536. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26537. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26538. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26539. * @returns true if it intersects
  26540. */
  26541. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26542. }
  26543. /**
  26544. * Represents the shape of the model used by one particle of a solid particle system.
  26545. * SPS internal tool, don't use it manually.
  26546. */
  26547. class ModelShape {
  26548. /**
  26549. * The shape id
  26550. * @hidden
  26551. */
  26552. shapeID: number;
  26553. /**
  26554. * flat array of model positions (internal use)
  26555. * @hidden
  26556. */
  26557. _shape: Vector3[];
  26558. /**
  26559. * flat array of model UVs (internal use)
  26560. * @hidden
  26561. */
  26562. _shapeUV: number[];
  26563. /**
  26564. * length of the shape in the model indices array (internal use)
  26565. * @hidden
  26566. */
  26567. _indicesLength: number;
  26568. /**
  26569. * Custom position function (internal use)
  26570. * @hidden
  26571. */
  26572. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26573. /**
  26574. * Custom vertex function (internal use)
  26575. * @hidden
  26576. */
  26577. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26578. /**
  26579. * 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.
  26580. * SPS internal tool, don't use it manually.
  26581. * @hidden
  26582. */
  26583. 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>);
  26584. }
  26585. /**
  26586. * Represents a Depth Sorted Particle in the solid particle system.
  26587. */
  26588. class DepthSortedParticle {
  26589. /**
  26590. * Index of the particle in the "indices" array
  26591. */
  26592. ind: number;
  26593. /**
  26594. * Length of the particle shape in the "indices" array
  26595. */
  26596. indicesLength: number;
  26597. /**
  26598. * Squared distance from the particle to the camera
  26599. */
  26600. sqDistance: number;
  26601. }
  26602. }
  26603. declare module BABYLON {
  26604. /**
  26605. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26606. *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.
  26607. * The SPS is also a particle system. It provides some methods to manage the particles.
  26608. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26609. *
  26610. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26611. */
  26612. class SolidParticleSystem implements IDisposable {
  26613. /**
  26614. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26615. * Example : var p = SPS.particles[i];
  26616. */
  26617. particles: SolidParticle[];
  26618. /**
  26619. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26620. */
  26621. nbParticles: number;
  26622. /**
  26623. * If the particles must ever face the camera (default false). Useful for planar particles.
  26624. */
  26625. billboard: boolean;
  26626. /**
  26627. * Recompute normals when adding a shape
  26628. */
  26629. recomputeNormals: boolean;
  26630. /**
  26631. * This a counter ofr your own usage. It's not set by any SPS functions.
  26632. */
  26633. counter: number;
  26634. /**
  26635. * The SPS name. This name is also given to the underlying mesh.
  26636. */
  26637. name: string;
  26638. /**
  26639. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26640. */
  26641. mesh: Mesh;
  26642. /**
  26643. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26644. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26645. */
  26646. vars: any;
  26647. /**
  26648. * This array is populated when the SPS is set as 'pickable'.
  26649. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26650. * Each element of this array is an object `{idx: int, faceId: int}`.
  26651. * `idx` is the picked particle index in the `SPS.particles` array
  26652. * `faceId` is the picked face index counted within this particle.
  26653. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26654. */
  26655. pickedParticles: {
  26656. idx: number;
  26657. faceId: number;
  26658. }[];
  26659. /**
  26660. * This array is populated when `enableDepthSort` is set to true.
  26661. * Each element of this array is an instance of the class DepthSortedParticle.
  26662. */
  26663. depthSortedParticles: DepthSortedParticle[];
  26664. /**
  26665. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26666. * @hidden
  26667. */
  26668. _bSphereOnly: boolean;
  26669. /**
  26670. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26671. * @hidden
  26672. */
  26673. _bSphereRadiusFactor: number;
  26674. private _scene;
  26675. private _positions;
  26676. private _indices;
  26677. private _normals;
  26678. private _colors;
  26679. private _uvs;
  26680. private _indices32;
  26681. private _positions32;
  26682. private _normals32;
  26683. private _fixedNormal32;
  26684. private _colors32;
  26685. private _uvs32;
  26686. private _index;
  26687. private _updatable;
  26688. private _pickable;
  26689. private _isVisibilityBoxLocked;
  26690. private _alwaysVisible;
  26691. private _depthSort;
  26692. private _shapeCounter;
  26693. private _copy;
  26694. private _shape;
  26695. private _shapeUV;
  26696. private _color;
  26697. private _computeParticleColor;
  26698. private _computeParticleTexture;
  26699. private _computeParticleRotation;
  26700. private _computeParticleVertex;
  26701. private _computeBoundingBox;
  26702. private _depthSortParticles;
  26703. private _cam_axisZ;
  26704. private _cam_axisY;
  26705. private _cam_axisX;
  26706. private _axisZ;
  26707. private _camera;
  26708. private _particle;
  26709. private _camDir;
  26710. private _camInvertedPosition;
  26711. private _rotMatrix;
  26712. private _invertMatrix;
  26713. private _rotated;
  26714. private _quaternion;
  26715. private _vertex;
  26716. private _normal;
  26717. private _yaw;
  26718. private _pitch;
  26719. private _roll;
  26720. private _halfroll;
  26721. private _halfpitch;
  26722. private _halfyaw;
  26723. private _sinRoll;
  26724. private _cosRoll;
  26725. private _sinPitch;
  26726. private _cosPitch;
  26727. private _sinYaw;
  26728. private _cosYaw;
  26729. private _mustUnrotateFixedNormals;
  26730. private _minimum;
  26731. private _maximum;
  26732. private _minBbox;
  26733. private _maxBbox;
  26734. private _particlesIntersect;
  26735. private _depthSortFunction;
  26736. private _needs32Bits;
  26737. private _pivotBackTranslation;
  26738. private _scaledPivot;
  26739. private _particleHasParent;
  26740. private _parent;
  26741. /**
  26742. * Creates a SPS (Solid Particle System) object.
  26743. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26744. * @param scene (Scene) is the scene in which the SPS is added.
  26745. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26746. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26747. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26748. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26749. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26750. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26751. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26752. */
  26753. constructor(name: string, scene: Scene, options?: {
  26754. updatable?: boolean;
  26755. isPickable?: boolean;
  26756. enableDepthSort?: boolean;
  26757. particleIntersection?: boolean;
  26758. boundingSphereOnly?: boolean;
  26759. bSphereRadiusFactor?: number;
  26760. });
  26761. /**
  26762. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26763. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26764. * @returns the created mesh
  26765. */
  26766. buildMesh(): Mesh;
  26767. /**
  26768. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26769. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26770. * Thus the particles generated from `digest()` have their property `position` set yet.
  26771. * @param mesh ( Mesh ) is the mesh to be digested
  26772. * @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
  26773. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26774. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26775. * @returns the current SPS
  26776. */
  26777. digest(mesh: Mesh, options?: {
  26778. facetNb?: number;
  26779. number?: number;
  26780. delta?: number;
  26781. }): SolidParticleSystem;
  26782. private _unrotateFixedNormals;
  26783. private _resetCopy;
  26784. private _meshBuilder;
  26785. private _posToShape;
  26786. private _uvsToShapeUV;
  26787. private _addParticle;
  26788. /**
  26789. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26790. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26791. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26792. * @param nb (positive integer) the number of particles to be created from this model
  26793. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26794. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26795. * @returns the number of shapes in the system
  26796. */
  26797. addShape(mesh: Mesh, nb: number, options?: {
  26798. positionFunction?: any;
  26799. vertexFunction?: any;
  26800. }): number;
  26801. private _rebuildParticle;
  26802. /**
  26803. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26804. * @returns the SPS.
  26805. */
  26806. rebuildMesh(): SolidParticleSystem;
  26807. /**
  26808. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26809. * This method calls `updateParticle()` for each particle of the SPS.
  26810. * For an animated SPS, it is usually called within the render loop.
  26811. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26812. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26813. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26814. * @returns the SPS.
  26815. */
  26816. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26817. private _quaternionRotationYPR;
  26818. private _quaternionToRotationMatrix;
  26819. /**
  26820. * Disposes the SPS.
  26821. */
  26822. dispose(): void;
  26823. /**
  26824. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26825. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26826. * @returns the SPS.
  26827. */
  26828. refreshVisibleSize(): SolidParticleSystem;
  26829. /**
  26830. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26831. * @param size the size (float) of the visibility box
  26832. * note : this doesn't lock the SPS mesh bounding box.
  26833. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26834. */
  26835. setVisibilityBox(size: number): void;
  26836. /**
  26837. * Gets whether the SPS as always visible or not
  26838. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26839. */
  26840. /**
  26841. * Sets the SPS as always visible or not
  26842. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26843. */
  26844. isAlwaysVisible: boolean;
  26845. /**
  26846. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26847. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26848. */
  26849. /**
  26850. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26851. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26852. */
  26853. isVisibilityBoxLocked: boolean;
  26854. /**
  26855. * Tells to `setParticles()` to compute the particle rotations or not.
  26856. * Default value : true. The SPS is faster when it's set to false.
  26857. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26858. */
  26859. /**
  26860. * Gets if `setParticles()` computes the particle rotations or not.
  26861. * Default value : true. The SPS is faster when it's set to false.
  26862. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26863. */
  26864. computeParticleRotation: boolean;
  26865. /**
  26866. * Tells to `setParticles()` to compute the particle colors or not.
  26867. * Default value : true. The SPS is faster when it's set to false.
  26868. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26869. */
  26870. /**
  26871. * Gets if `setParticles()` computes the particle colors or not.
  26872. * Default value : true. The SPS is faster when it's set to false.
  26873. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26874. */
  26875. computeParticleColor: boolean;
  26876. /**
  26877. * Gets if `setParticles()` computes the particle textures or not.
  26878. * Default value : true. The SPS is faster when it's set to false.
  26879. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26880. */
  26881. computeParticleTexture: boolean;
  26882. /**
  26883. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26884. * Default value : false. The SPS is faster when it's set to false.
  26885. * Note : the particle custom vertex positions aren't stored values.
  26886. */
  26887. /**
  26888. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26889. * Default value : false. The SPS is faster when it's set to false.
  26890. * Note : the particle custom vertex positions aren't stored values.
  26891. */
  26892. computeParticleVertex: boolean;
  26893. /**
  26894. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26895. */
  26896. /**
  26897. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26898. */
  26899. computeBoundingBox: boolean;
  26900. /**
  26901. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26902. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26903. * Default : `true`
  26904. */
  26905. /**
  26906. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26907. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26908. * Default : `true`
  26909. */
  26910. depthSortParticles: boolean;
  26911. /**
  26912. * This function does nothing. It may be overwritten to set all the particle first values.
  26913. * The SPS doesn't call this function, you may have to call it by your own.
  26914. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26915. */
  26916. initParticles(): void;
  26917. /**
  26918. * This function does nothing. It may be overwritten to recycle a particle.
  26919. * The SPS doesn't call this function, you may have to call it by your own.
  26920. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26921. * @param particle The particle to recycle
  26922. * @returns the recycled particle
  26923. */
  26924. recycleParticle(particle: SolidParticle): SolidParticle;
  26925. /**
  26926. * Updates a particle : this function should be overwritten by the user.
  26927. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26928. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26929. * @example : just set a particle position or velocity and recycle conditions
  26930. * @param particle The particle to update
  26931. * @returns the updated particle
  26932. */
  26933. updateParticle(particle: SolidParticle): SolidParticle;
  26934. /**
  26935. * Updates a vertex of a particle : it can be overwritten by the user.
  26936. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26937. * @param particle the current particle
  26938. * @param vertex the current index of the current particle
  26939. * @param pt the index of the current vertex in the particle shape
  26940. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26941. * @example : just set a vertex particle position
  26942. * @returns the updated vertex
  26943. */
  26944. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26945. /**
  26946. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26947. * This does nothing and may be overwritten by the user.
  26948. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26949. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26950. * @param update the boolean update value actually passed to setParticles()
  26951. */
  26952. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26953. /**
  26954. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26955. * This will be passed three parameters.
  26956. * This does nothing and may be overwritten by the user.
  26957. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26958. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26959. * @param update the boolean update value actually passed to setParticles()
  26960. */
  26961. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26962. }
  26963. }
  26964. declare module BABYLON {
  26965. /**
  26966. * Type of sub emitter
  26967. */
  26968. enum SubEmitterType {
  26969. /**
  26970. * Attached to the particle over it's lifetime
  26971. */
  26972. ATTACHED = 0,
  26973. /**
  26974. * Created when the particle dies
  26975. */
  26976. END = 1
  26977. }
  26978. /**
  26979. * Sub emitter class used to emit particles from an existing particle
  26980. */
  26981. class SubEmitter {
  26982. /**
  26983. * the particle system to be used by the sub emitter
  26984. */
  26985. particleSystem: ParticleSystem;
  26986. /**
  26987. * Type of the submitter (Default: END)
  26988. */
  26989. type: SubEmitterType;
  26990. /**
  26991. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  26992. * Note: This only is supported when using an emitter of type Mesh
  26993. */
  26994. inheritDirection: boolean;
  26995. /**
  26996. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  26997. */
  26998. inheritedVelocityAmount: number;
  26999. /**
  27000. * Creates a sub emitter
  27001. * @param particleSystem the particle system to be used by the sub emitter
  27002. */
  27003. constructor(
  27004. /**
  27005. * the particle system to be used by the sub emitter
  27006. */
  27007. particleSystem: ParticleSystem);
  27008. /**
  27009. * Clones the sub emitter
  27010. * @returns the cloned sub emitter
  27011. */
  27012. clone(): SubEmitter;
  27013. }
  27014. }
  27015. declare module BABYLON {
  27016. interface PhysicsImpostorJoint {
  27017. mainImpostor: PhysicsImpostor;
  27018. connectedImpostor: PhysicsImpostor;
  27019. joint: PhysicsJoint;
  27020. }
  27021. class PhysicsEngine {
  27022. private _physicsPlugin;
  27023. gravity: Vector3;
  27024. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  27025. setGravity(gravity: Vector3): void;
  27026. /**
  27027. * Set the time step of the physics engine.
  27028. * default is 1/60.
  27029. * To slow it down, enter 1/600 for example.
  27030. * To speed it up, 1/30
  27031. * @param {number} newTimeStep the new timestep to apply to this world.
  27032. */
  27033. setTimeStep(newTimeStep?: number): void;
  27034. /**
  27035. * Get the time step of the physics engine.
  27036. */
  27037. getTimeStep(): number;
  27038. dispose(): void;
  27039. getPhysicsPluginName(): string;
  27040. static Epsilon: number;
  27041. private _impostors;
  27042. private _joints;
  27043. /**
  27044. * Adding a new impostor for the impostor tracking.
  27045. * This will be done by the impostor itself.
  27046. * @param {PhysicsImpostor} impostor the impostor to add
  27047. */
  27048. addImpostor(impostor: PhysicsImpostor): void;
  27049. /**
  27050. * Remove an impostor from the engine.
  27051. * This impostor and its mesh will not longer be updated by the physics engine.
  27052. * @param {PhysicsImpostor} impostor the impostor to remove
  27053. */
  27054. removeImpostor(impostor: PhysicsImpostor): void;
  27055. /**
  27056. * Add a joint to the physics engine
  27057. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  27058. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  27059. * @param {PhysicsJoint} the joint that will connect both impostors.
  27060. */
  27061. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27062. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27063. /**
  27064. * Called by the scene. no need to call it.
  27065. * @hidden
  27066. */
  27067. _step(delta: number): void;
  27068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27069. getImpostors(): Array<PhysicsImpostor>;
  27070. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27071. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27072. }
  27073. interface IPhysicsEnginePlugin {
  27074. world: any;
  27075. name: string;
  27076. setGravity(gravity: Vector3): void;
  27077. setTimeStep(timeStep: number): void;
  27078. getTimeStep(): number;
  27079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27080. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27081. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27082. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27083. removePhysicsBody(impostor: PhysicsImpostor): void;
  27084. generateJoint(joint: PhysicsImpostorJoint): void;
  27085. removeJoint(joint: PhysicsImpostorJoint): void;
  27086. isSupported(): boolean;
  27087. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27088. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27089. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27090. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27091. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27092. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27093. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27094. getBodyMass(impostor: PhysicsImpostor): number;
  27095. getBodyFriction(impostor: PhysicsImpostor): number;
  27096. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27097. getBodyRestitution(impostor: PhysicsImpostor): number;
  27098. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27099. sleepBody(impostor: PhysicsImpostor): void;
  27100. wakeUpBody(impostor: PhysicsImpostor): void;
  27101. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27102. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27103. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27104. getRadius(impostor: PhysicsImpostor): number;
  27105. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27106. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27107. dispose(): void;
  27108. }
  27109. }
  27110. declare module BABYLON {
  27111. class PhysicsHelper {
  27112. private _scene;
  27113. private _physicsEngine;
  27114. constructor(scene: Scene);
  27115. /**
  27116. * @param {Vector3} origin the origin of the explosion
  27117. * @param {number} radius the explosion radius
  27118. * @param {number} strength the explosion strength
  27119. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  27120. */
  27121. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  27122. /**
  27123. * @param {Vector3} origin the origin of the explosion
  27124. * @param {number} radius the explosion radius
  27125. * @param {number} strength the explosion strength
  27126. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  27127. */
  27128. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  27129. /**
  27130. * @param {Vector3} origin the origin of the explosion
  27131. * @param {number} radius the explosion radius
  27132. * @param {number} strength the explosion strength
  27133. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  27134. */
  27135. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  27136. /**
  27137. * @param {Vector3} origin the origin of the updraft
  27138. * @param {number} radius the radius of the updraft
  27139. * @param {number} strength the strength of the updraft
  27140. * @param {number} height the height of the updraft
  27141. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  27142. */
  27143. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  27144. /**
  27145. * @param {Vector3} origin the of the vortex
  27146. * @param {number} radius the radius of the vortex
  27147. * @param {number} strength the strength of the vortex
  27148. * @param {number} height the height of the vortex
  27149. */
  27150. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  27151. }
  27152. /***** Radial explosion *****/
  27153. class PhysicsRadialExplosionEvent {
  27154. private _scene;
  27155. private _sphere;
  27156. private _sphereOptions;
  27157. private _rays;
  27158. private _dataFetched;
  27159. constructor(scene: Scene);
  27160. /**
  27161. * Returns the data related to the radial explosion event (sphere & rays).
  27162. * @returns {PhysicsRadialExplosionEventData}
  27163. */
  27164. getData(): PhysicsRadialExplosionEventData;
  27165. /**
  27166. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  27167. * @param impostor
  27168. * @param {Vector3} origin the origin of the explosion
  27169. * @param {number} radius the explosion radius
  27170. * @param {number} strength the explosion strength
  27171. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  27172. * @returns {Nullable<PhysicsForceAndContactPoint>}
  27173. */
  27174. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  27175. /**
  27176. * Disposes the sphere.
  27177. * @param {bolean} force
  27178. */
  27179. dispose(force?: boolean): void;
  27180. /*** Helpers ***/
  27181. private _prepareSphere;
  27182. private _intersectsWithSphere;
  27183. }
  27184. /***** Gravitational Field *****/
  27185. class PhysicsGravitationalFieldEvent {
  27186. private _physicsHelper;
  27187. private _scene;
  27188. private _origin;
  27189. private _radius;
  27190. private _strength;
  27191. private _falloff;
  27192. private _tickCallback;
  27193. private _sphere;
  27194. private _dataFetched;
  27195. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  27196. /**
  27197. * Returns the data related to the gravitational field event (sphere).
  27198. * @returns {PhysicsGravitationalFieldEventData}
  27199. */
  27200. getData(): PhysicsGravitationalFieldEventData;
  27201. /**
  27202. * Enables the gravitational field.
  27203. */
  27204. enable(): void;
  27205. /**
  27206. * Disables the gravitational field.
  27207. */
  27208. disable(): void;
  27209. /**
  27210. * Disposes the sphere.
  27211. * @param {bolean} force
  27212. */
  27213. dispose(force?: boolean): void;
  27214. private _tick;
  27215. }
  27216. /***** Updraft *****/
  27217. class PhysicsUpdraftEvent {
  27218. private _scene;
  27219. private _origin;
  27220. private _radius;
  27221. private _strength;
  27222. private _height;
  27223. private _updraftMode;
  27224. private _physicsEngine;
  27225. private _originTop;
  27226. private _originDirection;
  27227. private _tickCallback;
  27228. private _cylinder;
  27229. private _cylinderPosition;
  27230. private _dataFetched;
  27231. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  27232. /**
  27233. * Returns the data related to the updraft event (cylinder).
  27234. * @returns {PhysicsUpdraftEventData}
  27235. */
  27236. getData(): PhysicsUpdraftEventData;
  27237. /**
  27238. * Enables the updraft.
  27239. */
  27240. enable(): void;
  27241. /**
  27242. * Disables the cortex.
  27243. */
  27244. disable(): void;
  27245. /**
  27246. * Disposes the sphere.
  27247. * @param {bolean} force
  27248. */
  27249. dispose(force?: boolean): void;
  27250. private getImpostorForceAndContactPoint;
  27251. private _tick;
  27252. /*** Helpers ***/
  27253. private _prepareCylinder;
  27254. private _intersectsWithCylinder;
  27255. }
  27256. /***** Vortex *****/
  27257. class PhysicsVortexEvent {
  27258. private _scene;
  27259. private _origin;
  27260. private _radius;
  27261. private _strength;
  27262. private _height;
  27263. private _physicsEngine;
  27264. private _originTop;
  27265. private _centripetalForceThreshold;
  27266. private _updraftMultiplier;
  27267. private _tickCallback;
  27268. private _cylinder;
  27269. private _cylinderPosition;
  27270. private _dataFetched;
  27271. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  27272. /**
  27273. * Returns the data related to the vortex event (cylinder).
  27274. * @returns {PhysicsVortexEventData}
  27275. */
  27276. getData(): PhysicsVortexEventData;
  27277. /**
  27278. * Enables the vortex.
  27279. */
  27280. enable(): void;
  27281. /**
  27282. * Disables the cortex.
  27283. */
  27284. disable(): void;
  27285. /**
  27286. * Disposes the sphere.
  27287. * @param {bolean} force
  27288. */
  27289. dispose(force?: boolean): void;
  27290. private getImpostorForceAndContactPoint;
  27291. private _tick;
  27292. /*** Helpers ***/
  27293. private _prepareCylinder;
  27294. private _intersectsWithCylinder;
  27295. }
  27296. /***** Enums *****/
  27297. /**
  27298. * The strenght of the force in correspondence to the distance of the affected object
  27299. */
  27300. enum PhysicsRadialImpulseFalloff {
  27301. /** Defines that impulse is constant in strength across it's whole radius */
  27302. Constant = 0,
  27303. /** DEfines that impulse gets weaker if it's further from the origin */
  27304. Linear = 1
  27305. }
  27306. /**
  27307. * The strenght of the force in correspondence to the distance of the affected object
  27308. */
  27309. enum PhysicsUpdraftMode {
  27310. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  27311. Center = 0,
  27312. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  27313. Perpendicular = 1
  27314. }
  27315. /***** Data interfaces *****/
  27316. interface PhysicsForceAndContactPoint {
  27317. force: Vector3;
  27318. contactPoint: Vector3;
  27319. }
  27320. interface PhysicsRadialExplosionEventData {
  27321. sphere: Mesh;
  27322. rays: Array<Ray>;
  27323. }
  27324. interface PhysicsGravitationalFieldEventData {
  27325. sphere: Mesh;
  27326. }
  27327. interface PhysicsUpdraftEventData {
  27328. cylinder: Mesh;
  27329. }
  27330. interface PhysicsVortexEventData {
  27331. cylinder: Mesh;
  27332. }
  27333. }
  27334. declare module BABYLON {
  27335. interface PhysicsImpostorParameters {
  27336. mass: number;
  27337. friction?: number;
  27338. restitution?: number;
  27339. nativeOptions?: any;
  27340. ignoreParent?: boolean;
  27341. disableBidirectionalTransformation?: boolean;
  27342. }
  27343. interface IPhysicsEnabledObject {
  27344. position: Vector3;
  27345. rotationQuaternion: Nullable<Quaternion>;
  27346. scaling: Vector3;
  27347. rotation?: Vector3;
  27348. parent?: any;
  27349. getBoundingInfo(): BoundingInfo;
  27350. computeWorldMatrix(force: boolean): Matrix;
  27351. getWorldMatrix?(): Matrix;
  27352. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27353. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27354. getIndices?(): Nullable<IndicesArray>;
  27355. getScene?(): Scene;
  27356. getAbsolutePosition(): Vector3;
  27357. getAbsolutePivotPoint(): Vector3;
  27358. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27359. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27360. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27361. getClassName(): string;
  27362. }
  27363. class PhysicsImpostor {
  27364. object: IPhysicsEnabledObject;
  27365. type: number;
  27366. private _options;
  27367. private _scene?;
  27368. static DEFAULT_OBJECT_SIZE: Vector3;
  27369. static IDENTITY_QUATERNION: Quaternion;
  27370. private _physicsEngine;
  27371. private _physicsBody;
  27372. private _bodyUpdateRequired;
  27373. private _onBeforePhysicsStepCallbacks;
  27374. private _onAfterPhysicsStepCallbacks;
  27375. private _onPhysicsCollideCallbacks;
  27376. private _deltaPosition;
  27377. private _deltaRotation;
  27378. private _deltaRotationConjugated;
  27379. private _parent;
  27380. private _isDisposed;
  27381. private static _tmpVecs;
  27382. private static _tmpQuat;
  27383. readonly isDisposed: boolean;
  27384. mass: number;
  27385. friction: number;
  27386. restitution: number;
  27387. uniqueId: number;
  27388. private _joints;
  27389. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27390. /**
  27391. * This function will completly initialize this impostor.
  27392. * It will create a new body - but only if this mesh has no parent.
  27393. * If it has, this impostor will not be used other than to define the impostor
  27394. * of the child mesh.
  27395. * @hidden
  27396. */
  27397. _init(): void;
  27398. private _getPhysicsParent;
  27399. /**
  27400. * Should a new body be generated.
  27401. */
  27402. isBodyInitRequired(): boolean;
  27403. setScalingUpdated(updated: boolean): void;
  27404. /**
  27405. * Force a regeneration of this or the parent's impostor's body.
  27406. * Use under cautious - This will remove all joints already implemented.
  27407. */
  27408. forceUpdate(): void;
  27409. /**
  27410. * Gets the body that holds this impostor. Either its own, or its parent.
  27411. */
  27412. /**
  27413. * Set the physics body. Used mainly by the physics engine/plugin
  27414. */
  27415. physicsBody: any;
  27416. parent: Nullable<PhysicsImpostor>;
  27417. resetUpdateFlags(): void;
  27418. getObjectExtendSize(): Vector3;
  27419. getObjectCenter(): Vector3;
  27420. /**
  27421. * Get a specific parametes from the options parameter.
  27422. */
  27423. getParam(paramName: string): any;
  27424. /**
  27425. * Sets a specific parameter in the options given to the physics plugin
  27426. */
  27427. setParam(paramName: string, value: number): void;
  27428. /**
  27429. * Specifically change the body's mass option. Won't recreate the physics body object
  27430. */
  27431. setMass(mass: number): void;
  27432. getLinearVelocity(): Nullable<Vector3>;
  27433. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27434. getAngularVelocity(): Nullable<Vector3>;
  27435. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27436. /**
  27437. * Execute a function with the physics plugin native code.
  27438. * Provide a function the will have two variables - the world object and the physics body object.
  27439. */
  27440. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27441. /**
  27442. * Register a function that will be executed before the physics world is stepping forward.
  27443. */
  27444. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27445. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27446. /**
  27447. * Register a function that will be executed after the physics step
  27448. */
  27449. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27450. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27451. /**
  27452. * register a function that will be executed when this impostor collides against a different body.
  27453. */
  27454. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27455. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27456. private _tmpQuat;
  27457. private _tmpQuat2;
  27458. getParentsRotation(): Quaternion;
  27459. /**
  27460. * this function is executed by the physics engine.
  27461. */
  27462. beforeStep: () => void;
  27463. /**
  27464. * this function is executed by the physics engine.
  27465. */
  27466. afterStep: () => void;
  27467. /**
  27468. * Legacy collision detection event support
  27469. */
  27470. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27471. onCollide: (e: {
  27472. body: any;
  27473. }) => void;
  27474. /**
  27475. * Apply a force
  27476. */
  27477. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27478. /**
  27479. * Apply an impulse
  27480. */
  27481. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27482. /**
  27483. * A help function to create a joint.
  27484. */
  27485. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27486. /**
  27487. * Add a joint to this impostor with a different impostor.
  27488. */
  27489. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27490. /**
  27491. * Will keep this body still, in a sleep mode.
  27492. */
  27493. sleep(): PhysicsImpostor;
  27494. /**
  27495. * Wake the body up.
  27496. */
  27497. wakeUp(): PhysicsImpostor;
  27498. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27499. dispose(): void;
  27500. setDeltaPosition(position: Vector3): void;
  27501. setDeltaRotation(rotation: Quaternion): void;
  27502. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27503. getRadius(): number;
  27504. /**
  27505. * Sync a bone with this impostor
  27506. * @param bone The bone to sync to the impostor.
  27507. * @param boneMesh The mesh that the bone is influencing.
  27508. * @param jointPivot The pivot of the joint / bone in local space.
  27509. * @param distToJoint Optional distance from the impostor to the joint.
  27510. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27511. */
  27512. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27513. /**
  27514. * Sync impostor to a bone
  27515. * @param bone The bone that the impostor will be synced to.
  27516. * @param boneMesh The mesh that the bone is influencing.
  27517. * @param jointPivot The pivot of the joint / bone in local space.
  27518. * @param distToJoint Optional distance from the impostor to the joint.
  27519. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27520. * @param boneAxis Optional vector3 axis the bone is aligned with
  27521. */
  27522. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27523. static NoImpostor: number;
  27524. static SphereImpostor: number;
  27525. static BoxImpostor: number;
  27526. static PlaneImpostor: number;
  27527. static MeshImpostor: number;
  27528. static CylinderImpostor: number;
  27529. static ParticleImpostor: number;
  27530. static HeightmapImpostor: number;
  27531. }
  27532. }
  27533. declare module BABYLON {
  27534. interface PhysicsJointData {
  27535. mainPivot?: Vector3;
  27536. connectedPivot?: Vector3;
  27537. mainAxis?: Vector3;
  27538. connectedAxis?: Vector3;
  27539. collision?: boolean;
  27540. nativeParams?: any;
  27541. }
  27542. /**
  27543. * This is a holder class for the physics joint created by the physics plugin.
  27544. * It holds a set of functions to control the underlying joint.
  27545. */
  27546. class PhysicsJoint {
  27547. type: number;
  27548. jointData: PhysicsJointData;
  27549. private _physicsJoint;
  27550. protected _physicsPlugin: IPhysicsEnginePlugin;
  27551. constructor(type: number, jointData: PhysicsJointData);
  27552. physicsJoint: any;
  27553. physicsPlugin: IPhysicsEnginePlugin;
  27554. /**
  27555. * Execute a function that is physics-plugin specific.
  27556. * @param {Function} func the function that will be executed.
  27557. * It accepts two parameters: the physics world and the physics joint.
  27558. */
  27559. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27560. static DistanceJoint: number;
  27561. static HingeJoint: number;
  27562. static BallAndSocketJoint: number;
  27563. static WheelJoint: number;
  27564. static SliderJoint: number;
  27565. static PrismaticJoint: number;
  27566. static UniversalJoint: number;
  27567. static Hinge2Joint: number;
  27568. static PointToPointJoint: number;
  27569. static SpringJoint: number;
  27570. static LockJoint: number;
  27571. }
  27572. /**
  27573. * A class representing a physics distance joint.
  27574. */
  27575. class DistanceJoint extends PhysicsJoint {
  27576. constructor(jointData: DistanceJointData);
  27577. /**
  27578. * Update the predefined distance.
  27579. */
  27580. updateDistance(maxDistance: number, minDistance?: number): void;
  27581. }
  27582. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27583. constructor(type: number, jointData: PhysicsJointData);
  27584. /**
  27585. * Set the motor values.
  27586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27587. * @param {number} force the force to apply
  27588. * @param {number} maxForce max force for this motor.
  27589. */
  27590. setMotor(force?: number, maxForce?: number): void;
  27591. /**
  27592. * Set the motor's limits.
  27593. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27594. */
  27595. setLimit(upperLimit: number, lowerLimit?: number): void;
  27596. }
  27597. /**
  27598. * This class represents a single hinge physics joint
  27599. */
  27600. class HingeJoint extends MotorEnabledJoint {
  27601. constructor(jointData: PhysicsJointData);
  27602. /**
  27603. * Set the motor values.
  27604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27605. * @param {number} force the force to apply
  27606. * @param {number} maxForce max force for this motor.
  27607. */
  27608. setMotor(force?: number, maxForce?: number): void;
  27609. /**
  27610. * Set the motor's limits.
  27611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27612. */
  27613. setLimit(upperLimit: number, lowerLimit?: number): void;
  27614. }
  27615. /**
  27616. * This class represents a dual hinge physics joint (same as wheel joint)
  27617. */
  27618. class Hinge2Joint extends MotorEnabledJoint {
  27619. constructor(jointData: PhysicsJointData);
  27620. /**
  27621. * Set the motor values.
  27622. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27623. * @param {number} force the force to apply
  27624. * @param {number} maxForce max force for this motor.
  27625. * @param {motorIndex} the motor's index, 0 or 1.
  27626. */
  27627. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27628. /**
  27629. * Set the motor limits.
  27630. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27631. * @param {number} upperLimit the upper limit
  27632. * @param {number} lowerLimit lower limit
  27633. * @param {motorIndex} the motor's index, 0 or 1.
  27634. */
  27635. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27636. }
  27637. interface IMotorEnabledJoint {
  27638. physicsJoint: any;
  27639. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27640. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27641. }
  27642. interface DistanceJointData extends PhysicsJointData {
  27643. maxDistance: number;
  27644. }
  27645. interface SpringJointData extends PhysicsJointData {
  27646. length: number;
  27647. stiffness: number;
  27648. damping: number;
  27649. /** this callback will be called when applying the force to the impostors. */
  27650. forceApplicationCallback: () => void;
  27651. }
  27652. }
  27653. declare module BABYLON {
  27654. interface Scene {
  27655. /**
  27656. * The list of reflection probes added to the scene
  27657. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  27658. */
  27659. reflectionProbes: Array<ReflectionProbe>;
  27660. }
  27661. /**
  27662. * Class used to generate realtime reflection / refraction cube textures
  27663. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  27664. */
  27665. class ReflectionProbe {
  27666. /** defines the name of the probe */
  27667. name: string;
  27668. private _scene;
  27669. private _renderTargetTexture;
  27670. private _projectionMatrix;
  27671. private _viewMatrix;
  27672. private _target;
  27673. private _add;
  27674. private _attachedMesh;
  27675. private _invertYAxis;
  27676. /** Gets or sets probe position (center of the cube map) */
  27677. position: Vector3;
  27678. /**
  27679. * Creates a new reflection probe
  27680. * @param name defines the name of the probe
  27681. * @param size defines the texture resolution (for each face)
  27682. * @param scene defines the hosting scene
  27683. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  27684. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  27685. */
  27686. constructor(
  27687. /** defines the name of the probe */
  27688. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  27689. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  27690. samples: number;
  27691. /** Gets or sets the refresh rate to use (on every frame by default) */
  27692. refreshRate: number;
  27693. /**
  27694. * Gets the hosting scene
  27695. * @returns a Scene
  27696. */
  27697. getScene(): Scene;
  27698. /** Gets the internal CubeTexture used to render to */
  27699. readonly cubeTexture: RenderTargetTexture;
  27700. /** Gets the list of meshes to render */
  27701. readonly renderList: Nullable<AbstractMesh[]>;
  27702. /**
  27703. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  27704. * @param mesh defines the mesh to attach to
  27705. */
  27706. attachToMesh(mesh: AbstractMesh): void;
  27707. /**
  27708. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  27709. * @param renderingGroupId The rendering group id corresponding to its index
  27710. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27711. */
  27712. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27713. /**
  27714. * Clean all associated resources
  27715. */
  27716. dispose(): void;
  27717. }
  27718. }
  27719. declare module BABYLON {
  27720. /**
  27721. * Postprocess used to generate anaglyphic rendering
  27722. */
  27723. class AnaglyphPostProcess extends PostProcess {
  27724. private _passedProcess;
  27725. /**
  27726. * Creates a new AnaglyphPostProcess
  27727. * @param name defines postprocess name
  27728. * @param options defines creation options or target ratio scale
  27729. * @param rigCameras defines cameras using this postprocess
  27730. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27731. * @param engine defines hosting engine
  27732. * @param reusable defines if the postprocess will be reused multiple times per frame
  27733. */
  27734. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27735. }
  27736. }
  27737. declare module BABYLON {
  27738. class BlackAndWhitePostProcess extends PostProcess {
  27739. degree: number;
  27740. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27741. }
  27742. }
  27743. declare module BABYLON {
  27744. /**
  27745. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27746. */
  27747. class BloomEffect extends PostProcessRenderEffect {
  27748. private bloomScale;
  27749. /**
  27750. * @hidden Internal
  27751. */
  27752. _effects: Array<PostProcess>;
  27753. /**
  27754. * @hidden Internal
  27755. */
  27756. _downscale: ExtractHighlightsPostProcess;
  27757. private _blurX;
  27758. private _blurY;
  27759. private _merge;
  27760. /**
  27761. * The luminance threshold to find bright areas of the image to bloom.
  27762. */
  27763. threshold: number;
  27764. /**
  27765. * The strength of the bloom.
  27766. */
  27767. weight: number;
  27768. /**
  27769. * Specifies the size of the bloom blur kernel, relative to the final output size
  27770. */
  27771. kernel: number;
  27772. /**
  27773. * Creates a new instance of @see BloomEffect
  27774. * @param scene The scene the effect belongs to.
  27775. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27776. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27777. * @param bloomWeight The the strength of bloom.
  27778. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27779. * @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)
  27780. */
  27781. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27782. /**
  27783. * Disposes each of the internal effects for a given camera.
  27784. * @param camera The camera to dispose the effect on.
  27785. */
  27786. disposeEffects(camera: Camera): void;
  27787. /**
  27788. * @hidden Internal
  27789. */
  27790. _updateEffects(): void;
  27791. /**
  27792. * Internal
  27793. * @returns if all the contained post processes are ready.
  27794. * @hidden
  27795. */
  27796. _isReady(): boolean;
  27797. }
  27798. }
  27799. declare module BABYLON {
  27800. /**
  27801. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27802. */
  27803. class BloomMergePostProcess extends PostProcess {
  27804. /** Weight of the bloom to be added to the original input. */
  27805. weight: number;
  27806. /**
  27807. * Creates a new instance of @see BloomMergePostProcess
  27808. * @param name The name of the effect.
  27809. * @param originalFromInput Post process which's input will be used for the merge.
  27810. * @param blurred Blurred highlights post process which's output will be used.
  27811. * @param weight Weight of the bloom to be added to the original input.
  27812. * @param options The required width/height ratio to downsize to before computing the render pass.
  27813. * @param camera The camera to apply the render pass to.
  27814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27815. * @param engine The engine which the post process will be applied. (default: current engine)
  27816. * @param reusable If the post process can be reused on the same frame. (default: false)
  27817. * @param textureType Type of textures used when performing the post process. (default: 0)
  27818. * @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)
  27819. */
  27820. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27821. /** Weight of the bloom to be added to the original input. */
  27822. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27823. }
  27824. }
  27825. declare module BABYLON {
  27826. /**
  27827. * The Blur Post Process which blurs an image based on a kernel and direction.
  27828. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27829. */
  27830. class BlurPostProcess extends PostProcess {
  27831. /** The direction in which to blur the image. */
  27832. direction: Vector2;
  27833. private blockCompilation;
  27834. protected _kernel: number;
  27835. protected _idealKernel: number;
  27836. protected _packedFloat: boolean;
  27837. private _staticDefines;
  27838. /**
  27839. * Sets the length in pixels of the blur sample region
  27840. */
  27841. /**
  27842. * Gets the length in pixels of the blur sample region
  27843. */
  27844. kernel: number;
  27845. /**
  27846. * Sets wether or not the blur needs to unpack/repack floats
  27847. */
  27848. /**
  27849. * Gets wether or not the blur is unpacking/repacking floats
  27850. */
  27851. packedFloat: boolean;
  27852. /**
  27853. * Creates a new instance BlurPostProcess
  27854. * @param name The name of the effect.
  27855. * @param direction The direction in which to blur the image.
  27856. * @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.
  27857. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27858. * @param camera The camera to apply the render pass to.
  27859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27860. * @param engine The engine which the post process will be applied. (default: current engine)
  27861. * @param reusable If the post process can be reused on the same frame. (default: false)
  27862. * @param textureType Type of textures used when performing the post process. (default: 0)
  27863. * @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)
  27864. */
  27865. constructor(name: string,
  27866. /** The direction in which to blur the image. */
  27867. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27868. /**
  27869. * Updates the effect with the current post process compile time values and recompiles the shader.
  27870. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27871. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27872. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27873. * @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
  27874. * @param onCompiled Called when the shader has been compiled.
  27875. * @param onError Called if there is an error when compiling a shader.
  27876. */
  27877. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27878. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27879. /**
  27880. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27881. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27882. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27883. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27884. * The gaps between physical kernels are compensated for in the weighting of the samples
  27885. * @param idealKernel Ideal blur kernel.
  27886. * @return Nearest best kernel.
  27887. */
  27888. protected _nearestBestKernel(idealKernel: number): number;
  27889. /**
  27890. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27891. * @param x The point on the Gaussian distribution to sample.
  27892. * @return the value of the Gaussian function at x.
  27893. */
  27894. protected _gaussianWeight(x: number): number;
  27895. /**
  27896. * Generates a string that can be used as a floating point number in GLSL.
  27897. * @param x Value to print.
  27898. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27899. * @return GLSL float string.
  27900. */
  27901. protected _glslFloat(x: number, decimalFigures?: number): string;
  27902. }
  27903. }
  27904. declare module BABYLON {
  27905. /**
  27906. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27907. */
  27908. class ChromaticAberrationPostProcess extends PostProcess {
  27909. /**
  27910. * The amount of seperation of rgb channels (default: 30)
  27911. */
  27912. aberrationAmount: number;
  27913. /**
  27914. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27915. */
  27916. radialIntensity: number;
  27917. /**
  27918. * 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))
  27919. */
  27920. direction: Vector2;
  27921. /**
  27922. * 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))
  27923. */
  27924. centerPosition: Vector2;
  27925. /**
  27926. * Creates a new instance ChromaticAberrationPostProcess
  27927. * @param name The name of the effect.
  27928. * @param screenWidth The width of the screen to apply the effect on.
  27929. * @param screenHeight The height of the screen to apply the effect on.
  27930. * @param options The required width/height ratio to downsize to before computing the render pass.
  27931. * @param camera The camera to apply the render pass to.
  27932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27933. * @param engine The engine which the post process will be applied. (default: current engine)
  27934. * @param reusable If the post process can be reused on the same frame. (default: false)
  27935. * @param textureType Type of textures used when performing the post process. (default: 0)
  27936. * @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)
  27937. */
  27938. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27939. }
  27940. }
  27941. declare module BABYLON {
  27942. /**
  27943. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27944. */
  27945. class CircleOfConfusionPostProcess extends PostProcess {
  27946. /**
  27947. * 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.
  27948. */
  27949. lensSize: number;
  27950. /**
  27951. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27952. */
  27953. fStop: number;
  27954. /**
  27955. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27956. */
  27957. focusDistance: number;
  27958. /**
  27959. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27960. */
  27961. focalLength: number;
  27962. private _depthTexture;
  27963. /**
  27964. * Creates a new instance CircleOfConfusionPostProcess
  27965. * @param name The name of the effect.
  27966. * @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.
  27967. * @param options The required width/height ratio to downsize to before computing the render pass.
  27968. * @param camera The camera to apply the render pass to.
  27969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27970. * @param engine The engine which the post process will be applied. (default: current engine)
  27971. * @param reusable If the post process can be reused on the same frame. (default: false)
  27972. * @param textureType Type of textures used when performing the post process. (default: 0)
  27973. * @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)
  27974. */
  27975. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27976. /**
  27977. * 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.
  27978. */
  27979. depthTexture: RenderTargetTexture;
  27980. }
  27981. }
  27982. declare module BABYLON {
  27983. class ColorCorrectionPostProcess extends PostProcess {
  27984. private _colorTableTexture;
  27985. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27986. }
  27987. }
  27988. declare module BABYLON {
  27989. /**
  27990. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27991. * input texture to perform effects such as edge detection or sharpening
  27992. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27993. */
  27994. class ConvolutionPostProcess extends PostProcess {
  27995. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27996. kernel: number[];
  27997. /**
  27998. * Creates a new instance ConvolutionPostProcess
  27999. * @param name The name of the effect.
  28000. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  28001. * @param options The required width/height ratio to downsize to before computing the render pass.
  28002. * @param camera The camera to apply the render pass to.
  28003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28004. * @param engine The engine which the post process will be applied. (default: current engine)
  28005. * @param reusable If the post process can be reused on the same frame. (default: false)
  28006. * @param textureType Type of textures used when performing the post process. (default: 0)
  28007. */
  28008. constructor(name: string,
  28009. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  28010. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28011. /**
  28012. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28013. */
  28014. static EdgeDetect0Kernel: number[];
  28015. /**
  28016. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28017. */
  28018. static EdgeDetect1Kernel: number[];
  28019. /**
  28020. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28021. */
  28022. static EdgeDetect2Kernel: number[];
  28023. /**
  28024. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28025. */
  28026. static SharpenKernel: number[];
  28027. /**
  28028. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28029. */
  28030. static EmbossKernel: number[];
  28031. /**
  28032. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28033. */
  28034. static GaussianKernel: number[];
  28035. }
  28036. }
  28037. declare module BABYLON {
  28038. /**
  28039. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  28040. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  28041. * based on samples that have a large difference in distance than the center pixel.
  28042. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  28043. */
  28044. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  28045. direction: Vector2;
  28046. /**
  28047. * Creates a new instance CircleOfConfusionPostProcess
  28048. * @param name The name of the effect.
  28049. * @param scene The scene the effect belongs to.
  28050. * @param direction The direction the blur should be applied.
  28051. * @param kernel The size of the kernel used to blur.
  28052. * @param options The required width/height ratio to downsize to before computing the render pass.
  28053. * @param camera The camera to apply the render pass to.
  28054. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  28055. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  28056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28057. * @param engine The engine which the post process will be applied. (default: current engine)
  28058. * @param reusable If the post process can be reused on the same frame. (default: false)
  28059. * @param textureType Type of textures used when performing the post process. (default: 0)
  28060. * @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)
  28061. */
  28062. 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);
  28063. }
  28064. }
  28065. declare module BABYLON {
  28066. /**
  28067. * Specifies the level of max blur that should be applied when using the depth of field effect
  28068. */
  28069. enum DepthOfFieldEffectBlurLevel {
  28070. /**
  28071. * Subtle blur
  28072. */
  28073. Low = 0,
  28074. /**
  28075. * Medium blur
  28076. */
  28077. Medium = 1,
  28078. /**
  28079. * Large blur
  28080. */
  28081. High = 2
  28082. }
  28083. /**
  28084. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  28085. */
  28086. class DepthOfFieldEffect extends PostProcessRenderEffect {
  28087. private _circleOfConfusion;
  28088. /**
  28089. * @hidden Internal, blurs from high to low
  28090. */
  28091. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  28092. private _depthOfFieldBlurY;
  28093. private _dofMerge;
  28094. /**
  28095. * @hidden Internal post processes in depth of field effect
  28096. */
  28097. _effects: Array<PostProcess>;
  28098. /**
  28099. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  28100. */
  28101. focalLength: number;
  28102. /**
  28103. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  28104. */
  28105. fStop: number;
  28106. /**
  28107. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  28108. */
  28109. focusDistance: number;
  28110. /**
  28111. * 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.
  28112. */
  28113. lensSize: number;
  28114. /**
  28115. * Creates a new instance DepthOfFieldEffect
  28116. * @param scene The scene the effect belongs to.
  28117. * @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.
  28118. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  28119. * @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)
  28120. */
  28121. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  28122. /**
  28123. * 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.
  28124. */
  28125. depthTexture: RenderTargetTexture;
  28126. /**
  28127. * Disposes each of the internal effects for a given camera.
  28128. * @param camera The camera to dispose the effect on.
  28129. */
  28130. disposeEffects(camera: Camera): void;
  28131. /**
  28132. * @hidden Internal
  28133. */
  28134. _updateEffects(): void;
  28135. /**
  28136. * Internal
  28137. * @returns if all the contained post processes are ready.
  28138. * @hidden
  28139. */
  28140. _isReady(): boolean;
  28141. }
  28142. }
  28143. declare module BABYLON {
  28144. /**
  28145. * Options to be set when merging outputs from the default pipeline.
  28146. */
  28147. class DepthOfFieldMergePostProcessOptions {
  28148. /**
  28149. * The original image to merge on top of
  28150. */
  28151. originalFromInput: PostProcess;
  28152. /**
  28153. * Parameters to perform the merge of the depth of field effect
  28154. */
  28155. depthOfField?: {
  28156. circleOfConfusion: PostProcess;
  28157. blurSteps: Array<PostProcess>;
  28158. };
  28159. /**
  28160. * Parameters to perform the merge of bloom effect
  28161. */
  28162. bloom?: {
  28163. blurred: PostProcess;
  28164. weight: number;
  28165. };
  28166. }
  28167. /**
  28168. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  28169. */
  28170. class DepthOfFieldMergePostProcess extends PostProcess {
  28171. private blurSteps;
  28172. /**
  28173. * Creates a new instance of DepthOfFieldMergePostProcess
  28174. * @param name The name of the effect.
  28175. * @param originalFromInput Post process which's input will be used for the merge.
  28176. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  28177. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  28178. * @param options The required width/height ratio to downsize to before computing the render pass.
  28179. * @param camera The camera to apply the render pass to.
  28180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28181. * @param engine The engine which the post process will be applied. (default: current engine)
  28182. * @param reusable If the post process can be reused on the same frame. (default: false)
  28183. * @param textureType Type of textures used when performing the post process. (default: 0)
  28184. * @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)
  28185. */
  28186. 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);
  28187. /**
  28188. * Updates the effect with the current post process compile time values and recompiles the shader.
  28189. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28190. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28191. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28192. * @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
  28193. * @param onCompiled Called when the shader has been compiled.
  28194. * @param onError Called if there is an error when compiling a shader.
  28195. */
  28196. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28197. }
  28198. }
  28199. declare module BABYLON {
  28200. class DisplayPassPostProcess extends PostProcess {
  28201. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28202. }
  28203. }
  28204. declare module BABYLON {
  28205. /**
  28206. * 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.
  28207. */
  28208. class ExtractHighlightsPostProcess extends PostProcess {
  28209. /**
  28210. * The luminance threshold, pixels below this value will be set to black.
  28211. */
  28212. threshold: number;
  28213. /** @hidden */
  28214. _exposure: number;
  28215. /**
  28216. * Post process which has the input texture to be used when performing highlight extraction
  28217. * @hidden
  28218. */
  28219. _inputPostProcess: Nullable<PostProcess>;
  28220. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28221. }
  28222. }
  28223. declare module BABYLON {
  28224. class FilterPostProcess extends PostProcess {
  28225. kernelMatrix: Matrix;
  28226. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28227. }
  28228. }
  28229. declare module BABYLON {
  28230. class FxaaPostProcess extends PostProcess {
  28231. texelWidth: number;
  28232. texelHeight: number;
  28233. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28234. private _getDefines;
  28235. }
  28236. }
  28237. declare module BABYLON {
  28238. /**
  28239. * The GrainPostProcess adds noise to the image at mid luminance levels
  28240. */
  28241. class GrainPostProcess extends PostProcess {
  28242. /**
  28243. * The intensity of the grain added (default: 30)
  28244. */
  28245. intensity: number;
  28246. /**
  28247. * If the grain should be randomized on every frame
  28248. */
  28249. animated: boolean;
  28250. /**
  28251. * Creates a new instance of @see GrainPostProcess
  28252. * @param name The name of the effect.
  28253. * @param options The required width/height ratio to downsize to before computing the render pass.
  28254. * @param camera The camera to apply the render pass to.
  28255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28256. * @param engine The engine which the post process will be applied. (default: current engine)
  28257. * @param reusable If the post process can be reused on the same frame. (default: false)
  28258. * @param textureType Type of textures used when performing the post process. (default: 0)
  28259. * @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)
  28260. */
  28261. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28262. }
  28263. }
  28264. declare module BABYLON {
  28265. class HighlightsPostProcess extends PostProcess {
  28266. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28267. }
  28268. }
  28269. declare module BABYLON {
  28270. class ImageProcessingPostProcess extends PostProcess {
  28271. /**
  28272. * Default configuration related to image processing available in the PBR Material.
  28273. */
  28274. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28275. /**
  28276. * Gets the image processing configuration used either in this material.
  28277. */
  28278. /**
  28279. * Sets the Default image processing configuration used either in the this material.
  28280. *
  28281. * If sets to null, the scene one is in use.
  28282. */
  28283. imageProcessingConfiguration: ImageProcessingConfiguration;
  28284. /**
  28285. * Keep track of the image processing observer to allow dispose and replace.
  28286. */
  28287. private _imageProcessingObserver;
  28288. /**
  28289. * Attaches a new image processing configuration to the PBR Material.
  28290. * @param configuration
  28291. */
  28292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  28293. /**
  28294. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28295. */
  28296. /**
  28297. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28298. */
  28299. colorCurves: Nullable<ColorCurves>;
  28300. /**
  28301. * Gets wether the color curves effect is enabled.
  28302. */
  28303. /**
  28304. * Sets wether the color curves effect is enabled.
  28305. */
  28306. colorCurvesEnabled: boolean;
  28307. /**
  28308. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28309. */
  28310. /**
  28311. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28312. */
  28313. colorGradingTexture: Nullable<BaseTexture>;
  28314. /**
  28315. * Gets wether the color grading effect is enabled.
  28316. */
  28317. /**
  28318. * Gets wether the color grading effect is enabled.
  28319. */
  28320. colorGradingEnabled: boolean;
  28321. /**
  28322. * Gets exposure used in the effect.
  28323. */
  28324. /**
  28325. * Sets exposure used in the effect.
  28326. */
  28327. exposure: number;
  28328. /**
  28329. * Gets wether tonemapping is enabled or not.
  28330. */
  28331. /**
  28332. * Sets wether tonemapping is enabled or not
  28333. */
  28334. toneMappingEnabled: boolean;
  28335. /**
  28336. * Gets contrast used in the effect.
  28337. */
  28338. /**
  28339. * Sets contrast used in the effect.
  28340. */
  28341. contrast: number;
  28342. /**
  28343. * Gets Vignette stretch size.
  28344. */
  28345. /**
  28346. * Sets Vignette stretch size.
  28347. */
  28348. vignetteStretch: number;
  28349. /**
  28350. * Gets Vignette centre X Offset.
  28351. */
  28352. /**
  28353. * Sets Vignette centre X Offset.
  28354. */
  28355. vignetteCentreX: number;
  28356. /**
  28357. * Gets Vignette centre Y Offset.
  28358. */
  28359. /**
  28360. * Sets Vignette centre Y Offset.
  28361. */
  28362. vignetteCentreY: number;
  28363. /**
  28364. * Gets Vignette weight or intensity of the vignette effect.
  28365. */
  28366. /**
  28367. * Sets Vignette weight or intensity of the vignette effect.
  28368. */
  28369. vignetteWeight: number;
  28370. /**
  28371. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28372. * if vignetteEnabled is set to true.
  28373. */
  28374. /**
  28375. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28376. * if vignetteEnabled is set to true.
  28377. */
  28378. vignetteColor: Color4;
  28379. /**
  28380. * Gets Camera field of view used by the Vignette effect.
  28381. */
  28382. /**
  28383. * Sets Camera field of view used by the Vignette effect.
  28384. */
  28385. vignetteCameraFov: number;
  28386. /**
  28387. * Gets the vignette blend mode allowing different kind of effect.
  28388. */
  28389. /**
  28390. * Sets the vignette blend mode allowing different kind of effect.
  28391. */
  28392. vignetteBlendMode: number;
  28393. /**
  28394. * Gets wether the vignette effect is enabled.
  28395. */
  28396. /**
  28397. * Sets wether the vignette effect is enabled.
  28398. */
  28399. vignetteEnabled: boolean;
  28400. private _fromLinearSpace;
  28401. /**
  28402. * Gets wether the input of the processing is in Gamma or Linear Space.
  28403. */
  28404. /**
  28405. * Sets wether the input of the processing is in Gamma or Linear Space.
  28406. */
  28407. fromLinearSpace: boolean;
  28408. /**
  28409. * Defines cache preventing GC.
  28410. */
  28411. private _defines;
  28412. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  28413. getClassName(): string;
  28414. protected _updateParameters(): void;
  28415. dispose(camera?: Camera): void;
  28416. }
  28417. }
  28418. declare module BABYLON {
  28419. class PassPostProcess extends PostProcess {
  28420. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28421. }
  28422. }
  28423. declare module BABYLON {
  28424. type PostProcessOptions = {
  28425. width: number;
  28426. height: number;
  28427. };
  28428. /**
  28429. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28430. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28431. */
  28432. class PostProcess {
  28433. /** Name of the PostProcess. */
  28434. name: string;
  28435. /**
  28436. * Width of the texture to apply the post process on
  28437. */
  28438. width: number;
  28439. /**
  28440. * Height of the texture to apply the post process on
  28441. */
  28442. height: number;
  28443. /**
  28444. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28445. * @hidden
  28446. */
  28447. _outputTexture: Nullable<InternalTexture>;
  28448. /**
  28449. * Sampling mode used by the shader
  28450. * See https://doc.babylonjs.com/classes/3.1/texture
  28451. */
  28452. renderTargetSamplingMode: number;
  28453. /**
  28454. * Clear color to use when screen clearing
  28455. */
  28456. clearColor: Color4;
  28457. /**
  28458. * If the buffer needs to be cleared before applying the post process. (default: true)
  28459. * Should be set to false if shader will overwrite all previous pixels.
  28460. */
  28461. autoClear: boolean;
  28462. /**
  28463. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28464. */
  28465. alphaMode: number;
  28466. /**
  28467. * Sets the setAlphaBlendConstants of the babylon engine
  28468. */
  28469. alphaConstants: Color4;
  28470. /**
  28471. * Animations to be used for the post processing
  28472. */
  28473. animations: Animation[];
  28474. /**
  28475. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28476. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28477. */
  28478. enablePixelPerfectMode: boolean;
  28479. /**
  28480. * Force the postprocess to be applied without taking in account viewport
  28481. */
  28482. forceFullscreenViewport: boolean;
  28483. /**
  28484. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28485. *
  28486. * | Value | Type | Description |
  28487. * | ----- | ----------------------------------- | ----------- |
  28488. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28489. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28490. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28491. *
  28492. */
  28493. scaleMode: number;
  28494. /**
  28495. * Force textures to be a power of two (default: false)
  28496. */
  28497. alwaysForcePOT: boolean;
  28498. private _samples;
  28499. /**
  28500. * Number of sample textures (default: 1)
  28501. */
  28502. samples: number;
  28503. /**
  28504. * Modify the scale of the post process to be the same as the viewport (default: false)
  28505. */
  28506. adaptScaleToCurrentViewport: boolean;
  28507. private _camera;
  28508. private _scene;
  28509. private _engine;
  28510. private _options;
  28511. private _reusable;
  28512. private _textureType;
  28513. /**
  28514. * Smart array of input and output textures for the post process.
  28515. * @hidden
  28516. */
  28517. _textures: SmartArray<InternalTexture>;
  28518. /**
  28519. * The index in _textures that corresponds to the output texture.
  28520. * @hidden
  28521. */
  28522. _currentRenderTextureInd: number;
  28523. private _effect;
  28524. private _samplers;
  28525. private _fragmentUrl;
  28526. private _vertexUrl;
  28527. private _parameters;
  28528. private _scaleRatio;
  28529. protected _indexParameters: any;
  28530. private _shareOutputWithPostProcess;
  28531. private _texelSize;
  28532. private _forcedOutputTexture;
  28533. /**
  28534. * An event triggered when the postprocess is activated.
  28535. */
  28536. onActivateObservable: Observable<Camera>;
  28537. private _onActivateObserver;
  28538. /**
  28539. * A function that is added to the onActivateObservable
  28540. */
  28541. onActivate: Nullable<(camera: Camera) => void>;
  28542. /**
  28543. * An event triggered when the postprocess changes its size.
  28544. */
  28545. onSizeChangedObservable: Observable<PostProcess>;
  28546. private _onSizeChangedObserver;
  28547. /**
  28548. * A function that is added to the onSizeChangedObservable
  28549. */
  28550. onSizeChanged: (postProcess: PostProcess) => void;
  28551. /**
  28552. * An event triggered when the postprocess applies its effect.
  28553. */
  28554. onApplyObservable: Observable<Effect>;
  28555. private _onApplyObserver;
  28556. /**
  28557. * A function that is added to the onApplyObservable
  28558. */
  28559. onApply: (effect: Effect) => void;
  28560. /**
  28561. * An event triggered before rendering the postprocess
  28562. */
  28563. onBeforeRenderObservable: Observable<Effect>;
  28564. private _onBeforeRenderObserver;
  28565. /**
  28566. * A function that is added to the onBeforeRenderObservable
  28567. */
  28568. onBeforeRender: (effect: Effect) => void;
  28569. /**
  28570. * An event triggered after rendering the postprocess
  28571. */
  28572. onAfterRenderObservable: Observable<Effect>;
  28573. private _onAfterRenderObserver;
  28574. /**
  28575. * A function that is added to the onAfterRenderObservable
  28576. */
  28577. onAfterRender: (efect: Effect) => void;
  28578. /**
  28579. * 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
  28580. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28581. */
  28582. inputTexture: InternalTexture;
  28583. /**
  28584. * Gets the camera which post process is applied to.
  28585. * @returns The camera the post process is applied to.
  28586. */
  28587. getCamera(): Camera;
  28588. /**
  28589. * Gets the texel size of the postprocess.
  28590. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28591. */
  28592. readonly texelSize: Vector2;
  28593. /**
  28594. * Creates a new instance PostProcess
  28595. * @param name The name of the PostProcess.
  28596. * @param fragmentUrl The url of the fragment shader to be used.
  28597. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28598. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28599. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28600. * @param camera The camera to apply the render pass to.
  28601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28602. * @param engine The engine which the post process will be applied. (default: current engine)
  28603. * @param reusable If the post process can be reused on the same frame. (default: false)
  28604. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28605. * @param textureType Type of textures used when performing the post process. (default: 0)
  28606. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28607. * @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
  28608. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28609. */
  28610. constructor(
  28611. /** Name of the PostProcess. */
  28612. 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);
  28613. /**
  28614. * Gets the engine which this post process belongs to.
  28615. * @returns The engine the post process was enabled with.
  28616. */
  28617. getEngine(): Engine;
  28618. /**
  28619. * The effect that is created when initializing the post process.
  28620. * @returns The created effect corrisponding the the postprocess.
  28621. */
  28622. getEffect(): Effect;
  28623. /**
  28624. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28625. * @param postProcess The post process to share the output with.
  28626. * @returns This post process.
  28627. */
  28628. shareOutputWith(postProcess: PostProcess): PostProcess;
  28629. /**
  28630. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28631. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28632. */
  28633. useOwnOutput(): void;
  28634. /**
  28635. * Updates the effect with the current post process compile time values and recompiles the shader.
  28636. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28637. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28638. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28639. * @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
  28640. * @param onCompiled Called when the shader has been compiled.
  28641. * @param onError Called if there is an error when compiling a shader.
  28642. */
  28643. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28644. /**
  28645. * The post process is reusable if it can be used multiple times within one frame.
  28646. * @returns If the post process is reusable
  28647. */
  28648. isReusable(): boolean;
  28649. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28650. markTextureDirty(): void;
  28651. /**
  28652. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28653. * 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.
  28654. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28655. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28656. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28657. * @returns The target texture that was bound to be written to.
  28658. */
  28659. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28660. /**
  28661. * If the post process is supported.
  28662. */
  28663. readonly isSupported: boolean;
  28664. /**
  28665. * The aspect ratio of the output texture.
  28666. */
  28667. readonly aspectRatio: number;
  28668. /**
  28669. * Get a value indicating if the post-process is ready to be used
  28670. * @returns true if the post-process is ready (shader is compiled)
  28671. */
  28672. isReady(): boolean;
  28673. /**
  28674. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28675. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28676. */
  28677. apply(): Nullable<Effect>;
  28678. private _disposeTextures;
  28679. /**
  28680. * Disposes the post process.
  28681. * @param camera The camera to dispose the post process on.
  28682. */
  28683. dispose(camera?: Camera): void;
  28684. }
  28685. }
  28686. declare module BABYLON {
  28687. /**
  28688. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28689. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28690. */
  28691. class PostProcessManager {
  28692. private _scene;
  28693. private _indexBuffer;
  28694. private _vertexBuffers;
  28695. /**
  28696. * Creates a new instance PostProcess
  28697. * @param scene The scene that the post process is associated with.
  28698. */
  28699. constructor(scene: Scene);
  28700. private _prepareBuffers;
  28701. private _buildIndexBuffer;
  28702. /**
  28703. * Rebuilds the vertex buffers of the manager.
  28704. * @hidden
  28705. */
  28706. _rebuild(): void;
  28707. /**
  28708. * Prepares a frame to be run through a post process.
  28709. * @param sourceTexture The input texture to the post procesess. (default: null)
  28710. * @param postProcesses An array of post processes to be run. (default: null)
  28711. * @returns True if the post processes were able to be run.
  28712. * @hidden
  28713. */
  28714. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28715. /**
  28716. * Manually render a set of post processes to a texture.
  28717. * @param postProcesses An array of post processes to be run.
  28718. * @param targetTexture The target texture to render to.
  28719. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28720. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28721. * @param lodLevel defines which lod of the texture to render to
  28722. */
  28723. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28724. /**
  28725. * Finalize the result of the output of the postprocesses.
  28726. * @param doNotPresent If true the result will not be displayed to the screen.
  28727. * @param targetTexture The target texture to render to.
  28728. * @param faceIndex The index of the face to bind the target texture to.
  28729. * @param postProcesses The array of post processes to render.
  28730. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28731. * @hidden
  28732. */
  28733. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28734. /**
  28735. * Disposes of the post process manager.
  28736. */
  28737. dispose(): void;
  28738. }
  28739. }
  28740. declare module BABYLON {
  28741. class RefractionPostProcess extends PostProcess {
  28742. color: Color3;
  28743. depth: number;
  28744. colorLevel: number;
  28745. private _refTexture;
  28746. private _ownRefractionTexture;
  28747. /**
  28748. * Gets or sets the refraction texture
  28749. * Please note that you are responsible for disposing the texture if you set it manually
  28750. */
  28751. refractionTexture: Texture;
  28752. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28753. dispose(camera: Camera): void;
  28754. }
  28755. }
  28756. declare module BABYLON {
  28757. /**
  28758. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28759. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28760. */
  28761. class SharpenPostProcess extends PostProcess {
  28762. /**
  28763. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28764. */
  28765. colorAmount: number;
  28766. /**
  28767. * How much sharpness should be applied (default: 0.3)
  28768. */
  28769. edgeAmount: number;
  28770. /**
  28771. * Creates a new instance ConvolutionPostProcess
  28772. * @param name The name of the effect.
  28773. * @param options The required width/height ratio to downsize to before computing the render pass.
  28774. * @param camera The camera to apply the render pass to.
  28775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28776. * @param engine The engine which the post process will be applied. (default: current engine)
  28777. * @param reusable If the post process can be reused on the same frame. (default: false)
  28778. * @param textureType Type of textures used when performing the post process. (default: 0)
  28779. * @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)
  28780. */
  28781. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28782. }
  28783. }
  28784. declare module BABYLON {
  28785. class StereoscopicInterlacePostProcess extends PostProcess {
  28786. private _stepSize;
  28787. private _passedProcess;
  28788. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28789. }
  28790. }
  28791. declare module BABYLON {
  28792. /** Defines operator used for tonemapping */
  28793. enum TonemappingOperator {
  28794. /** Hable */
  28795. Hable = 0,
  28796. /** Reinhard */
  28797. Reinhard = 1,
  28798. /** HejiDawson */
  28799. HejiDawson = 2,
  28800. /** Photographic */
  28801. Photographic = 3
  28802. }
  28803. /**
  28804. * Defines a post process to apply tone mapping
  28805. */
  28806. class TonemapPostProcess extends PostProcess {
  28807. private _operator;
  28808. /** Defines the required exposure adjustement */
  28809. exposureAdjustment: number;
  28810. /**
  28811. * Creates a new TonemapPostProcess
  28812. * @param name defines the name of the postprocess
  28813. * @param _operator defines the operator to use
  28814. * @param exposureAdjustment defines the required exposure adjustement
  28815. * @param camera defines the camera to use (can be null)
  28816. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28817. * @param engine defines the hosting engine (can be ignore if camera is set)
  28818. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28819. */
  28820. constructor(name: string, _operator: TonemappingOperator,
  28821. /** Defines the required exposure adjustement */
  28822. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28823. }
  28824. }
  28825. declare module BABYLON {
  28826. class VolumetricLightScatteringPostProcess extends PostProcess {
  28827. private _volumetricLightScatteringPass;
  28828. private _volumetricLightScatteringRTT;
  28829. private _viewPort;
  28830. private _screenCoordinates;
  28831. private _cachedDefines;
  28832. /**
  28833. * If not undefined, the mesh position is computed from the attached node position
  28834. */
  28835. attachedNode: {
  28836. position: Vector3;
  28837. };
  28838. /**
  28839. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28840. */
  28841. customMeshPosition: Vector3;
  28842. /**
  28843. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28844. */
  28845. useCustomMeshPosition: boolean;
  28846. /**
  28847. * If the post-process should inverse the light scattering direction
  28848. */
  28849. invert: boolean;
  28850. /**
  28851. * The internal mesh used by the post-process
  28852. */
  28853. mesh: Mesh;
  28854. useDiffuseColor: boolean;
  28855. /**
  28856. * Array containing the excluded meshes not rendered in the internal pass
  28857. */
  28858. excludedMeshes: AbstractMesh[];
  28859. /**
  28860. * Controls the overall intensity of the post-process
  28861. */
  28862. exposure: number;
  28863. /**
  28864. * Dissipates each sample's contribution in range [0, 1]
  28865. */
  28866. decay: number;
  28867. /**
  28868. * Controls the overall intensity of each sample
  28869. */
  28870. weight: number;
  28871. /**
  28872. * Controls the density of each sample
  28873. */
  28874. density: number;
  28875. /**
  28876. * @constructor
  28877. * @param {string} name - The post-process name
  28878. * @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)
  28879. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28880. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28881. * @param {number} samples - The post-process quality, default 100
  28882. * @param {number} samplingMode - The post-process filtering mode
  28883. * @param {BABYLON.Engine} engine - The babylon engine
  28884. * @param {boolean} reusable - If the post-process is reusable
  28885. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28886. */
  28887. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28888. getClassName(): string;
  28889. private _isReady;
  28890. /**
  28891. * Sets the new light position for light scattering effect
  28892. * @param {BABYLON.Vector3} The new custom light position
  28893. */
  28894. setCustomMeshPosition(position: Vector3): void;
  28895. /**
  28896. * Returns the light position for light scattering effect
  28897. * @return {BABYLON.Vector3} The custom light position
  28898. */
  28899. getCustomMeshPosition(): Vector3;
  28900. /**
  28901. * Disposes the internal assets and detaches the post-process from the camera
  28902. */
  28903. dispose(camera: Camera): void;
  28904. /**
  28905. * Returns the render target texture used by the post-process
  28906. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28907. */
  28908. getPass(): RenderTargetTexture;
  28909. private _meshExcluded;
  28910. private _createPass;
  28911. private _updateMeshScreenCoordinates;
  28912. /**
  28913. * Creates a default mesh for the Volumeric Light Scattering post-process
  28914. * @param {string} The mesh name
  28915. * @param {BABYLON.Scene} The scene where to create the mesh
  28916. * @return {BABYLON.Mesh} the default mesh
  28917. */
  28918. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28919. }
  28920. }
  28921. declare module BABYLON {
  28922. class VRDistortionCorrectionPostProcess extends PostProcess {
  28923. private _isRightEye;
  28924. private _distortionFactors;
  28925. private _postProcessScaleFactor;
  28926. private _lensCenterOffset;
  28927. private _scaleIn;
  28928. private _scaleFactor;
  28929. private _lensCenter;
  28930. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28931. }
  28932. }
  28933. declare module BABYLON {
  28934. class Sprite {
  28935. name: string;
  28936. position: Vector3;
  28937. color: Color4;
  28938. width: number;
  28939. height: number;
  28940. angle: number;
  28941. cellIndex: number;
  28942. invertU: number;
  28943. invertV: number;
  28944. disposeWhenFinishedAnimating: boolean;
  28945. animations: Animation[];
  28946. isPickable: boolean;
  28947. actionManager: ActionManager;
  28948. private _animationStarted;
  28949. private _loopAnimation;
  28950. private _fromIndex;
  28951. private _toIndex;
  28952. private _delay;
  28953. private _direction;
  28954. private _manager;
  28955. private _time;
  28956. private _onAnimationEnd;
  28957. /**
  28958. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  28959. */
  28960. isVisible: boolean;
  28961. size: number;
  28962. constructor(name: string, manager: ISpriteManager);
  28963. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  28964. stopAnimation(): void;
  28965. /** @hidden */
  28966. _animate(deltaTime: number): void;
  28967. dispose(): void;
  28968. }
  28969. }
  28970. declare module BABYLON {
  28971. /**
  28972. * Defines the minimum interface to fullfil in order to be a sprite manager.
  28973. */
  28974. interface ISpriteManager extends IDisposable {
  28975. /**
  28976. * Restricts the camera to viewing objects with the same layerMask.
  28977. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  28978. */
  28979. layerMask: number;
  28980. /**
  28981. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28982. */
  28983. isPickable: boolean;
  28984. /**
  28985. * Specifies the rendering group id for this mesh (0 by default)
  28986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28987. */
  28988. renderingGroupId: number;
  28989. /**
  28990. * Defines the list of sprites managed by the manager.
  28991. */
  28992. sprites: Array<Sprite>;
  28993. /**
  28994. * Tests the intersection of a sprite with a specific ray.
  28995. * @param ray The ray we are sending to test the collision
  28996. * @param camera The camera space we are sending rays in
  28997. * @param predicate A predicate allowing excluding sprites from the list of object to test
  28998. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  28999. * @returns picking info or null.
  29000. */
  29001. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29002. /**
  29003. * Renders the list of sprites on screen.
  29004. */
  29005. render(): void;
  29006. }
  29007. class SpriteManager implements ISpriteManager {
  29008. name: string;
  29009. sprites: Sprite[];
  29010. renderingGroupId: number;
  29011. layerMask: number;
  29012. fogEnabled: boolean;
  29013. isPickable: boolean;
  29014. cellWidth: number;
  29015. cellHeight: number;
  29016. /**
  29017. * An event triggered when the manager is disposed.
  29018. */
  29019. onDisposeObservable: Observable<SpriteManager>;
  29020. private _onDisposeObserver;
  29021. onDispose: () => void;
  29022. private _capacity;
  29023. private _spriteTexture;
  29024. private _epsilon;
  29025. private _scene;
  29026. private _vertexData;
  29027. private _buffer;
  29028. private _vertexBuffers;
  29029. private _indexBuffer;
  29030. private _effectBase;
  29031. private _effectFog;
  29032. texture: Texture;
  29033. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29034. private _appendSpriteVertex;
  29035. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29036. render(): void;
  29037. dispose(): void;
  29038. }
  29039. }
  29040. declare module BABYLON {
  29041. interface Scene {
  29042. /** @hidden */
  29043. _pointerOverSprite: Nullable<Sprite>;
  29044. /** @hidden */
  29045. _pickedDownSprite: Nullable<Sprite>;
  29046. /** @hidden */
  29047. _tempSpritePickingRay: Nullable<Ray>;
  29048. /**
  29049. * All of the sprite managers added to this scene
  29050. * @see http://doc.babylonjs.com/babylon101/sprites
  29051. */
  29052. spriteManagers: Array<ISpriteManager>;
  29053. /**
  29054. * An event triggered when sprites rendering is about to start
  29055. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29056. */
  29057. onBeforeSpritesRenderingObservable: Observable<Scene>;
  29058. /**
  29059. * An event triggered when sprites rendering is done
  29060. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29061. */
  29062. onAfterSpritesRenderingObservable: Observable<Scene>;
  29063. /** @hidden */
  29064. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29065. /** Launch a ray to try to pick a sprite in the scene
  29066. * @param x position on screen
  29067. * @param y position on screen
  29068. * @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
  29069. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29070. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  29071. * @returns a PickingInfo
  29072. */
  29073. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29074. /** Use the given ray to pick a sprite in the scene
  29075. * @param ray The ray (in world space) to use to pick meshes
  29076. * @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
  29077. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29078. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  29079. * @returns a PickingInfo
  29080. */
  29081. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29082. /**
  29083. * Force the sprite under the pointer
  29084. * @param sprite defines the sprite to use
  29085. */
  29086. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  29087. /**
  29088. * Gets the sprite under the pointer
  29089. * @returns a Sprite or null if no sprite is under the pointer
  29090. */
  29091. getPointerOverSprite(): Nullable<Sprite>;
  29092. }
  29093. /**
  29094. * Defines the sprite scene component responsible to manage sprites
  29095. * in a given scene.
  29096. */
  29097. class SpriteSceneComponent implements ISceneComponent {
  29098. /**
  29099. * The component name helpfull to identify the component in the list of scene components.
  29100. */
  29101. readonly name: string;
  29102. /**
  29103. * The scene the component belongs to.
  29104. */
  29105. scene: Scene;
  29106. /** @hidden */
  29107. private _spritePredicate;
  29108. /**
  29109. * Creates a new instance of the component for the given scene
  29110. * @param scene Defines the scene to register the component in
  29111. */
  29112. constructor(scene: Scene);
  29113. /**
  29114. * Registers the component in a given scene
  29115. */
  29116. register(): void;
  29117. /**
  29118. * Rebuilds the elements related to this component in case of
  29119. * context lost for instance.
  29120. */
  29121. rebuild(): void;
  29122. /**
  29123. * Disposes the component and the associated ressources.
  29124. */
  29125. dispose(): void;
  29126. private _pickSpriteButKeepRay;
  29127. private _pointerMove;
  29128. private _pointerDown;
  29129. private _pointerUp;
  29130. }
  29131. }
  29132. declare module BABYLON {
  29133. interface Scene {
  29134. /** @hidden (Backing field) */
  29135. _boundingBoxRenderer: BoundingBoxRenderer;
  29136. /** @hidden (Backing field) */
  29137. _forceShowBoundingBoxes: boolean;
  29138. /**
  29139. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  29140. */
  29141. forceShowBoundingBoxes: boolean;
  29142. /**
  29143. * Gets the bounding box renderer associated with the scene
  29144. * @returns a BoundingBoxRenderer
  29145. */
  29146. getBoundingBoxRenderer(): BoundingBoxRenderer;
  29147. }
  29148. interface AbstractMesh {
  29149. /** @hidden (Backing field) */
  29150. _showBoundingBox: boolean;
  29151. /**
  29152. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  29153. */
  29154. showBoundingBox: boolean;
  29155. }
  29156. class BoundingBoxRenderer implements ISceneComponent {
  29157. /**
  29158. * The component name helpfull to identify the component in the list of scene components.
  29159. */
  29160. readonly name: string;
  29161. /**
  29162. * The scene the component belongs to.
  29163. */
  29164. scene: Scene;
  29165. frontColor: Color3;
  29166. backColor: Color3;
  29167. showBackLines: boolean;
  29168. renderList: SmartArray<BoundingBox>;
  29169. private _colorShader;
  29170. private _vertexBuffers;
  29171. private _indexBuffer;
  29172. constructor(scene: Scene);
  29173. /**
  29174. * Registers the component in a given scene
  29175. */
  29176. register(): void;
  29177. private _evaluateSubMesh;
  29178. private _activeMesh;
  29179. private _prepareRessources;
  29180. private _createIndexBuffer;
  29181. /**
  29182. * Rebuilds the elements related to this component in case of
  29183. * context lost for instance.
  29184. */
  29185. rebuild(): void;
  29186. reset(): void;
  29187. render(): void;
  29188. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  29189. dispose(): void;
  29190. }
  29191. }
  29192. declare module BABYLON {
  29193. /**
  29194. * This represents a depth renderer in Babylon.
  29195. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  29196. */
  29197. class DepthRenderer {
  29198. private _scene;
  29199. private _depthMap;
  29200. private _effect;
  29201. private _cachedDefines;
  29202. private _camera;
  29203. /**
  29204. * Specifiess that the depth renderer will only be used within
  29205. * the camera it is created for.
  29206. * This can help forcing its rendering during the camera processing.
  29207. */
  29208. useOnlyInActiveCamera: boolean;
  29209. /**
  29210. * Instantiates a depth renderer
  29211. * @param scene The scene the renderer belongs to
  29212. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  29213. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  29214. */
  29215. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  29216. /**
  29217. * Creates the depth rendering effect and checks if the effect is ready.
  29218. * @param subMesh The submesh to be used to render the depth map of
  29219. * @param useInstances If multiple world instances should be used
  29220. * @returns if the depth renderer is ready to render the depth map
  29221. */
  29222. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29223. /**
  29224. * Gets the texture which the depth map will be written to.
  29225. * @returns The depth map texture
  29226. */
  29227. getDepthMap(): RenderTargetTexture;
  29228. /**
  29229. * Disposes of the depth renderer.
  29230. */
  29231. dispose(): void;
  29232. }
  29233. }
  29234. declare module BABYLON {
  29235. interface Scene {
  29236. /** @hidden (Backing field) */
  29237. _depthRenderer: {
  29238. [id: string]: DepthRenderer;
  29239. };
  29240. /**
  29241. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  29242. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  29243. * @returns the created depth renderer
  29244. */
  29245. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  29246. /**
  29247. * Disables a depth renderer for a given camera
  29248. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  29249. */
  29250. disableDepthRenderer(camera?: Nullable<Camera>): void;
  29251. }
  29252. /**
  29253. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  29254. * in several rendering techniques.
  29255. */
  29256. class DepthRendererSceneComponent implements ISceneComponent {
  29257. /**
  29258. * The component name helpfull to identify the component in the list of scene components.
  29259. */
  29260. readonly name: string;
  29261. /**
  29262. * The scene the component belongs to.
  29263. */
  29264. scene: Scene;
  29265. /**
  29266. * Creates a new instance of the component for the given scene
  29267. * @param scene Defines the scene to register the component in
  29268. */
  29269. constructor(scene: Scene);
  29270. /**
  29271. * Registers the component in a given scene
  29272. */
  29273. register(): void;
  29274. /**
  29275. * Rebuilds the elements related to this component in case of
  29276. * context lost for instance.
  29277. */
  29278. rebuild(): void;
  29279. /**
  29280. * Disposes the component and the associated ressources
  29281. */
  29282. dispose(): void;
  29283. private _gatherRenderTargets;
  29284. private _gatherActiveCameraRenderTargets;
  29285. }
  29286. }
  29287. declare module BABYLON {
  29288. interface AbstractMesh {
  29289. /**
  29290. * Disables the mesh edge rendering mode
  29291. * @returns the currentAbstractMesh
  29292. */
  29293. disableEdgesRendering(): AbstractMesh;
  29294. /**
  29295. * Enables the edge rendering mode on the mesh.
  29296. * This mode makes the mesh edges visible
  29297. * @param epsilon defines the maximal distance between two angles to detect a face
  29298. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29299. * @returns the currentAbstractMesh
  29300. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29301. */
  29302. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29303. /**
  29304. * Gets the edgesRenderer associated with the mesh
  29305. */
  29306. edgesRenderer: Nullable<EdgesRenderer>;
  29307. }
  29308. interface LinesMesh {
  29309. /**
  29310. * Enables the edge rendering mode on the mesh.
  29311. * This mode makes the mesh edges visible
  29312. * @param epsilon defines the maximal distance between two angles to detect a face
  29313. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29314. * @returns the currentAbstractMesh
  29315. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29316. */
  29317. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29318. }
  29319. /**
  29320. * Defines the minimum contract an Edges renderer should follow.
  29321. */
  29322. interface IEdgesRenderer extends IDisposable {
  29323. /**
  29324. * Gets or sets a boolean indicating if the edgesRenderer is active
  29325. */
  29326. isEnabled: boolean;
  29327. /**
  29328. * Renders the edges of the attached mesh,
  29329. */
  29330. render(): void;
  29331. /**
  29332. * Checks wether or not the edges renderer is ready to render.
  29333. * @return true if ready, otherwise false.
  29334. */
  29335. isReady(): boolean;
  29336. }
  29337. /**
  29338. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29339. */
  29340. class EdgesRenderer implements IEdgesRenderer {
  29341. edgesWidthScalerForOrthographic: number;
  29342. edgesWidthScalerForPerspective: number;
  29343. protected _source: AbstractMesh;
  29344. protected _linesPositions: number[];
  29345. protected _linesNormals: number[];
  29346. protected _linesIndices: number[];
  29347. protected _epsilon: number;
  29348. protected _indicesCount: number;
  29349. protected _lineShader: ShaderMaterial;
  29350. protected _ib: WebGLBuffer;
  29351. protected _buffers: {
  29352. [key: string]: Nullable<VertexBuffer>;
  29353. };
  29354. protected _checkVerticesInsteadOfIndices: boolean;
  29355. private _meshRebuildObserver;
  29356. private _meshDisposeObserver;
  29357. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29358. isEnabled: boolean;
  29359. /**
  29360. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29361. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29362. * @param source Mesh used to create edges
  29363. * @param epsilon sum of angles in adjacency to check for edge
  29364. * @param checkVerticesInsteadOfIndices
  29365. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29366. */
  29367. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  29368. protected _prepareRessources(): void;
  29369. /** @hidden */
  29370. _rebuild(): void;
  29371. /**
  29372. * Releases the required resources for the edges renderer
  29373. */
  29374. dispose(): void;
  29375. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29376. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29377. /**
  29378. * Checks if the pair of p0 and p1 is en edge
  29379. * @param faceIndex
  29380. * @param edge
  29381. * @param faceNormals
  29382. * @param p0
  29383. * @param p1
  29384. * @private
  29385. */
  29386. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29387. /**
  29388. * Generates lines edges from adjacencjes
  29389. * @private
  29390. */
  29391. _generateEdgesLines(): void;
  29392. /**
  29393. * Checks wether or not the edges renderer is ready to render.
  29394. * @return true if ready, otherwise false.
  29395. */
  29396. isReady(): boolean;
  29397. /**
  29398. * Renders the edges of the attached mesh,
  29399. */
  29400. render(): void;
  29401. }
  29402. }
  29403. declare module BABYLON {
  29404. /**
  29405. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  29406. */
  29407. class GeometryBufferRenderer {
  29408. private _scene;
  29409. private _multiRenderTarget;
  29410. private _ratio;
  29411. private _enablePosition;
  29412. protected _effect: Effect;
  29413. protected _cachedDefines: string;
  29414. /**
  29415. * Set the render list (meshes to be rendered) used in the G buffer.
  29416. */
  29417. renderList: Mesh[];
  29418. /**
  29419. * Gets wether or not G buffer are supported by the running hardware.
  29420. * This requires draw buffer supports
  29421. */
  29422. readonly isSupported: boolean;
  29423. /**
  29424. * Gets wether or not position are enabled for the G buffer.
  29425. */
  29426. /**
  29427. * Sets wether or not position are enabled for the G buffer.
  29428. */
  29429. enablePosition: boolean;
  29430. /**
  29431. * Gets the scene associated with the buffer.
  29432. */
  29433. readonly scene: Scene;
  29434. /**
  29435. * Gets the ratio used by the buffer during its creation.
  29436. * How big is the buffer related to the main canvas.
  29437. */
  29438. readonly ratio: number;
  29439. /**
  29440. * Creates a new G Buffer for the scene
  29441. * @param scene The scene the buffer belongs to
  29442. * @param ratio How big is the buffer related to the main canvas.
  29443. */
  29444. constructor(scene: Scene, ratio?: number);
  29445. /**
  29446. * Checks wether everything is ready to render a submesh to the G buffer.
  29447. * @param subMesh the submesh to check readiness for
  29448. * @param useInstances is the mesh drawn using instance or not
  29449. * @returns true if ready otherwise false
  29450. */
  29451. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29452. /**
  29453. * Gets the current underlying G Buffer.
  29454. * @returns the buffer
  29455. */
  29456. getGBuffer(): MultiRenderTarget;
  29457. /**
  29458. * Gets the number of samples used to render the buffer (anti aliasing).
  29459. */
  29460. /**
  29461. * Sets the number of samples used to render the buffer (anti aliasing).
  29462. */
  29463. samples: number;
  29464. /**
  29465. * Disposes the renderer and frees up associated resources.
  29466. */
  29467. dispose(): void;
  29468. protected _createRenderTargets(): void;
  29469. }
  29470. }
  29471. declare module BABYLON {
  29472. interface Scene {
  29473. /** @hidden (Backing field) */
  29474. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  29475. /**
  29476. * Gets or Sets the current geometry buffer associated to the scene.
  29477. */
  29478. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  29479. /**
  29480. * Enables a GeometryBufferRender and associates it with the scene
  29481. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  29482. * @returns the GeometryBufferRenderer
  29483. */
  29484. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  29485. /**
  29486. * Disables the GeometryBufferRender associated with the scene
  29487. */
  29488. disableGeometryBufferRenderer(): void;
  29489. }
  29490. /**
  29491. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  29492. * in several rendering techniques.
  29493. */
  29494. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  29495. /**
  29496. * The component name helpfull to identify the component in the list of scene components.
  29497. */
  29498. readonly name: string;
  29499. /**
  29500. * The scene the component belongs to.
  29501. */
  29502. scene: Scene;
  29503. /**
  29504. * Creates a new instance of the component for the given scene
  29505. * @param scene Defines the scene to register the component in
  29506. */
  29507. constructor(scene: Scene);
  29508. /**
  29509. * Registers the component in a given scene
  29510. */
  29511. register(): void;
  29512. /**
  29513. * Rebuilds the elements related to this component in case of
  29514. * context lost for instance.
  29515. */
  29516. rebuild(): void;
  29517. /**
  29518. * Disposes the component and the associated ressources
  29519. */
  29520. dispose(): void;
  29521. private _gatherRenderTargets;
  29522. }
  29523. }
  29524. declare module BABYLON {
  29525. /**
  29526. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29527. */
  29528. class LineEdgesRenderer extends EdgesRenderer {
  29529. /**
  29530. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29531. * @param source LineMesh used to generate edges
  29532. * @param epsilon not important (specified angle for edge detection)
  29533. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29534. */
  29535. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29536. /**
  29537. * Always create the edge since its a line so only important things are p0 and p1
  29538. * @param faceIndex not important for LineMesh
  29539. * @param edge not important for LineMesh
  29540. * @param faceNormals not important for LineMesh
  29541. * @param p0 beginnig of line
  29542. * @param p1 end of line
  29543. */
  29544. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29545. /**
  29546. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29547. */
  29548. _generateEdgesLines(): void;
  29549. }
  29550. }
  29551. declare module BABYLON {
  29552. interface Scene {
  29553. /** @hidden */
  29554. _outlineRenderer: OutlineRenderer;
  29555. /**
  29556. * Gets the outline renderer associated with the scene
  29557. * @returns a OutlineRenderer
  29558. */
  29559. getOutlineRenderer(): OutlineRenderer;
  29560. }
  29561. interface AbstractMesh {
  29562. /** @hidden (Backing field) */
  29563. _renderOutline: boolean;
  29564. /**
  29565. * Gets or sets a boolean indicating if the outline must be rendered as well
  29566. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  29567. */
  29568. renderOutline: boolean;
  29569. /** @hidden (Backing field) */
  29570. _renderOverlay: boolean;
  29571. /**
  29572. * Gets or sets a boolean indicating if the overlay must be rendered as well
  29573. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  29574. */
  29575. renderOverlay: boolean;
  29576. }
  29577. /**
  29578. * This class is responsible to draw bothe outline/overlay of meshes.
  29579. * It should not be used directly but through the available method on mesh.
  29580. */
  29581. class OutlineRenderer implements ISceneComponent {
  29582. /**
  29583. * The name of the component. Each component must have a unique name.
  29584. */
  29585. name: string;
  29586. /**
  29587. * The scene the component belongs to.
  29588. */
  29589. scene: Scene;
  29590. /**
  29591. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  29592. */
  29593. zOffset: number;
  29594. private _engine;
  29595. private _effect;
  29596. private _cachedDefines;
  29597. private _savedDepthWrite;
  29598. /**
  29599. * Instantiates a new outline renderer. (There could be only one per scene).
  29600. * @param scene Defines the scene it belongs to
  29601. */
  29602. constructor(scene: Scene);
  29603. /**
  29604. * Register the component to one instance of a scene.
  29605. */
  29606. register(): void;
  29607. /**
  29608. * Rebuilds the elements related to this component in case of
  29609. * context lost for instance.
  29610. */
  29611. rebuild(): void;
  29612. /**
  29613. * Disposes the component and the associated ressources.
  29614. */
  29615. dispose(): void;
  29616. /**
  29617. * Renders the outline in the canvas.
  29618. * @param subMesh Defines the sumesh to render
  29619. * @param batch Defines the batch of meshes in case of instances
  29620. * @param useOverlay Defines if the rendering is for the overlay or the outline
  29621. */
  29622. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  29623. /**
  29624. * Returns whether or not the outline renderer is ready for a given submesh.
  29625. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  29626. * @param subMesh Defines the submesh to check readyness for
  29627. * @param useInstances Defines wheter wee are trying to render instances or not
  29628. * @returns true if ready otherwise false
  29629. */
  29630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29631. private _beforeRenderingMesh;
  29632. private _afterRenderingMesh;
  29633. }
  29634. }
  29635. declare module BABYLON {
  29636. class RenderingGroup {
  29637. index: number;
  29638. private _scene;
  29639. private _opaqueSubMeshes;
  29640. private _transparentSubMeshes;
  29641. private _alphaTestSubMeshes;
  29642. private _depthOnlySubMeshes;
  29643. private _particleSystems;
  29644. private _spriteManagers;
  29645. private _opaqueSortCompareFn;
  29646. private _alphaTestSortCompareFn;
  29647. private _transparentSortCompareFn;
  29648. private _renderOpaque;
  29649. private _renderAlphaTest;
  29650. private _renderTransparent;
  29651. private _edgesRenderers;
  29652. onBeforeTransparentRendering: () => void;
  29653. /**
  29654. * Set the opaque sort comparison function.
  29655. * If null the sub meshes will be render in the order they were created
  29656. */
  29657. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29658. /**
  29659. * Set the alpha test sort comparison function.
  29660. * If null the sub meshes will be render in the order they were created
  29661. */
  29662. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29663. /**
  29664. * Set the transparent sort comparison function.
  29665. * If null the sub meshes will be render in the order they were created
  29666. */
  29667. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29668. /**
  29669. * Creates a new rendering group.
  29670. * @param index The rendering group index
  29671. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29672. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29673. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29674. */
  29675. 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>);
  29676. /**
  29677. * Render all the sub meshes contained in the group.
  29678. * @param customRenderFunction Used to override the default render behaviour of the group.
  29679. * @returns true if rendered some submeshes.
  29680. */
  29681. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29682. /**
  29683. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29684. * @param subMeshes The submeshes to render
  29685. */
  29686. private renderOpaqueSorted;
  29687. /**
  29688. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29689. * @param subMeshes The submeshes to render
  29690. */
  29691. private renderAlphaTestSorted;
  29692. /**
  29693. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29694. * @param subMeshes The submeshes to render
  29695. */
  29696. private renderTransparentSorted;
  29697. /**
  29698. * Renders the submeshes in a specified order.
  29699. * @param subMeshes The submeshes to sort before render
  29700. * @param sortCompareFn The comparison function use to sort
  29701. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29702. * @param transparent Specifies to activate blending if true
  29703. */
  29704. private static renderSorted;
  29705. /**
  29706. * Renders the submeshes in the order they were dispatched (no sort applied).
  29707. * @param subMeshes The submeshes to render
  29708. */
  29709. private static renderUnsorted;
  29710. /**
  29711. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29712. * are rendered back to front if in the same alpha index.
  29713. *
  29714. * @param a The first submesh
  29715. * @param b The second submesh
  29716. * @returns The result of the comparison
  29717. */
  29718. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29719. /**
  29720. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29721. * are rendered back to front.
  29722. *
  29723. * @param a The first submesh
  29724. * @param b The second submesh
  29725. * @returns The result of the comparison
  29726. */
  29727. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29728. /**
  29729. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29730. * are rendered front to back (prevent overdraw).
  29731. *
  29732. * @param a The first submesh
  29733. * @param b The second submesh
  29734. * @returns The result of the comparison
  29735. */
  29736. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29737. /**
  29738. * Resets the different lists of submeshes to prepare a new frame.
  29739. */
  29740. prepare(): void;
  29741. dispose(): void;
  29742. /**
  29743. * Inserts the submesh in its correct queue depending on its material.
  29744. * @param subMesh The submesh to dispatch
  29745. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29746. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29747. */
  29748. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29749. dispatchSprites(spriteManager: ISpriteManager): void;
  29750. dispatchParticles(particleSystem: IParticleSystem): void;
  29751. private _renderParticles;
  29752. private _renderSprites;
  29753. }
  29754. }
  29755. declare module BABYLON {
  29756. /**
  29757. * Interface describing the different options available in the rendering manager
  29758. * regarding Auto Clear between groups.
  29759. */
  29760. interface IRenderingManagerAutoClearSetup {
  29761. /**
  29762. * Defines whether or not autoclear is enable.
  29763. */
  29764. autoClear: boolean;
  29765. /**
  29766. * Defines whether or not to autoclear the depth buffer.
  29767. */
  29768. depth: boolean;
  29769. /**
  29770. * Defines whether or not to autoclear the stencil buffer.
  29771. */
  29772. stencil: boolean;
  29773. }
  29774. class RenderingManager {
  29775. /**
  29776. * The max id used for rendering groups (not included)
  29777. */
  29778. static MAX_RENDERINGGROUPS: number;
  29779. /**
  29780. * The min id used for rendering groups (included)
  29781. */
  29782. static MIN_RENDERINGGROUPS: number;
  29783. /**
  29784. * Used to globally prevent autoclearing scenes.
  29785. */
  29786. static AUTOCLEAR: boolean;
  29787. /**
  29788. * @hidden
  29789. */
  29790. _useSceneAutoClearSetup: boolean;
  29791. private _scene;
  29792. private _renderingGroups;
  29793. private _depthStencilBufferAlreadyCleaned;
  29794. private _autoClearDepthStencil;
  29795. private _customOpaqueSortCompareFn;
  29796. private _customAlphaTestSortCompareFn;
  29797. private _customTransparentSortCompareFn;
  29798. private _renderingGroupInfo;
  29799. constructor(scene: Scene);
  29800. private _clearDepthStencilBuffer;
  29801. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29802. reset(): void;
  29803. dispose(): void;
  29804. /**
  29805. * Clear the info related to rendering groups preventing retention points during dispose.
  29806. */
  29807. freeRenderingGroups(): void;
  29808. private _prepareRenderingGroup;
  29809. dispatchSprites(spriteManager: ISpriteManager): void;
  29810. dispatchParticles(particleSystem: IParticleSystem): void;
  29811. /**
  29812. * @param subMesh The submesh to dispatch
  29813. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29814. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29815. */
  29816. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29817. /**
  29818. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29819. * This allowed control for front to back rendering or reversly depending of the special needs.
  29820. *
  29821. * @param renderingGroupId The rendering group id corresponding to its index
  29822. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29823. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29824. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29825. */
  29826. 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;
  29827. /**
  29828. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29829. *
  29830. * @param renderingGroupId The rendering group id corresponding to its index
  29831. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29832. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29833. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29834. */
  29835. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29836. /**
  29837. * Gets the current auto clear configuration for one rendering group of the rendering
  29838. * manager.
  29839. * @param index the rendering group index to get the information for
  29840. * @returns The auto clear setup for the requested rendering group
  29841. */
  29842. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29843. }
  29844. }
  29845. declare module BABYLON {
  29846. /**
  29847. * Renders a layer on top of an existing scene
  29848. */
  29849. class UtilityLayerRenderer implements IDisposable {
  29850. /** the original scene that will be rendered on top of */
  29851. originalScene: Scene;
  29852. private _pointerCaptures;
  29853. private _lastPointerEvents;
  29854. private static _DefaultUtilityLayer;
  29855. private static _DefaultKeepDepthUtilityLayer;
  29856. /**
  29857. * 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)
  29858. */
  29859. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29860. /**
  29861. * 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)
  29862. */
  29863. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29864. /**
  29865. * The scene that is rendered on top of the original scene
  29866. */
  29867. utilityLayerScene: Scene;
  29868. /**
  29869. * If the utility layer should automatically be rendered on top of existing scene
  29870. */
  29871. shouldRender: boolean;
  29872. /**
  29873. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29874. */
  29875. onlyCheckPointerDownEvents: boolean;
  29876. /**
  29877. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29878. */
  29879. processAllEvents: boolean;
  29880. /**
  29881. * Observable raised when the pointer move from the utility layer scene to the main scene
  29882. */
  29883. onPointerOutObservable: Observable<number>;
  29884. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29885. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29886. private _afterRenderObserver;
  29887. private _sceneDisposeObserver;
  29888. private _originalPointerObserver;
  29889. /**
  29890. * Instantiates a UtilityLayerRenderer
  29891. * @param originalScene the original scene that will be rendered on top of
  29892. */
  29893. constructor(
  29894. /** the original scene that will be rendered on top of */
  29895. originalScene: Scene);
  29896. private _notifyObservers;
  29897. /**
  29898. * Renders the utility layers scene on top of the original scene
  29899. */
  29900. render(): void;
  29901. /**
  29902. * Disposes of the renderer
  29903. */
  29904. dispose(): void;
  29905. private _updateCamera;
  29906. }
  29907. }
  29908. declare module BABYLON {
  29909. /**
  29910. * @hidden
  29911. **/
  29912. class _AlphaState {
  29913. private _isAlphaBlendDirty;
  29914. private _isBlendFunctionParametersDirty;
  29915. private _isBlendEquationParametersDirty;
  29916. private _isBlendConstantsDirty;
  29917. private _alphaBlend;
  29918. private _blendFunctionParameters;
  29919. private _blendEquationParameters;
  29920. private _blendConstants;
  29921. /**
  29922. * Initializes the state.
  29923. */
  29924. constructor();
  29925. readonly isDirty: boolean;
  29926. alphaBlend: boolean;
  29927. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29928. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29929. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29930. reset(): void;
  29931. apply(gl: WebGLRenderingContext): void;
  29932. }
  29933. }
  29934. declare module BABYLON {
  29935. /**
  29936. * @hidden
  29937. **/
  29938. class _DepthCullingState {
  29939. private _isDepthTestDirty;
  29940. private _isDepthMaskDirty;
  29941. private _isDepthFuncDirty;
  29942. private _isCullFaceDirty;
  29943. private _isCullDirty;
  29944. private _isZOffsetDirty;
  29945. private _isFrontFaceDirty;
  29946. private _depthTest;
  29947. private _depthMask;
  29948. private _depthFunc;
  29949. private _cull;
  29950. private _cullFace;
  29951. private _zOffset;
  29952. private _frontFace;
  29953. /**
  29954. * Initializes the state.
  29955. */
  29956. constructor();
  29957. readonly isDirty: boolean;
  29958. zOffset: number;
  29959. cullFace: Nullable<number>;
  29960. cull: Nullable<boolean>;
  29961. depthFunc: Nullable<number>;
  29962. depthMask: boolean;
  29963. depthTest: boolean;
  29964. frontFace: Nullable<number>;
  29965. reset(): void;
  29966. apply(gl: WebGLRenderingContext): void;
  29967. }
  29968. }
  29969. declare module BABYLON {
  29970. /**
  29971. * @hidden
  29972. **/
  29973. class _StencilState {
  29974. private _isStencilTestDirty;
  29975. private _isStencilMaskDirty;
  29976. private _isStencilFuncDirty;
  29977. private _isStencilOpDirty;
  29978. private _stencilTest;
  29979. private _stencilMask;
  29980. private _stencilFunc;
  29981. private _stencilFuncRef;
  29982. private _stencilFuncMask;
  29983. private _stencilOpStencilFail;
  29984. private _stencilOpDepthFail;
  29985. private _stencilOpStencilDepthPass;
  29986. readonly isDirty: boolean;
  29987. stencilFunc: number;
  29988. stencilFuncRef: number;
  29989. stencilFuncMask: number;
  29990. stencilOpStencilFail: number;
  29991. stencilOpDepthFail: number;
  29992. stencilOpStencilDepthPass: number;
  29993. stencilMask: number;
  29994. stencilTest: boolean;
  29995. constructor();
  29996. reset(): void;
  29997. apply(gl: WebGLRenderingContext): void;
  29998. }
  29999. }
  30000. declare module BABYLON {
  30001. /**
  30002. * Class used to evalaute queries containing `and` and `or` operators
  30003. */
  30004. class AndOrNotEvaluator {
  30005. /**
  30006. * Evaluate a query
  30007. * @param query defines the query to evaluate
  30008. * @param evaluateCallback defines the callback used to filter result
  30009. * @returns true if the query matches
  30010. */
  30011. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  30012. private static _HandleParenthesisContent;
  30013. private static _SimplifyNegation;
  30014. }
  30015. }
  30016. declare module BABYLON {
  30017. /**
  30018. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  30019. */
  30020. enum AssetTaskState {
  30021. /**
  30022. * Initialization
  30023. */
  30024. INIT = 0,
  30025. /**
  30026. * Running
  30027. */
  30028. RUNNING = 1,
  30029. /**
  30030. * Done
  30031. */
  30032. DONE = 2,
  30033. /**
  30034. * Error
  30035. */
  30036. ERROR = 3
  30037. }
  30038. /**
  30039. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  30040. */
  30041. abstract class AbstractAssetTask {
  30042. /**
  30043. * Task name
  30044. */ name: string;
  30045. /**
  30046. * Callback called when the task is successful
  30047. */
  30048. onSuccess: (task: any) => void;
  30049. /**
  30050. * Callback called when the task is not successful
  30051. */
  30052. onError: (task: any, message?: string, exception?: any) => void;
  30053. /**
  30054. * Creates a new {BABYLON.AssetsManager}
  30055. * @param name defines the name of the task
  30056. */
  30057. constructor(
  30058. /**
  30059. * Task name
  30060. */ name: string);
  30061. private _isCompleted;
  30062. private _taskState;
  30063. private _errorObject;
  30064. /**
  30065. * Get if the task is completed
  30066. */
  30067. readonly isCompleted: boolean;
  30068. /**
  30069. * Gets the current state of the task
  30070. */
  30071. readonly taskState: AssetTaskState;
  30072. /**
  30073. * Gets the current error object (if task is in error)
  30074. */
  30075. readonly errorObject: {
  30076. message?: string;
  30077. exception?: any;
  30078. };
  30079. /**
  30080. * Internal only
  30081. * @hidden
  30082. */
  30083. _setErrorObject(message?: string, exception?: any): void;
  30084. /**
  30085. * Execute the current task
  30086. * @param scene defines the scene where you want your assets to be loaded
  30087. * @param onSuccess is a callback called when the task is successfully executed
  30088. * @param onError is a callback called if an error occurs
  30089. */
  30090. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30091. /**
  30092. * Execute the current task
  30093. * @param scene defines the scene where you want your assets to be loaded
  30094. * @param onSuccess is a callback called when the task is successfully executed
  30095. * @param onError is a callback called if an error occurs
  30096. */
  30097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30098. /**
  30099. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  30100. * This can be used with failed tasks that have the reason for failure fixed.
  30101. */
  30102. reset(): void;
  30103. private onErrorCallback;
  30104. private onDoneCallback;
  30105. }
  30106. /**
  30107. * Define the interface used by progress events raised during assets loading
  30108. */
  30109. interface IAssetsProgressEvent {
  30110. /**
  30111. * Defines the number of remaining tasks to process
  30112. */
  30113. remainingCount: number;
  30114. /**
  30115. * Defines the total number of tasks
  30116. */
  30117. totalCount: number;
  30118. /**
  30119. * Defines the task that was just processed
  30120. */
  30121. task: AbstractAssetTask;
  30122. }
  30123. /**
  30124. * Class used to share progress information about assets loading
  30125. */
  30126. class AssetsProgressEvent implements IAssetsProgressEvent {
  30127. /**
  30128. * Defines the number of remaining tasks to process
  30129. */
  30130. remainingCount: number;
  30131. /**
  30132. * Defines the total number of tasks
  30133. */
  30134. totalCount: number;
  30135. /**
  30136. * Defines the task that was just processed
  30137. */
  30138. task: AbstractAssetTask;
  30139. /**
  30140. * Creates a {BABYLON.AssetsProgressEvent}
  30141. * @param remainingCount defines the number of remaining tasks to process
  30142. * @param totalCount defines the total number of tasks
  30143. * @param task defines the task that was just processed
  30144. */
  30145. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  30146. }
  30147. /**
  30148. * Define a task used by {BABYLON.AssetsManager} to load meshes
  30149. */
  30150. class MeshAssetTask extends AbstractAssetTask {
  30151. /**
  30152. * Defines the name of the task
  30153. */
  30154. name: string;
  30155. /**
  30156. * Defines the list of mesh's names you want to load
  30157. */
  30158. meshesNames: any;
  30159. /**
  30160. * Defines the root url to use as a base to load your meshes and associated resources
  30161. */
  30162. rootUrl: string;
  30163. /**
  30164. * Defines the filename of the scene to load from
  30165. */
  30166. sceneFilename: string;
  30167. /**
  30168. * Gets the list of loaded meshes
  30169. */
  30170. loadedMeshes: Array<AbstractMesh>;
  30171. /**
  30172. * Gets the list of loaded particle systems
  30173. */
  30174. loadedParticleSystems: Array<IParticleSystem>;
  30175. /**
  30176. * Gets the list of loaded skeletons
  30177. */
  30178. loadedSkeletons: Array<Skeleton>;
  30179. /**
  30180. * Callback called when the task is successful
  30181. */
  30182. onSuccess: (task: MeshAssetTask) => void;
  30183. /**
  30184. * Callback called when the task is successful
  30185. */
  30186. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  30187. /**
  30188. * Creates a new {BABYLON.MeshAssetTask}
  30189. * @param name defines the name of the task
  30190. * @param meshesNames defines the list of mesh's names you want to load
  30191. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  30192. * @param sceneFilename defines the filename of the scene to load from
  30193. */
  30194. constructor(
  30195. /**
  30196. * Defines the name of the task
  30197. */
  30198. name: string,
  30199. /**
  30200. * Defines the list of mesh's names you want to load
  30201. */
  30202. meshesNames: any,
  30203. /**
  30204. * Defines the root url to use as a base to load your meshes and associated resources
  30205. */
  30206. rootUrl: string,
  30207. /**
  30208. * Defines the filename of the scene to load from
  30209. */
  30210. sceneFilename: string);
  30211. /**
  30212. * Execute the current task
  30213. * @param scene defines the scene where you want your assets to be loaded
  30214. * @param onSuccess is a callback called when the task is successfully executed
  30215. * @param onError is a callback called if an error occurs
  30216. */
  30217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30218. }
  30219. /**
  30220. * Define a task used by {BABYLON.AssetsManager} to load text content
  30221. */
  30222. class TextFileAssetTask extends AbstractAssetTask {
  30223. /**
  30224. * Defines the name of the task
  30225. */
  30226. name: string;
  30227. /**
  30228. * Defines the location of the file to load
  30229. */
  30230. url: string;
  30231. /**
  30232. * Gets the loaded text string
  30233. */
  30234. text: string;
  30235. /**
  30236. * Callback called when the task is successful
  30237. */
  30238. onSuccess: (task: TextFileAssetTask) => void;
  30239. /**
  30240. * Callback called when the task is successful
  30241. */
  30242. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  30243. /**
  30244. * Creates a new TextFileAssetTask object
  30245. * @param name defines the name of the task
  30246. * @param url defines the location of the file to load
  30247. */
  30248. constructor(
  30249. /**
  30250. * Defines the name of the task
  30251. */
  30252. name: string,
  30253. /**
  30254. * Defines the location of the file to load
  30255. */
  30256. url: string);
  30257. /**
  30258. * Execute the current task
  30259. * @param scene defines the scene where you want your assets to be loaded
  30260. * @param onSuccess is a callback called when the task is successfully executed
  30261. * @param onError is a callback called if an error occurs
  30262. */
  30263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30264. }
  30265. /**
  30266. * Define a task used by {BABYLON.AssetsManager} to load binary data
  30267. */
  30268. class BinaryFileAssetTask extends AbstractAssetTask {
  30269. /**
  30270. * Defines the name of the task
  30271. */
  30272. name: string;
  30273. /**
  30274. * Defines the location of the file to load
  30275. */
  30276. url: string;
  30277. /**
  30278. * Gets the lodaded data (as an array buffer)
  30279. */
  30280. data: ArrayBuffer;
  30281. /**
  30282. * Callback called when the task is successful
  30283. */
  30284. onSuccess: (task: BinaryFileAssetTask) => void;
  30285. /**
  30286. * Callback called when the task is successful
  30287. */
  30288. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  30289. /**
  30290. * Creates a new BinaryFileAssetTask object
  30291. * @param name defines the name of the new task
  30292. * @param url defines the location of the file to load
  30293. */
  30294. constructor(
  30295. /**
  30296. * Defines the name of the task
  30297. */
  30298. name: string,
  30299. /**
  30300. * Defines the location of the file to load
  30301. */
  30302. url: string);
  30303. /**
  30304. * Execute the current task
  30305. * @param scene defines the scene where you want your assets to be loaded
  30306. * @param onSuccess is a callback called when the task is successfully executed
  30307. * @param onError is a callback called if an error occurs
  30308. */
  30309. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30310. }
  30311. /**
  30312. * Define a task used by {BABYLON.AssetsManager} to load images
  30313. */
  30314. class ImageAssetTask extends AbstractAssetTask {
  30315. /**
  30316. * Defines the name of the task
  30317. */
  30318. name: string;
  30319. /**
  30320. * Defines the location of the image to load
  30321. */
  30322. url: string;
  30323. /**
  30324. * Gets the loaded images
  30325. */
  30326. image: HTMLImageElement;
  30327. /**
  30328. * Callback called when the task is successful
  30329. */
  30330. onSuccess: (task: ImageAssetTask) => void;
  30331. /**
  30332. * Callback called when the task is successful
  30333. */
  30334. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  30335. /**
  30336. * Creates a new ImageAssetTask
  30337. * @param name defines the name of the task
  30338. * @param url defines the location of the image to load
  30339. */
  30340. constructor(
  30341. /**
  30342. * Defines the name of the task
  30343. */
  30344. name: string,
  30345. /**
  30346. * Defines the location of the image to load
  30347. */
  30348. url: string);
  30349. /**
  30350. * Execute the current task
  30351. * @param scene defines the scene where you want your assets to be loaded
  30352. * @param onSuccess is a callback called when the task is successfully executed
  30353. * @param onError is a callback called if an error occurs
  30354. */
  30355. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30356. }
  30357. /**
  30358. * Defines the interface used by texture loading tasks
  30359. */
  30360. interface ITextureAssetTask<TEX extends BaseTexture> {
  30361. /**
  30362. * Gets the loaded texture
  30363. */
  30364. texture: TEX;
  30365. }
  30366. /**
  30367. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  30368. */
  30369. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  30370. /**
  30371. * Defines the name of the task
  30372. */
  30373. name: string;
  30374. /**
  30375. * Defines the location of the file to load
  30376. */
  30377. url: string;
  30378. /**
  30379. * Defines if mipmap should not be generated (default is false)
  30380. */
  30381. noMipmap?: boolean | undefined;
  30382. /**
  30383. * Defines if texture must be inverted on Y axis (default is false)
  30384. */
  30385. invertY?: boolean | undefined;
  30386. /**
  30387. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30388. */
  30389. samplingMode: number;
  30390. /**
  30391. * Gets the loaded texture
  30392. */
  30393. texture: Texture;
  30394. /**
  30395. * Callback called when the task is successful
  30396. */
  30397. onSuccess: (task: TextureAssetTask) => void;
  30398. /**
  30399. * Callback called when the task is successful
  30400. */
  30401. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  30402. /**
  30403. * Creates a new TextureAssetTask object
  30404. * @param name defines the name of the task
  30405. * @param url defines the location of the file to load
  30406. * @param noMipmap defines if mipmap should not be generated (default is false)
  30407. * @param invertY defines if texture must be inverted on Y axis (default is false)
  30408. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30409. */
  30410. constructor(
  30411. /**
  30412. * Defines the name of the task
  30413. */
  30414. name: string,
  30415. /**
  30416. * Defines the location of the file to load
  30417. */
  30418. url: string,
  30419. /**
  30420. * Defines if mipmap should not be generated (default is false)
  30421. */
  30422. noMipmap?: boolean | undefined,
  30423. /**
  30424. * Defines if texture must be inverted on Y axis (default is false)
  30425. */
  30426. invertY?: boolean | undefined,
  30427. /**
  30428. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30429. */
  30430. samplingMode?: number);
  30431. /**
  30432. * Execute the current task
  30433. * @param scene defines the scene where you want your assets to be loaded
  30434. * @param onSuccess is a callback called when the task is successfully executed
  30435. * @param onError is a callback called if an error occurs
  30436. */
  30437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30438. }
  30439. /**
  30440. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  30441. */
  30442. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  30443. /**
  30444. * Defines the name of the task
  30445. */
  30446. name: string;
  30447. /**
  30448. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30449. */
  30450. url: string;
  30451. /**
  30452. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30453. */
  30454. extensions?: string[] | undefined;
  30455. /**
  30456. * Defines if mipmaps should not be generated (default is false)
  30457. */
  30458. noMipmap?: boolean | undefined;
  30459. /**
  30460. * Defines the explicit list of files (undefined by default)
  30461. */
  30462. files?: string[] | undefined;
  30463. /**
  30464. * Gets the loaded texture
  30465. */
  30466. texture: CubeTexture;
  30467. /**
  30468. * Callback called when the task is successful
  30469. */
  30470. onSuccess: (task: CubeTextureAssetTask) => void;
  30471. /**
  30472. * Callback called when the task is successful
  30473. */
  30474. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  30475. /**
  30476. * Creates a new CubeTextureAssetTask
  30477. * @param name defines the name of the task
  30478. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30479. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30480. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30481. * @param files defines the explicit list of files (undefined by default)
  30482. */
  30483. constructor(
  30484. /**
  30485. * Defines the name of the task
  30486. */
  30487. name: string,
  30488. /**
  30489. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30490. */
  30491. url: string,
  30492. /**
  30493. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30494. */
  30495. extensions?: string[] | undefined,
  30496. /**
  30497. * Defines if mipmaps should not be generated (default is false)
  30498. */
  30499. noMipmap?: boolean | undefined,
  30500. /**
  30501. * Defines the explicit list of files (undefined by default)
  30502. */
  30503. files?: string[] | undefined);
  30504. /**
  30505. * Execute the current task
  30506. * @param scene defines the scene where you want your assets to be loaded
  30507. * @param onSuccess is a callback called when the task is successfully executed
  30508. * @param onError is a callback called if an error occurs
  30509. */
  30510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30511. }
  30512. /**
  30513. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  30514. */
  30515. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  30516. /**
  30517. * Defines the name of the task
  30518. */
  30519. name: string;
  30520. /**
  30521. * Defines the location of the file to load
  30522. */
  30523. url: string;
  30524. /**
  30525. * Defines the desired size (the more it increases the longer the generation will be)
  30526. */
  30527. size: number;
  30528. /**
  30529. * Defines if mipmaps should not be generated (default is false)
  30530. */
  30531. noMipmap: boolean;
  30532. /**
  30533. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30534. */
  30535. generateHarmonics: boolean;
  30536. /**
  30537. * 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)
  30538. */
  30539. gammaSpace: boolean;
  30540. /**
  30541. * Internal Use Only
  30542. */
  30543. reserved: boolean;
  30544. /**
  30545. * Gets the loaded texture
  30546. */
  30547. texture: HDRCubeTexture;
  30548. /**
  30549. * Callback called when the task is successful
  30550. */
  30551. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  30552. /**
  30553. * Callback called when the task is successful
  30554. */
  30555. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  30556. /**
  30557. * Creates a new HDRCubeTextureAssetTask object
  30558. * @param name defines the name of the task
  30559. * @param url defines the location of the file to load
  30560. * @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.
  30561. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30562. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30563. * @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)
  30564. * @param reserved Internal use only
  30565. */
  30566. constructor(
  30567. /**
  30568. * Defines the name of the task
  30569. */
  30570. name: string,
  30571. /**
  30572. * Defines the location of the file to load
  30573. */
  30574. url: string,
  30575. /**
  30576. * Defines the desired size (the more it increases the longer the generation will be)
  30577. */
  30578. size: number,
  30579. /**
  30580. * Defines if mipmaps should not be generated (default is false)
  30581. */
  30582. noMipmap?: boolean,
  30583. /**
  30584. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30585. */
  30586. generateHarmonics?: boolean,
  30587. /**
  30588. * 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)
  30589. */
  30590. gammaSpace?: boolean,
  30591. /**
  30592. * Internal Use Only
  30593. */
  30594. reserved?: boolean);
  30595. /**
  30596. * Execute the current task
  30597. * @param scene defines the scene where you want your assets to be loaded
  30598. * @param onSuccess is a callback called when the task is successfully executed
  30599. * @param onError is a callback called if an error occurs
  30600. */
  30601. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30602. }
  30603. /**
  30604. * This class can be used to easily import assets into a scene
  30605. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  30606. */
  30607. class AssetsManager {
  30608. private _scene;
  30609. private _isLoading;
  30610. protected _tasks: AbstractAssetTask[];
  30611. protected _waitingTasksCount: number;
  30612. protected _totalTasksCount: number;
  30613. /**
  30614. * Callback called when all tasks are processed
  30615. */
  30616. onFinish: (tasks: AbstractAssetTask[]) => void;
  30617. /**
  30618. * Callback called when a task is successful
  30619. */
  30620. onTaskSuccess: (task: AbstractAssetTask) => void;
  30621. /**
  30622. * Callback called when a task had an error
  30623. */
  30624. onTaskError: (task: AbstractAssetTask) => void;
  30625. /**
  30626. * Callback called when a task is done (whatever the result is)
  30627. */
  30628. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  30629. /**
  30630. * Observable called when all tasks are processed
  30631. */
  30632. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  30633. /**
  30634. * Observable called when a task had an error
  30635. */
  30636. onTaskErrorObservable: Observable<AbstractAssetTask>;
  30637. /**
  30638. * Observable called when a task is successful
  30639. */
  30640. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  30641. /**
  30642. * Observable called when a task is done (whatever the result is)
  30643. */
  30644. onProgressObservable: Observable<IAssetsProgressEvent>;
  30645. /**
  30646. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  30647. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30648. */
  30649. useDefaultLoadingScreen: boolean;
  30650. /**
  30651. * Creates a new AssetsManager
  30652. * @param scene defines the scene to work on
  30653. */
  30654. constructor(scene: Scene);
  30655. /**
  30656. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  30657. * @param taskName defines the name of the new task
  30658. * @param meshesNames defines the name of meshes to load
  30659. * @param rootUrl defines the root url to use to locate files
  30660. * @param sceneFilename defines the filename of the scene file
  30661. * @returns a new {BABYLON.MeshAssetTask} object
  30662. */
  30663. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  30664. /**
  30665. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  30666. * @param taskName defines the name of the new task
  30667. * @param url defines the url of the file to load
  30668. * @returns a new {BABYLON.TextFileAssetTask} object
  30669. */
  30670. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  30671. /**
  30672. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  30673. * @param taskName defines the name of the new task
  30674. * @param url defines the url of the file to load
  30675. * @returns a new {BABYLON.BinaryFileAssetTask} object
  30676. */
  30677. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  30678. /**
  30679. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  30680. * @param taskName defines the name of the new task
  30681. * @param url defines the url of the file to load
  30682. * @returns a new {BABYLON.ImageAssetTask} object
  30683. */
  30684. addImageTask(taskName: string, url: string): ImageAssetTask;
  30685. /**
  30686. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  30687. * @param taskName defines the name of the new task
  30688. * @param url defines the url of the file to load
  30689. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30690. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  30691. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  30692. * @returns a new {BABYLON.TextureAssetTask} object
  30693. */
  30694. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  30695. /**
  30696. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  30697. * @param taskName defines the name of the new task
  30698. * @param url defines the url of the file to load
  30699. * @param extensions defines the extension to use to load the cube map (can be null)
  30700. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30701. * @param files defines the list of files to load (can be null)
  30702. * @returns a new {BABYLON.CubeTextureAssetTask} object
  30703. */
  30704. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  30705. /**
  30706. *
  30707. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  30708. * @param taskName defines the name of the new task
  30709. * @param url defines the url of the file to load
  30710. * @param size defines the size you want for the cubemap (can be null)
  30711. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30712. * @param generateHarmonics defines if you want to automatically generate (true by default)
  30713. * @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)
  30714. * @param reserved Internal use only
  30715. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  30716. */
  30717. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  30718. /**
  30719. * Remove a task from the assets manager.
  30720. * @param task the task to remove
  30721. */
  30722. removeTask(task: AbstractAssetTask): void;
  30723. private _decreaseWaitingTasksCount;
  30724. private _runTask;
  30725. /**
  30726. * Reset the {BABYLON.AssetsManager} and remove all tasks
  30727. * @return the current instance of the {BABYLON.AssetsManager}
  30728. */
  30729. reset(): AssetsManager;
  30730. /**
  30731. * Start the loading process
  30732. * @return the current instance of the {BABYLON.AssetsManager}
  30733. */
  30734. load(): AssetsManager;
  30735. }
  30736. }
  30737. declare module BABYLON {
  30738. /**
  30739. * Class used to enable access to IndexedDB
  30740. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  30741. */
  30742. class Database {
  30743. private callbackManifestChecked;
  30744. private currentSceneUrl;
  30745. private db;
  30746. private _enableSceneOffline;
  30747. private _enableTexturesOffline;
  30748. private manifestVersionFound;
  30749. private mustUpdateRessources;
  30750. private hasReachedQuota;
  30751. private isSupported;
  30752. private idbFactory;
  30753. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30754. static IsUASupportingBlobStorage: boolean;
  30755. /** Gets a boolean indicating if Database storate is enabled */
  30756. static IDBStorageEnabled: boolean;
  30757. /**
  30758. * Gets a boolean indicating if scene must be saved in the database
  30759. */
  30760. readonly enableSceneOffline: boolean;
  30761. /**
  30762. * Gets a boolean indicating if textures must be saved in the database
  30763. */
  30764. readonly enableTexturesOffline: boolean;
  30765. /**
  30766. * Creates a new Database
  30767. * @param urlToScene defines the url to load the scene
  30768. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30769. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30770. */
  30771. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30772. private static _ParseURL;
  30773. private static _ReturnFullUrlLocation;
  30774. private _checkManifestFile;
  30775. /**
  30776. * Open the database and make it available
  30777. * @param successCallback defines the callback to call on success
  30778. * @param errorCallback defines the callback to call on error
  30779. */
  30780. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30781. /**
  30782. * Loads an image from the database
  30783. * @param url defines the url to load from
  30784. * @param image defines the target DOM image
  30785. */
  30786. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30787. private _loadImageFromDBAsync;
  30788. private _saveImageIntoDBAsync;
  30789. private _checkVersionFromDB;
  30790. private _loadVersionFromDBAsync;
  30791. private _saveVersionIntoDBAsync;
  30792. /**
  30793. * Loads a file from database
  30794. * @param url defines the URL to load from
  30795. * @param sceneLoaded defines a callback to call on success
  30796. * @param progressCallBack defines a callback to call when progress changed
  30797. * @param errorCallback defines a callback to call on error
  30798. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30799. */
  30800. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30801. private _loadFileFromDBAsync;
  30802. private _saveFileIntoDBAsync;
  30803. }
  30804. }
  30805. declare module BABYLON {
  30806. interface DDSInfo {
  30807. width: number;
  30808. height: number;
  30809. mipmapCount: number;
  30810. isFourCC: boolean;
  30811. isRGB: boolean;
  30812. isLuminance: boolean;
  30813. isCube: boolean;
  30814. isCompressed: boolean;
  30815. dxgiFormat: number;
  30816. textureType: number;
  30817. /** Sphericle polynomial created for the dds texture */
  30818. sphericalPolynomial?: SphericalPolynomial;
  30819. }
  30820. class DDSTools {
  30821. static StoreLODInAlphaChannel: boolean;
  30822. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30823. private static _FloatView;
  30824. private static _Int32View;
  30825. private static _ToHalfFloat;
  30826. private static _FromHalfFloat;
  30827. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30828. private static _GetHalfFloatRGBAArrayBuffer;
  30829. private static _GetFloatRGBAArrayBuffer;
  30830. private static _GetFloatAsUIntRGBAArrayBuffer;
  30831. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30832. private static _GetRGBAArrayBuffer;
  30833. private static _ExtractLongWordOrder;
  30834. private static _GetRGBArrayBuffer;
  30835. private static _GetLuminanceArrayBuffer;
  30836. /**
  30837. * Uploads DDS Levels to a Babylon Texture
  30838. * @hidden
  30839. */
  30840. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30841. }
  30842. }
  30843. declare module BABYLON {
  30844. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30845. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30846. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30847. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30848. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30849. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30850. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30851. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30852. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30853. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30854. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30855. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30856. /**
  30857. * Decorator used to define property that can be serialized as reference to a camera
  30858. * @param sourceName defines the name of the property to decorate
  30859. */
  30860. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30861. class SerializationHelper {
  30862. static Serialize<T>(entity: T, serializationObject?: any): any;
  30863. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30864. static Clone<T>(creationFunction: () => T, source: T): T;
  30865. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30866. }
  30867. }
  30868. declare module BABYLON {
  30869. /**
  30870. * Wrapper class for promise with external resolve and reject.
  30871. */
  30872. class Deferred<T> {
  30873. /**
  30874. * The promise associated with this deferred object.
  30875. */
  30876. readonly promise: Promise<T>;
  30877. private _resolve;
  30878. private _reject;
  30879. /**
  30880. * The resolve method of the promise associated with this deferred object.
  30881. */
  30882. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30883. /**
  30884. * The reject method of the promise associated with this deferred object.
  30885. */
  30886. readonly reject: (reason?: any) => void;
  30887. /**
  30888. * Constructor for this deferred object.
  30889. */
  30890. constructor();
  30891. }
  30892. }
  30893. declare module BABYLON {
  30894. /**
  30895. * Raw texture data and descriptor sufficient for WebGL texture upload
  30896. */
  30897. interface EnvironmentTextureInfo {
  30898. /**
  30899. * Version of the environment map
  30900. */
  30901. version: number;
  30902. /**
  30903. * Width of image
  30904. */
  30905. width: number;
  30906. /**
  30907. * Irradiance information stored in the file.
  30908. */
  30909. irradiance: any;
  30910. /**
  30911. * Specular information stored in the file.
  30912. */
  30913. specular: any;
  30914. }
  30915. /**
  30916. * Sets of helpers addressing the serialization and deserialization of environment texture
  30917. * stored in a BabylonJS env file.
  30918. * Those files are usually stored as .env files.
  30919. */
  30920. class EnvironmentTextureTools {
  30921. /**
  30922. * Magic number identifying the env file.
  30923. */
  30924. private static _MagicBytes;
  30925. /**
  30926. * Gets the environment info from an env file.
  30927. * @param data The array buffer containing the .env bytes.
  30928. * @returns the environment file info (the json header) if successfully parsed.
  30929. */
  30930. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30931. /**
  30932. * Creates an environment texture from a loaded cube texture.
  30933. * @param texture defines the cube texture to convert in env file
  30934. * @return a promise containing the environment data if succesfull.
  30935. */
  30936. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30937. /**
  30938. * Creates a JSON representation of the spherical data.
  30939. * @param texture defines the texture containing the polynomials
  30940. * @return the JSON representation of the spherical info
  30941. */
  30942. private static _CreateEnvTextureIrradiance;
  30943. /**
  30944. * Uploads the texture info contained in the env file to the GPU.
  30945. * @param texture defines the internal texture to upload to
  30946. * @param arrayBuffer defines the buffer cotaining the data to load
  30947. * @param info defines the texture info retrieved through the GetEnvInfo method
  30948. * @returns a promise
  30949. */
  30950. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30951. /**
  30952. * Uploads the levels of image data to the GPU.
  30953. * @param texture defines the internal texture to upload to
  30954. * @param imageData defines the array buffer views of image data [mipmap][face]
  30955. * @returns a promise
  30956. */
  30957. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30958. /**
  30959. * Uploads spherical polynomials information to the texture.
  30960. * @param texture defines the texture we are trying to upload the information to
  30961. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30962. */
  30963. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30964. }
  30965. }
  30966. declare module BABYLON {
  30967. class FilesInput {
  30968. static FilesToLoad: {
  30969. [key: string]: File;
  30970. };
  30971. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30972. private _engine;
  30973. private _currentScene;
  30974. private _sceneLoadedCallback;
  30975. private _progressCallback;
  30976. private _additionalRenderLoopLogicCallback;
  30977. private _textureLoadingCallback;
  30978. private _startingProcessingFilesCallback;
  30979. private _onReloadCallback;
  30980. private _errorCallback;
  30981. private _elementToMonitor;
  30982. private _sceneFileToLoad;
  30983. private _filesToLoad;
  30984. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  30985. private _dragEnterHandler;
  30986. private _dragOverHandler;
  30987. private _dropHandler;
  30988. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30989. dispose(): void;
  30990. private renderFunction;
  30991. private drag;
  30992. private drop;
  30993. private _traverseFolder;
  30994. private _processFiles;
  30995. loadFiles(event: any): void;
  30996. private _processReload;
  30997. reload(): void;
  30998. }
  30999. }
  31000. declare module BABYLON {
  31001. /**
  31002. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31003. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31004. */
  31005. class KhronosTextureContainer {
  31006. arrayBuffer: any;
  31007. static HEADER_LEN: number;
  31008. static COMPRESSED_2D: number;
  31009. static COMPRESSED_3D: number;
  31010. static TEX_2D: number;
  31011. static TEX_3D: number;
  31012. glType: number;
  31013. glTypeSize: number;
  31014. glFormat: number;
  31015. glInternalFormat: number;
  31016. glBaseInternalFormat: number;
  31017. pixelWidth: number;
  31018. pixelHeight: number;
  31019. pixelDepth: number;
  31020. numberOfArrayElements: number;
  31021. numberOfFaces: number;
  31022. numberOfMipmapLevels: number;
  31023. bytesOfKeyValueData: number;
  31024. loadType: number;
  31025. /**
  31026. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  31027. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  31028. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  31029. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  31030. */
  31031. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  31032. switchEndainness(val: number): number;
  31033. /**
  31034. * Uploads KTX content to a Babylon Texture.
  31035. * It is assumed that the texture has already been created & is currently bound
  31036. * @hidden
  31037. */
  31038. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  31039. private _upload2DCompressedLevels;
  31040. }
  31041. }
  31042. declare module BABYLON {
  31043. /**
  31044. * A class serves as a medium between the observable and its observers
  31045. */
  31046. class EventState {
  31047. /**
  31048. * Create a new EventState
  31049. * @param mask defines the mask associated with this state
  31050. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  31051. * @param target defines the original target of the state
  31052. * @param currentTarget defines the current target of the state
  31053. */
  31054. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  31055. /**
  31056. * Initialize the current event state
  31057. * @param mask defines the mask associated with this state
  31058. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  31059. * @param target defines the original target of the state
  31060. * @param currentTarget defines the current target of the state
  31061. * @returns the current event state
  31062. */
  31063. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  31064. /**
  31065. * An Observer can set this property to true to prevent subsequent observers of being notified
  31066. */
  31067. skipNextObservers: boolean;
  31068. /**
  31069. * Get the mask value that were used to trigger the event corresponding to this EventState object
  31070. */
  31071. mask: number;
  31072. /**
  31073. * The object that originally notified the event
  31074. */
  31075. target?: any;
  31076. /**
  31077. * The current object in the bubbling phase
  31078. */
  31079. currentTarget?: any;
  31080. /**
  31081. * This will be populated with the return value of the last function that was executed.
  31082. * If it is the first function in the callback chain it will be the event data.
  31083. */
  31084. lastReturnValue?: any;
  31085. }
  31086. /**
  31087. * Represent an Observer registered to a given Observable object.
  31088. */
  31089. class Observer<T> {
  31090. /**
  31091. * Defines the callback to call when the observer is notified
  31092. */
  31093. callback: (eventData: T, eventState: EventState) => void;
  31094. /**
  31095. * Defines the mask of the observer (used to filter notifications)
  31096. */
  31097. mask: number;
  31098. /**
  31099. * Defines the current scope used to restore the JS context
  31100. */
  31101. scope: any;
  31102. /** @hidden */
  31103. _willBeUnregistered: boolean;
  31104. /**
  31105. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  31106. */
  31107. unregisterOnNextCall: boolean;
  31108. /**
  31109. * Creates a new observer
  31110. * @param callback defines the callback to call when the observer is notified
  31111. * @param mask defines the mask of the observer (used to filter notifications)
  31112. * @param scope defines the current scope used to restore the JS context
  31113. */
  31114. constructor(
  31115. /**
  31116. * Defines the callback to call when the observer is notified
  31117. */
  31118. callback: (eventData: T, eventState: EventState) => void,
  31119. /**
  31120. * Defines the mask of the observer (used to filter notifications)
  31121. */
  31122. mask: number,
  31123. /**
  31124. * Defines the current scope used to restore the JS context
  31125. */
  31126. scope?: any);
  31127. }
  31128. /**
  31129. * Represent a list of observers registered to multiple Observables object.
  31130. */
  31131. class MultiObserver<T> {
  31132. private _observers;
  31133. private _observables;
  31134. /**
  31135. * Release associated resources
  31136. */
  31137. dispose(): void;
  31138. /**
  31139. * Raise a callback when one of the observable will notify
  31140. * @param observables defines a list of observables to watch
  31141. * @param callback defines the callback to call on notification
  31142. * @param mask defines the mask used to filter notifications
  31143. * @param scope defines the current scope used to restore the JS context
  31144. * @returns the new MultiObserver
  31145. */
  31146. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  31147. }
  31148. /**
  31149. * The Observable class is a simple implementation of the Observable pattern.
  31150. *
  31151. * 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.
  31152. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  31153. * 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).
  31154. * 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.
  31155. */
  31156. class Observable<T> {
  31157. private _observers;
  31158. private _eventState;
  31159. private _onObserverAdded;
  31160. /**
  31161. * Creates a new observable
  31162. * @param onObserverAdded defines a callback to call when a new observer is added
  31163. */
  31164. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  31165. /**
  31166. * Create a new Observer with the specified callback
  31167. * @param callback the callback that will be executed for that Observer
  31168. * @param mask the mask used to filter observers
  31169. * @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.
  31170. * @param scope optional scope for the callback to be called from
  31171. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  31172. * @returns the new observer created for the callback
  31173. */
  31174. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  31175. /**
  31176. * Create a new Observer with the specified callback and unregisters after the next notification
  31177. * @param callback the callback that will be executed for that Observer
  31178. * @returns the new observer created for the callback
  31179. */
  31180. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  31181. /**
  31182. * Remove an Observer from the Observable object
  31183. * @param observer the instance of the Observer to remove
  31184. * @returns false if it doesn't belong to this Observable
  31185. */
  31186. remove(observer: Nullable<Observer<T>>): boolean;
  31187. /**
  31188. * Remove a callback from the Observable object
  31189. * @param callback the callback to remove
  31190. * @param scope optional scope. If used only the callbacks with this scope will be removed
  31191. * @returns false if it doesn't belong to this Observable
  31192. */
  31193. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  31194. private _deferUnregister;
  31195. private _remove;
  31196. /**
  31197. * Notify all Observers by calling their respective callback with the given data
  31198. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  31199. * @param eventData defines the data to send to all observers
  31200. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  31201. * @param target defines the original target of the state
  31202. * @param currentTarget defines the current target of the state
  31203. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  31204. */
  31205. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  31206. /**
  31207. * Calling this will execute each callback, expecting it to be a promise or return a value.
  31208. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  31209. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  31210. * and it is crucial that all callbacks will be executed.
  31211. * The order of the callbacks is kept, callbacks are not executed parallel.
  31212. *
  31213. * @param eventData The data to be sent to each callback
  31214. * @param mask is used to filter observers defaults to -1
  31215. * @param target defines the callback target (see EventState)
  31216. * @param currentTarget defines he current object in the bubbling phase
  31217. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  31218. */
  31219. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  31220. /**
  31221. * Notify a specific observer
  31222. * @param observer defines the observer to notify
  31223. * @param eventData defines the data to be sent to each callback
  31224. * @param mask is used to filter observers defaults to -1
  31225. */
  31226. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  31227. /**
  31228. * Gets a boolean indicating if the observable has at least one observer
  31229. * @returns true is the Observable has at least one Observer registered
  31230. */
  31231. hasObservers(): boolean;
  31232. /**
  31233. * Clear the list of observers
  31234. */
  31235. clear(): void;
  31236. /**
  31237. * Clone the current observable
  31238. * @returns a new observable
  31239. */
  31240. clone(): Observable<T>;
  31241. /**
  31242. * Does this observable handles observer registered with a given mask
  31243. * @param mask defines the mask to be tested
  31244. * @return whether or not one observer registered with the given mask is handeled
  31245. **/
  31246. hasSpecificMask(mask?: number): boolean;
  31247. }
  31248. }
  31249. declare module BABYLON {
  31250. /**
  31251. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31252. */
  31253. class PerformanceMonitor {
  31254. private _enabled;
  31255. private _rollingFrameTime;
  31256. private _lastFrameTimeMs;
  31257. /**
  31258. * constructor
  31259. * @param frameSampleSize The number of samples required to saturate the sliding window
  31260. */
  31261. constructor(frameSampleSize?: number);
  31262. /**
  31263. * Samples current frame
  31264. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31265. */
  31266. sampleFrame(timeMs?: number): void;
  31267. /**
  31268. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31269. * @return Average frame time in milliseconds
  31270. */
  31271. readonly averageFrameTime: number;
  31272. /**
  31273. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31274. * @return Frame time variance in milliseconds squared
  31275. */
  31276. readonly averageFrameTimeVariance: number;
  31277. /**
  31278. * Returns the frame time of the most recent frame
  31279. * @return Frame time in milliseconds
  31280. */
  31281. readonly instantaneousFrameTime: number;
  31282. /**
  31283. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31284. * @return Framerate in frames per second
  31285. */
  31286. readonly averageFPS: number;
  31287. /**
  31288. * Returns the average framerate in frames per second using the most recent frame time
  31289. * @return Framerate in frames per second
  31290. */
  31291. readonly instantaneousFPS: number;
  31292. /**
  31293. * Returns true if enough samples have been taken to completely fill the sliding window
  31294. * @return true if saturated
  31295. */
  31296. readonly isSaturated: boolean;
  31297. /**
  31298. * Enables contributions to the sliding window sample set
  31299. */
  31300. enable(): void;
  31301. /**
  31302. * Disables contributions to the sliding window sample set
  31303. * Samples will not be interpolated over the disabled period
  31304. */
  31305. disable(): void;
  31306. /**
  31307. * Returns true if sampling is enabled
  31308. * @return true if enabled
  31309. */
  31310. readonly isEnabled: boolean;
  31311. /**
  31312. * Resets performance monitor
  31313. */
  31314. reset(): void;
  31315. }
  31316. /**
  31317. * RollingAverage
  31318. *
  31319. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31320. */
  31321. class RollingAverage {
  31322. /**
  31323. * Current average
  31324. */
  31325. average: number;
  31326. /**
  31327. * Current variance
  31328. */
  31329. variance: number;
  31330. protected _samples: Array<number>;
  31331. protected _sampleCount: number;
  31332. protected _pos: number;
  31333. protected _m2: number;
  31334. /**
  31335. * constructor
  31336. * @param length The number of samples required to saturate the sliding window
  31337. */
  31338. constructor(length: number);
  31339. /**
  31340. * Adds a sample to the sample set
  31341. * @param v The sample value
  31342. */
  31343. add(v: number): void;
  31344. /**
  31345. * Returns previously added values or null if outside of history or outside the sliding window domain
  31346. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31347. * @return Value previously recorded with add() or null if outside of range
  31348. */
  31349. history(i: number): number;
  31350. /**
  31351. * Returns true if enough samples have been taken to completely fill the sliding window
  31352. * @return true if sample-set saturated
  31353. */
  31354. isSaturated(): boolean;
  31355. /**
  31356. * Resets the rolling average (equivalent to 0 samples taken so far)
  31357. */
  31358. reset(): void;
  31359. /**
  31360. * Wraps a value around the sample range boundaries
  31361. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31362. * @return Wrapped position in sample range
  31363. */
  31364. protected _wrapPosition(i: number): number;
  31365. }
  31366. }
  31367. declare module BABYLON {
  31368. /**
  31369. * Helper class that provides a small promise polyfill
  31370. */
  31371. class PromisePolyfill {
  31372. /**
  31373. * Static function used to check if the polyfill is required
  31374. * If this is the case then the function will inject the polyfill to window.Promise
  31375. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31376. */
  31377. static Apply(force?: boolean): void;
  31378. }
  31379. }
  31380. declare module BABYLON {
  31381. /**
  31382. * Defines the root class used to create scene optimization to use with SceneOptimizer
  31383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31384. */
  31385. class SceneOptimization {
  31386. /**
  31387. * Defines the priority of this optimization (0 by default which means first in the list)
  31388. */
  31389. priority: number;
  31390. /**
  31391. * Gets a string describing the action executed by the current optimization
  31392. * @returns description string
  31393. */
  31394. getDescription(): string;
  31395. /**
  31396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31397. * @param scene defines the current scene where to apply this optimization
  31398. * @param optimizer defines the current optimizer
  31399. * @returns true if everything that can be done was applied
  31400. */
  31401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31402. /**
  31403. * Creates the SceneOptimization object
  31404. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31405. * @param desc defines the description associated with the optimization
  31406. */
  31407. constructor(
  31408. /**
  31409. * Defines the priority of this optimization (0 by default which means first in the list)
  31410. */
  31411. priority?: number);
  31412. }
  31413. /**
  31414. * Defines an optimization used to reduce the size of render target textures
  31415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31416. */
  31417. class TextureOptimization extends SceneOptimization {
  31418. /**
  31419. * Defines the priority of this optimization (0 by default which means first in the list)
  31420. */
  31421. priority: number;
  31422. /**
  31423. * 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
  31424. */
  31425. maximumSize: number;
  31426. /**
  31427. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31428. */
  31429. step: number;
  31430. /**
  31431. * Gets a string describing the action executed by the current optimization
  31432. * @returns description string
  31433. */
  31434. getDescription(): string;
  31435. /**
  31436. * Creates the TextureOptimization object
  31437. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31438. * @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
  31439. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31440. */
  31441. constructor(
  31442. /**
  31443. * Defines the priority of this optimization (0 by default which means first in the list)
  31444. */
  31445. priority?: number,
  31446. /**
  31447. * 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
  31448. */
  31449. maximumSize?: number,
  31450. /**
  31451. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31452. */
  31453. step?: number);
  31454. /**
  31455. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31456. * @param scene defines the current scene where to apply this optimization
  31457. * @param optimizer defines the current optimizer
  31458. * @returns true if everything that can be done was applied
  31459. */
  31460. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31461. }
  31462. /**
  31463. * Defines an optimization used to increase or decrease the rendering resolution
  31464. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31465. */
  31466. class HardwareScalingOptimization extends SceneOptimization {
  31467. /**
  31468. * Defines the priority of this optimization (0 by default which means first in the list)
  31469. */
  31470. priority: number;
  31471. /**
  31472. * Defines the maximum scale to use (2 by default)
  31473. */
  31474. maximumScale: number;
  31475. /**
  31476. * Defines the step to use between two passes (0.5 by default)
  31477. */
  31478. step: number;
  31479. private _currentScale;
  31480. private _directionOffset;
  31481. /**
  31482. * Gets a string describing the action executed by the current optimization
  31483. * @return description string
  31484. */
  31485. getDescription(): string;
  31486. /**
  31487. * Creates the HardwareScalingOptimization object
  31488. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31489. * @param maximumScale defines the maximum scale to use (2 by default)
  31490. * @param step defines the step to use between two passes (0.5 by default)
  31491. */
  31492. constructor(
  31493. /**
  31494. * Defines the priority of this optimization (0 by default which means first in the list)
  31495. */
  31496. priority?: number,
  31497. /**
  31498. * Defines the maximum scale to use (2 by default)
  31499. */
  31500. maximumScale?: number,
  31501. /**
  31502. * Defines the step to use between two passes (0.5 by default)
  31503. */
  31504. step?: number);
  31505. /**
  31506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31507. * @param scene defines the current scene where to apply this optimization
  31508. * @param optimizer defines the current optimizer
  31509. * @returns true if everything that can be done was applied
  31510. */
  31511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31512. }
  31513. /**
  31514. * Defines an optimization used to remove shadows
  31515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31516. */
  31517. class ShadowsOptimization extends SceneOptimization {
  31518. /**
  31519. * Gets a string describing the action executed by the current optimization
  31520. * @return description string
  31521. */
  31522. getDescription(): string;
  31523. /**
  31524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31525. * @param scene defines the current scene where to apply this optimization
  31526. * @param optimizer defines the current optimizer
  31527. * @returns true if everything that can be done was applied
  31528. */
  31529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31530. }
  31531. /**
  31532. * Defines an optimization used to turn post-processes off
  31533. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31534. */
  31535. class PostProcessesOptimization extends SceneOptimization {
  31536. /**
  31537. * Gets a string describing the action executed by the current optimization
  31538. * @return description string
  31539. */
  31540. getDescription(): string;
  31541. /**
  31542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31543. * @param scene defines the current scene where to apply this optimization
  31544. * @param optimizer defines the current optimizer
  31545. * @returns true if everything that can be done was applied
  31546. */
  31547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31548. }
  31549. /**
  31550. * Defines an optimization used to turn lens flares off
  31551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31552. */
  31553. class LensFlaresOptimization extends SceneOptimization {
  31554. /**
  31555. * Gets a string describing the action executed by the current optimization
  31556. * @return description string
  31557. */
  31558. getDescription(): string;
  31559. /**
  31560. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31561. * @param scene defines the current scene where to apply this optimization
  31562. * @param optimizer defines the current optimizer
  31563. * @returns true if everything that can be done was applied
  31564. */
  31565. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31566. }
  31567. /**
  31568. * Defines an optimization based on user defined callback.
  31569. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31570. */
  31571. class CustomOptimization extends SceneOptimization {
  31572. /**
  31573. * Callback called to apply the custom optimization.
  31574. */
  31575. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  31576. /**
  31577. * Callback called to get custom description
  31578. */
  31579. onGetDescription: () => string;
  31580. /**
  31581. * Gets a string describing the action executed by the current optimization
  31582. * @returns description string
  31583. */
  31584. getDescription(): string;
  31585. /**
  31586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31587. * @param scene defines the current scene where to apply this optimization
  31588. * @param optimizer defines the current optimizer
  31589. * @returns true if everything that can be done was applied
  31590. */
  31591. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31592. }
  31593. /**
  31594. * Defines an optimization used to turn particles off
  31595. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31596. */
  31597. class ParticlesOptimization extends SceneOptimization {
  31598. /**
  31599. * Gets a string describing the action executed by the current optimization
  31600. * @return description string
  31601. */
  31602. getDescription(): string;
  31603. /**
  31604. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31605. * @param scene defines the current scene where to apply this optimization
  31606. * @param optimizer defines the current optimizer
  31607. * @returns true if everything that can be done was applied
  31608. */
  31609. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31610. }
  31611. /**
  31612. * Defines an optimization used to turn render targets off
  31613. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31614. */
  31615. class RenderTargetsOptimization extends SceneOptimization {
  31616. /**
  31617. * Gets a string describing the action executed by the current optimization
  31618. * @return description string
  31619. */
  31620. getDescription(): string;
  31621. /**
  31622. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31623. * @param scene defines the current scene where to apply this optimization
  31624. * @param optimizer defines the current optimizer
  31625. * @returns true if everything that can be done was applied
  31626. */
  31627. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31628. }
  31629. /**
  31630. * Defines an optimization used to merge meshes with compatible materials
  31631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31632. */
  31633. class MergeMeshesOptimization extends SceneOptimization {
  31634. private static _UpdateSelectionTree;
  31635. /**
  31636. * Gets or sets a boolean which defines if optimization octree has to be updated
  31637. */
  31638. /**
  31639. * Gets or sets a boolean which defines if optimization octree has to be updated
  31640. */
  31641. static UpdateSelectionTree: boolean;
  31642. /**
  31643. * Gets a string describing the action executed by the current optimization
  31644. * @return description string
  31645. */
  31646. getDescription(): string;
  31647. private _canBeMerged;
  31648. /**
  31649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31650. * @param scene defines the current scene where to apply this optimization
  31651. * @param optimizer defines the current optimizer
  31652. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  31653. * @returns true if everything that can be done was applied
  31654. */
  31655. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  31656. }
  31657. /**
  31658. * Defines a list of options used by SceneOptimizer
  31659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31660. */
  31661. class SceneOptimizerOptions {
  31662. /**
  31663. * Defines the target frame rate to reach (60 by default)
  31664. */
  31665. targetFrameRate: number;
  31666. /**
  31667. * Defines the interval between two checkes (2000ms by default)
  31668. */
  31669. trackerDuration: number;
  31670. /**
  31671. * Gets the list of optimizations to apply
  31672. */
  31673. optimizations: SceneOptimization[];
  31674. /**
  31675. * Creates a new list of options used by SceneOptimizer
  31676. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  31677. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  31678. */
  31679. constructor(
  31680. /**
  31681. * Defines the target frame rate to reach (60 by default)
  31682. */
  31683. targetFrameRate?: number,
  31684. /**
  31685. * Defines the interval between two checkes (2000ms by default)
  31686. */
  31687. trackerDuration?: number);
  31688. /**
  31689. * Add a new optimization
  31690. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  31691. * @returns the current SceneOptimizerOptions
  31692. */
  31693. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  31694. /**
  31695. * Add a new custom optimization
  31696. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  31697. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  31698. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31699. * @returns the current SceneOptimizerOptions
  31700. */
  31701. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  31702. /**
  31703. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  31704. * @param targetFrameRate defines the target frame rate (60 by default)
  31705. * @returns a SceneOptimizerOptions object
  31706. */
  31707. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31708. /**
  31709. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  31710. * @param targetFrameRate defines the target frame rate (60 by default)
  31711. * @returns a SceneOptimizerOptions object
  31712. */
  31713. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31714. /**
  31715. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  31716. * @param targetFrameRate defines the target frame rate (60 by default)
  31717. * @returns a SceneOptimizerOptions object
  31718. */
  31719. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31720. }
  31721. /**
  31722. * Class used to run optimizations in order to reach a target frame rate
  31723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31724. */
  31725. class SceneOptimizer implements IDisposable {
  31726. private _isRunning;
  31727. private _options;
  31728. private _scene;
  31729. private _currentPriorityLevel;
  31730. private _targetFrameRate;
  31731. private _trackerDuration;
  31732. private _currentFrameRate;
  31733. private _sceneDisposeObserver;
  31734. private _improvementMode;
  31735. /**
  31736. * Defines an observable called when the optimizer reaches the target frame rate
  31737. */
  31738. onSuccessObservable: Observable<SceneOptimizer>;
  31739. /**
  31740. * Defines an observable called when the optimizer enables an optimization
  31741. */
  31742. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  31743. /**
  31744. * Defines an observable called when the optimizer is not able to reach the target frame rate
  31745. */
  31746. onFailureObservable: Observable<SceneOptimizer>;
  31747. /**
  31748. * Gets a boolean indicating if the optimizer is in improvement mode
  31749. */
  31750. readonly isInImprovementMode: boolean;
  31751. /**
  31752. * Gets the current priority level (0 at start)
  31753. */
  31754. readonly currentPriorityLevel: number;
  31755. /**
  31756. * Gets the current frame rate checked by the SceneOptimizer
  31757. */
  31758. readonly currentFrameRate: number;
  31759. /**
  31760. * Gets or sets the current target frame rate (60 by default)
  31761. */
  31762. /**
  31763. * Gets or sets the current target frame rate (60 by default)
  31764. */
  31765. targetFrameRate: number;
  31766. /**
  31767. * Gets or sets the current interval between two checks (every 2000ms by default)
  31768. */
  31769. /**
  31770. * Gets or sets the current interval between two checks (every 2000ms by default)
  31771. */
  31772. trackerDuration: number;
  31773. /**
  31774. * Gets the list of active optimizations
  31775. */
  31776. readonly optimizations: SceneOptimization[];
  31777. /**
  31778. * Creates a new SceneOptimizer
  31779. * @param scene defines the scene to work on
  31780. * @param options defines the options to use with the SceneOptimizer
  31781. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31782. * @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)
  31783. */
  31784. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31785. /**
  31786. * Stops the current optimizer
  31787. */
  31788. stop(): void;
  31789. /**
  31790. * Reset the optimizer to initial step (current priority level = 0)
  31791. */
  31792. reset(): void;
  31793. /**
  31794. * Start the optimizer. By default it will try to reach a specific framerate
  31795. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31796. */
  31797. start(): void;
  31798. private _checkCurrentState;
  31799. /**
  31800. * Release all resources
  31801. */
  31802. dispose(): void;
  31803. /**
  31804. * Helper function to create a SceneOptimizer with one single line of code
  31805. * @param scene defines the scene to work on
  31806. * @param options defines the options to use with the SceneOptimizer
  31807. * @param onSuccess defines a callback to call on success
  31808. * @param onFailure defines a callback to call on failure
  31809. * @returns the new SceneOptimizer object
  31810. */
  31811. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31812. }
  31813. }
  31814. declare module BABYLON {
  31815. class SceneSerializer {
  31816. static ClearCache(): void;
  31817. static Serialize(scene: Scene): any;
  31818. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31819. }
  31820. }
  31821. declare module BABYLON {
  31822. /**
  31823. * Defines an array and its length.
  31824. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  31825. */
  31826. interface ISmartArrayLike<T> {
  31827. /**
  31828. * The data of the array.
  31829. */
  31830. data: Array<T>;
  31831. /**
  31832. * The active length of the array.
  31833. */
  31834. length: number;
  31835. }
  31836. /**
  31837. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  31838. */
  31839. class SmartArray<T> implements ISmartArrayLike<T> {
  31840. /**
  31841. * The full set of data from the array.
  31842. */
  31843. data: Array<T>;
  31844. /**
  31845. * The active length of the array.
  31846. */
  31847. length: number;
  31848. protected _id: number;
  31849. /**
  31850. * Instantiates a Smart Array.
  31851. * @param capacity defines the default capacity of the array.
  31852. */
  31853. constructor(capacity: number);
  31854. /**
  31855. * Pushes a value at the end of the active data.
  31856. * @param value defines the object to push in the array.
  31857. */
  31858. push(value: T): void;
  31859. /**
  31860. * Iterates over the active data and apply the lambda to them.
  31861. * @param func defines the action to apply on each value.
  31862. */
  31863. forEach(func: (content: T) => void): void;
  31864. /**
  31865. * Sorts the full sets of data.
  31866. * @param compareFn defines the comparison function to apply.
  31867. */
  31868. sort(compareFn: (a: T, b: T) => number): void;
  31869. /**
  31870. * Resets the active data to an empty array.
  31871. */
  31872. reset(): void;
  31873. /**
  31874. * Releases all the data from the array as well as the array.
  31875. */
  31876. dispose(): void;
  31877. /**
  31878. * Concats the active data with a given array.
  31879. * @param array defines the data to concatenate with.
  31880. */
  31881. concat(array: any): void;
  31882. /**
  31883. * Returns the position of a value in the active data.
  31884. * @param value defines the value to find the index for
  31885. * @returns the index if found in the active data otherwise -1
  31886. */
  31887. indexOf(value: T): number;
  31888. /**
  31889. * Returns whether an element is part of the active data.
  31890. * @param value defines the value to look for
  31891. * @returns true if found in the active data otherwise false
  31892. */
  31893. contains(value: T): boolean;
  31894. private static _GlobalId;
  31895. }
  31896. /**
  31897. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  31898. * The data in this array can only be present once
  31899. */
  31900. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31901. private _duplicateId;
  31902. /**
  31903. * Pushes a value at the end of the active data.
  31904. * THIS DOES NOT PREVENT DUPPLICATE DATA
  31905. * @param value defines the object to push in the array.
  31906. */
  31907. push(value: T): void;
  31908. /**
  31909. * Pushes a value at the end of the active data.
  31910. * If the data is already present, it won t be added again
  31911. * @param value defines the object to push in the array.
  31912. * @returns true if added false if it was already present
  31913. */
  31914. pushNoDuplicate(value: T): boolean;
  31915. /**
  31916. * Resets the active data to an empty array.
  31917. */
  31918. reset(): void;
  31919. /**
  31920. * Concats the active data with a given array.
  31921. * This ensures no dupplicate will be present in the result.
  31922. * @param array defines the data to concatenate with.
  31923. */
  31924. concatWithNoDuplicate(array: any): void;
  31925. }
  31926. }
  31927. declare module BABYLON {
  31928. /**
  31929. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31930. * The underlying implementation relies on an associative array to ensure the best performances.
  31931. * The value can be anything including 'null' but except 'undefined'
  31932. */
  31933. class StringDictionary<T> {
  31934. /**
  31935. * This will clear this dictionary and copy the content from the 'source' one.
  31936. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31937. * @param source the dictionary to take the content from and copy to this dictionary
  31938. */
  31939. copyFrom(source: StringDictionary<T>): void;
  31940. /**
  31941. * Get a value based from its key
  31942. * @param key the given key to get the matching value from
  31943. * @return the value if found, otherwise undefined is returned
  31944. */
  31945. get(key: string): T | undefined;
  31946. /**
  31947. * Get a value from its key or add it if it doesn't exist.
  31948. * This method will ensure you that a given key/data will be present in the dictionary.
  31949. * @param key the given key to get the matching value from
  31950. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31951. * The factory will only be invoked if there's no data for the given key.
  31952. * @return the value corresponding to the key.
  31953. */
  31954. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31955. /**
  31956. * Get a value from its key if present in the dictionary otherwise add it
  31957. * @param key the key to get the value from
  31958. * @param val if there's no such key/value pair in the dictionary add it with this value
  31959. * @return the value corresponding to the key
  31960. */
  31961. getOrAdd(key: string, val: T): T;
  31962. /**
  31963. * Check if there's a given key in the dictionary
  31964. * @param key the key to check for
  31965. * @return true if the key is present, false otherwise
  31966. */
  31967. contains(key: string): boolean;
  31968. /**
  31969. * Add a new key and its corresponding value
  31970. * @param key the key to add
  31971. * @param value the value corresponding to the key
  31972. * @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
  31973. */
  31974. add(key: string, value: T): boolean;
  31975. set(key: string, value: T): boolean;
  31976. /**
  31977. * Get the element of the given key and remove it from the dictionary
  31978. * @param key
  31979. */
  31980. getAndRemove(key: string): Nullable<T>;
  31981. /**
  31982. * Remove a key/value from the dictionary.
  31983. * @param key the key to remove
  31984. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31985. */
  31986. remove(key: string): boolean;
  31987. /**
  31988. * Clear the whole content of the dictionary
  31989. */
  31990. clear(): void;
  31991. readonly count: number;
  31992. /**
  31993. * Execute a callback on each key/val of the dictionary.
  31994. * Note that you can remove any element in this dictionary in the callback implementation
  31995. * @param callback the callback to execute on a given key/value pair
  31996. */
  31997. forEach(callback: (key: string, val: T) => void): void;
  31998. /**
  31999. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32000. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32001. * Note that you can remove any element in this dictionary in the callback implementation
  32002. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32003. */
  32004. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32005. private _count;
  32006. private _data;
  32007. }
  32008. }
  32009. declare module BABYLON {
  32010. class Tags {
  32011. static EnableFor(obj: any): void;
  32012. static DisableFor(obj: any): void;
  32013. static HasTags(obj: any): boolean;
  32014. static GetTags(obj: any, asString?: boolean): any;
  32015. static AddTagsTo(obj: any, tagsString: string): void;
  32016. static _AddTagTo(obj: any, tag: string): void;
  32017. static RemoveTagsFrom(obj: any, tagsString: string): void;
  32018. static _RemoveTagFrom(obj: any, tag: string): void;
  32019. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  32020. }
  32021. }
  32022. declare module BABYLON {
  32023. class TextureTools {
  32024. /**
  32025. * Uses the GPU to create a copy texture rescaled at a given size
  32026. * @param texture Texture to copy from
  32027. * @param width Desired width
  32028. * @param height Desired height
  32029. * @return Generated texture
  32030. */
  32031. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  32032. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  32033. private static _environmentBRDFBase64Texture;
  32034. }
  32035. }
  32036. declare module BABYLON {
  32037. class TGATools {
  32038. private static _TYPE_INDEXED;
  32039. private static _TYPE_RGB;
  32040. private static _TYPE_GREY;
  32041. private static _TYPE_RLE_INDEXED;
  32042. private static _TYPE_RLE_RGB;
  32043. private static _TYPE_RLE_GREY;
  32044. private static _ORIGIN_MASK;
  32045. private static _ORIGIN_SHIFT;
  32046. private static _ORIGIN_BL;
  32047. private static _ORIGIN_BR;
  32048. private static _ORIGIN_UL;
  32049. private static _ORIGIN_UR;
  32050. static GetTGAHeader(data: Uint8Array): any;
  32051. /**
  32052. * Uploads TGA content to a Babylon Texture
  32053. * @hidden
  32054. */
  32055. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  32056. 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;
  32057. 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;
  32058. 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;
  32059. 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;
  32060. 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;
  32061. 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;
  32062. }
  32063. }
  32064. declare module BABYLON {
  32065. interface IAnimatable {
  32066. animations: Array<Animation>;
  32067. }
  32068. /** Interface used by value gradients (color, factor, ...) */
  32069. interface IValueGradient {
  32070. /**
  32071. * Gets or sets the gradient value (between 0 and 1)
  32072. */
  32073. gradient: number;
  32074. }
  32075. /** Class used to store color gradient */
  32076. class ColorGradient implements IValueGradient {
  32077. /**
  32078. * Gets or sets the gradient value (between 0 and 1)
  32079. */
  32080. gradient: number;
  32081. /**
  32082. * Gets or sets first associated color
  32083. */
  32084. color1: Color4;
  32085. /**
  32086. * Gets or sets second associated color
  32087. */
  32088. color2?: Color4;
  32089. /**
  32090. * Will get a color picked randomly between color1 and color2.
  32091. * If color2 is undefined then color1 will be used
  32092. * @param result defines the target Color4 to store the result in
  32093. */
  32094. getColorToRef(result: Color4): void;
  32095. }
  32096. /** Class used to store factor gradient */
  32097. class FactorGradient implements IValueGradient {
  32098. /**
  32099. * Gets or sets the gradient value (between 0 and 1)
  32100. */
  32101. gradient: number;
  32102. /**
  32103. * Gets or sets first associated factor
  32104. */
  32105. factor1: number;
  32106. /**
  32107. * Gets or sets second associated factor
  32108. */
  32109. factor2?: number;
  32110. /**
  32111. * Will get a number picked randomly between factor1 and factor2.
  32112. * If factor2 is undefined then factor1 will be used
  32113. * @returns the picked number
  32114. */
  32115. getFactor(): number;
  32116. }
  32117. class LoadFileError extends Error {
  32118. request?: XMLHttpRequest | undefined;
  32119. private static _setPrototypeOf;
  32120. constructor(message: string, request?: XMLHttpRequest | undefined);
  32121. }
  32122. class RetryStrategy {
  32123. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32124. }
  32125. interface IFileRequest {
  32126. /**
  32127. * Raised when the request is complete (success or error).
  32128. */
  32129. onCompleteObservable: Observable<IFileRequest>;
  32130. /**
  32131. * Aborts the request for a file.
  32132. */
  32133. abort: () => void;
  32134. }
  32135. class Tools {
  32136. static BaseUrl: string;
  32137. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32138. /**
  32139. * Default behaviour for cors in the application.
  32140. * It can be a string if the expected behavior is identical in the entire app.
  32141. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32142. */
  32143. static CorsBehavior: string | ((url: string | string[]) => string);
  32144. static UseFallbackTexture: boolean;
  32145. /**
  32146. * Use this object to register external classes like custom textures or material
  32147. * to allow the laoders to instantiate them
  32148. */
  32149. static RegisteredExternalClasses: {
  32150. [key: string]: Object;
  32151. };
  32152. static fallbackTexture: string;
  32153. /**
  32154. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32155. * @param u defines the coordinate on X axis
  32156. * @param v defines the coordinate on Y axis
  32157. * @param width defines the width of the source data
  32158. * @param height defines the height of the source data
  32159. * @param pixels defines the source byte array
  32160. * @param color defines the output color
  32161. */
  32162. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32163. /**
  32164. * Interpolates between a and b via alpha
  32165. * @param a The lower value (returned when alpha = 0)
  32166. * @param b The upper value (returned when alpha = 1)
  32167. * @param alpha The interpolation-factor
  32168. * @return The mixed value
  32169. */
  32170. static Mix(a: number, b: number, alpha: number): number;
  32171. static Instantiate(className: string): any;
  32172. /**
  32173. * Provides a slice function that will work even on IE
  32174. * @param data defines the array to slice
  32175. * @param start defines the start of the data (optional)
  32176. * @param end defines the end of the data (optional)
  32177. * @returns the new sliced array
  32178. */
  32179. static Slice<T>(data: T, start?: number, end?: number): T;
  32180. static SetImmediate(action: () => void): void;
  32181. static IsExponentOfTwo(value: number): boolean;
  32182. private static _tmpFloatArray;
  32183. /**
  32184. * Returns the nearest 32-bit single precision float representation of a Number
  32185. * @param value A Number. If the parameter is of a different type, it will get converted
  32186. * to a number or to NaN if it cannot be converted
  32187. * @returns number
  32188. */
  32189. static FloatRound(value: number): number;
  32190. /**
  32191. * Find the next highest power of two.
  32192. * @param x Number to start search from.
  32193. * @return Next highest power of two.
  32194. */
  32195. static CeilingPOT(x: number): number;
  32196. /**
  32197. * Find the next lowest power of two.
  32198. * @param x Number to start search from.
  32199. * @return Next lowest power of two.
  32200. */
  32201. static FloorPOT(x: number): number;
  32202. /**
  32203. * Find the nearest power of two.
  32204. * @param x Number to start search from.
  32205. * @return Next nearest power of two.
  32206. */
  32207. static NearestPOT(x: number): number;
  32208. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32209. static GetFilename(path: string): string;
  32210. /**
  32211. * Extracts the "folder" part of a path (everything before the filename).
  32212. * @param uri The URI to extract the info from
  32213. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32214. * @returns The "folder" part of the path
  32215. */
  32216. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32217. static GetDOMTextContent(element: HTMLElement): string;
  32218. static ToDegrees(angle: number): number;
  32219. static ToRadians(angle: number): number;
  32220. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32221. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32222. minimum: Vector3;
  32223. maximum: Vector3;
  32224. };
  32225. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32226. minimum: Vector3;
  32227. maximum: Vector3;
  32228. };
  32229. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  32230. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  32231. minimum: Vector2;
  32232. maximum: Vector2;
  32233. };
  32234. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32235. static GetPointerPrefix(): string;
  32236. /**
  32237. * @param func - the function to be called
  32238. * @param requester - the object that will request the next frame. Falls back to window.
  32239. */
  32240. static QueueNewFrame(func: () => void, requester?: any): number;
  32241. static RequestFullscreen(element: HTMLElement): void;
  32242. static ExitFullscreen(): void;
  32243. static SetCorsBehavior(url: string | string[], element: {
  32244. crossOrigin: string | null;
  32245. }): void;
  32246. static CleanUrl(url: string): string;
  32247. static PreprocessUrl: (url: string) => string;
  32248. /**
  32249. * Loads an image as an HTMLImageElement.
  32250. * @param input url string, ArrayBuffer, or Blob to load
  32251. * @param onLoad callback called when the image successfully loads
  32252. * @param onError callback called when the image fails to load
  32253. * @param database database for caching
  32254. * @returns the HTMLImageElement of the loaded image
  32255. */
  32256. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  32257. 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;
  32258. /**
  32259. * Load a script (identified by an url). When the url returns, the
  32260. * content of this file is added into a new script element, attached to the DOM (body element)
  32261. */
  32262. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32263. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32264. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32265. static FileAsURL(content: string): string;
  32266. static Format(value: number, decimals?: number): string;
  32267. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32268. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32269. static IsEmpty(obj: any): boolean;
  32270. static RegisterTopRootEvents(events: {
  32271. name: string;
  32272. handler: Nullable<(e: FocusEvent) => any>;
  32273. }[]): void;
  32274. static UnregisterTopRootEvents(events: {
  32275. name: string;
  32276. handler: Nullable<(e: FocusEvent) => any>;
  32277. }[]): void;
  32278. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32279. /**
  32280. * Converts the canvas data to blob.
  32281. * This acts as a polyfill for browsers not supporting the to blob function.
  32282. * @param canvas Defines the canvas to extract the data from
  32283. * @param successCallback Defines the callback triggered once the data are available
  32284. * @param mimeType Defines the mime type of the result
  32285. */
  32286. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32287. /**
  32288. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32289. * @param successCallback Defines the callback triggered once the data are available
  32290. * @param mimeType Defines the mime type of the result
  32291. * @param fileName The filename to download. If present, the result will automatically be downloaded
  32292. */
  32293. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32294. /**
  32295. * Downloads a blob in the browser
  32296. * @param blob defines the blob to download
  32297. * @param fileName defines the name of the downloaded file
  32298. */
  32299. static Download(blob: Blob, fileName: string): void;
  32300. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32301. /**
  32302. * Generates an image screenshot from the specified camera.
  32303. *
  32304. * @param engine The engine to use for rendering
  32305. * @param camera The camera to use for rendering
  32306. * @param size This parameter can be set to a single number or to an object with the
  32307. * following (optional) properties: precision, width, height. If a single number is passed,
  32308. * it will be used for both width and height. If an object is passed, the screenshot size
  32309. * will be derived from the parameters. The precision property is a multiplier allowing
  32310. * rendering at a higher or lower resolution.
  32311. * @param successCallback The callback receives a single parameter which contains the
  32312. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32313. * src parameter of an <img> to display it.
  32314. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32315. * Check your browser for supported MIME types.
  32316. * @param samples Texture samples (default: 1)
  32317. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32318. * @param fileName A name for for the downloaded file.
  32319. * @constructor
  32320. */
  32321. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32322. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  32323. /**
  32324. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32325. * Be aware Math.random() could cause collisions, but:
  32326. * "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"
  32327. */
  32328. static RandomId(): string;
  32329. /**
  32330. * Test if the given uri is a base64 string.
  32331. * @param uri The uri to test
  32332. * @return True if the uri is a base64 string or false otherwise.
  32333. */
  32334. static IsBase64(uri: string): boolean;
  32335. /**
  32336. * Decode the given base64 uri.
  32337. * @param uri The uri to decode
  32338. * @return The decoded base64 data.
  32339. */
  32340. static DecodeBase64(uri: string): ArrayBuffer;
  32341. private static _NoneLogLevel;
  32342. private static _MessageLogLevel;
  32343. private static _WarningLogLevel;
  32344. private static _ErrorLogLevel;
  32345. private static _LogCache;
  32346. static errorsCount: number;
  32347. static OnNewCacheEntry: (entry: string) => void;
  32348. static readonly NoneLogLevel: number;
  32349. static readonly MessageLogLevel: number;
  32350. static readonly WarningLogLevel: number;
  32351. static readonly ErrorLogLevel: number;
  32352. static readonly AllLogLevel: number;
  32353. private static _AddLogEntry;
  32354. private static _FormatMessage;
  32355. private static _LogDisabled;
  32356. private static _LogEnabled;
  32357. private static _WarnDisabled;
  32358. private static _WarnEnabled;
  32359. private static _ErrorDisabled;
  32360. private static _ErrorEnabled;
  32361. static Log: (message: string) => void;
  32362. static Warn: (message: string) => void;
  32363. static Error: (message: string) => void;
  32364. static readonly LogCache: string;
  32365. static ClearLogCache(): void;
  32366. static LogLevels: number;
  32367. /**
  32368. * Check if the loaded document was accessed via `file:`-Protocol.
  32369. * @returns boolean
  32370. */
  32371. static IsFileURL(): boolean;
  32372. static IsWindowObjectExist(): boolean;
  32373. private static _PerformanceNoneLogLevel;
  32374. private static _PerformanceUserMarkLogLevel;
  32375. private static _PerformanceConsoleLogLevel;
  32376. private static _performance;
  32377. static readonly PerformanceNoneLogLevel: number;
  32378. static readonly PerformanceUserMarkLogLevel: number;
  32379. static readonly PerformanceConsoleLogLevel: number;
  32380. static PerformanceLogLevel: number;
  32381. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32382. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32383. static _StartUserMark(counterName: string, condition?: boolean): void;
  32384. static _EndUserMark(counterName: string, condition?: boolean): void;
  32385. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  32386. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  32387. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32388. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32389. static readonly Now: number;
  32390. /**
  32391. * This method will return the name of the class used to create the instance of the given object.
  32392. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32393. * @param object the object to get the class name from
  32394. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  32395. */
  32396. static GetClassName(object: any, isType?: boolean): string;
  32397. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32398. /**
  32399. * This method will return the name of the full name of the class, including its owning module (if any).
  32400. * 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).
  32401. * @param object the object to get the class name from
  32402. * @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.
  32403. */
  32404. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32405. /**
  32406. * 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.
  32407. * @param array
  32408. */
  32409. static arrayOrStringFeeder(array: any): (i: number) => number;
  32410. /**
  32411. * Compute the hashCode of a stream of number
  32412. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  32413. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  32414. * @return the hash code computed
  32415. */
  32416. static hashCodeFromStream(feeder: (index: number) => number): number;
  32417. /**
  32418. * Returns a promise that resolves after the given amount of time.
  32419. * @param delay Number of milliseconds to delay
  32420. * @returns Promise that resolves after the given amount of time
  32421. */
  32422. static DelayAsync(delay: number): Promise<void>;
  32423. /**
  32424. * Gets the current gradient from an array of IValueGradient
  32425. * @param ratio defines the current ratio to get
  32426. * @param gradients defines the array of IValueGradient
  32427. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32428. */
  32429. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32430. }
  32431. /**
  32432. * This class is used to track a performance counter which is number based.
  32433. * The user has access to many properties which give statistics of different nature
  32434. *
  32435. * The implementer can track two kinds of Performance Counter: time and count
  32436. * 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.
  32437. * 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.
  32438. */
  32439. class PerfCounter {
  32440. static Enabled: boolean;
  32441. /**
  32442. * Returns the smallest value ever
  32443. */
  32444. readonly min: number;
  32445. /**
  32446. * Returns the biggest value ever
  32447. */
  32448. readonly max: number;
  32449. /**
  32450. * Returns the average value since the performance counter is running
  32451. */
  32452. readonly average: number;
  32453. /**
  32454. * Returns the average value of the last second the counter was monitored
  32455. */
  32456. readonly lastSecAverage: number;
  32457. /**
  32458. * Returns the current value
  32459. */
  32460. readonly current: number;
  32461. readonly total: number;
  32462. readonly count: number;
  32463. constructor();
  32464. /**
  32465. * Call this method to start monitoring a new frame.
  32466. * 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.
  32467. */
  32468. fetchNewFrame(): void;
  32469. /**
  32470. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32471. * @param newCount the count value to add to the monitored count
  32472. * @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.
  32473. */
  32474. addCount(newCount: number, fetchResult: boolean): void;
  32475. /**
  32476. * Start monitoring this performance counter
  32477. */
  32478. beginMonitoring(): void;
  32479. /**
  32480. * Compute the time lapsed since the previous beginMonitoring() call.
  32481. * @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
  32482. */
  32483. endMonitoring(newFrame?: boolean): void;
  32484. private _fetchResult;
  32485. private _startMonitoringTime;
  32486. private _min;
  32487. private _max;
  32488. private _average;
  32489. private _current;
  32490. private _totalValueCount;
  32491. private _totalAccumulated;
  32492. private _lastSecAverage;
  32493. private _lastSecAccumulated;
  32494. private _lastSecTime;
  32495. private _lastSecValueCount;
  32496. }
  32497. /**
  32498. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32499. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32500. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32501. * @param name The name of the class, case should be preserved
  32502. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32503. */
  32504. function className(name: string, module?: string): (target: Object) => void;
  32505. /**
  32506. * An implementation of a loop for asynchronous functions.
  32507. */
  32508. class AsyncLoop {
  32509. iterations: number;
  32510. private _fn;
  32511. private _successCallback;
  32512. index: number;
  32513. private _done;
  32514. /**
  32515. * Constroctor.
  32516. * @param iterations the number of iterations.
  32517. * @param _fn the function to run each iteration
  32518. * @param _successCallback the callback that will be called upon succesful execution
  32519. * @param offset starting offset.
  32520. */
  32521. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  32522. /**
  32523. * Execute the next iteration. Must be called after the last iteration was finished.
  32524. */
  32525. executeNext(): void;
  32526. /**
  32527. * Break the loop and run the success callback.
  32528. */
  32529. breakLoop(): void;
  32530. /**
  32531. * Helper function
  32532. */
  32533. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  32534. /**
  32535. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32536. * @param iterations total number of iterations
  32537. * @param syncedIterations number of synchronous iterations in each async iteration.
  32538. * @param fn the function to call each iteration.
  32539. * @param callback a success call back that will be called when iterating stops.
  32540. * @param breakFunction a break condition (optional)
  32541. * @param timeout timeout settings for the setTimeout function. default - 0.
  32542. * @constructor
  32543. */
  32544. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  32545. }
  32546. }
  32547. interface HTMLCanvasElement {
  32548. /** Track wether a record is in progress */
  32549. isRecording: boolean;
  32550. /** Capture Stream method defined by some browsers */
  32551. captureStream(fps?: number): MediaStream;
  32552. }
  32553. interface MediaRecorder {
  32554. /** Starts recording */
  32555. start(timeSlice: number): void;
  32556. /** Stops recording */
  32557. stop(): void;
  32558. /** Event raised when an error arised. */
  32559. onerror: (event: ErrorEvent) => void;
  32560. /** Event raised when the recording stops. */
  32561. onstop: (event: Event) => void;
  32562. /** Event raised when a new chunk of data is available and should be tracked. */
  32563. ondataavailable: (event: Event) => void;
  32564. }
  32565. interface MediaRecorderOptions {
  32566. /** The mime type you want to use as the recording container for the new MediaRecorder */
  32567. mimeType?: string;
  32568. /** The chosen bitrate for the audio component of the media. */
  32569. audioBitsPerSecond?: number;
  32570. /** The chosen bitrate for the video component of the media. */
  32571. videoBitsPerSecond?: number;
  32572. /** 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. */
  32573. bitsPerSecond?: number;
  32574. }
  32575. interface MediaRecorderConstructor {
  32576. /**
  32577. * A reference to the prototype.
  32578. */
  32579. readonly prototype: MediaRecorder;
  32580. /**
  32581. * Creates a new MediaRecorder.
  32582. * @param stream Defines the stream to record.
  32583. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  32584. */
  32585. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  32586. }
  32587. /**
  32588. * MediaRecoreder object available in some browsers.
  32589. */
  32590. declare var MediaRecorder: MediaRecorderConstructor;
  32591. declare module BABYLON {
  32592. /**
  32593. * This represents the different options avilable for the video capture.
  32594. */
  32595. interface VideoRecorderOptions {
  32596. /** Defines the mime type of the video */
  32597. mimeType: string;
  32598. /** Defines the video the video should be recorded at */
  32599. fps: number;
  32600. /** Defines the chunk size for the recording data */
  32601. recordChunckSize: number;
  32602. }
  32603. /**
  32604. * This can helps recording videos from BabylonJS.
  32605. * This is based on the available WebRTC functionalities of the browser.
  32606. *
  32607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  32608. */
  32609. class VideoRecorder {
  32610. private static readonly _defaultOptions;
  32611. /**
  32612. * Returns wehther or not the VideoRecorder is available in your browser.
  32613. * @param engine Defines the Babylon Engine to check the support for
  32614. * @returns true if supported otherwise false
  32615. */
  32616. static IsSupported(engine: Engine): boolean;
  32617. private readonly _options;
  32618. private _canvas;
  32619. private _mediaRecorder;
  32620. private _recordedChunks;
  32621. private _fileName;
  32622. private _resolve;
  32623. private _reject;
  32624. /**
  32625. * True wether a recording is already in progress.
  32626. */
  32627. readonly isRecording: boolean;
  32628. /**
  32629. * Create a new VideoCapture object which can help converting what you see in Babylon to
  32630. * a video file.
  32631. * @param engine Defines the BabylonJS Engine you wish to record
  32632. * @param options Defines options that can be used to customized the capture
  32633. */
  32634. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  32635. /**
  32636. * Stops the current recording before the default capture timeout passed in the startRecording
  32637. * functions.
  32638. */
  32639. stopRecording(): void;
  32640. /**
  32641. * Starts recording the canvas for a max duration specified in parameters.
  32642. * @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.
  32643. * @param maxDuration Defines the maximum recording time in seconds.
  32644. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  32645. * @return a promise callback at the end of the recording with the video data in Blob.
  32646. */
  32647. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  32648. /**
  32649. * Releases internal resources used during the recording.
  32650. */
  32651. dispose(): void;
  32652. private _handleDataAvailable;
  32653. private _handleError;
  32654. private _handleStop;
  32655. }
  32656. }
  32657. declare module BABYLON {
  32658. /**
  32659. * Defines the potential axis of a Joystick
  32660. */
  32661. enum JoystickAxis {
  32662. /** X axis */
  32663. X = 0,
  32664. /** Y axis */
  32665. Y = 1,
  32666. /** Z axis */
  32667. Z = 2
  32668. }
  32669. /**
  32670. * Class used to define virtual joystick (used in touch mode)
  32671. */
  32672. class VirtualJoystick {
  32673. /**
  32674. * Gets or sets a boolean indicating that left and right values must be inverted
  32675. */
  32676. reverseLeftRight: boolean;
  32677. /**
  32678. * Gets or sets a boolean indicating that up and down values must be inverted
  32679. */
  32680. reverseUpDown: boolean;
  32681. /**
  32682. * Gets the offset value for the position (ie. the change of the position value)
  32683. */
  32684. deltaPosition: Vector3;
  32685. /**
  32686. * Gets a boolean indicating if the virtual joystick was pressed
  32687. */
  32688. pressed: boolean;
  32689. private static _globalJoystickIndex;
  32690. private static vjCanvas;
  32691. private static vjCanvasContext;
  32692. private static vjCanvasWidth;
  32693. private static vjCanvasHeight;
  32694. private static halfWidth;
  32695. private _action;
  32696. private _axisTargetedByLeftAndRight;
  32697. private _axisTargetedByUpAndDown;
  32698. private _joystickSensibility;
  32699. private _inversedSensibility;
  32700. private _joystickPointerID;
  32701. private _joystickColor;
  32702. private _joystickPointerPos;
  32703. private _joystickPreviousPointerPos;
  32704. private _joystickPointerStartPos;
  32705. private _deltaJoystickVector;
  32706. private _leftJoystick;
  32707. private _touches;
  32708. private _onPointerDownHandlerRef;
  32709. private _onPointerMoveHandlerRef;
  32710. private _onPointerUpHandlerRef;
  32711. private _onResize;
  32712. /**
  32713. * Creates a new virtual joystick
  32714. * @param leftJoystick defines that the joystick is for left hand (false by default)
  32715. */
  32716. constructor(leftJoystick?: boolean);
  32717. /**
  32718. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  32719. * @param newJoystickSensibility defines the new sensibility
  32720. */
  32721. setJoystickSensibility(newJoystickSensibility: number): void;
  32722. private _onPointerDown;
  32723. private _onPointerMove;
  32724. private _onPointerUp;
  32725. /**
  32726. * Change the color of the virtual joystick
  32727. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  32728. */
  32729. setJoystickColor(newColor: string): void;
  32730. /**
  32731. * Defines a callback to call when the joystick is touched
  32732. * @param action defines the callback
  32733. */
  32734. setActionOnTouch(action: () => any): void;
  32735. /**
  32736. * Defines which axis you'd like to control for left & right
  32737. * @param axis defines the axis to use
  32738. */
  32739. setAxisForLeftRight(axis: JoystickAxis): void;
  32740. /**
  32741. * Defines which axis you'd like to control for up & down
  32742. * @param axis defines the axis to use
  32743. */
  32744. setAxisForUpDown(axis: JoystickAxis): void;
  32745. private _drawVirtualJoystick;
  32746. /**
  32747. * Release internal HTML canvas
  32748. */
  32749. releaseCanvas(): void;
  32750. }
  32751. }
  32752. declare module BABYLON {
  32753. /**
  32754. * Helper class to push actions to a pool of workers.
  32755. */
  32756. class WorkerPool implements IDisposable {
  32757. private _workerInfos;
  32758. private _pendingActions;
  32759. /**
  32760. * Constructor
  32761. * @param workers Array of workers to use for actions
  32762. */
  32763. constructor(workers: Array<Worker>);
  32764. /**
  32765. * Terminates all workers and clears any pending actions.
  32766. */
  32767. dispose(): void;
  32768. /**
  32769. * Pushes an action to the worker pool. If all the workers are active, the action will be
  32770. * pended until a worker has completed its action.
  32771. * @param action The action to perform. Call onComplete when the action is complete.
  32772. */
  32773. push(action: (worker: Worker, onComplete: () => void) => void): void;
  32774. private _execute;
  32775. }
  32776. }
  32777. declare module BABYLON {
  32778. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  32779. readonly name: string;
  32780. private _zoomStopsAnimation;
  32781. private _idleRotationSpeed;
  32782. private _idleRotationWaitTime;
  32783. private _idleRotationSpinupTime;
  32784. /**
  32785. * Sets the flag that indicates if user zooming should stop animation.
  32786. */
  32787. /**
  32788. * Gets the flag that indicates if user zooming should stop animation.
  32789. */
  32790. zoomStopsAnimation: boolean;
  32791. /**
  32792. * Sets the default speed at which the camera rotates around the model.
  32793. */
  32794. /**
  32795. * Gets the default speed at which the camera rotates around the model.
  32796. */
  32797. idleRotationSpeed: number;
  32798. /**
  32799. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  32800. */
  32801. /**
  32802. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  32803. */
  32804. idleRotationWaitTime: number;
  32805. /**
  32806. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32807. */
  32808. /**
  32809. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32810. */
  32811. idleRotationSpinupTime: number;
  32812. /**
  32813. * Gets a value indicating if the camera is currently rotating because of this behavior
  32814. */
  32815. readonly rotationInProgress: boolean;
  32816. private _onPrePointerObservableObserver;
  32817. private _onAfterCheckInputsObserver;
  32818. private _attachedCamera;
  32819. private _isPointerDown;
  32820. private _lastFrameTime;
  32821. private _lastInteractionTime;
  32822. private _cameraRotationSpeed;
  32823. init(): void;
  32824. attach(camera: ArcRotateCamera): void;
  32825. detach(): void;
  32826. /**
  32827. * Returns true if user is scrolling.
  32828. * @return true if user is scrolling.
  32829. */
  32830. private _userIsZooming;
  32831. private _lastFrameRadius;
  32832. private _shouldAnimationStopForInteraction;
  32833. /**
  32834. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32835. */
  32836. private _applyUserInteraction;
  32837. private _userIsMoving;
  32838. }
  32839. }
  32840. declare module BABYLON {
  32841. /**
  32842. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32843. */
  32844. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32845. readonly name: string;
  32846. /**
  32847. * The easing function used by animations
  32848. */
  32849. static EasingFunction: BackEase;
  32850. /**
  32851. * The easing mode used by animations
  32852. */
  32853. static EasingMode: number;
  32854. /**
  32855. * The duration of the animation, in milliseconds
  32856. */
  32857. transitionDuration: number;
  32858. /**
  32859. * Length of the distance animated by the transition when lower radius is reached
  32860. */
  32861. lowerRadiusTransitionRange: number;
  32862. /**
  32863. * Length of the distance animated by the transition when upper radius is reached
  32864. */
  32865. upperRadiusTransitionRange: number;
  32866. private _autoTransitionRange;
  32867. /**
  32868. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32869. */
  32870. /**
  32871. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32872. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32873. */
  32874. autoTransitionRange: boolean;
  32875. private _attachedCamera;
  32876. private _onAfterCheckInputsObserver;
  32877. private _onMeshTargetChangedObserver;
  32878. init(): void;
  32879. attach(camera: ArcRotateCamera): void;
  32880. detach(): void;
  32881. private _radiusIsAnimating;
  32882. private _radiusBounceTransition;
  32883. private _animatables;
  32884. private _cachedWheelPrecision;
  32885. /**
  32886. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32887. * @param radiusLimit The limit to check against.
  32888. * @return Bool to indicate if at limit.
  32889. */
  32890. private _isRadiusAtLimit;
  32891. /**
  32892. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32893. * @param radiusDelta The delta by which to animate to. Can be negative.
  32894. */
  32895. private _applyBoundRadiusAnimation;
  32896. /**
  32897. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32898. */
  32899. protected _clearAnimationLocks(): void;
  32900. /**
  32901. * Stops and removes all animations that have been applied to the camera
  32902. */
  32903. stopAllAnimations(): void;
  32904. }
  32905. }
  32906. declare module BABYLON {
  32907. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32908. readonly name: string;
  32909. private _mode;
  32910. private _radiusScale;
  32911. private _positionScale;
  32912. private _defaultElevation;
  32913. private _elevationReturnTime;
  32914. private _elevationReturnWaitTime;
  32915. private _zoomStopsAnimation;
  32916. private _framingTime;
  32917. /**
  32918. * The easing function used by animations
  32919. */
  32920. static EasingFunction: ExponentialEase;
  32921. /**
  32922. * The easing mode used by animations
  32923. */
  32924. static EasingMode: number;
  32925. /**
  32926. * Sets the current mode used by the behavior
  32927. */
  32928. /**
  32929. * Gets current mode used by the behavior.
  32930. */
  32931. mode: number;
  32932. /**
  32933. * Sets the scale applied to the radius (1 by default)
  32934. */
  32935. /**
  32936. * Gets the scale applied to the radius
  32937. */
  32938. radiusScale: number;
  32939. /**
  32940. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32941. */
  32942. /**
  32943. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32944. */
  32945. positionScale: number;
  32946. /**
  32947. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32948. * behaviour is triggered, in radians.
  32949. */
  32950. /**
  32951. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32952. * behaviour is triggered, in radians.
  32953. */
  32954. defaultElevation: number;
  32955. /**
  32956. * Sets the time (in milliseconds) taken to return to the default beta position.
  32957. * Negative value indicates camera should not return to default.
  32958. */
  32959. /**
  32960. * Gets the time (in milliseconds) taken to return to the default beta position.
  32961. * Negative value indicates camera should not return to default.
  32962. */
  32963. elevationReturnTime: number;
  32964. /**
  32965. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32966. */
  32967. /**
  32968. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32969. */
  32970. elevationReturnWaitTime: number;
  32971. /**
  32972. * Sets the flag that indicates if user zooming should stop animation.
  32973. */
  32974. /**
  32975. * Gets the flag that indicates if user zooming should stop animation.
  32976. */
  32977. zoomStopsAnimation: boolean;
  32978. /**
  32979. * Sets the transition time when framing the mesh, in milliseconds
  32980. */
  32981. /**
  32982. * Gets the transition time when framing the mesh, in milliseconds
  32983. */
  32984. framingTime: number;
  32985. private _onPrePointerObservableObserver;
  32986. private _onAfterCheckInputsObserver;
  32987. private _onMeshTargetChangedObserver;
  32988. private _attachedCamera;
  32989. private _isPointerDown;
  32990. private _lastInteractionTime;
  32991. init(): void;
  32992. attach(camera: ArcRotateCamera): void;
  32993. detach(): void;
  32994. private _animatables;
  32995. private _betaIsAnimating;
  32996. private _betaTransition;
  32997. private _radiusTransition;
  32998. private _vectorTransition;
  32999. /**
  33000. * Targets the given mesh and updates zoom level accordingly.
  33001. * @param mesh The mesh to target.
  33002. * @param radius Optional. If a cached radius position already exists, overrides default.
  33003. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33006. */
  33007. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33008. /**
  33009. * Targets the given mesh with its children and updates zoom level accordingly.
  33010. * @param mesh The mesh to target.
  33011. * @param radius Optional. If a cached radius position already exists, overrides default.
  33012. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33013. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33014. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33015. */
  33016. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33017. /**
  33018. * Targets the given meshes with their children and updates zoom level accordingly.
  33019. * @param meshes The mesh to target.
  33020. * @param radius Optional. If a cached radius position already exists, overrides default.
  33021. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33022. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33023. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33024. */
  33025. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33026. /**
  33027. * Targets the given mesh and updates zoom level accordingly.
  33028. * @param mesh The mesh to target.
  33029. * @param radius Optional. If a cached radius position already exists, overrides default.
  33030. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33031. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33032. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33033. */
  33034. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33035. /**
  33036. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33037. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33038. * frustum width.
  33039. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33040. * to fully enclose the mesh in the viewing frustum.
  33041. */
  33042. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33043. /**
  33044. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33045. * is automatically returned to its default position (expected to be above ground plane).
  33046. */
  33047. private _maintainCameraAboveGround;
  33048. /**
  33049. * Returns the frustum slope based on the canvas ratio and camera FOV
  33050. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33051. */
  33052. private _getFrustumSlope;
  33053. /**
  33054. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33055. */
  33056. private _clearAnimationLocks;
  33057. /**
  33058. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33059. */
  33060. private _applyUserInteraction;
  33061. /**
  33062. * Stops and removes all animations that have been applied to the camera
  33063. */
  33064. stopAllAnimations(): void;
  33065. /**
  33066. * Gets a value indicating if the user is moving the camera
  33067. */
  33068. readonly isUserIsMoving: boolean;
  33069. /**
  33070. * The camera can move all the way towards the mesh.
  33071. */
  33072. static IgnoreBoundsSizeMode: number;
  33073. /**
  33074. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33075. */
  33076. static FitFrustumSidesMode: number;
  33077. }
  33078. }
  33079. declare module BABYLON {
  33080. /**
  33081. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  33082. */
  33083. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  33084. private ui;
  33085. /**
  33086. * The name of the behavior
  33087. */
  33088. name: string;
  33089. /**
  33090. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  33091. */
  33092. distanceAwayFromFace: number;
  33093. /**
  33094. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  33095. */
  33096. distanceAwayFromBottomOfFace: number;
  33097. private _faceVectors;
  33098. private _target;
  33099. private _scene;
  33100. private _onRenderObserver;
  33101. private _tmpMatrix;
  33102. private _tmpVector;
  33103. /**
  33104. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  33105. * @param ui The transform node that should be attched to the mesh
  33106. */
  33107. constructor(ui: BABYLON.TransformNode);
  33108. /**
  33109. * Initializes the behavior
  33110. */
  33111. init(): void;
  33112. private _closestFace;
  33113. private _zeroVector;
  33114. private _lookAtTmpMatrix;
  33115. private _lookAtToRef;
  33116. /**
  33117. * Attaches the AttachToBoxBehavior to the passed in mesh
  33118. * @param target The mesh that the specified node will be attached to
  33119. */
  33120. attach(target: BABYLON.Mesh): void;
  33121. /**
  33122. * Detaches the behavior from the mesh
  33123. */
  33124. detach(): void;
  33125. }
  33126. }
  33127. declare module BABYLON {
  33128. /**
  33129. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  33130. */
  33131. class FadeInOutBehavior implements Behavior<Mesh> {
  33132. /**
  33133. * Time in milliseconds to delay before fading in (Default: 0)
  33134. */
  33135. delay: number;
  33136. /**
  33137. * Time in milliseconds for the mesh to fade in (Default: 300)
  33138. */
  33139. fadeInTime: number;
  33140. private _millisecondsPerFrame;
  33141. private _hovered;
  33142. private _hoverValue;
  33143. private _ownerNode;
  33144. /**
  33145. * Instatiates the FadeInOutBehavior
  33146. */
  33147. constructor();
  33148. /**
  33149. * The name of the behavior
  33150. */
  33151. readonly name: string;
  33152. /**
  33153. * Initializes the behavior
  33154. */
  33155. init(): void;
  33156. /**
  33157. * Attaches the fade behavior on the passed in mesh
  33158. * @param ownerNode The mesh that will be faded in/out once attached
  33159. */
  33160. attach(ownerNode: Mesh): void;
  33161. /**
  33162. * Detaches the behavior from the mesh
  33163. */
  33164. detach(): void;
  33165. /**
  33166. * Triggers the mesh to begin fading in or out
  33167. * @param value if the object should fade in or out (true to fade in)
  33168. */
  33169. fadeIn(value: boolean): void;
  33170. private _update;
  33171. private _setAllVisibility;
  33172. }
  33173. }
  33174. declare module BABYLON {
  33175. /**
  33176. * A behavior that when attached to a mesh will allow the mesh to be scaled
  33177. */
  33178. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  33179. private _dragBehaviorA;
  33180. private _dragBehaviorB;
  33181. private _startDistance;
  33182. private _initialScale;
  33183. private _targetScale;
  33184. private _ownerNode;
  33185. private _sceneRenderObserver;
  33186. constructor();
  33187. /**
  33188. * The name of the behavior
  33189. */
  33190. readonly name: string;
  33191. /**
  33192. * Initializes the behavior
  33193. */
  33194. init(): void;
  33195. private _getCurrentDistance;
  33196. /**
  33197. * Attaches the scale behavior the passed in mesh
  33198. * @param ownerNode The mesh that will be scaled around once attached
  33199. */
  33200. attach(ownerNode: Mesh): void;
  33201. /**
  33202. * Detaches the behavior from the mesh
  33203. */
  33204. detach(): void;
  33205. }
  33206. }
  33207. declare module BABYLON {
  33208. /**
  33209. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  33210. */
  33211. class PointerDragBehavior implements Behavior<Mesh> {
  33212. private _attachedNode;
  33213. private _dragPlane;
  33214. private _scene;
  33215. private _pointerObserver;
  33216. private _beforeRenderObserver;
  33217. private static _planeScene;
  33218. /**
  33219. * 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)
  33220. */
  33221. maxDragAngle: number;
  33222. /**
  33223. * @hidden
  33224. */
  33225. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  33226. /**
  33227. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33228. */
  33229. currentDraggingPointerID: number;
  33230. /**
  33231. * The last position where the pointer hit the drag plane in world space
  33232. */
  33233. lastDragPosition: Vector3;
  33234. /**
  33235. * If the behavior is currently in a dragging state
  33236. */
  33237. dragging: boolean;
  33238. /**
  33239. * 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)
  33240. */
  33241. dragDeltaRatio: number;
  33242. /**
  33243. * If the drag plane orientation should be updated during the dragging (Default: true)
  33244. */
  33245. updateDragPlane: boolean;
  33246. private _debugMode;
  33247. private _moving;
  33248. /**
  33249. * Fires each time the attached mesh is dragged with the pointer
  33250. * * delta between last drag position and current drag position in world space
  33251. * * dragDistance along the drag axis
  33252. * * dragPlaneNormal normal of the current drag plane used during the drag
  33253. * * dragPlanePoint in world space where the drag intersects the drag plane
  33254. */
  33255. onDragObservable: Observable<{
  33256. delta: Vector3;
  33257. dragPlanePoint: Vector3;
  33258. dragPlaneNormal: Vector3;
  33259. dragDistance: number;
  33260. pointerId: number;
  33261. }>;
  33262. /**
  33263. * Fires each time a drag begins (eg. mouse down on mesh)
  33264. */
  33265. onDragStartObservable: Observable<{
  33266. dragPlanePoint: Vector3;
  33267. pointerId: number;
  33268. }>;
  33269. /**
  33270. * Fires each time a drag ends (eg. mouse release after drag)
  33271. */
  33272. onDragEndObservable: Observable<{
  33273. dragPlanePoint: Vector3;
  33274. pointerId: number;
  33275. }>;
  33276. /**
  33277. * If the attached mesh should be moved when dragged
  33278. */
  33279. moveAttached: boolean;
  33280. /**
  33281. * If the drag behavior will react to drag events (Default: true)
  33282. */
  33283. enabled: boolean;
  33284. /**
  33285. * If camera controls should be detached during the drag
  33286. */
  33287. detachCameraControls: boolean;
  33288. /**
  33289. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  33290. */
  33291. useObjectOrienationForDragging: boolean;
  33292. private _options;
  33293. /**
  33294. * Creates a pointer drag behavior that can be attached to a mesh
  33295. * @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)
  33296. */
  33297. constructor(options?: {
  33298. dragAxis?: Vector3;
  33299. dragPlaneNormal?: Vector3;
  33300. });
  33301. /**
  33302. * The name of the behavior
  33303. */
  33304. readonly name: string;
  33305. /**
  33306. * Initializes the behavior
  33307. */
  33308. init(): void;
  33309. private _tmpVector;
  33310. private _alternatePickedPoint;
  33311. private _worldDragAxis;
  33312. private _targetPosition;
  33313. private _attachedElement;
  33314. /**
  33315. * Attaches the drag behavior the passed in mesh
  33316. * @param ownerNode The mesh that will be dragged around once attached
  33317. */
  33318. attach(ownerNode: Mesh): void;
  33319. releaseDrag(): void;
  33320. private _startDragRay;
  33321. private _lastPointerRay;
  33322. /**
  33323. * Simulates the start of a pointer drag event on the behavior
  33324. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  33325. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  33326. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  33327. */
  33328. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  33329. private _startDrag;
  33330. private _dragDelta;
  33331. private _moveDrag;
  33332. private _pickWithRayOnDragPlane;
  33333. private _pointA;
  33334. private _pointB;
  33335. private _pointC;
  33336. private _lineA;
  33337. private _lineB;
  33338. private _localAxis;
  33339. private _lookAt;
  33340. private _updateDragPlanePosition;
  33341. /**
  33342. * Detaches the behavior from the mesh
  33343. */
  33344. detach(): void;
  33345. }
  33346. }
  33347. declare module BABYLON {
  33348. /**
  33349. * 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
  33350. */
  33351. class SixDofDragBehavior implements Behavior<Mesh> {
  33352. private static _virtualScene;
  33353. private _ownerNode;
  33354. private _sceneRenderObserver;
  33355. private _scene;
  33356. private _targetPosition;
  33357. private _virtualOriginMesh;
  33358. private _virtualDragMesh;
  33359. private _pointerObserver;
  33360. private _moving;
  33361. private _startingOrientation;
  33362. /**
  33363. * 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)
  33364. */
  33365. private zDragFactor;
  33366. /**
  33367. * If the behavior is currently in a dragging state
  33368. */
  33369. dragging: boolean;
  33370. /**
  33371. * 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)
  33372. */
  33373. dragDeltaRatio: number;
  33374. /**
  33375. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33376. */
  33377. currentDraggingPointerID: number;
  33378. /**
  33379. * If camera controls should be detached during the drag
  33380. */
  33381. detachCameraControls: boolean;
  33382. constructor();
  33383. /**
  33384. * The name of the behavior
  33385. */
  33386. readonly name: string;
  33387. /**
  33388. * Initializes the behavior
  33389. */
  33390. init(): void;
  33391. /**
  33392. * Attaches the scale behavior the passed in mesh
  33393. * @param ownerNode The mesh that will be scaled around once attached
  33394. */
  33395. attach(ownerNode: Mesh): void;
  33396. /**
  33397. * Detaches the behavior from the mesh
  33398. */
  33399. detach(): void;
  33400. }
  33401. }
  33402. declare module BABYLON {
  33403. interface IOctreeContainer<T> {
  33404. blocks: Array<OctreeBlock<T>>;
  33405. }
  33406. class Octree<T> {
  33407. maxDepth: number;
  33408. blocks: Array<OctreeBlock<T>>;
  33409. dynamicContent: T[];
  33410. private _maxBlockCapacity;
  33411. private _selectionContent;
  33412. private _creationFunc;
  33413. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  33414. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  33415. addMesh(entry: T): void;
  33416. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  33417. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  33418. intersectsRay(ray: Ray): SmartArray<T>;
  33419. 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;
  33420. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  33421. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  33422. }
  33423. }
  33424. declare module BABYLON {
  33425. class OctreeBlock<T> {
  33426. entries: T[];
  33427. blocks: Array<OctreeBlock<T>>;
  33428. private _depth;
  33429. private _maxDepth;
  33430. private _capacity;
  33431. private _minPoint;
  33432. private _maxPoint;
  33433. private _boundingVectors;
  33434. private _creationFunc;
  33435. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  33436. readonly capacity: number;
  33437. readonly minPoint: Vector3;
  33438. readonly maxPoint: Vector3;
  33439. addEntry(entry: T): void;
  33440. addEntries(entries: T[]): void;
  33441. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33442. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33443. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  33444. createInnerBlocks(): void;
  33445. }
  33446. }
  33447. declare module BABYLON {
  33448. interface Scene {
  33449. /**
  33450. * @hidden
  33451. * Backing Filed
  33452. */
  33453. _selectionOctree: Octree<AbstractMesh>;
  33454. /**
  33455. * Gets the octree used to boost mesh selection (picking)
  33456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  33457. */
  33458. selectionOctree: Octree<AbstractMesh>;
  33459. /**
  33460. * Creates or updates the octree used to boost selection (picking)
  33461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  33462. * @param maxCapacity defines the maximum capacity per leaf
  33463. * @param maxDepth defines the maximum depth of the octree
  33464. * @returns an octree of AbstractMesh
  33465. */
  33466. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  33467. }
  33468. interface AbstractMesh {
  33469. /**
  33470. * @hidden
  33471. * Backing Field
  33472. */
  33473. _submeshesOctree: Octree<SubMesh>;
  33474. /**
  33475. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  33476. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  33477. * @param maxCapacity defines the maximum size of each block (64 by default)
  33478. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  33479. * @returns the new octree
  33480. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  33481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  33482. */
  33483. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  33484. }
  33485. /**
  33486. * Defines the octree scene component responsible to manage any octrees
  33487. * in a given scene.
  33488. */
  33489. class OctreeSceneComponent {
  33490. /**
  33491. * The component name helpfull to identify the component in the list of scene components.
  33492. */
  33493. readonly name: string;
  33494. /**
  33495. * The scene the component belongs to.
  33496. */
  33497. scene: Scene;
  33498. /**
  33499. * Indicates if the meshes have been checked to make sure they are isEnabled()
  33500. */
  33501. readonly checksIsEnabled: boolean;
  33502. /**
  33503. * Creates a new instance of the component for the given scene
  33504. * @param scene Defines the scene to register the component in
  33505. */
  33506. constructor(scene: Scene);
  33507. /**
  33508. * Registers the component in a given scene
  33509. */
  33510. register(): void;
  33511. /**
  33512. * Return the list of active meshes
  33513. * @returns the list of active meshes
  33514. */
  33515. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33516. /**
  33517. * Return the list of active sub meshes
  33518. * @param mesh The mesh to get the candidates sub meshes from
  33519. * @returns the list of active sub meshes
  33520. */
  33521. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33522. private _tempRay;
  33523. /**
  33524. * Return the list of sub meshes intersecting with a given local ray
  33525. * @param mesh defines the mesh to find the submesh for
  33526. * @param localRay defines the ray in local space
  33527. * @returns the list of intersecting sub meshes
  33528. */
  33529. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  33530. /**
  33531. * Return the list of sub meshes colliding with a collider
  33532. * @param mesh defines the mesh to find the submesh for
  33533. * @param collider defines the collider to evaluate the collision against
  33534. * @returns the list of colliding sub meshes
  33535. */
  33536. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  33537. /**
  33538. * Rebuilds the elements related to this component in case of
  33539. * context lost for instance.
  33540. */
  33541. rebuild(): void;
  33542. /**
  33543. * Disposes the component and the associated ressources.
  33544. */
  33545. dispose(): void;
  33546. }
  33547. }
  33548. declare module BABYLON {
  33549. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  33550. camera: ArcRotateCamera;
  33551. gamepad: Nullable<Gamepad>;
  33552. private _onGamepadConnectedObserver;
  33553. private _onGamepadDisconnectedObserver;
  33554. gamepadRotationSensibility: number;
  33555. gamepadMoveSensibility: number;
  33556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33557. detachControl(element: Nullable<HTMLElement>): void;
  33558. checkInputs(): void;
  33559. getClassName(): string;
  33560. getSimpleName(): string;
  33561. }
  33562. }
  33563. declare module BABYLON {
  33564. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33565. camera: ArcRotateCamera;
  33566. private _keys;
  33567. keysUp: number[];
  33568. keysDown: number[];
  33569. keysLeft: number[];
  33570. keysRight: number[];
  33571. keysReset: number[];
  33572. panningSensibility: number;
  33573. zoomingSensibility: number;
  33574. useAltToZoom: boolean;
  33575. private _ctrlPressed;
  33576. private _altPressed;
  33577. private _onCanvasBlurObserver;
  33578. private _onKeyboardObserver;
  33579. private _engine;
  33580. private _scene;
  33581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33582. detachControl(element: Nullable<HTMLElement>): void;
  33583. checkInputs(): void;
  33584. getClassName(): string;
  33585. getSimpleName(): string;
  33586. }
  33587. }
  33588. declare module BABYLON {
  33589. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33590. camera: ArcRotateCamera;
  33591. private _wheel;
  33592. private _observer;
  33593. wheelPrecision: number;
  33594. /**
  33595. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33596. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33597. */
  33598. wheelDeltaPercentage: number;
  33599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33600. detachControl(element: Nullable<HTMLElement>): void;
  33601. getClassName(): string;
  33602. getSimpleName(): string;
  33603. }
  33604. }
  33605. declare module BABYLON {
  33606. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33607. camera: ArcRotateCamera;
  33608. buttons: number[];
  33609. angularSensibilityX: number;
  33610. angularSensibilityY: number;
  33611. pinchPrecision: number;
  33612. /**
  33613. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33614. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33615. */
  33616. pinchDeltaPercentage: number;
  33617. panningSensibility: number;
  33618. multiTouchPanning: boolean;
  33619. multiTouchPanAndZoom: boolean;
  33620. private _isPanClick;
  33621. pinchInwards: boolean;
  33622. private _pointerInput;
  33623. private _observer;
  33624. private _onMouseMove;
  33625. private _onGestureStart;
  33626. private _onGesture;
  33627. private _MSGestureHandler;
  33628. private _onLostFocus;
  33629. private _onContextMenu;
  33630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33631. detachControl(element: Nullable<HTMLElement>): void;
  33632. getClassName(): string;
  33633. getSimpleName(): string;
  33634. }
  33635. }
  33636. declare module BABYLON {
  33637. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  33638. camera: ArcRotateCamera;
  33639. alphaCorrection: number;
  33640. betaCorrection: number;
  33641. gammaCorrection: number;
  33642. private _alpha;
  33643. private _gamma;
  33644. private _dirty;
  33645. private _deviceOrientationHandler;
  33646. constructor();
  33647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33648. /** @hidden */
  33649. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  33650. checkInputs(): void;
  33651. detachControl(element: Nullable<HTMLElement>): void;
  33652. getClassName(): string;
  33653. getSimpleName(): string;
  33654. }
  33655. }
  33656. declare module BABYLON {
  33657. /**
  33658. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  33659. * Screen rotation is taken into account.
  33660. */
  33661. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  33662. private _camera;
  33663. private _screenOrientationAngle;
  33664. private _constantTranform;
  33665. private _screenQuaternion;
  33666. private _alpha;
  33667. private _beta;
  33668. private _gamma;
  33669. constructor();
  33670. camera: FreeCamera;
  33671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33672. private _orientationChanged;
  33673. private _deviceOrientation;
  33674. detachControl(element: Nullable<HTMLElement>): void;
  33675. checkInputs(): void;
  33676. getClassName(): string;
  33677. getSimpleName(): string;
  33678. }
  33679. }
  33680. declare module BABYLON {
  33681. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  33682. camera: FreeCamera;
  33683. gamepad: Nullable<Gamepad>;
  33684. private _onGamepadConnectedObserver;
  33685. private _onGamepadDisconnectedObserver;
  33686. gamepadAngularSensibility: number;
  33687. gamepadMoveSensibility: number;
  33688. private _cameraTransform;
  33689. private _deltaTransform;
  33690. private _vector3;
  33691. private _vector2;
  33692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33693. detachControl(element: Nullable<HTMLElement>): void;
  33694. checkInputs(): void;
  33695. getClassName(): string;
  33696. getSimpleName(): string;
  33697. }
  33698. }
  33699. declare module BABYLON {
  33700. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  33701. camera: FreeCamera;
  33702. private _keys;
  33703. private _onCanvasBlurObserver;
  33704. private _onKeyboardObserver;
  33705. private _engine;
  33706. private _scene;
  33707. keysUp: number[];
  33708. keysDown: number[];
  33709. keysLeft: number[];
  33710. keysRight: number[];
  33711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33712. detachControl(element: Nullable<HTMLElement>): void;
  33713. checkInputs(): void;
  33714. getClassName(): string;
  33715. /** @hidden */
  33716. _onLostFocus(e: FocusEvent): void;
  33717. getSimpleName(): string;
  33718. }
  33719. }
  33720. declare module BABYLON {
  33721. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  33722. touchEnabled: boolean;
  33723. camera: FreeCamera;
  33724. buttons: number[];
  33725. angularSensibility: number;
  33726. private _pointerInput;
  33727. private _onMouseMove;
  33728. private _observer;
  33729. private previousPosition;
  33730. constructor(touchEnabled?: boolean);
  33731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33732. detachControl(element: Nullable<HTMLElement>): void;
  33733. getClassName(): string;
  33734. getSimpleName(): string;
  33735. }
  33736. }
  33737. declare module BABYLON {
  33738. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  33739. camera: FreeCamera;
  33740. private _offsetX;
  33741. private _offsetY;
  33742. private _pointerPressed;
  33743. private _pointerInput;
  33744. private _observer;
  33745. private _onLostFocus;
  33746. touchAngularSensibility: number;
  33747. touchMoveSensibility: number;
  33748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33749. detachControl(element: Nullable<HTMLElement>): void;
  33750. checkInputs(): void;
  33751. getClassName(): string;
  33752. getSimpleName(): string;
  33753. }
  33754. }
  33755. declare module BABYLON {
  33756. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  33757. camera: FreeCamera;
  33758. private _leftjoystick;
  33759. private _rightjoystick;
  33760. getLeftJoystick(): VirtualJoystick;
  33761. getRightJoystick(): VirtualJoystick;
  33762. checkInputs(): void;
  33763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33764. detachControl(element: Nullable<HTMLElement>): void;
  33765. getClassName(): string;
  33766. getSimpleName(): string;
  33767. }
  33768. }
  33769. declare module BABYLON {
  33770. /**
  33771. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  33772. */
  33773. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  33774. /**
  33775. * Creates a new AnaglyphArcRotateCamera
  33776. * @param name defines camera name
  33777. * @param alpha defines alpha angle (in radians)
  33778. * @param beta defines beta angle (in radians)
  33779. * @param radius defines radius
  33780. * @param target defines camera target
  33781. * @param interaxialDistance defines distance between each color axis
  33782. * @param scene defines the hosting scene
  33783. */
  33784. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  33785. /**
  33786. * Gets camera class name
  33787. * @returns AnaglyphArcRotateCamera
  33788. */
  33789. getClassName(): string;
  33790. }
  33791. }
  33792. declare module BABYLON {
  33793. /**
  33794. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  33795. */
  33796. class AnaglyphFreeCamera extends FreeCamera {
  33797. /**
  33798. * Creates a new AnaglyphFreeCamera
  33799. * @param name defines camera name
  33800. * @param position defines initial position
  33801. * @param interaxialDistance defines distance between each color axis
  33802. * @param scene defines the hosting scene
  33803. */
  33804. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33805. /**
  33806. * Gets camera class name
  33807. * @returns AnaglyphFreeCamera
  33808. */
  33809. getClassName(): string;
  33810. }
  33811. }
  33812. declare module BABYLON {
  33813. /**
  33814. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  33815. */
  33816. class AnaglyphGamepadCamera extends GamepadCamera {
  33817. /**
  33818. * Creates a new AnaglyphGamepadCamera
  33819. * @param name defines camera name
  33820. * @param position defines initial position
  33821. * @param interaxialDistance defines distance between each color axis
  33822. * @param scene defines the hosting scene
  33823. */
  33824. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33825. /**
  33826. * Gets camera class name
  33827. * @returns AnaglyphGamepadCamera
  33828. */
  33829. getClassName(): string;
  33830. }
  33831. }
  33832. declare module BABYLON {
  33833. /**
  33834. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  33835. */
  33836. class AnaglyphUniversalCamera extends UniversalCamera {
  33837. /**
  33838. * Creates a new AnaglyphUniversalCamera
  33839. * @param name defines camera name
  33840. * @param position defines initial position
  33841. * @param interaxialDistance defines distance between each color axis
  33842. * @param scene defines the hosting scene
  33843. */
  33844. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33845. /**
  33846. * Gets camera class name
  33847. * @returns AnaglyphUniversalCamera
  33848. */
  33849. getClassName(): string;
  33850. }
  33851. }
  33852. declare module BABYLON {
  33853. /**
  33854. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  33855. */
  33856. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  33857. /**
  33858. * Creates a new StereoscopicArcRotateCamera
  33859. * @param name defines camera name
  33860. * @param alpha defines alpha angle (in radians)
  33861. * @param beta defines beta angle (in radians)
  33862. * @param radius defines radius
  33863. * @param target defines camera target
  33864. * @param interaxialDistance defines distance between each color axis
  33865. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33866. * @param scene defines the hosting scene
  33867. */
  33868. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33869. /**
  33870. * Gets camera class name
  33871. * @returns StereoscopicArcRotateCamera
  33872. */
  33873. getClassName(): string;
  33874. }
  33875. }
  33876. declare module BABYLON {
  33877. /**
  33878. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  33879. */
  33880. class StereoscopicFreeCamera extends FreeCamera {
  33881. /**
  33882. * Creates a new StereoscopicFreeCamera
  33883. * @param name defines camera name
  33884. * @param position defines initial position
  33885. * @param interaxialDistance defines distance between each color axis
  33886. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33887. * @param scene defines the hosting scene
  33888. */
  33889. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33890. /**
  33891. * Gets camera class name
  33892. * @returns StereoscopicFreeCamera
  33893. */
  33894. getClassName(): string;
  33895. }
  33896. }
  33897. declare module BABYLON {
  33898. /**
  33899. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  33900. */
  33901. class StereoscopicGamepadCamera extends GamepadCamera {
  33902. /**
  33903. * Creates a new StereoscopicGamepadCamera
  33904. * @param name defines camera name
  33905. * @param position defines initial position
  33906. * @param interaxialDistance defines distance between each color axis
  33907. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33908. * @param scene defines the hosting scene
  33909. */
  33910. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33911. /**
  33912. * Gets camera class name
  33913. * @returns StereoscopicGamepadCamera
  33914. */
  33915. getClassName(): string;
  33916. }
  33917. }
  33918. declare module BABYLON {
  33919. /**
  33920. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  33921. */
  33922. class StereoscopicUniversalCamera extends UniversalCamera {
  33923. /**
  33924. * Creates a new StereoscopicUniversalCamera
  33925. * @param name defines camera name
  33926. * @param position defines initial position
  33927. * @param interaxialDistance defines distance between each color axis
  33928. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33929. * @param scene defines the hosting scene
  33930. */
  33931. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33932. /**
  33933. * Gets camera class name
  33934. * @returns StereoscopicUniversalCamera
  33935. */
  33936. getClassName(): string;
  33937. }
  33938. }
  33939. declare module BABYLON {
  33940. class VRCameraMetrics {
  33941. hResolution: number;
  33942. vResolution: number;
  33943. hScreenSize: number;
  33944. vScreenSize: number;
  33945. vScreenCenter: number;
  33946. eyeToScreenDistance: number;
  33947. lensSeparationDistance: number;
  33948. interpupillaryDistance: number;
  33949. distortionK: number[];
  33950. chromaAbCorrection: number[];
  33951. postProcessScaleFactor: number;
  33952. lensCenterOffset: number;
  33953. compensateDistortion: boolean;
  33954. readonly aspectRatio: number;
  33955. readonly aspectRatioFov: number;
  33956. readonly leftHMatrix: Matrix;
  33957. readonly rightHMatrix: Matrix;
  33958. readonly leftPreViewMatrix: Matrix;
  33959. readonly rightPreViewMatrix: Matrix;
  33960. static GetDefault(): VRCameraMetrics;
  33961. }
  33962. }
  33963. declare module BABYLON {
  33964. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  33965. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33966. getClassName(): string;
  33967. }
  33968. }
  33969. declare module BABYLON {
  33970. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  33971. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33972. getClassName(): string;
  33973. }
  33974. }
  33975. declare module BABYLON {
  33976. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  33977. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33978. getClassName(): string;
  33979. }
  33980. }
  33981. declare module BABYLON {
  33982. /**
  33983. * Options to modify the vr teleportation behavior.
  33984. */
  33985. interface VRTeleportationOptions {
  33986. /**
  33987. * The name of the mesh which should be used as the teleportation floor. (default: null)
  33988. */
  33989. floorMeshName?: string;
  33990. /**
  33991. * A list of meshes to be used as the teleportation floor. (default: empty)
  33992. */
  33993. floorMeshes?: Mesh[];
  33994. }
  33995. /**
  33996. * Options to modify the vr experience helper's behavior.
  33997. */
  33998. interface VRExperienceHelperOptions extends WebVROptions {
  33999. /**
  34000. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  34001. */
  34002. createDeviceOrientationCamera?: boolean;
  34003. /**
  34004. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  34005. */
  34006. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  34007. /**
  34008. * Uses the main button on the controller to toggle the laser casted. (default: true)
  34009. */
  34010. laserToggle?: boolean;
  34011. /**
  34012. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  34013. */
  34014. floorMeshes?: Mesh[];
  34015. }
  34016. /**
  34017. * Helps to quickly add VR support to an existing scene.
  34018. * See http://doc.babylonjs.com/how_to/webvr_helper
  34019. */
  34020. class VRExperienceHelper {
  34021. /** Options to modify the vr experience helper's behavior. */
  34022. webVROptions: VRExperienceHelperOptions;
  34023. private _scene;
  34024. private _position;
  34025. private _btnVR;
  34026. private _btnVRDisplayed;
  34027. private _webVRsupported;
  34028. private _webVRready;
  34029. private _webVRrequesting;
  34030. private _webVRpresenting;
  34031. private _hasEnteredVR;
  34032. private _fullscreenVRpresenting;
  34033. private _canvas;
  34034. private _webVRCamera;
  34035. private _vrDeviceOrientationCamera;
  34036. private _deviceOrientationCamera;
  34037. private _existingCamera;
  34038. private _onKeyDown;
  34039. private _onVrDisplayPresentChange;
  34040. private _onVRDisplayChanged;
  34041. private _onVRRequestPresentStart;
  34042. private _onVRRequestPresentComplete;
  34043. /**
  34044. * Observable raised when entering VR.
  34045. */
  34046. onEnteringVRObservable: Observable<VRExperienceHelper>;
  34047. /**
  34048. * Observable raised when exiting VR.
  34049. */
  34050. onExitingVRObservable: Observable<VRExperienceHelper>;
  34051. /**
  34052. * Observable raised when controller mesh is loaded.
  34053. */
  34054. onControllerMeshLoadedObservable: Observable<WebVRController>;
  34055. /** Return this.onEnteringVRObservable
  34056. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  34057. */
  34058. readonly onEnteringVR: Observable<VRExperienceHelper>;
  34059. /** Return this.onExitingVRObservable
  34060. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  34061. */
  34062. readonly onExitingVR: Observable<VRExperienceHelper>;
  34063. /** Return this.onControllerMeshLoadedObservable
  34064. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  34065. */
  34066. readonly onControllerMeshLoaded: Observable<WebVRController>;
  34067. private _rayLength;
  34068. private _useCustomVRButton;
  34069. private _teleportationRequested;
  34070. private _teleportActive;
  34071. private _floorMeshName;
  34072. private _floorMeshesCollection;
  34073. private _rotationAllowed;
  34074. private _teleportBackwardsVector;
  34075. private _teleportationTarget;
  34076. private _isDefaultTeleportationTarget;
  34077. private _postProcessMove;
  34078. private _teleportationFillColor;
  34079. private _teleportationBorderColor;
  34080. private _rotationAngle;
  34081. private _haloCenter;
  34082. private _cameraGazer;
  34083. private _padSensibilityUp;
  34084. private _padSensibilityDown;
  34085. private _leftController;
  34086. private _rightController;
  34087. /**
  34088. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  34089. */
  34090. onNewMeshSelected: Observable<AbstractMesh>;
  34091. /**
  34092. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  34093. */
  34094. onNewMeshPicked: Observable<PickingInfo>;
  34095. private _circleEase;
  34096. /**
  34097. * Observable raised before camera teleportation
  34098. */
  34099. onBeforeCameraTeleport: Observable<Vector3>;
  34100. /**
  34101. * Observable raised after camera teleportation
  34102. */
  34103. onAfterCameraTeleport: Observable<Vector3>;
  34104. /**
  34105. * Observable raised when current selected mesh gets unselected
  34106. */
  34107. onSelectedMeshUnselected: Observable<AbstractMesh>;
  34108. private _raySelectionPredicate;
  34109. /**
  34110. * To be optionaly changed by user to define custom ray selection
  34111. */
  34112. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  34113. /**
  34114. * To be optionaly changed by user to define custom selection logic (after ray selection)
  34115. */
  34116. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  34117. /**
  34118. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  34119. */
  34120. teleportationEnabled: boolean;
  34121. private _defaultHeight;
  34122. private _teleportationInitialized;
  34123. private _interactionsEnabled;
  34124. private _interactionsRequested;
  34125. private _displayGaze;
  34126. private _displayLaserPointer;
  34127. /**
  34128. * The mesh used to display where the user is going to teleport.
  34129. */
  34130. /**
  34131. * Sets the mesh to be used to display where the user is going to teleport.
  34132. */
  34133. teleportationTarget: Mesh;
  34134. /**
  34135. * 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
  34136. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  34137. * See http://doc.babylonjs.com/resources/baking_transformations
  34138. */
  34139. gazeTrackerMesh: Mesh;
  34140. /**
  34141. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  34142. */
  34143. updateGazeTrackerScale: boolean;
  34144. /**
  34145. * The gaze tracking mesh corresponding to the left controller
  34146. */
  34147. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  34148. /**
  34149. * The gaze tracking mesh corresponding to the right controller
  34150. */
  34151. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  34152. /**
  34153. * If the ray of the gaze should be displayed.
  34154. */
  34155. /**
  34156. * Sets if the ray of the gaze should be displayed.
  34157. */
  34158. displayGaze: boolean;
  34159. /**
  34160. * If the ray of the LaserPointer should be displayed.
  34161. */
  34162. /**
  34163. * Sets if the ray of the LaserPointer should be displayed.
  34164. */
  34165. displayLaserPointer: boolean;
  34166. /**
  34167. * The deviceOrientationCamera used as the camera when not in VR.
  34168. */
  34169. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  34170. /**
  34171. * Based on the current WebVR support, returns the current VR camera used.
  34172. */
  34173. readonly currentVRCamera: Nullable<Camera>;
  34174. /**
  34175. * The webVRCamera which is used when in VR.
  34176. */
  34177. readonly webVRCamera: WebVRFreeCamera;
  34178. /**
  34179. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  34180. */
  34181. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  34182. private readonly _teleportationRequestInitiated;
  34183. /**
  34184. * Instantiates a VRExperienceHelper.
  34185. * Helps to quickly add VR support to an existing scene.
  34186. * @param scene The scene the VRExperienceHelper belongs to.
  34187. * @param webVROptions Options to modify the vr experience helper's behavior.
  34188. */
  34189. constructor(scene: Scene,
  34190. /** Options to modify the vr experience helper's behavior. */
  34191. webVROptions?: VRExperienceHelperOptions);
  34192. private _onDefaultMeshLoaded;
  34193. private _onResize;
  34194. private _onFullscreenChange;
  34195. /**
  34196. * Gets a value indicating if we are currently in VR mode.
  34197. */
  34198. readonly isInVRMode: boolean;
  34199. private onVrDisplayPresentChange;
  34200. private onVRDisplayChanged;
  34201. private moveButtonToBottomRight;
  34202. private displayVRButton;
  34203. private updateButtonVisibility;
  34204. /**
  34205. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  34206. * Otherwise, will use the fullscreen API.
  34207. */
  34208. enterVR(): void;
  34209. /**
  34210. * Attempt to exit VR, or fullscreen.
  34211. */
  34212. exitVR(): void;
  34213. /**
  34214. * The position of the vr experience helper.
  34215. */
  34216. /**
  34217. * Sets the position of the vr experience helper.
  34218. */
  34219. position: Vector3;
  34220. /**
  34221. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  34222. */
  34223. enableInteractions(): void;
  34224. private readonly _noControllerIsActive;
  34225. private beforeRender;
  34226. private _isTeleportationFloor;
  34227. /**
  34228. * Adds a floor mesh to be used for teleportation.
  34229. * @param floorMesh the mesh to be used for teleportation.
  34230. */
  34231. addFloorMesh(floorMesh: Mesh): void;
  34232. /**
  34233. * Removes a floor mesh from being used for teleportation.
  34234. * @param floorMesh the mesh to be removed.
  34235. */
  34236. removeFloorMesh(floorMesh: Mesh): void;
  34237. /**
  34238. * Enables interactions and teleportation using the VR controllers and gaze.
  34239. * @param vrTeleportationOptions options to modify teleportation behavior.
  34240. */
  34241. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  34242. private _onNewGamepadConnected;
  34243. private _tryEnableInteractionOnController;
  34244. private _onNewGamepadDisconnected;
  34245. private _enableInteractionOnController;
  34246. private _checkTeleportWithRay;
  34247. private _checkRotate;
  34248. private _checkTeleportBackwards;
  34249. private _enableTeleportationOnController;
  34250. private _createTeleportationCircles;
  34251. private _displayTeleportationTarget;
  34252. private _hideTeleportationTarget;
  34253. private _rotateCamera;
  34254. private _moveTeleportationSelectorTo;
  34255. private _workingVector;
  34256. private _workingQuaternion;
  34257. private _workingMatrix;
  34258. /**
  34259. * Teleports the users feet to the desired location
  34260. * @param location The location where the user's feet should be placed
  34261. */
  34262. teleportCamera(location: Vector3): void;
  34263. private _convertNormalToDirectionOfRay;
  34264. private _castRayAndSelectObject;
  34265. private _notifySelectedMeshUnselected;
  34266. /**
  34267. * Sets the color of the laser ray from the vr controllers.
  34268. * @param color new color for the ray.
  34269. */
  34270. changeLaserColor(color: Color3): void;
  34271. /**
  34272. * Sets the color of the ray from the vr headsets gaze.
  34273. * @param color new color for the ray.
  34274. */
  34275. changeGazeColor(color: Color3): void;
  34276. /**
  34277. * Exits VR and disposes of the vr experience helper
  34278. */
  34279. dispose(): void;
  34280. /**
  34281. * Gets the name of the VRExperienceHelper class
  34282. * @returns "VRExperienceHelper"
  34283. */
  34284. getClassName(): string;
  34285. }
  34286. }
  34287. declare module BABYLON {
  34288. /**
  34289. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  34290. * IMPORTANT!! The data is right-hand data.
  34291. * @export
  34292. * @interface DevicePose
  34293. */
  34294. interface DevicePose {
  34295. /**
  34296. * The position of the device, values in array are [x,y,z].
  34297. */
  34298. readonly position: Nullable<Float32Array>;
  34299. /**
  34300. * The linearVelocity of the device, values in array are [x,y,z].
  34301. */
  34302. readonly linearVelocity: Nullable<Float32Array>;
  34303. /**
  34304. * The linearAcceleration of the device, values in array are [x,y,z].
  34305. */
  34306. readonly linearAcceleration: Nullable<Float32Array>;
  34307. /**
  34308. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  34309. */
  34310. readonly orientation: Nullable<Float32Array>;
  34311. /**
  34312. * The angularVelocity of the device, values in array are [x,y,z].
  34313. */
  34314. readonly angularVelocity: Nullable<Float32Array>;
  34315. /**
  34316. * The angularAcceleration of the device, values in array are [x,y,z].
  34317. */
  34318. readonly angularAcceleration: Nullable<Float32Array>;
  34319. }
  34320. /**
  34321. * Interface representing a pose controlled object in Babylon.
  34322. * A pose controlled object has both regular pose values as well as pose values
  34323. * from an external device such as a VR head mounted display
  34324. */
  34325. interface PoseControlled {
  34326. /**
  34327. * The position of the object in babylon space.
  34328. */
  34329. position: Vector3;
  34330. /**
  34331. * The rotation quaternion of the object in babylon space.
  34332. */
  34333. rotationQuaternion: Quaternion;
  34334. /**
  34335. * The position of the device in babylon space.
  34336. */
  34337. devicePosition?: Vector3;
  34338. /**
  34339. * The rotation quaternion of the device in babylon space.
  34340. */
  34341. deviceRotationQuaternion: Quaternion;
  34342. /**
  34343. * The raw pose coming from the device.
  34344. */
  34345. rawPose: Nullable<DevicePose>;
  34346. /**
  34347. * The scale of the device to be used when translating from device space to babylon space.
  34348. */
  34349. deviceScaleFactor: number;
  34350. /**
  34351. * Updates the poseControlled values based on the input device pose.
  34352. * @param poseData the pose data to update the object with
  34353. */
  34354. updateFromDevice(poseData: DevicePose): void;
  34355. }
  34356. /**
  34357. * Set of options to customize the webVRCamera
  34358. */
  34359. interface WebVROptions {
  34360. /**
  34361. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  34362. */
  34363. trackPosition?: boolean;
  34364. /**
  34365. * Sets the scale of the vrDevice in babylon space. (default: 1)
  34366. */
  34367. positionScale?: number;
  34368. /**
  34369. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  34370. */
  34371. displayName?: string;
  34372. /**
  34373. * Should the native controller meshes be initialized. (default: true)
  34374. */
  34375. controllerMeshes?: boolean;
  34376. /**
  34377. * Creating a default HemiLight only on controllers. (default: true)
  34378. */
  34379. defaultLightingOnControllers?: boolean;
  34380. /**
  34381. * If you don't want to use the default VR button of the helper. (default: false)
  34382. */
  34383. useCustomVRButton?: boolean;
  34384. /**
  34385. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  34386. */
  34387. customVRButton?: HTMLButtonElement;
  34388. /**
  34389. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  34390. */
  34391. rayLength?: number;
  34392. /**
  34393. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  34394. */
  34395. defaultHeight?: number;
  34396. }
  34397. /**
  34398. * This represents a WebVR camera.
  34399. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  34400. * @example http://doc.babylonjs.com/how_to/webvr_camera
  34401. */
  34402. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  34403. private webVROptions;
  34404. /**
  34405. * @hidden
  34406. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  34407. */
  34408. _vrDevice: any;
  34409. /**
  34410. * The rawPose of the vrDevice.
  34411. */
  34412. rawPose: Nullable<DevicePose>;
  34413. private _onVREnabled;
  34414. private _specsVersion;
  34415. private _attached;
  34416. private _frameData;
  34417. protected _descendants: Array<Node>;
  34418. private _deviceRoomPosition;
  34419. /** @hidden */
  34420. _deviceRoomRotationQuaternion: Quaternion;
  34421. private _standingMatrix;
  34422. /**
  34423. * Represents device position in babylon space.
  34424. */
  34425. devicePosition: Vector3;
  34426. /**
  34427. * Represents device rotation in babylon space.
  34428. */
  34429. deviceRotationQuaternion: Quaternion;
  34430. /**
  34431. * The scale of the device to be used when translating from device space to babylon space.
  34432. */
  34433. deviceScaleFactor: number;
  34434. private _deviceToWorld;
  34435. private _worldToDevice;
  34436. /**
  34437. * References to the webVR controllers for the vrDevice.
  34438. */
  34439. controllers: Array<WebVRController>;
  34440. /**
  34441. * Emits an event when a controller is attached.
  34442. */
  34443. onControllersAttachedObservable: Observable<WebVRController[]>;
  34444. /**
  34445. * Emits an event when a controller's mesh has been loaded;
  34446. */
  34447. onControllerMeshLoadedObservable: Observable<WebVRController>;
  34448. /**
  34449. * Emits an event when the HMD's pose has been updated.
  34450. */
  34451. onPoseUpdatedFromDeviceObservable: Observable<any>;
  34452. private _poseSet;
  34453. /**
  34454. * If the rig cameras be used as parent instead of this camera.
  34455. */
  34456. rigParenting: boolean;
  34457. private _lightOnControllers;
  34458. private _defaultHeight?;
  34459. /**
  34460. * Instantiates a WebVRFreeCamera.
  34461. * @param name The name of the WebVRFreeCamera
  34462. * @param position The starting anchor position for the camera
  34463. * @param scene The scene the camera belongs to
  34464. * @param webVROptions a set of customizable options for the webVRCamera
  34465. */
  34466. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  34467. /**
  34468. * Gets the device distance from the ground in meters.
  34469. * @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.
  34470. */
  34471. deviceDistanceToRoomGround(): number;
  34472. /**
  34473. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  34474. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  34475. */
  34476. useStandingMatrix(callback?: (bool: boolean) => void): void;
  34477. /**
  34478. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  34479. * @returns A promise with a boolean set to if the standing matrix is supported.
  34480. */
  34481. useStandingMatrixAsync(): Promise<boolean>;
  34482. /**
  34483. * Disposes the camera
  34484. */
  34485. dispose(): void;
  34486. /**
  34487. * Gets a vrController by name.
  34488. * @param name The name of the controller to retreive
  34489. * @returns the controller matching the name specified or null if not found
  34490. */
  34491. getControllerByName(name: string): Nullable<WebVRController>;
  34492. private _leftController;
  34493. /**
  34494. * The controller corrisponding to the users left hand.
  34495. */
  34496. readonly leftController: Nullable<WebVRController>;
  34497. private _rightController;
  34498. /**
  34499. * The controller corrisponding to the users right hand.
  34500. */
  34501. readonly rightController: Nullable<WebVRController>;
  34502. /**
  34503. * Casts a ray forward from the vrCamera's gaze.
  34504. * @param length Length of the ray (default: 100)
  34505. * @returns the ray corrisponding to the gaze
  34506. */
  34507. getForwardRay(length?: number): Ray;
  34508. /**
  34509. * @hidden
  34510. * Updates the camera based on device's frame data
  34511. */
  34512. _checkInputs(): void;
  34513. /**
  34514. * Updates the poseControlled values based on the input device pose.
  34515. * @param poseData Pose coming from the device
  34516. */
  34517. updateFromDevice(poseData: DevicePose): void;
  34518. private _htmlElementAttached;
  34519. private _detachIfAttached;
  34520. /**
  34521. * WebVR's attach control will start broadcasting frames to the device.
  34522. * Note that in certain browsers (chrome for example) this function must be called
  34523. * within a user-interaction callback. Example:
  34524. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  34525. *
  34526. * @param element html element to attach the vrDevice to
  34527. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  34528. */
  34529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34530. /**
  34531. * Detaches the camera from the html element and disables VR
  34532. *
  34533. * @param element html element to detach from
  34534. */
  34535. detachControl(element: HTMLElement): void;
  34536. /**
  34537. * @returns the name of this class
  34538. */
  34539. getClassName(): string;
  34540. /**
  34541. * Calls resetPose on the vrDisplay
  34542. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  34543. */
  34544. resetToCurrentRotation(): void;
  34545. /**
  34546. * @hidden
  34547. * Updates the rig cameras (left and right eye)
  34548. */
  34549. _updateRigCameras(): void;
  34550. private _workingVector;
  34551. private _oneVector;
  34552. private _workingMatrix;
  34553. private updateCacheCalled;
  34554. private _correctPositionIfNotTrackPosition;
  34555. /**
  34556. * @hidden
  34557. * Updates the cached values of the camera
  34558. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  34559. */
  34560. _updateCache(ignoreParentClass?: boolean): void;
  34561. /**
  34562. * Updates the current device position and rotation in the babylon world
  34563. */
  34564. update(): void;
  34565. /**
  34566. * @hidden
  34567. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  34568. * @returns an identity matrix
  34569. */
  34570. _getViewMatrix(): Matrix;
  34571. private _tmpMatrix;
  34572. /**
  34573. * This function is called by the two RIG cameras.
  34574. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  34575. */
  34576. protected _getWebVRViewMatrix(): Matrix;
  34577. protected _getWebVRProjectionMatrix(): Matrix;
  34578. private _onGamepadConnectedObserver;
  34579. private _onGamepadDisconnectedObserver;
  34580. /**
  34581. * Initializes the controllers and their meshes
  34582. */
  34583. initControllers(): void;
  34584. }
  34585. }
  34586. declare module BABYLON {
  34587. interface Engine {
  34588. /**
  34589. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  34590. * @return the new query
  34591. */
  34592. createQuery(): WebGLQuery;
  34593. /**
  34594. * Delete and release a webGL query
  34595. * @param query defines the query to delete
  34596. * @return the current engine
  34597. */
  34598. deleteQuery(query: WebGLQuery): Engine;
  34599. /**
  34600. * Check if a given query has resolved and got its value
  34601. * @param query defines the query to check
  34602. * @returns true if the query got its value
  34603. */
  34604. isQueryResultAvailable(query: WebGLQuery): boolean;
  34605. /**
  34606. * Gets the value of a given query
  34607. * @param query defines the query to check
  34608. * @returns the value of the query
  34609. */
  34610. getQueryResult(query: WebGLQuery): number;
  34611. /**
  34612. * Initiates an occlusion query
  34613. * @param algorithmType defines the algorithm to use
  34614. * @param query defines the query to use
  34615. * @returns the current engine
  34616. * @see http://doc.babylonjs.com/features/occlusionquery
  34617. */
  34618. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  34619. /**
  34620. * Ends an occlusion query
  34621. * @see http://doc.babylonjs.com/features/occlusionquery
  34622. * @param algorithmType defines the algorithm to use
  34623. * @returns the current engine
  34624. */
  34625. endOcclusionQuery(algorithmType: number): Engine;
  34626. /**
  34627. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  34628. * Please note that only one query can be issued at a time
  34629. * @returns a time token used to track the time span
  34630. */
  34631. startTimeQuery(): Nullable<_TimeToken>;
  34632. /**
  34633. * Ends a time query
  34634. * @param token defines the token used to measure the time span
  34635. * @returns the time spent (in ns)
  34636. */
  34637. endTimeQuery(token: _TimeToken): int;
  34638. /** @hidden */
  34639. _currentNonTimestampToken: Nullable<_TimeToken>;
  34640. /** @hidden */
  34641. _createTimeQuery(): WebGLQuery;
  34642. /** @hidden */
  34643. _deleteTimeQuery(query: WebGLQuery): void;
  34644. /** @hidden */
  34645. _getGlAlgorithmType(algorithmType: number): number;
  34646. /** @hidden */
  34647. _getTimeQueryResult(query: WebGLQuery): any;
  34648. /** @hidden */
  34649. _getTimeQueryAvailability(query: WebGLQuery): any;
  34650. }
  34651. }
  34652. declare module BABYLON {
  34653. interface Engine {
  34654. /**
  34655. * Creates a webGL transform feedback object
  34656. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  34657. * @returns the webGL transform feedback object
  34658. */
  34659. createTransformFeedback(): WebGLTransformFeedback;
  34660. /**
  34661. * Delete a webGL transform feedback object
  34662. * @param value defines the webGL transform feedback object to delete
  34663. */
  34664. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  34665. /**
  34666. * Bind a webGL transform feedback object to the webgl context
  34667. * @param value defines the webGL transform feedback object to bind
  34668. */
  34669. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  34670. /**
  34671. * Begins a transform feedback operation
  34672. * @param usePoints defines if points or triangles must be used
  34673. */
  34674. beginTransformFeedback(usePoints: boolean): void;
  34675. /**
  34676. * Ends a transform feedback operation
  34677. */
  34678. endTransformFeedback(): void;
  34679. /**
  34680. * Specify the varyings to use with transform feedback
  34681. * @param program defines the associated webGL program
  34682. * @param value defines the list of strings representing the varying names
  34683. */
  34684. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  34685. /**
  34686. * Bind a webGL buffer for a transform feedback operation
  34687. * @param value defines the webGL buffer to bind
  34688. */
  34689. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  34690. }
  34691. }
  34692. declare module BABYLON {
  34693. /**
  34694. * Google Daydream controller
  34695. */
  34696. class DaydreamController extends WebVRController {
  34697. /**
  34698. * Base Url for the controller model.
  34699. */
  34700. static MODEL_BASE_URL: string;
  34701. /**
  34702. * File name for the controller model.
  34703. */
  34704. static MODEL_FILENAME: string;
  34705. /**
  34706. * Gamepad Id prefix used to identify Daydream Controller.
  34707. */
  34708. static readonly GAMEPAD_ID_PREFIX: string;
  34709. /**
  34710. * Creates a new DaydreamController from a gamepad
  34711. * @param vrGamepad the gamepad that the controller should be created from
  34712. */
  34713. constructor(vrGamepad: any);
  34714. /**
  34715. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34716. * @param scene scene in which to add meshes
  34717. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34718. */
  34719. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34720. /**
  34721. * Called once for each button that changed state since the last frame
  34722. * @param buttonIdx Which button index changed
  34723. * @param state New state of the button
  34724. * @param changes Which properties on the state changed since last frame
  34725. */
  34726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34727. }
  34728. }
  34729. declare module BABYLON {
  34730. /**
  34731. * Gear VR Controller
  34732. */
  34733. class GearVRController extends WebVRController {
  34734. /**
  34735. * Base Url for the controller model.
  34736. */
  34737. static MODEL_BASE_URL: string;
  34738. /**
  34739. * File name for the controller model.
  34740. */
  34741. static MODEL_FILENAME: string;
  34742. private _maxRotationDistFromHeadset;
  34743. private _draggedRoomRotation;
  34744. private _tmpVector;
  34745. /**
  34746. * Gamepad Id prefix used to identify this controller.
  34747. */
  34748. static readonly GAMEPAD_ID_PREFIX: string;
  34749. private readonly _buttonIndexToObservableNameMap;
  34750. /**
  34751. * Creates a new GearVRController from a gamepad
  34752. * @param vrGamepad the gamepad that the controller should be created from
  34753. */
  34754. constructor(vrGamepad: any);
  34755. /**
  34756. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34757. * @param poseData raw pose fromthe device
  34758. */
  34759. updateFromDevice(poseData: DevicePose): void;
  34760. /**
  34761. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34762. * @param scene scene in which to add meshes
  34763. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34764. */
  34765. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34766. /**
  34767. * Called once for each button that changed state since the last frame
  34768. * @param buttonIdx Which button index changed
  34769. * @param state New state of the button
  34770. * @param changes Which properties on the state changed since last frame
  34771. */
  34772. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34773. }
  34774. }
  34775. declare module BABYLON {
  34776. /**
  34777. * Generic Controller
  34778. */
  34779. class GenericController extends WebVRController {
  34780. /**
  34781. * Base Url for the controller model.
  34782. */
  34783. static readonly MODEL_BASE_URL: string;
  34784. /**
  34785. * File name for the controller model.
  34786. */
  34787. static readonly MODEL_FILENAME: string;
  34788. /**
  34789. * Creates a new GenericController from a gamepad
  34790. * @param vrGamepad the gamepad that the controller should be created from
  34791. */
  34792. constructor(vrGamepad: any);
  34793. /**
  34794. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34795. * @param scene scene in which to add meshes
  34796. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34797. */
  34798. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34799. /**
  34800. * Called once for each button that changed state since the last frame
  34801. * @param buttonIdx Which button index changed
  34802. * @param state New state of the button
  34803. * @param changes Which properties on the state changed since last frame
  34804. */
  34805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. /**
  34810. * Oculus Touch Controller
  34811. */
  34812. class OculusTouchController extends WebVRController {
  34813. /**
  34814. * Base Url for the controller model.
  34815. */
  34816. static MODEL_BASE_URL: string;
  34817. /**
  34818. * File name for the left controller model.
  34819. */
  34820. static MODEL_LEFT_FILENAME: string;
  34821. /**
  34822. * File name for the right controller model.
  34823. */
  34824. static MODEL_RIGHT_FILENAME: string;
  34825. /**
  34826. * Fired when the secondary trigger on this controller is modified
  34827. */
  34828. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34829. /**
  34830. * Fired when the thumb rest on this controller is modified
  34831. */
  34832. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  34833. /**
  34834. * Creates a new OculusTouchController from a gamepad
  34835. * @param vrGamepad the gamepad that the controller should be created from
  34836. */
  34837. constructor(vrGamepad: any);
  34838. /**
  34839. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34840. * @param scene scene in which to add meshes
  34841. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34842. */
  34843. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34844. /**
  34845. * Fired when the A button on this controller is modified
  34846. */
  34847. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34848. /**
  34849. * Fired when the B button on this controller is modified
  34850. */
  34851. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34852. /**
  34853. * Fired when the X button on this controller is modified
  34854. */
  34855. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34856. /**
  34857. * Fired when the Y button on this controller is modified
  34858. */
  34859. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34860. /**
  34861. * Called once for each button that changed state since the last frame
  34862. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34863. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34864. * 2) secondary trigger (same)
  34865. * 3) A (right) X (left), touch, pressed = value
  34866. * 4) B / Y
  34867. * 5) thumb rest
  34868. * @param buttonIdx Which button index changed
  34869. * @param state New state of the button
  34870. * @param changes Which properties on the state changed since last frame
  34871. */
  34872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34873. }
  34874. }
  34875. declare module BABYLON {
  34876. /**
  34877. * Defines the types of pose enabled controllers that are supported
  34878. */
  34879. enum PoseEnabledControllerType {
  34880. /**
  34881. * HTC Vive
  34882. */
  34883. VIVE = 0,
  34884. /**
  34885. * Oculus Rift
  34886. */
  34887. OCULUS = 1,
  34888. /**
  34889. * Windows mixed reality
  34890. */
  34891. WINDOWS = 2,
  34892. /**
  34893. * Samsung gear VR
  34894. */
  34895. GEAR_VR = 3,
  34896. /**
  34897. * Google Daydream
  34898. */
  34899. DAYDREAM = 4,
  34900. /**
  34901. * Generic
  34902. */
  34903. GENERIC = 5
  34904. }
  34905. /**
  34906. * Defines the MutableGamepadButton interface for the state of a gamepad button
  34907. */
  34908. interface MutableGamepadButton {
  34909. /**
  34910. * Value of the button/trigger
  34911. */
  34912. value: number;
  34913. /**
  34914. * If the button/trigger is currently touched
  34915. */
  34916. touched: boolean;
  34917. /**
  34918. * If the button/trigger is currently pressed
  34919. */
  34920. pressed: boolean;
  34921. }
  34922. /**
  34923. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  34924. * @hidden
  34925. */
  34926. interface ExtendedGamepadButton extends GamepadButton {
  34927. /**
  34928. * If the button/trigger is currently pressed
  34929. */
  34930. readonly pressed: boolean;
  34931. /**
  34932. * If the button/trigger is currently touched
  34933. */
  34934. readonly touched: boolean;
  34935. /**
  34936. * Value of the button/trigger
  34937. */
  34938. readonly value: number;
  34939. }
  34940. /**
  34941. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34942. */
  34943. class PoseEnabledControllerHelper {
  34944. /**
  34945. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34946. * @param vrGamepad the gamepad to initialized
  34947. * @returns a vr controller of the type the gamepad identified as
  34948. */
  34949. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  34950. }
  34951. /**
  34952. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34953. */
  34954. class PoseEnabledController extends Gamepad implements PoseControlled {
  34955. private _deviceRoomPosition;
  34956. private _deviceRoomRotationQuaternion;
  34957. /**
  34958. * The device position in babylon space
  34959. */
  34960. devicePosition: Vector3;
  34961. /**
  34962. * The device rotation in babylon space
  34963. */
  34964. deviceRotationQuaternion: Quaternion;
  34965. /**
  34966. * The scale factor of the device in babylon space
  34967. */
  34968. deviceScaleFactor: number;
  34969. /**
  34970. * (Likely devicePosition should be used instead) The device position in its room space
  34971. */
  34972. position: Vector3;
  34973. /**
  34974. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  34975. */
  34976. rotationQuaternion: Quaternion;
  34977. /**
  34978. * The type of controller (Eg. Windows mixed reality)
  34979. */
  34980. controllerType: PoseEnabledControllerType;
  34981. protected _calculatedPosition: Vector3;
  34982. private _calculatedRotation;
  34983. /**
  34984. * The raw pose from the device
  34985. */
  34986. rawPose: DevicePose;
  34987. /**
  34988. * Internal, the mesh attached to the controller
  34989. * @hidden
  34990. */
  34991. _mesh: Nullable<AbstractMesh>;
  34992. private _poseControlledCamera;
  34993. private _leftHandSystemQuaternion;
  34994. /**
  34995. * Internal, matrix used to convert room space to babylon space
  34996. * @hidden
  34997. */
  34998. _deviceToWorld: Matrix;
  34999. /**
  35000. * Node to be used when casting a ray from the controller
  35001. * @hidden
  35002. */
  35003. _pointingPoseNode: Nullable<AbstractMesh>;
  35004. /**
  35005. * Name of the child mesh that can be used to cast a ray from the controller
  35006. */
  35007. static readonly POINTING_POSE: string;
  35008. /**
  35009. * Creates a new PoseEnabledController from a gamepad
  35010. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35011. */
  35012. constructor(browserGamepad: any);
  35013. private _workingMatrix;
  35014. /**
  35015. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35016. */
  35017. update(): void;
  35018. /**
  35019. * Updates only the pose device and mesh without doing any button event checking
  35020. */
  35021. protected _updatePoseAndMesh(): void;
  35022. /**
  35023. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35024. * @param poseData raw pose fromthe device
  35025. */
  35026. updateFromDevice(poseData: DevicePose): void;
  35027. /**
  35028. * @hidden
  35029. */
  35030. _meshAttachedObservable: Observable<AbstractMesh>;
  35031. /**
  35032. * Attaches a mesh to the controller
  35033. * @param mesh the mesh to be attached
  35034. */
  35035. attachToMesh(mesh: AbstractMesh): void;
  35036. /**
  35037. * Attaches the controllers mesh to a camera
  35038. * @param camera the camera the mesh should be attached to
  35039. */
  35040. attachToPoseControlledCamera(camera: TargetCamera): void;
  35041. /**
  35042. * Disposes of the controller
  35043. */
  35044. dispose(): void;
  35045. /**
  35046. * The mesh that is attached to the controller
  35047. */
  35048. readonly mesh: Nullable<AbstractMesh>;
  35049. /**
  35050. * Gets the ray of the controller in the direction the controller is pointing
  35051. * @param length the length the resulting ray should be
  35052. * @returns a ray in the direction the controller is pointing
  35053. */
  35054. getForwardRay(length?: number): Ray;
  35055. }
  35056. }
  35057. declare module BABYLON {
  35058. /**
  35059. * Vive Controller
  35060. */
  35061. class ViveController extends WebVRController {
  35062. /**
  35063. * Base Url for the controller model.
  35064. */
  35065. static MODEL_BASE_URL: string;
  35066. /**
  35067. * File name for the controller model.
  35068. */
  35069. static MODEL_FILENAME: string;
  35070. /**
  35071. * Creates a new ViveController from a gamepad
  35072. * @param vrGamepad the gamepad that the controller should be created from
  35073. */
  35074. constructor(vrGamepad: any);
  35075. /**
  35076. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35077. * @param scene scene in which to add meshes
  35078. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35079. */
  35080. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  35081. /**
  35082. * Fired when the left button on this controller is modified
  35083. */
  35084. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35085. /**
  35086. * Fired when the right button on this controller is modified
  35087. */
  35088. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35089. /**
  35090. * Fired when the menu button on this controller is modified
  35091. */
  35092. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35093. /**
  35094. * Called once for each button that changed state since the last frame
  35095. * Vive mapping:
  35096. * 0: touchpad
  35097. * 1: trigger
  35098. * 2: left AND right buttons
  35099. * 3: menu button
  35100. * @param buttonIdx Which button index changed
  35101. * @param state New state of the button
  35102. * @param changes Which properties on the state changed since last frame
  35103. */
  35104. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  35105. }
  35106. }
  35107. declare module BABYLON {
  35108. /**
  35109. * Defines the WebVRController object that represents controllers tracked in 3D space
  35110. */
  35111. abstract class WebVRController extends PoseEnabledController {
  35112. /**
  35113. * Internal, the default controller model for the controller
  35114. */
  35115. protected _defaultModel: AbstractMesh;
  35116. /**
  35117. * Fired when the trigger state has changed
  35118. */
  35119. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  35120. /**
  35121. * Fired when the main button state has changed
  35122. */
  35123. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35124. /**
  35125. * Fired when the secondary button state has changed
  35126. */
  35127. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35128. /**
  35129. * Fired when the pad state has changed
  35130. */
  35131. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  35132. /**
  35133. * Fired when controllers stick values have changed
  35134. */
  35135. onPadValuesChangedObservable: Observable<StickValues>;
  35136. /**
  35137. * Array of button availible on the controller
  35138. */
  35139. protected _buttons: Array<MutableGamepadButton>;
  35140. private _onButtonStateChange;
  35141. /**
  35142. * Fired when a controller button's state has changed
  35143. * @param callback the callback containing the button that was modified
  35144. */
  35145. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  35146. /**
  35147. * X and Y axis corrisponding to the controllers joystick
  35148. */
  35149. pad: StickValues;
  35150. /**
  35151. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  35152. */
  35153. hand: string;
  35154. /**
  35155. * The default controller model for the controller
  35156. */
  35157. readonly defaultModel: AbstractMesh;
  35158. /**
  35159. * Creates a new WebVRController from a gamepad
  35160. * @param vrGamepad the gamepad that the WebVRController should be created from
  35161. */
  35162. constructor(vrGamepad: any);
  35163. /**
  35164. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35165. */
  35166. update(): void;
  35167. /**
  35168. * Function to be called when a button is modified
  35169. */
  35170. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  35171. /**
  35172. * Loads a mesh and attaches it to the controller
  35173. * @param scene the scene the mesh should be added to
  35174. * @param meshLoaded callback for when the mesh has been loaded
  35175. */
  35176. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  35177. private _setButtonValue;
  35178. private _changes;
  35179. private _checkChanges;
  35180. /**
  35181. * Disposes of th webVRCOntroller
  35182. */
  35183. dispose(): void;
  35184. }
  35185. }
  35186. declare module BABYLON {
  35187. /**
  35188. * Defines the WindowsMotionController object that the state of the windows motion controller
  35189. */
  35190. class WindowsMotionController extends WebVRController {
  35191. /**
  35192. * The base url used to load the left and right controller models
  35193. */
  35194. static MODEL_BASE_URL: string;
  35195. /**
  35196. * The name of the left controller model file
  35197. */
  35198. static MODEL_LEFT_FILENAME: string;
  35199. /**
  35200. * The name of the right controller model file
  35201. */
  35202. static MODEL_RIGHT_FILENAME: string;
  35203. /**
  35204. * The controller name prefix for this controller type
  35205. */
  35206. static readonly GAMEPAD_ID_PREFIX: string;
  35207. /**
  35208. * The controller id pattern for this controller type
  35209. */
  35210. private static readonly GAMEPAD_ID_PATTERN;
  35211. private _loadedMeshInfo;
  35212. private readonly _mapping;
  35213. /**
  35214. * Fired when the trackpad on this controller is clicked
  35215. */
  35216. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  35217. /**
  35218. * Fired when the trackpad on this controller is modified
  35219. */
  35220. onTrackpadValuesChangedObservable: Observable<StickValues>;
  35221. /**
  35222. * The current x and y values of this controller's trackpad
  35223. */
  35224. trackpad: StickValues;
  35225. /**
  35226. * Creates a new WindowsMotionController from a gamepad
  35227. * @param vrGamepad the gamepad that the controller should be created from
  35228. */
  35229. constructor(vrGamepad: any);
  35230. /**
  35231. * Fired when the trigger on this controller is modified
  35232. */
  35233. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35234. /**
  35235. * Fired when the menu button on this controller is modified
  35236. */
  35237. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35238. /**
  35239. * Fired when the grip button on this controller is modified
  35240. */
  35241. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35242. /**
  35243. * Fired when the thumbstick button on this controller is modified
  35244. */
  35245. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35246. /**
  35247. * Fired when the touchpad button on this controller is modified
  35248. */
  35249. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35250. /**
  35251. * Fired when the touchpad values on this controller are modified
  35252. */
  35253. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  35254. private _updateTrackpad;
  35255. /**
  35256. * Called once per frame by the engine.
  35257. */
  35258. update(): void;
  35259. /**
  35260. * Called once for each button that changed state since the last frame
  35261. * @param buttonIdx Which button index changed
  35262. * @param state New state of the button
  35263. * @param changes Which properties on the state changed since last frame
  35264. */
  35265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  35266. /**
  35267. * Moves the buttons on the controller mesh based on their current state
  35268. * @param buttonName the name of the button to move
  35269. * @param buttonValue the value of the button which determines the buttons new position
  35270. */
  35271. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  35272. /**
  35273. * Moves the axis on the controller mesh based on its current state
  35274. * @param axis the index of the axis
  35275. * @param axisValue the value of the axis which determines the meshes new position
  35276. * @hidden
  35277. */
  35278. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  35279. /**
  35280. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35281. * @param scene scene in which to add meshes
  35282. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35283. */
  35284. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  35285. /**
  35286. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35287. * can be transformed by button presses and axes values, based on this._mapping.
  35288. *
  35289. * @param scene scene in which the meshes exist
  35290. * @param meshes list of meshes that make up the controller model to process
  35291. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35292. */
  35293. private processModel;
  35294. private createMeshInfo;
  35295. /**
  35296. * Gets the ray of the controller in the direction the controller is pointing
  35297. * @param length the length the resulting ray should be
  35298. * @returns a ray in the direction the controller is pointing
  35299. */
  35300. getForwardRay(length?: number): Ray;
  35301. /**
  35302. * Disposes of the controller
  35303. */
  35304. dispose(): void;
  35305. }
  35306. }
  35307. declare module BABYLON {
  35308. /**
  35309. * Interface to implement to create a shadow generator compatible with BJS.
  35310. */
  35311. interface IShadowGenerator {
  35312. /**
  35313. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35314. * @returns The render target texture if present otherwise, null
  35315. */
  35316. getShadowMap(): Nullable<RenderTargetTexture>;
  35317. /**
  35318. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35319. * @returns The render target texture if the shadow map is present otherwise, null
  35320. */
  35321. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35322. /**
  35323. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35324. * @param subMesh The submesh we want to render in the shadow map
  35325. * @param useInstances Defines wether will draw in the map using instances
  35326. * @returns true if ready otherwise, false
  35327. */
  35328. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35329. /**
  35330. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35331. * @param defines Defines of the material we want to update
  35332. * @param lightIndex Index of the light in the enabled light list of the material
  35333. */
  35334. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  35335. /**
  35336. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35337. * defined in the generator but impacting the effect).
  35338. * It implies the unifroms available on the materials are the standard BJS ones.
  35339. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35340. * @param effect The effect we are binfing the information for
  35341. */
  35342. bindShadowLight(lightIndex: string, effect: Effect): void;
  35343. /**
  35344. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35345. * (eq to shadow prjection matrix * light transform matrix)
  35346. * @returns The transform matrix used to create the shadow map
  35347. */
  35348. getTransformMatrix(): Matrix;
  35349. /**
  35350. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35351. * Cube and 2D textures for instance.
  35352. */
  35353. recreateShadowMap(): void;
  35354. /**
  35355. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35356. * @param onCompiled Callback triggered at the and of the effects compilation
  35357. * @param options Sets of optional options forcing the compilation with different modes
  35358. */
  35359. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35360. useInstances: boolean;
  35361. }>): void;
  35362. /**
  35363. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35364. * @param options Sets of optional options forcing the compilation with different modes
  35365. * @returns A promise that resolves when the compilation completes
  35366. */
  35367. forceCompilationAsync(options?: Partial<{
  35368. useInstances: boolean;
  35369. }>): Promise<void>;
  35370. /**
  35371. * Serializes the shadow generator setup to a json object.
  35372. * @returns The serialized JSON object
  35373. */
  35374. serialize(): any;
  35375. /**
  35376. * Disposes the Shadow map and related Textures and effects.
  35377. */
  35378. dispose(): void;
  35379. }
  35380. /**
  35381. * Default implementation IShadowGenerator.
  35382. * This is the main object responsible of generating shadows in the framework.
  35383. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  35384. */
  35385. class ShadowGenerator implements IShadowGenerator {
  35386. /**
  35387. * Shadow generator mode None: no filtering applied.
  35388. */
  35389. static readonly FILTER_NONE: number;
  35390. /**
  35391. * Shadow generator mode ESM: Exponential Shadow Mapping.
  35392. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35393. */
  35394. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  35395. /**
  35396. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  35397. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  35398. */
  35399. static readonly FILTER_POISSONSAMPLING: number;
  35400. /**
  35401. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  35402. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35403. */
  35404. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  35405. /**
  35406. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  35407. * edge artifacts on steep falloff.
  35408. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35409. */
  35410. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  35411. /**
  35412. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  35413. * edge artifacts on steep falloff.
  35414. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35415. */
  35416. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  35417. /**
  35418. * Shadow generator mode PCF: Percentage Closer Filtering
  35419. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  35420. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  35421. */
  35422. static readonly FILTER_PCF: number;
  35423. /**
  35424. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  35425. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  35426. * Contact Hardening
  35427. */
  35428. static readonly FILTER_PCSS: number;
  35429. /**
  35430. * Reserved for PCF and PCSS
  35431. * Highest Quality.
  35432. *
  35433. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  35434. *
  35435. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  35436. */
  35437. static readonly QUALITY_HIGH: number;
  35438. /**
  35439. * Reserved for PCF and PCSS
  35440. * Good tradeoff for quality/perf cross devices
  35441. *
  35442. * Execute PCF on a 3*3 kernel.
  35443. *
  35444. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  35445. */
  35446. static readonly QUALITY_MEDIUM: number;
  35447. /**
  35448. * Reserved for PCF and PCSS
  35449. * The lowest quality but the fastest.
  35450. *
  35451. * Execute PCF on a 1*1 kernel.
  35452. *
  35453. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  35454. */
  35455. static readonly QUALITY_LOW: number;
  35456. private _bias;
  35457. /**
  35458. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  35459. */
  35460. /**
  35461. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  35462. */
  35463. bias: number;
  35464. private _normalBias;
  35465. /**
  35466. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35467. */
  35468. /**
  35469. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35470. */
  35471. normalBias: number;
  35472. private _blurBoxOffset;
  35473. /**
  35474. * Gets the blur box offset: offset applied during the blur pass.
  35475. * Only usefull if useKernelBlur = false
  35476. */
  35477. /**
  35478. * Sets the blur box offset: offset applied during the blur pass.
  35479. * Only usefull if useKernelBlur = false
  35480. */
  35481. blurBoxOffset: number;
  35482. private _blurScale;
  35483. /**
  35484. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  35485. * 2 means half of the size.
  35486. */
  35487. /**
  35488. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  35489. * 2 means half of the size.
  35490. */
  35491. blurScale: number;
  35492. private _blurKernel;
  35493. /**
  35494. * Gets the blur kernel: kernel size of the blur pass.
  35495. * Only usefull if useKernelBlur = true
  35496. */
  35497. /**
  35498. * Sets the blur kernel: kernel size of the blur pass.
  35499. * Only usefull if useKernelBlur = true
  35500. */
  35501. blurKernel: number;
  35502. private _useKernelBlur;
  35503. /**
  35504. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  35505. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35506. */
  35507. /**
  35508. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  35509. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35510. */
  35511. useKernelBlur: boolean;
  35512. private _depthScale;
  35513. /**
  35514. * Gets the depth scale used in ESM mode.
  35515. */
  35516. /**
  35517. * Sets the depth scale used in ESM mode.
  35518. * This can override the scale stored on the light.
  35519. */
  35520. depthScale: number;
  35521. private _filter;
  35522. /**
  35523. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  35524. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35525. */
  35526. /**
  35527. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  35528. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35529. */
  35530. filter: number;
  35531. /**
  35532. * Gets if the current filter is set to Poisson Sampling.
  35533. */
  35534. /**
  35535. * Sets the current filter to Poisson Sampling.
  35536. */
  35537. usePoissonSampling: boolean;
  35538. /**
  35539. * Gets if the current filter is set to VSM.
  35540. * DEPRECATED. Should use useExponentialShadowMap instead.
  35541. */
  35542. /**
  35543. * Sets the current filter is to VSM.
  35544. * DEPRECATED. Should use useExponentialShadowMap instead.
  35545. */
  35546. useVarianceShadowMap: boolean;
  35547. /**
  35548. * Gets if the current filter is set to blurred VSM.
  35549. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35550. */
  35551. /**
  35552. * Sets the current filter is to blurred VSM.
  35553. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35554. */
  35555. useBlurVarianceShadowMap: boolean;
  35556. /**
  35557. * Gets if the current filter is set to ESM.
  35558. */
  35559. /**
  35560. * Sets the current filter is to ESM.
  35561. */
  35562. useExponentialShadowMap: boolean;
  35563. /**
  35564. * Gets if the current filter is set to filtered ESM.
  35565. */
  35566. /**
  35567. * Gets if the current filter is set to filtered ESM.
  35568. */
  35569. useBlurExponentialShadowMap: boolean;
  35570. /**
  35571. * Gets if the current filter is set to "close ESM" (using the inverse of the
  35572. * exponential to prevent steep falloff artifacts).
  35573. */
  35574. /**
  35575. * Sets the current filter to "close ESM" (using the inverse of the
  35576. * exponential to prevent steep falloff artifacts).
  35577. */
  35578. useCloseExponentialShadowMap: boolean;
  35579. /**
  35580. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  35581. * exponential to prevent steep falloff artifacts).
  35582. */
  35583. /**
  35584. * Sets the current filter to filtered "close ESM" (using the inverse of the
  35585. * exponential to prevent steep falloff artifacts).
  35586. */
  35587. useBlurCloseExponentialShadowMap: boolean;
  35588. /**
  35589. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  35590. */
  35591. /**
  35592. * Sets the current filter to "PCF" (percentage closer filtering).
  35593. */
  35594. usePercentageCloserFiltering: boolean;
  35595. private _filteringQuality;
  35596. /**
  35597. * Gets the PCF or PCSS Quality.
  35598. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35599. */
  35600. /**
  35601. * Sets the PCF or PCSS Quality.
  35602. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35603. */
  35604. filteringQuality: number;
  35605. /**
  35606. * Gets if the current filter is set to "PCSS" (contact hardening).
  35607. */
  35608. /**
  35609. * Sets the current filter to "PCSS" (contact hardening).
  35610. */
  35611. useContactHardeningShadow: boolean;
  35612. private _contactHardeningLightSizeUVRatio;
  35613. /**
  35614. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35615. * Using a ratio helps keeping shape stability independently of the map size.
  35616. *
  35617. * It does not account for the light projection as it was having too much
  35618. * instability during the light setup or during light position changes.
  35619. *
  35620. * Only valid if useContactHardeningShadow is true.
  35621. */
  35622. /**
  35623. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35624. * Using a ratio helps keeping shape stability independently of the map size.
  35625. *
  35626. * It does not account for the light projection as it was having too much
  35627. * instability during the light setup or during light position changes.
  35628. *
  35629. * Only valid if useContactHardeningShadow is true.
  35630. */
  35631. contactHardeningLightSizeUVRatio: number;
  35632. private _darkness;
  35633. /**
  35634. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  35635. * 0 means strongest and 1 would means no shadow.
  35636. * @returns the darkness.
  35637. */
  35638. getDarkness(): number;
  35639. /**
  35640. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  35641. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  35642. * @returns the shadow generator allowing fluent coding.
  35643. */
  35644. setDarkness(darkness: number): ShadowGenerator;
  35645. private _transparencyShadow;
  35646. /**
  35647. * Sets the ability to have transparent shadow (boolean).
  35648. * @param transparent True if transparent else False
  35649. * @returns the shadow generator allowing fluent coding
  35650. */
  35651. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  35652. private _shadowMap;
  35653. private _shadowMap2;
  35654. /**
  35655. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35656. * @returns The render target texture if present otherwise, null
  35657. */
  35658. getShadowMap(): Nullable<RenderTargetTexture>;
  35659. /**
  35660. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35661. * @returns The render target texture if the shadow map is present otherwise, null
  35662. */
  35663. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35664. /**
  35665. * Helper function to add a mesh and its descendants to the list of shadow casters.
  35666. * @param mesh Mesh to add
  35667. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  35668. * @returns the Shadow Generator itself
  35669. */
  35670. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35671. /**
  35672. * Helper function to remove a mesh and its descendants from the list of shadow casters
  35673. * @param mesh Mesh to remove
  35674. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  35675. * @returns the Shadow Generator itself
  35676. */
  35677. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35678. /**
  35679. * Controls the extent to which the shadows fade out at the edge of the frustum
  35680. * Used only by directionals and spots
  35681. */
  35682. frustumEdgeFalloff: number;
  35683. private _light;
  35684. /**
  35685. * Returns the associated light object.
  35686. * @returns the light generating the shadow
  35687. */
  35688. getLight(): IShadowLight;
  35689. /**
  35690. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  35691. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  35692. * It might on the other hand introduce peter panning.
  35693. */
  35694. forceBackFacesOnly: boolean;
  35695. private _scene;
  35696. private _lightDirection;
  35697. private _effect;
  35698. private _viewMatrix;
  35699. private _projectionMatrix;
  35700. private _transformMatrix;
  35701. private _cachedPosition;
  35702. private _cachedDirection;
  35703. private _cachedDefines;
  35704. private _currentRenderID;
  35705. private _boxBlurPostprocess;
  35706. private _kernelBlurXPostprocess;
  35707. private _kernelBlurYPostprocess;
  35708. private _blurPostProcesses;
  35709. private _mapSize;
  35710. private _currentFaceIndex;
  35711. private _currentFaceIndexCache;
  35712. private _textureType;
  35713. private _defaultTextureMatrix;
  35714. /**
  35715. * Creates a ShadowGenerator object.
  35716. * A ShadowGenerator is the required tool to use the shadows.
  35717. * Each light casting shadows needs to use its own ShadowGenerator.
  35718. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  35719. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  35720. * @param light The light object generating the shadows.
  35721. * @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.
  35722. */
  35723. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  35724. private _initializeGenerator;
  35725. private _initializeShadowMap;
  35726. private _initializeBlurRTTAndPostProcesses;
  35727. private _renderForShadowMap;
  35728. private _renderSubMeshForShadowMap;
  35729. private _applyFilterValues;
  35730. /**
  35731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35732. * @param onCompiled Callback triggered at the and of the effects compilation
  35733. * @param options Sets of optional options forcing the compilation with different modes
  35734. */
  35735. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35736. useInstances: boolean;
  35737. }>): void;
  35738. /**
  35739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35740. * @param options Sets of optional options forcing the compilation with different modes
  35741. * @returns A promise that resolves when the compilation completes
  35742. */
  35743. forceCompilationAsync(options?: Partial<{
  35744. useInstances: boolean;
  35745. }>): Promise<void>;
  35746. /**
  35747. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35748. * @param subMesh The submesh we want to render in the shadow map
  35749. * @param useInstances Defines wether will draw in the map using instances
  35750. * @returns true if ready otherwise, false
  35751. */
  35752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35753. /**
  35754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35755. * @param defines Defines of the material we want to update
  35756. * @param lightIndex Index of the light in the enabled light list of the material
  35757. */
  35758. prepareDefines(defines: any, lightIndex: number): void;
  35759. /**
  35760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35761. * defined in the generator but impacting the effect).
  35762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35763. * @param effect The effect we are binfing the information for
  35764. */
  35765. bindShadowLight(lightIndex: string, effect: Effect): void;
  35766. /**
  35767. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35768. * (eq to shadow prjection matrix * light transform matrix)
  35769. * @returns The transform matrix used to create the shadow map
  35770. */
  35771. getTransformMatrix(): Matrix;
  35772. /**
  35773. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35774. * Cube and 2D textures for instance.
  35775. */
  35776. recreateShadowMap(): void;
  35777. private _disposeBlurPostProcesses;
  35778. private _disposeRTTandPostProcesses;
  35779. /**
  35780. * Disposes the ShadowGenerator.
  35781. * Returns nothing.
  35782. */
  35783. dispose(): void;
  35784. /**
  35785. * Serializes the shadow generator setup to a json object.
  35786. * @returns The serialized JSON object
  35787. */
  35788. serialize(): any;
  35789. /**
  35790. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  35791. * @param parsedShadowGenerator The JSON object to parse
  35792. * @param scene The scene to create the shadow map for
  35793. * @returns The parsed shadow generator
  35794. */
  35795. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  35796. }
  35797. }
  35798. declare module BABYLON {
  35799. /**
  35800. * Defines the shadow generator component responsible to manage any shadow generators
  35801. * in a given scene.
  35802. */
  35803. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  35804. /**
  35805. * The component name helpfull to identify the component in the list of scene components.
  35806. */
  35807. readonly name: string;
  35808. /**
  35809. * The scene the component belongs to.
  35810. */
  35811. scene: Scene;
  35812. /**
  35813. * Creates a new instance of the component for the given scene
  35814. * @param scene Defines the scene to register the component in
  35815. */
  35816. constructor(scene: Scene);
  35817. /**
  35818. * Registers the component in a given scene
  35819. */
  35820. register(): void;
  35821. /**
  35822. * Rebuilds the elements related to this component in case of
  35823. * context lost for instance.
  35824. */
  35825. rebuild(): void;
  35826. /**
  35827. * Serializes the component data to the specified json object
  35828. * @param serializationObject The object to serialize to
  35829. */
  35830. serialize(serializationObject: any): void;
  35831. /**
  35832. * Adds all the element from the container to the scene
  35833. * @param container the container holding the elements
  35834. */
  35835. addFromContainer(container: AbstractScene): void;
  35836. /**
  35837. * Removes all the elements in the container from the scene
  35838. * @param container contains the elements to remove
  35839. */
  35840. removeFromContainer(container: AbstractScene): void;
  35841. /**
  35842. * Rebuilds the elements related to this component in case of
  35843. * context lost for instance.
  35844. */
  35845. dispose(): void;
  35846. private _gatherRenderTargets;
  35847. }
  35848. }
  35849. declare module BABYLON {
  35850. }
  35851. declare module BABYLON {
  35852. /**
  35853. * Background material used to create an efficient environement around your scene.
  35854. */
  35855. class BackgroundMaterial extends PushMaterial {
  35856. /**
  35857. * Standard reflectance value at parallel view angle.
  35858. */
  35859. static StandardReflectance0: number;
  35860. /**
  35861. * Standard reflectance value at grazing angle.
  35862. */
  35863. static StandardReflectance90: number;
  35864. protected _primaryColor: Color3;
  35865. /**
  35866. * Key light Color (multiply against the environement texture)
  35867. */
  35868. primaryColor: Color3;
  35869. protected __perceptualColor: Nullable<Color3>;
  35870. /**
  35871. * Experimental Internal Use Only.
  35872. *
  35873. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  35874. * This acts as a helper to set the primary color to a more "human friendly" value.
  35875. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  35876. * output color as close as possible from the chosen value.
  35877. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  35878. * part of lighting setup.)
  35879. */
  35880. _perceptualColor: Nullable<Color3>;
  35881. protected _primaryColorShadowLevel: float;
  35882. /**
  35883. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  35884. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  35885. */
  35886. primaryColorShadowLevel: float;
  35887. protected _primaryColorHighlightLevel: float;
  35888. /**
  35889. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  35890. * The primary color is used at the level chosen to define what the white area would look.
  35891. */
  35892. primaryColorHighlightLevel: float;
  35893. protected _reflectionTexture: Nullable<BaseTexture>;
  35894. /**
  35895. * Reflection Texture used in the material.
  35896. * Should be author in a specific way for the best result (refer to the documentation).
  35897. */
  35898. reflectionTexture: Nullable<BaseTexture>;
  35899. protected _reflectionBlur: float;
  35900. /**
  35901. * Reflection Texture level of blur.
  35902. *
  35903. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  35904. * texture twice.
  35905. */
  35906. reflectionBlur: float;
  35907. protected _diffuseTexture: Nullable<BaseTexture>;
  35908. /**
  35909. * Diffuse Texture used in the material.
  35910. * Should be author in a specific way for the best result (refer to the documentation).
  35911. */
  35912. diffuseTexture: Nullable<BaseTexture>;
  35913. protected _shadowLights: Nullable<IShadowLight[]>;
  35914. /**
  35915. * Specify the list of lights casting shadow on the material.
  35916. * All scene shadow lights will be included if null.
  35917. */
  35918. shadowLights: Nullable<IShadowLight[]>;
  35919. protected _shadowLevel: float;
  35920. /**
  35921. * Helps adjusting the shadow to a softer level if required.
  35922. * 0 means black shadows and 1 means no shadows.
  35923. */
  35924. shadowLevel: float;
  35925. protected _sceneCenter: Vector3;
  35926. /**
  35927. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  35928. * It is usually zero but might be interesting to modify according to your setup.
  35929. */
  35930. sceneCenter: Vector3;
  35931. protected _opacityFresnel: boolean;
  35932. /**
  35933. * This helps specifying that the material is falling off to the sky box at grazing angle.
  35934. * This helps ensuring a nice transition when the camera goes under the ground.
  35935. */
  35936. opacityFresnel: boolean;
  35937. protected _reflectionFresnel: boolean;
  35938. /**
  35939. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  35940. * This helps adding a mirror texture on the ground.
  35941. */
  35942. reflectionFresnel: boolean;
  35943. protected _reflectionFalloffDistance: number;
  35944. /**
  35945. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  35946. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  35947. */
  35948. reflectionFalloffDistance: number;
  35949. protected _reflectionAmount: number;
  35950. /**
  35951. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  35952. */
  35953. reflectionAmount: number;
  35954. protected _reflectionReflectance0: number;
  35955. /**
  35956. * This specifies the weight of the reflection at grazing angle.
  35957. */
  35958. reflectionReflectance0: number;
  35959. protected _reflectionReflectance90: number;
  35960. /**
  35961. * This specifies the weight of the reflection at a perpendicular point of view.
  35962. */
  35963. reflectionReflectance90: number;
  35964. /**
  35965. * Sets the reflection reflectance fresnel values according to the default standard
  35966. * empirically know to work well :-)
  35967. */
  35968. reflectionStandardFresnelWeight: number;
  35969. protected _useRGBColor: boolean;
  35970. /**
  35971. * Helps to directly use the maps channels instead of their level.
  35972. */
  35973. useRGBColor: boolean;
  35974. protected _enableNoise: boolean;
  35975. /**
  35976. * This helps reducing the banding effect that could occur on the background.
  35977. */
  35978. enableNoise: boolean;
  35979. /**
  35980. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  35981. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  35982. * Recommended to be keep at 1.0 except for special cases.
  35983. */
  35984. fovMultiplier: number;
  35985. private _fovMultiplier;
  35986. /**
  35987. * Enable the FOV adjustment feature controlled by fovMultiplier.
  35988. */
  35989. useEquirectangularFOV: boolean;
  35990. private _maxSimultaneousLights;
  35991. /**
  35992. * Number of Simultaneous lights allowed on the material.
  35993. */
  35994. maxSimultaneousLights: int;
  35995. /**
  35996. * Default configuration related to image processing available in the Background Material.
  35997. */
  35998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35999. /**
  36000. * Keep track of the image processing observer to allow dispose and replace.
  36001. */
  36002. private _imageProcessingObserver;
  36003. /**
  36004. * Attaches a new image processing configuration to the PBR Material.
  36005. * @param configuration (if null the scene configuration will be use)
  36006. */
  36007. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36008. /**
  36009. * Gets the image processing configuration used either in this material.
  36010. */
  36011. /**
  36012. * Sets the Default image processing configuration used either in the this material.
  36013. *
  36014. * If sets to null, the scene one is in use.
  36015. */
  36016. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  36017. /**
  36018. * Gets wether the color curves effect is enabled.
  36019. */
  36020. /**
  36021. * Sets wether the color curves effect is enabled.
  36022. */
  36023. cameraColorCurvesEnabled: boolean;
  36024. /**
  36025. * Gets wether the color grading effect is enabled.
  36026. */
  36027. /**
  36028. * Gets wether the color grading effect is enabled.
  36029. */
  36030. cameraColorGradingEnabled: boolean;
  36031. /**
  36032. * Gets wether tonemapping is enabled or not.
  36033. */
  36034. /**
  36035. * Sets wether tonemapping is enabled or not
  36036. */
  36037. cameraToneMappingEnabled: boolean;
  36038. /**
  36039. * The camera exposure used on this material.
  36040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36041. * This corresponds to a photographic exposure.
  36042. */
  36043. /**
  36044. * The camera exposure used on this material.
  36045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36046. * This corresponds to a photographic exposure.
  36047. */
  36048. cameraExposure: float;
  36049. /**
  36050. * Gets The camera contrast used on this material.
  36051. */
  36052. /**
  36053. * Sets The camera contrast used on this material.
  36054. */
  36055. cameraContrast: float;
  36056. /**
  36057. * Gets the Color Grading 2D Lookup Texture.
  36058. */
  36059. /**
  36060. * Sets the Color Grading 2D Lookup Texture.
  36061. */
  36062. cameraColorGradingTexture: Nullable<BaseTexture>;
  36063. /**
  36064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36066. * 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;
  36067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36068. */
  36069. /**
  36070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36072. * 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;
  36073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36074. */
  36075. cameraColorCurves: Nullable<ColorCurves>;
  36076. /**
  36077. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  36078. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  36079. */
  36080. switchToBGR: boolean;
  36081. private _renderTargets;
  36082. private _reflectionControls;
  36083. private _white;
  36084. private _primaryShadowColor;
  36085. private _primaryHighlightColor;
  36086. /**
  36087. * Instantiates a Background Material in the given scene
  36088. * @param name The friendly name of the material
  36089. * @param scene The scene to add the material to
  36090. */
  36091. constructor(name: string, scene: Scene);
  36092. /**
  36093. * Gets a boolean indicating that current material needs to register RTT
  36094. */
  36095. readonly hasRenderTargetTextures: boolean;
  36096. /**
  36097. * The entire material has been created in order to prevent overdraw.
  36098. * @returns false
  36099. */
  36100. needAlphaTesting(): boolean;
  36101. /**
  36102. * The entire material has been created in order to prevent overdraw.
  36103. * @returns true if blending is enable
  36104. */
  36105. needAlphaBlending(): boolean;
  36106. /**
  36107. * Checks wether the material is ready to be rendered for a given mesh.
  36108. * @param mesh The mesh to render
  36109. * @param subMesh The submesh to check against
  36110. * @param useInstances Specify wether or not the material is used with instances
  36111. * @returns true if all the dependencies are ready (Textures, Effects...)
  36112. */
  36113. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  36114. /**
  36115. * Compute the primary color according to the chosen perceptual color.
  36116. */
  36117. private _computePrimaryColorFromPerceptualColor;
  36118. /**
  36119. * Compute the highlights and shadow colors according to their chosen levels.
  36120. */
  36121. private _computePrimaryColors;
  36122. /**
  36123. * Build the uniform buffer used in the material.
  36124. */
  36125. buildUniformLayout(): void;
  36126. /**
  36127. * Unbind the material.
  36128. */
  36129. unbind(): void;
  36130. /**
  36131. * Bind only the world matrix to the material.
  36132. * @param world The world matrix to bind.
  36133. */
  36134. bindOnlyWorldMatrix(world: Matrix): void;
  36135. /**
  36136. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  36137. * @param world The world matrix to bind.
  36138. * @param subMesh The submesh to bind for.
  36139. */
  36140. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  36141. /**
  36142. * Dispose the material.
  36143. * @param forceDisposeEffect Force disposal of the associated effect.
  36144. * @param forceDisposeTextures Force disposal of the associated textures.
  36145. */
  36146. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  36147. /**
  36148. * Clones the material.
  36149. * @param name The cloned name.
  36150. * @returns The cloned material.
  36151. */
  36152. clone(name: string): BackgroundMaterial;
  36153. /**
  36154. * Serializes the current material to its JSON representation.
  36155. * @returns The JSON representation.
  36156. */
  36157. serialize(): any;
  36158. /**
  36159. * Gets the class name of the material
  36160. * @returns "BackgroundMaterial"
  36161. */
  36162. getClassName(): string;
  36163. /**
  36164. * Parse a JSON input to create back a background material.
  36165. * @param source The JSON data to parse
  36166. * @param scene The scene to create the parsed material in
  36167. * @param rootUrl The root url of the assets the material depends upon
  36168. * @returns the instantiated BackgroundMaterial.
  36169. */
  36170. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  36171. }
  36172. }
  36173. declare module BABYLON {
  36174. /**
  36175. * The Physically based material base class of BJS.
  36176. *
  36177. * This offers the main features of a standard PBR material.
  36178. * For more information, please refer to the documentation :
  36179. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36180. */
  36181. abstract class PBRBaseMaterial extends PushMaterial {
  36182. /**
  36183. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  36184. */
  36185. static readonly LIGHTFALLOFF_PHYSICAL: number;
  36186. /**
  36187. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  36188. * to enhance interoperability with other engines.
  36189. */
  36190. static readonly LIGHTFALLOFF_GLTF: number;
  36191. /**
  36192. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  36193. * to enhance interoperability with other materials.
  36194. */
  36195. static readonly LIGHTFALLOFF_STANDARD: number;
  36196. /**
  36197. * Intensity of the direct lights e.g. the four lights available in your scene.
  36198. * This impacts both the direct diffuse and specular highlights.
  36199. */
  36200. protected _directIntensity: number;
  36201. /**
  36202. * Intensity of the emissive part of the material.
  36203. * This helps controlling the emissive effect without modifying the emissive color.
  36204. */
  36205. protected _emissiveIntensity: number;
  36206. /**
  36207. * Intensity of the environment e.g. how much the environment will light the object
  36208. * either through harmonics for rough material or through the refelction for shiny ones.
  36209. */
  36210. protected _environmentIntensity: number;
  36211. /**
  36212. * This is a special control allowing the reduction of the specular highlights coming from the
  36213. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36214. */
  36215. protected _specularIntensity: number;
  36216. /**
  36217. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  36218. */
  36219. private _lightingInfos;
  36220. /**
  36221. * Debug Control allowing disabling the bump map on this material.
  36222. */
  36223. protected _disableBumpMap: boolean;
  36224. /**
  36225. * AKA Diffuse Texture in standard nomenclature.
  36226. */
  36227. protected _albedoTexture: BaseTexture;
  36228. /**
  36229. * AKA Occlusion Texture in other nomenclature.
  36230. */
  36231. protected _ambientTexture: BaseTexture;
  36232. /**
  36233. * AKA Occlusion Texture Intensity in other nomenclature.
  36234. */
  36235. protected _ambientTextureStrength: number;
  36236. /**
  36237. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36238. * 1 means it completely occludes it
  36239. * 0 mean it has no impact
  36240. */
  36241. protected _ambientTextureImpactOnAnalyticalLights: number;
  36242. /**
  36243. * Stores the alpha values in a texture.
  36244. */
  36245. protected _opacityTexture: BaseTexture;
  36246. /**
  36247. * Stores the reflection values in a texture.
  36248. */
  36249. protected _reflectionTexture: BaseTexture;
  36250. /**
  36251. * Stores the refraction values in a texture.
  36252. */
  36253. protected _refractionTexture: BaseTexture;
  36254. /**
  36255. * Stores the emissive values in a texture.
  36256. */
  36257. protected _emissiveTexture: BaseTexture;
  36258. /**
  36259. * AKA Specular texture in other nomenclature.
  36260. */
  36261. protected _reflectivityTexture: BaseTexture;
  36262. /**
  36263. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36264. */
  36265. protected _metallicTexture: BaseTexture;
  36266. /**
  36267. * Specifies the metallic scalar of the metallic/roughness workflow.
  36268. * Can also be used to scale the metalness values of the metallic texture.
  36269. */
  36270. protected _metallic: Nullable<number>;
  36271. /**
  36272. * Specifies the roughness scalar of the metallic/roughness workflow.
  36273. * Can also be used to scale the roughness values of the metallic texture.
  36274. */
  36275. protected _roughness: Nullable<number>;
  36276. /**
  36277. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36278. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36279. */
  36280. protected _microSurfaceTexture: BaseTexture;
  36281. /**
  36282. * Stores surface normal data used to displace a mesh in a texture.
  36283. */
  36284. protected _bumpTexture: BaseTexture;
  36285. /**
  36286. * Stores the pre-calculated light information of a mesh in a texture.
  36287. */
  36288. protected _lightmapTexture: BaseTexture;
  36289. /**
  36290. * The color of a material in ambient lighting.
  36291. */
  36292. protected _ambientColor: Color3;
  36293. /**
  36294. * AKA Diffuse Color in other nomenclature.
  36295. */
  36296. protected _albedoColor: Color3;
  36297. /**
  36298. * AKA Specular Color in other nomenclature.
  36299. */
  36300. protected _reflectivityColor: Color3;
  36301. /**
  36302. * The color applied when light is reflected from a material.
  36303. */
  36304. protected _reflectionColor: Color3;
  36305. /**
  36306. * The color applied when light is emitted from a material.
  36307. */
  36308. protected _emissiveColor: Color3;
  36309. /**
  36310. * AKA Glossiness in other nomenclature.
  36311. */
  36312. protected _microSurface: number;
  36313. /**
  36314. * source material index of refraction (IOR)' / 'destination material IOR.
  36315. */
  36316. protected _indexOfRefraction: number;
  36317. /**
  36318. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36319. */
  36320. protected _invertRefractionY: boolean;
  36321. /**
  36322. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36323. * Materials half opaque for instance using refraction could benefit from this control.
  36324. */
  36325. protected _linkRefractionWithTransparency: boolean;
  36326. /**
  36327. * Specifies that the material will use the light map as a show map.
  36328. */
  36329. protected _useLightmapAsShadowmap: boolean;
  36330. /**
  36331. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36332. * makes the reflect vector face the model (under horizon).
  36333. */
  36334. protected _useHorizonOcclusion: boolean;
  36335. /**
  36336. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36337. * too much the area relying on ambient texture to define their ambient occlusion.
  36338. */
  36339. protected _useRadianceOcclusion: boolean;
  36340. /**
  36341. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36342. */
  36343. protected _useAlphaFromAlbedoTexture: boolean;
  36344. /**
  36345. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36346. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36347. */
  36348. protected _useSpecularOverAlpha: boolean;
  36349. /**
  36350. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36351. */
  36352. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36353. /**
  36354. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36355. */
  36356. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  36357. /**
  36358. * Specifies if the metallic texture contains the roughness information in its green channel.
  36359. */
  36360. protected _useRoughnessFromMetallicTextureGreen: boolean;
  36361. /**
  36362. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36363. */
  36364. protected _useMetallnessFromMetallicTextureBlue: boolean;
  36365. /**
  36366. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36367. */
  36368. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  36369. /**
  36370. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36371. */
  36372. protected _useAmbientInGrayScale: boolean;
  36373. /**
  36374. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36375. * The material will try to infer what glossiness each pixel should be.
  36376. */
  36377. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  36378. /**
  36379. * Defines the falloff type used in this material.
  36380. * It by default is Physical.
  36381. */
  36382. protected _lightFalloff: number;
  36383. /**
  36384. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36385. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36386. */
  36387. protected _useRadianceOverAlpha: boolean;
  36388. /**
  36389. * Allows using an object space normal map (instead of tangent space).
  36390. */
  36391. protected _useObjectSpaceNormalMap: boolean;
  36392. /**
  36393. * Allows using the bump map in parallax mode.
  36394. */
  36395. protected _useParallax: boolean;
  36396. /**
  36397. * Allows using the bump map in parallax occlusion mode.
  36398. */
  36399. protected _useParallaxOcclusion: boolean;
  36400. /**
  36401. * Controls the scale bias of the parallax mode.
  36402. */
  36403. protected _parallaxScaleBias: number;
  36404. /**
  36405. * If sets to true, disables all the lights affecting the material.
  36406. */
  36407. protected _disableLighting: boolean;
  36408. /**
  36409. * Number of Simultaneous lights allowed on the material.
  36410. */
  36411. protected _maxSimultaneousLights: number;
  36412. /**
  36413. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  36414. */
  36415. protected _invertNormalMapX: boolean;
  36416. /**
  36417. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  36418. */
  36419. protected _invertNormalMapY: boolean;
  36420. /**
  36421. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36422. */
  36423. protected _twoSidedLighting: boolean;
  36424. /**
  36425. * Defines the alpha limits in alpha test mode.
  36426. */
  36427. protected _alphaCutOff: number;
  36428. /**
  36429. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36430. */
  36431. protected _forceAlphaTest: boolean;
  36432. /**
  36433. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36434. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36435. */
  36436. protected _useAlphaFresnel: boolean;
  36437. /**
  36438. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36439. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36440. */
  36441. protected _useLinearAlphaFresnel: boolean;
  36442. /**
  36443. * The transparency mode of the material.
  36444. */
  36445. protected _transparencyMode: Nullable<number>;
  36446. /**
  36447. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  36448. * from cos thetav and roughness:
  36449. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  36450. */
  36451. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  36452. /**
  36453. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36454. */
  36455. protected _forceIrradianceInFragment: boolean;
  36456. /**
  36457. * Force normal to face away from face.
  36458. */
  36459. protected _forceNormalForward: boolean;
  36460. /**
  36461. * Enables specular anti aliasing in the PBR shader.
  36462. * It will both interacts on the Geometry for analytical and IBL lighting.
  36463. * It also prefilter the roughness map based on the bump values.
  36464. */
  36465. protected _enableSpecularAntiAliasing: boolean;
  36466. /**
  36467. * Default configuration related to image processing available in the PBR Material.
  36468. */
  36469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36470. /**
  36471. * Keep track of the image processing observer to allow dispose and replace.
  36472. */
  36473. private _imageProcessingObserver;
  36474. /**
  36475. * Attaches a new image processing configuration to the PBR Material.
  36476. * @param configuration
  36477. */
  36478. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36479. /**
  36480. * Stores the available render targets.
  36481. */
  36482. private _renderTargets;
  36483. /**
  36484. * Sets the global ambient color for the material used in lighting calculations.
  36485. */
  36486. private _globalAmbientColor;
  36487. /**
  36488. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  36489. */
  36490. private _useLogarithmicDepth;
  36491. /**
  36492. * If set to true, no lighting calculations will be applied.
  36493. */
  36494. private _unlit;
  36495. /**
  36496. * Instantiates a new PBRMaterial instance.
  36497. *
  36498. * @param name The material name
  36499. * @param scene The scene the material will be use in.
  36500. */
  36501. constructor(name: string, scene: Scene);
  36502. /**
  36503. * Gets a boolean indicating that current material needs to register RTT
  36504. */
  36505. readonly hasRenderTargetTextures: boolean;
  36506. /**
  36507. * Gets the name of the material class.
  36508. */
  36509. getClassName(): string;
  36510. /**
  36511. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  36512. */
  36513. /**
  36514. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  36515. */
  36516. useLogarithmicDepth: boolean;
  36517. /**
  36518. * Gets the current transparency mode.
  36519. */
  36520. /**
  36521. * Sets the transparency mode of the material.
  36522. *
  36523. * | Value | Type | Description |
  36524. * | ----- | ----------------------------------- | ----------- |
  36525. * | 0 | OPAQUE | |
  36526. * | 1 | ALPHATEST | |
  36527. * | 2 | ALPHABLEND | |
  36528. * | 3 | ALPHATESTANDBLEND | |
  36529. *
  36530. */
  36531. transparencyMode: Nullable<number>;
  36532. /**
  36533. * Returns true if alpha blending should be disabled.
  36534. */
  36535. private readonly _disableAlphaBlending;
  36536. /**
  36537. * Specifies whether or not this material should be rendered in alpha blend mode.
  36538. */
  36539. needAlphaBlending(): boolean;
  36540. /**
  36541. * Specifies if the mesh will require alpha blending.
  36542. * @param mesh - BJS mesh.
  36543. */
  36544. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  36545. /**
  36546. * Specifies whether or not this material should be rendered in alpha test mode.
  36547. */
  36548. needAlphaTesting(): boolean;
  36549. /**
  36550. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  36551. */
  36552. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  36553. /**
  36554. * Gets the texture used for the alpha test.
  36555. */
  36556. getAlphaTestTexture(): BaseTexture;
  36557. /**
  36558. * Stores the reflectivity values based on metallic roughness workflow.
  36559. */
  36560. private static _scaledReflectivity;
  36561. /**
  36562. * Specifies that the submesh is ready to be used.
  36563. * @param mesh - BJS mesh.
  36564. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  36565. * @param useInstances - Specifies that instances should be used.
  36566. * @returns - boolean indicating that the submesh is ready or not.
  36567. */
  36568. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  36569. /**
  36570. * Specifies if the material uses metallic roughness workflow.
  36571. * @returns boolean specifiying if the material uses metallic roughness workflow.
  36572. */
  36573. isMetallicWorkflow(): boolean;
  36574. private _prepareEffect;
  36575. private _prepareDefines;
  36576. /**
  36577. * Force shader compilation
  36578. */
  36579. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  36580. clipPlane: boolean;
  36581. }>): void;
  36582. /**
  36583. * Initializes the uniform buffer layout for the shader.
  36584. */
  36585. buildUniformLayout(): void;
  36586. /**
  36587. * Unbinds the textures.
  36588. */
  36589. unbind(): void;
  36590. /**
  36591. * Binds the submesh data.
  36592. * @param world - The world matrix.
  36593. * @param mesh - The BJS mesh.
  36594. * @param subMesh - A submesh of the BJS mesh.
  36595. */
  36596. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  36597. /**
  36598. * Returns the animatable textures.
  36599. * @returns - Array of animatable textures.
  36600. */
  36601. getAnimatables(): IAnimatable[];
  36602. /**
  36603. * Returns the texture used for reflections.
  36604. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  36605. */
  36606. private _getReflectionTexture;
  36607. /**
  36608. * Returns the texture used for refraction or null if none is used.
  36609. * @returns - Refection texture if present. If no refraction texture and refraction
  36610. * is linked with transparency, returns environment texture. Otherwise, returns null.
  36611. */
  36612. private _getRefractionTexture;
  36613. /**
  36614. * Disposes the resources of the material.
  36615. * @param forceDisposeEffect - Forces the disposal of effects.
  36616. * @param forceDisposeTextures - Forces the disposal of all textures.
  36617. */
  36618. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  36619. }
  36620. }
  36621. declare module BABYLON {
  36622. /**
  36623. * The Physically based simple base material of BJS.
  36624. *
  36625. * This enables better naming and convention enforcements on top of the pbrMaterial.
  36626. * It is used as the base class for both the specGloss and metalRough conventions.
  36627. */
  36628. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  36629. /**
  36630. * Number of Simultaneous lights allowed on the material.
  36631. */
  36632. maxSimultaneousLights: number;
  36633. /**
  36634. * If sets to true, disables all the lights affecting the material.
  36635. */
  36636. disableLighting: boolean;
  36637. /**
  36638. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  36639. */
  36640. environmentTexture: BaseTexture;
  36641. /**
  36642. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36643. */
  36644. invertNormalMapX: boolean;
  36645. /**
  36646. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36647. */
  36648. invertNormalMapY: boolean;
  36649. /**
  36650. * Normal map used in the model.
  36651. */
  36652. normalTexture: BaseTexture;
  36653. /**
  36654. * Emissivie color used to self-illuminate the model.
  36655. */
  36656. emissiveColor: Color3;
  36657. /**
  36658. * Emissivie texture used to self-illuminate the model.
  36659. */
  36660. emissiveTexture: BaseTexture;
  36661. /**
  36662. * Occlusion Channel Strenght.
  36663. */
  36664. occlusionStrength: number;
  36665. /**
  36666. * Occlusion Texture of the material (adding extra occlusion effects).
  36667. */
  36668. occlusionTexture: BaseTexture;
  36669. /**
  36670. * Defines the alpha limits in alpha test mode.
  36671. */
  36672. alphaCutOff: number;
  36673. /**
  36674. * Gets the current double sided mode.
  36675. */
  36676. /**
  36677. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36678. */
  36679. doubleSided: boolean;
  36680. lightmapTexture: BaseTexture;
  36681. useLightmapAsShadowmap: boolean;
  36682. /**
  36683. * Return the active textures of the material.
  36684. */
  36685. getActiveTextures(): BaseTexture[];
  36686. hasTexture(texture: BaseTexture): boolean;
  36687. /**
  36688. * Instantiates a new PBRMaterial instance.
  36689. *
  36690. * @param name The material name
  36691. * @param scene The scene the material will be use in.
  36692. */
  36693. constructor(name: string, scene: Scene);
  36694. getClassName(): string;
  36695. }
  36696. }
  36697. declare module BABYLON {
  36698. /**
  36699. * The Physically based material of BJS.
  36700. *
  36701. * This offers the main features of a standard PBR material.
  36702. * For more information, please refer to the documentation :
  36703. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36704. */
  36705. class PBRMaterial extends PBRBaseMaterial {
  36706. /**
  36707. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  36708. */
  36709. static readonly PBRMATERIAL_OPAQUE: number;
  36710. /**
  36711. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  36712. */
  36713. static readonly PBRMATERIAL_ALPHATEST: number;
  36714. /**
  36715. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36716. */
  36717. static readonly PBRMATERIAL_ALPHABLEND: number;
  36718. /**
  36719. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36720. * They are also discarded below the alpha cutoff threshold to improve performances.
  36721. */
  36722. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  36723. /**
  36724. * Defines the default value of how much AO map is occluding the analytical lights
  36725. * (point spot...).
  36726. */
  36727. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  36728. /**
  36729. * Intensity of the direct lights e.g. the four lights available in your scene.
  36730. * This impacts both the direct diffuse and specular highlights.
  36731. */
  36732. directIntensity: number;
  36733. /**
  36734. * Intensity of the emissive part of the material.
  36735. * This helps controlling the emissive effect without modifying the emissive color.
  36736. */
  36737. emissiveIntensity: number;
  36738. /**
  36739. * Intensity of the environment e.g. how much the environment will light the object
  36740. * either through harmonics for rough material or through the refelction for shiny ones.
  36741. */
  36742. environmentIntensity: number;
  36743. /**
  36744. * This is a special control allowing the reduction of the specular highlights coming from the
  36745. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36746. */
  36747. specularIntensity: number;
  36748. /**
  36749. * Debug Control allowing disabling the bump map on this material.
  36750. */
  36751. disableBumpMap: boolean;
  36752. /**
  36753. * AKA Diffuse Texture in standard nomenclature.
  36754. */
  36755. albedoTexture: BaseTexture;
  36756. /**
  36757. * AKA Occlusion Texture in other nomenclature.
  36758. */
  36759. ambientTexture: BaseTexture;
  36760. /**
  36761. * AKA Occlusion Texture Intensity in other nomenclature.
  36762. */
  36763. ambientTextureStrength: number;
  36764. /**
  36765. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36766. * 1 means it completely occludes it
  36767. * 0 mean it has no impact
  36768. */
  36769. ambientTextureImpactOnAnalyticalLights: number;
  36770. /**
  36771. * Stores the alpha values in a texture.
  36772. */
  36773. opacityTexture: BaseTexture;
  36774. /**
  36775. * Stores the reflection values in a texture.
  36776. */
  36777. reflectionTexture: Nullable<BaseTexture>;
  36778. /**
  36779. * Stores the emissive values in a texture.
  36780. */
  36781. emissiveTexture: BaseTexture;
  36782. /**
  36783. * AKA Specular texture in other nomenclature.
  36784. */
  36785. reflectivityTexture: BaseTexture;
  36786. /**
  36787. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36788. */
  36789. metallicTexture: BaseTexture;
  36790. /**
  36791. * Specifies the metallic scalar of the metallic/roughness workflow.
  36792. * Can also be used to scale the metalness values of the metallic texture.
  36793. */
  36794. metallic: Nullable<number>;
  36795. /**
  36796. * Specifies the roughness scalar of the metallic/roughness workflow.
  36797. * Can also be used to scale the roughness values of the metallic texture.
  36798. */
  36799. roughness: Nullable<number>;
  36800. /**
  36801. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36802. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36803. */
  36804. microSurfaceTexture: BaseTexture;
  36805. /**
  36806. * Stores surface normal data used to displace a mesh in a texture.
  36807. */
  36808. bumpTexture: BaseTexture;
  36809. /**
  36810. * Stores the pre-calculated light information of a mesh in a texture.
  36811. */
  36812. lightmapTexture: BaseTexture;
  36813. /**
  36814. * Stores the refracted light information in a texture.
  36815. */
  36816. refractionTexture: BaseTexture;
  36817. /**
  36818. * The color of a material in ambient lighting.
  36819. */
  36820. ambientColor: Color3;
  36821. /**
  36822. * AKA Diffuse Color in other nomenclature.
  36823. */
  36824. albedoColor: Color3;
  36825. /**
  36826. * AKA Specular Color in other nomenclature.
  36827. */
  36828. reflectivityColor: Color3;
  36829. /**
  36830. * The color reflected from the material.
  36831. */
  36832. reflectionColor: Color3;
  36833. /**
  36834. * The color emitted from the material.
  36835. */
  36836. emissiveColor: Color3;
  36837. /**
  36838. * AKA Glossiness in other nomenclature.
  36839. */
  36840. microSurface: number;
  36841. /**
  36842. * source material index of refraction (IOR)' / 'destination material IOR.
  36843. */
  36844. indexOfRefraction: number;
  36845. /**
  36846. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36847. */
  36848. invertRefractionY: boolean;
  36849. /**
  36850. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36851. * Materials half opaque for instance using refraction could benefit from this control.
  36852. */
  36853. linkRefractionWithTransparency: boolean;
  36854. useLightmapAsShadowmap: boolean;
  36855. /**
  36856. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36857. */
  36858. useAlphaFromAlbedoTexture: boolean;
  36859. /**
  36860. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36861. */
  36862. forceAlphaTest: boolean;
  36863. /**
  36864. * Defines the alpha limits in alpha test mode.
  36865. */
  36866. alphaCutOff: number;
  36867. /**
  36868. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36869. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36870. */
  36871. useSpecularOverAlpha: boolean;
  36872. /**
  36873. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36874. */
  36875. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36876. /**
  36877. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36878. */
  36879. useRoughnessFromMetallicTextureAlpha: boolean;
  36880. /**
  36881. * Specifies if the metallic texture contains the roughness information in its green channel.
  36882. */
  36883. useRoughnessFromMetallicTextureGreen: boolean;
  36884. /**
  36885. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36886. */
  36887. useMetallnessFromMetallicTextureBlue: boolean;
  36888. /**
  36889. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36890. */
  36891. useAmbientOcclusionFromMetallicTextureRed: boolean;
  36892. /**
  36893. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36894. */
  36895. useAmbientInGrayScale: boolean;
  36896. /**
  36897. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36898. * The material will try to infer what glossiness each pixel should be.
  36899. */
  36900. useAutoMicroSurfaceFromReflectivityMap: boolean;
  36901. /**
  36902. * BJS is using an harcoded light falloff based on a manually sets up range.
  36903. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36904. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36905. */
  36906. /**
  36907. * BJS is using an harcoded light falloff based on a manually sets up range.
  36908. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36909. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36910. */
  36911. usePhysicalLightFalloff: boolean;
  36912. /**
  36913. * In order to support the falloff compatibility with gltf, a special mode has been added
  36914. * to reproduce the gltf light falloff.
  36915. */
  36916. /**
  36917. * In order to support the falloff compatibility with gltf, a special mode has been added
  36918. * to reproduce the gltf light falloff.
  36919. */
  36920. useGLTFLightFalloff: boolean;
  36921. /**
  36922. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36923. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36924. */
  36925. useRadianceOverAlpha: boolean;
  36926. /**
  36927. * Allows using an object space normal map (instead of tangent space).
  36928. */
  36929. useObjectSpaceNormalMap: boolean;
  36930. /**
  36931. * Allows using the bump map in parallax mode.
  36932. */
  36933. useParallax: boolean;
  36934. /**
  36935. * Allows using the bump map in parallax occlusion mode.
  36936. */
  36937. useParallaxOcclusion: boolean;
  36938. /**
  36939. * Controls the scale bias of the parallax mode.
  36940. */
  36941. parallaxScaleBias: number;
  36942. /**
  36943. * If sets to true, disables all the lights affecting the material.
  36944. */
  36945. disableLighting: boolean;
  36946. /**
  36947. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36948. */
  36949. forceIrradianceInFragment: boolean;
  36950. /**
  36951. * Number of Simultaneous lights allowed on the material.
  36952. */
  36953. maxSimultaneousLights: number;
  36954. /**
  36955. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36956. */
  36957. invertNormalMapX: boolean;
  36958. /**
  36959. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36960. */
  36961. invertNormalMapY: boolean;
  36962. /**
  36963. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36964. */
  36965. twoSidedLighting: boolean;
  36966. /**
  36967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36968. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36969. */
  36970. useAlphaFresnel: boolean;
  36971. /**
  36972. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36973. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36974. */
  36975. useLinearAlphaFresnel: boolean;
  36976. /**
  36977. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36978. * And/Or occlude the blended part.
  36979. */
  36980. environmentBRDFTexture: Nullable<BaseTexture>;
  36981. /**
  36982. * Force normal to face away from face.
  36983. */
  36984. forceNormalForward: boolean;
  36985. /**
  36986. * Enables specular anti aliasing in the PBR shader.
  36987. * It will both interacts on the Geometry for analytical and IBL lighting.
  36988. * It also prefilter the roughness map based on the bump values.
  36989. */
  36990. enableSpecularAntiAliasing: boolean;
  36991. /**
  36992. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36993. * makes the reflect vector face the model (under horizon).
  36994. */
  36995. useHorizonOcclusion: boolean;
  36996. /**
  36997. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36998. * too much the area relying on ambient texture to define their ambient occlusion.
  36999. */
  37000. useRadianceOcclusion: boolean;
  37001. /**
  37002. * If set to true, no lighting calculations will be applied.
  37003. */
  37004. unlit: boolean;
  37005. /**
  37006. * Gets the image processing configuration used either in this material.
  37007. */
  37008. /**
  37009. * Sets the Default image processing configuration used either in the this material.
  37010. *
  37011. * If sets to null, the scene one is in use.
  37012. */
  37013. imageProcessingConfiguration: ImageProcessingConfiguration;
  37014. /**
  37015. * Gets wether the color curves effect is enabled.
  37016. */
  37017. /**
  37018. * Sets wether the color curves effect is enabled.
  37019. */
  37020. cameraColorCurvesEnabled: boolean;
  37021. /**
  37022. * Gets wether the color grading effect is enabled.
  37023. */
  37024. /**
  37025. * Gets wether the color grading effect is enabled.
  37026. */
  37027. cameraColorGradingEnabled: boolean;
  37028. /**
  37029. * Gets wether tonemapping is enabled or not.
  37030. */
  37031. /**
  37032. * Sets wether tonemapping is enabled or not
  37033. */
  37034. cameraToneMappingEnabled: boolean;
  37035. /**
  37036. * The camera exposure used on this material.
  37037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37038. * This corresponds to a photographic exposure.
  37039. */
  37040. /**
  37041. * The camera exposure used on this material.
  37042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37043. * This corresponds to a photographic exposure.
  37044. */
  37045. cameraExposure: number;
  37046. /**
  37047. * Gets The camera contrast used on this material.
  37048. */
  37049. /**
  37050. * Sets The camera contrast used on this material.
  37051. */
  37052. cameraContrast: number;
  37053. /**
  37054. * Gets the Color Grading 2D Lookup Texture.
  37055. */
  37056. /**
  37057. * Sets the Color Grading 2D Lookup Texture.
  37058. */
  37059. cameraColorGradingTexture: Nullable<BaseTexture>;
  37060. /**
  37061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37063. * 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;
  37064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37065. */
  37066. /**
  37067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37069. * 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;
  37070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37071. */
  37072. cameraColorCurves: Nullable<ColorCurves>;
  37073. /**
  37074. * Instantiates a new PBRMaterial instance.
  37075. *
  37076. * @param name The material name
  37077. * @param scene The scene the material will be use in.
  37078. */
  37079. constructor(name: string, scene: Scene);
  37080. /**
  37081. * Returns the name of this material class.
  37082. */
  37083. getClassName(): string;
  37084. /**
  37085. * Returns an array of the actively used textures.
  37086. * @returns - Array of BaseTextures
  37087. */
  37088. getActiveTextures(): BaseTexture[];
  37089. /**
  37090. * Checks to see if a texture is used in the material.
  37091. * @param texture - Base texture to use.
  37092. * @returns - Boolean specifying if a texture is used in the material.
  37093. */
  37094. hasTexture(texture: BaseTexture): boolean;
  37095. /**
  37096. * Makes a duplicate of the current material.
  37097. * @param name - name to use for the new material.
  37098. */
  37099. clone(name: string): PBRMaterial;
  37100. /**
  37101. * Serializes this PBR Material.
  37102. * @returns - An object with the serialized material.
  37103. */
  37104. serialize(): any;
  37105. /**
  37106. * Parses a PBR Material from a serialized object.
  37107. * @param source - Serialized object.
  37108. * @param scene - BJS scene instance.
  37109. * @param rootUrl - url for the scene object
  37110. * @returns - PBRMaterial
  37111. */
  37112. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  37113. }
  37114. }
  37115. declare module BABYLON {
  37116. /**
  37117. * The PBR material of BJS following the metal roughness convention.
  37118. *
  37119. * This fits to the PBR convention in the GLTF definition:
  37120. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  37121. */
  37122. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  37123. /**
  37124. * The base color has two different interpretations depending on the value of metalness.
  37125. * When the material is a metal, the base color is the specific measured reflectance value
  37126. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  37127. * of the material.
  37128. */
  37129. baseColor: Color3;
  37130. /**
  37131. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  37132. * well as opacity information in the alpha channel.
  37133. */
  37134. baseTexture: BaseTexture;
  37135. /**
  37136. * Specifies the metallic scalar value of the material.
  37137. * Can also be used to scale the metalness values of the metallic texture.
  37138. */
  37139. metallic: number;
  37140. /**
  37141. * Specifies the roughness scalar value of the material.
  37142. * Can also be used to scale the roughness values of the metallic texture.
  37143. */
  37144. roughness: number;
  37145. /**
  37146. * Texture containing both the metallic value in the B channel and the
  37147. * roughness value in the G channel to keep better precision.
  37148. */
  37149. metallicRoughnessTexture: BaseTexture;
  37150. /**
  37151. * Instantiates a new PBRMetalRoughnessMaterial instance.
  37152. *
  37153. * @param name The material name
  37154. * @param scene The scene the material will be use in.
  37155. */
  37156. constructor(name: string, scene: Scene);
  37157. /**
  37158. * Return the currrent class name of the material.
  37159. */
  37160. getClassName(): string;
  37161. /**
  37162. * Return the active textures of the material.
  37163. */
  37164. getActiveTextures(): BaseTexture[];
  37165. /**
  37166. * Checks to see if a texture is used in the material.
  37167. * @param texture - Base texture to use.
  37168. * @returns - Boolean specifying if a texture is used in the material.
  37169. */
  37170. hasTexture(texture: BaseTexture): boolean;
  37171. /**
  37172. * Makes a duplicate of the current material.
  37173. * @param name - name to use for the new material.
  37174. */
  37175. clone(name: string): PBRMetallicRoughnessMaterial;
  37176. /**
  37177. * Serialize the material to a parsable JSON object.
  37178. */
  37179. serialize(): any;
  37180. /**
  37181. * Parses a JSON object correponding to the serialize function.
  37182. */
  37183. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  37184. }
  37185. }
  37186. declare module BABYLON {
  37187. /**
  37188. * The PBR material of BJS following the specular glossiness convention.
  37189. *
  37190. * This fits to the PBR convention in the GLTF definition:
  37191. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  37192. */
  37193. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  37194. /**
  37195. * Specifies the diffuse color of the material.
  37196. */
  37197. diffuseColor: Color3;
  37198. /**
  37199. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  37200. * channel.
  37201. */
  37202. diffuseTexture: BaseTexture;
  37203. /**
  37204. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  37205. */
  37206. specularColor: Color3;
  37207. /**
  37208. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  37209. */
  37210. glossiness: number;
  37211. /**
  37212. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  37213. */
  37214. specularGlossinessTexture: BaseTexture;
  37215. /**
  37216. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  37217. *
  37218. * @param name The material name
  37219. * @param scene The scene the material will be use in.
  37220. */
  37221. constructor(name: string, scene: Scene);
  37222. /**
  37223. * Return the currrent class name of the material.
  37224. */
  37225. getClassName(): string;
  37226. /**
  37227. * Return the active textures of the material.
  37228. */
  37229. getActiveTextures(): BaseTexture[];
  37230. /**
  37231. * Checks to see if a texture is used in the material.
  37232. * @param texture - Base texture to use.
  37233. * @returns - Boolean specifying if a texture is used in the material.
  37234. */
  37235. hasTexture(texture: BaseTexture): boolean;
  37236. /**
  37237. * Makes a duplicate of the current material.
  37238. * @param name - name to use for the new material.
  37239. */
  37240. clone(name: string): PBRSpecularGlossinessMaterial;
  37241. /**
  37242. * Serialize the material to a parsable JSON object.
  37243. */
  37244. serialize(): any;
  37245. /**
  37246. * Parses a JSON object correponding to the serialize function.
  37247. */
  37248. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  37249. }
  37250. }
  37251. declare module BABYLON {
  37252. class BaseTexture {
  37253. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37254. name: string;
  37255. private _hasAlpha;
  37256. hasAlpha: boolean;
  37257. getAlphaFromRGB: boolean;
  37258. level: number;
  37259. coordinatesIndex: number;
  37260. private _coordinatesMode;
  37261. /**
  37262. * How a texture is mapped.
  37263. *
  37264. * | Value | Type | Description |
  37265. * | ----- | ----------------------------------- | ----------- |
  37266. * | 0 | EXPLICIT_MODE | |
  37267. * | 1 | SPHERICAL_MODE | |
  37268. * | 2 | PLANAR_MODE | |
  37269. * | 3 | CUBIC_MODE | |
  37270. * | 4 | PROJECTION_MODE | |
  37271. * | 5 | SKYBOX_MODE | |
  37272. * | 6 | INVCUBIC_MODE | |
  37273. * | 7 | EQUIRECTANGULAR_MODE | |
  37274. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37275. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37276. */
  37277. coordinatesMode: number;
  37278. /**
  37279. * | Value | Type | Description |
  37280. * | ----- | ------------------ | ----------- |
  37281. * | 0 | CLAMP_ADDRESSMODE | |
  37282. * | 1 | WRAP_ADDRESSMODE | |
  37283. * | 2 | MIRROR_ADDRESSMODE | |
  37284. */
  37285. wrapU: number;
  37286. /**
  37287. * | Value | Type | Description |
  37288. * | ----- | ------------------ | ----------- |
  37289. * | 0 | CLAMP_ADDRESSMODE | |
  37290. * | 1 | WRAP_ADDRESSMODE | |
  37291. * | 2 | MIRROR_ADDRESSMODE | |
  37292. */
  37293. wrapV: number;
  37294. /**
  37295. * | Value | Type | Description |
  37296. * | ----- | ------------------ | ----------- |
  37297. * | 0 | CLAMP_ADDRESSMODE | |
  37298. * | 1 | WRAP_ADDRESSMODE | |
  37299. * | 2 | MIRROR_ADDRESSMODE | |
  37300. */
  37301. wrapR: number;
  37302. anisotropicFilteringLevel: number;
  37303. isCube: boolean;
  37304. is3D: boolean;
  37305. gammaSpace: boolean;
  37306. /**
  37307. * Gets whether or not the texture contains RGBD data.
  37308. */
  37309. readonly isRGBD: boolean;
  37310. invertZ: boolean;
  37311. lodLevelInAlpha: boolean;
  37312. lodGenerationOffset: number;
  37313. lodGenerationScale: number;
  37314. isRenderTarget: boolean;
  37315. readonly uid: string;
  37316. toString(): string;
  37317. getClassName(): string;
  37318. animations: Animation[];
  37319. /**
  37320. * An event triggered when the texture is disposed.
  37321. */
  37322. onDisposeObservable: Observable<BaseTexture>;
  37323. private _onDisposeObserver;
  37324. onDispose: () => void;
  37325. delayLoadState: number;
  37326. private _scene;
  37327. /** @hidden */
  37328. _texture: Nullable<InternalTexture>;
  37329. private _uid;
  37330. readonly isBlocking: boolean;
  37331. constructor(scene: Nullable<Scene>);
  37332. getScene(): Nullable<Scene>;
  37333. getTextureMatrix(): Matrix;
  37334. getReflectionTextureMatrix(): Matrix;
  37335. getInternalTexture(): Nullable<InternalTexture>;
  37336. isReadyOrNotBlocking(): boolean;
  37337. isReady(): boolean;
  37338. private _cachedSize;
  37339. getSize(): ISize;
  37340. getBaseSize(): ISize;
  37341. scale(ratio: number): void;
  37342. readonly canRescale: boolean;
  37343. /** @hidden */
  37344. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  37345. /** @hidden */
  37346. _rebuild(): void;
  37347. delayLoad(): void;
  37348. clone(): Nullable<BaseTexture>;
  37349. readonly textureType: number;
  37350. readonly textureFormat: number;
  37351. /**
  37352. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37353. * This will returns an RGBA array buffer containing either in values (0-255) or
  37354. * float values (0-1) depending of the underlying buffer type.
  37355. * @param faceIndex The face of the texture to read (in case of cube texture)
  37356. * @param level The LOD level of the texture to read (in case of Mip Maps)
  37357. * @returns The Array buffer containing the pixels data.
  37358. */
  37359. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  37360. releaseInternalTexture(): void;
  37361. sphericalPolynomial: Nullable<SphericalPolynomial>;
  37362. readonly _lodTextureHigh: Nullable<BaseTexture>;
  37363. readonly _lodTextureMid: Nullable<BaseTexture>;
  37364. readonly _lodTextureLow: Nullable<BaseTexture>;
  37365. dispose(): void;
  37366. serialize(): any;
  37367. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37368. }
  37369. }
  37370. declare module BABYLON {
  37371. /**
  37372. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  37373. * It can help converting any input color in a desired output one. This can then be used to create effects
  37374. * from sepia, black and white to sixties or futuristic rendering...
  37375. *
  37376. * The only supported format is currently 3dl.
  37377. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  37378. */
  37379. class ColorGradingTexture extends BaseTexture {
  37380. /**
  37381. * The current texture matrix. (will always be identity in color grading texture)
  37382. */
  37383. private _textureMatrix;
  37384. /**
  37385. * The texture URL.
  37386. */
  37387. url: string;
  37388. /**
  37389. * Empty line regex stored for GC.
  37390. */
  37391. private static _noneEmptyLineRegex;
  37392. private _engine;
  37393. /**
  37394. * Instantiates a ColorGradingTexture from the following parameters.
  37395. *
  37396. * @param url The location of the color gradind data (currently only supporting 3dl)
  37397. * @param scene The scene the texture will be used in
  37398. */
  37399. constructor(url: string, scene: Scene);
  37400. /**
  37401. * Returns the texture matrix used in most of the material.
  37402. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  37403. */
  37404. getTextureMatrix(): Matrix;
  37405. /**
  37406. * Occurs when the file being loaded is a .3dl LUT file.
  37407. */
  37408. private load3dlTexture;
  37409. /**
  37410. * Starts the loading process of the texture.
  37411. */
  37412. private loadTexture;
  37413. /**
  37414. * Clones the color gradind texture.
  37415. */
  37416. clone(): ColorGradingTexture;
  37417. /**
  37418. * Called during delayed load for textures.
  37419. */
  37420. delayLoad(): void;
  37421. /**
  37422. * Parses a color grading texture serialized by Babylon.
  37423. * @param parsedTexture The texture information being parsedTexture
  37424. * @param scene The scene to load the texture in
  37425. * @param rootUrl The root url of the data assets to load
  37426. * @return A color gradind texture
  37427. */
  37428. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  37429. /**
  37430. * Serializes the LUT texture to json format.
  37431. */
  37432. serialize(): any;
  37433. }
  37434. }
  37435. declare module BABYLON {
  37436. class CubeTexture extends BaseTexture {
  37437. url: string;
  37438. /**
  37439. * Gets or sets the center of the bounding box associated with the cube texture
  37440. * It must define where the camera used to render the texture was set
  37441. */
  37442. boundingBoxPosition: Vector3;
  37443. private _boundingBoxSize;
  37444. /**
  37445. * Gets or sets the size of the bounding box associated with the cube texture
  37446. * When defined, the cubemap will switch to local mode
  37447. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37448. * @example https://www.babylonjs-playground.com/#RNASML
  37449. */
  37450. boundingBoxSize: Vector3;
  37451. protected _rotationY: number;
  37452. /**
  37453. * Sets texture matrix rotation angle around Y axis in radians.
  37454. */
  37455. /**
  37456. * Gets texture matrix rotation angle around Y axis radians.
  37457. */
  37458. rotationY: number;
  37459. private _noMipmap;
  37460. private _files;
  37461. private _extensions;
  37462. private _textureMatrix;
  37463. private _format;
  37464. private _createPolynomials;
  37465. /** @hidden */
  37466. readonly _prefiltered: boolean;
  37467. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  37468. /**
  37469. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  37470. * @param url defines the url of the prefiltered texture
  37471. * @param scene defines the scene the texture is attached to
  37472. * @param forcedExtension defines the extension of the file if different from the url
  37473. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  37474. * @return the prefiltered texture
  37475. */
  37476. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  37477. /**
  37478. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  37479. * as prefiltered data.
  37480. * @param rootUrl defines the url of the texture or the root name of the six images
  37481. * @param scene defines the scene the texture is attached to
  37482. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  37483. * @param noMipmap defines if mipmaps should be created or not
  37484. * @param files defines the six files to load for the different faces
  37485. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  37486. * @param onError defines a callback triggered in case of error during load
  37487. * @param format defines the internal format to use for the texture once loaded
  37488. * @param prefiltered defines whether or not the texture is created from prefiltered data
  37489. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  37490. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  37491. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37492. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37493. * @return the cube texture
  37494. */
  37495. 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);
  37496. delayLoad(): void;
  37497. getReflectionTextureMatrix(): Matrix;
  37498. setReflectionTextureMatrix(value: Matrix): void;
  37499. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  37500. clone(): CubeTexture;
  37501. }
  37502. }
  37503. declare module BABYLON {
  37504. /**
  37505. * A class extending {BABYLON.Texture} allowing drawing on a texture
  37506. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37507. */
  37508. class DynamicTexture extends Texture {
  37509. private _generateMipMaps;
  37510. private _canvas;
  37511. private _context;
  37512. private _engine;
  37513. /**
  37514. * Creates a {BABYLON.DynamicTexture}
  37515. * @param name defines the name of the texture
  37516. * @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
  37517. * @param scene defines the scene where you want the texture
  37518. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37519. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37520. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  37521. */
  37522. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37523. /**
  37524. * Gets the current state of canRescale
  37525. */
  37526. readonly canRescale: boolean;
  37527. private _recreate;
  37528. /**
  37529. * Scales the texture
  37530. * @param ratio the scale factor to apply to both width and height
  37531. */
  37532. scale(ratio: number): void;
  37533. /**
  37534. * Resizes the texture
  37535. * @param width the new width
  37536. * @param height the new height
  37537. */
  37538. scaleTo(width: number, height: number): void;
  37539. /**
  37540. * Gets the context of the canvas used by the texture
  37541. * @returns the canvas context of the dynamic texture
  37542. */
  37543. getContext(): CanvasRenderingContext2D;
  37544. /**
  37545. * Clears the texture
  37546. */
  37547. clear(): void;
  37548. /**
  37549. * Updates the texture
  37550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37551. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37552. */
  37553. update(invertY?: boolean, premulAlpha?: boolean): void;
  37554. /**
  37555. * Draws text onto the texture
  37556. * @param text defines the text to be drawn
  37557. * @param x defines the placement of the text from the left
  37558. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37559. * @param font defines the font to be used with font-style, font-size, font-name
  37560. * @param color defines the color used for the text
  37561. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37562. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37563. * @param update defines whether texture is immediately update (default is true)
  37564. */
  37565. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37566. /**
  37567. * Clones the texture
  37568. * @returns the clone of the texture.
  37569. */
  37570. clone(): DynamicTexture;
  37571. /**
  37572. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37573. * @returns a serialized dynamic texture object
  37574. */
  37575. serialize(): any;
  37576. /** @hidden */
  37577. _rebuild(): void;
  37578. }
  37579. }
  37580. declare module BABYLON {
  37581. /**
  37582. * This represents a texture coming from an HDR input.
  37583. *
  37584. * The only supported format is currently panorama picture stored in RGBE format.
  37585. * Example of such files can be found on HDRLib: http://hdrlib.com/
  37586. */
  37587. class HDRCubeTexture extends BaseTexture {
  37588. private static _facesMapping;
  37589. private _generateHarmonics;
  37590. private _noMipmap;
  37591. private _textureMatrix;
  37592. private _size;
  37593. private _onLoad;
  37594. private _onError;
  37595. /**
  37596. * The texture URL.
  37597. */
  37598. url: string;
  37599. /**
  37600. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  37601. */
  37602. coordinatesMode: number;
  37603. protected _isBlocking: boolean;
  37604. /**
  37605. * Sets wether or not the texture is blocking during loading.
  37606. */
  37607. /**
  37608. * Gets wether or not the texture is blocking during loading.
  37609. */
  37610. isBlocking: boolean;
  37611. protected _rotationY: number;
  37612. /**
  37613. * Sets texture matrix rotation angle around Y axis in radians.
  37614. */
  37615. /**
  37616. * Gets texture matrix rotation angle around Y axis radians.
  37617. */
  37618. rotationY: number;
  37619. /**
  37620. * Gets or sets the center of the bounding box associated with the cube texture
  37621. * It must define where the camera used to render the texture was set
  37622. */
  37623. boundingBoxPosition: Vector3;
  37624. private _boundingBoxSize;
  37625. /**
  37626. * Gets or sets the size of the bounding box associated with the cube texture
  37627. * When defined, the cubemap will switch to local mode
  37628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37629. * @example https://www.babylonjs-playground.com/#RNASML
  37630. */
  37631. boundingBoxSize: Vector3;
  37632. /**
  37633. * Instantiates an HDRTexture from the following parameters.
  37634. *
  37635. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  37636. * @param scene The scene the texture will be used in
  37637. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  37638. * @param noMipmap Forces to not generate the mipmap if true
  37639. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  37640. * @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)
  37641. * @param reserved Reserved flag for internal use.
  37642. */
  37643. 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>);
  37644. /**
  37645. * Occurs when the file is raw .hdr file.
  37646. */
  37647. private loadTexture;
  37648. clone(): HDRCubeTexture;
  37649. delayLoad(): void;
  37650. getReflectionTextureMatrix(): Matrix;
  37651. setReflectionTextureMatrix(value: Matrix): void;
  37652. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  37653. serialize(): any;
  37654. }
  37655. }
  37656. declare module BABYLON {
  37657. /**
  37658. * Class used to store data associated with WebGL texture data for the engine
  37659. * This class should not be used directly
  37660. */
  37661. class InternalTexture implements IInternalTextureTracker {
  37662. /**
  37663. * The source of the texture data is unknown
  37664. */
  37665. static DATASOURCE_UNKNOWN: number;
  37666. /**
  37667. * Texture data comes from an URL
  37668. */
  37669. static DATASOURCE_URL: number;
  37670. /**
  37671. * Texture data is only used for temporary storage
  37672. */
  37673. static DATASOURCE_TEMP: number;
  37674. /**
  37675. * Texture data comes from raw data (ArrayBuffer)
  37676. */
  37677. static DATASOURCE_RAW: number;
  37678. /**
  37679. * Texture content is dynamic (video or dynamic texture)
  37680. */
  37681. static DATASOURCE_DYNAMIC: number;
  37682. /**
  37683. * Texture content is generated by rendering to it
  37684. */
  37685. static DATASOURCE_RENDERTARGET: number;
  37686. /**
  37687. * Texture content is part of a multi render target process
  37688. */
  37689. static DATASOURCE_MULTIRENDERTARGET: number;
  37690. /**
  37691. * Texture data comes from a cube data file
  37692. */
  37693. static DATASOURCE_CUBE: number;
  37694. /**
  37695. * Texture data comes from a raw cube data
  37696. */
  37697. static DATASOURCE_CUBERAW: number;
  37698. /**
  37699. * Texture data come from a prefiltered cube data file
  37700. */
  37701. static DATASOURCE_CUBEPREFILTERED: number;
  37702. /**
  37703. * Texture content is raw 3D data
  37704. */
  37705. static DATASOURCE_RAW3D: number;
  37706. /**
  37707. * Texture content is a depth texture
  37708. */
  37709. static DATASOURCE_DEPTHTEXTURE: number;
  37710. /**
  37711. * Texture data comes from a raw cube data encoded with RGBD
  37712. */
  37713. static DATASOURCE_CUBERAW_RGBD: number;
  37714. /**
  37715. * Defines if the texture is ready
  37716. */
  37717. isReady: boolean;
  37718. /**
  37719. * Defines if the texture is a cube texture
  37720. */
  37721. isCube: boolean;
  37722. /**
  37723. * Defines if the texture contains 3D data
  37724. */
  37725. is3D: boolean;
  37726. /**
  37727. * Gets the URL used to load this texture
  37728. */
  37729. url: string;
  37730. /**
  37731. * Gets the sampling mode of the texture
  37732. */
  37733. samplingMode: number;
  37734. /**
  37735. * Gets a boolean indicating if the texture needs mipmaps generation
  37736. */
  37737. generateMipMaps: boolean;
  37738. /**
  37739. * Gets the number of samples used by the texture (WebGL2+ only)
  37740. */
  37741. samples: number;
  37742. /**
  37743. * Gets the type of the texture
  37744. */
  37745. type: number;
  37746. /**
  37747. * Gets the format of the texture
  37748. */
  37749. format: number;
  37750. /**
  37751. * Observable called when the texture is loaded
  37752. */
  37753. onLoadedObservable: Observable<InternalTexture>;
  37754. /**
  37755. * Gets the width of the texture
  37756. */
  37757. width: number;
  37758. /**
  37759. * Gets the height of the texture
  37760. */
  37761. height: number;
  37762. /**
  37763. * Gets the depth of the texture
  37764. */
  37765. depth: number;
  37766. /**
  37767. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37768. */
  37769. baseWidth: number;
  37770. /**
  37771. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37772. */
  37773. baseHeight: number;
  37774. /**
  37775. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37776. */
  37777. baseDepth: number;
  37778. /**
  37779. * Gets a boolean indicating if the texture is inverted on Y axis
  37780. */
  37781. invertY: boolean;
  37782. /**
  37783. * Gets or set the previous tracker in the list
  37784. */
  37785. previous: Nullable<IInternalTextureTracker>;
  37786. /**
  37787. * Gets or set the next tracker in the list
  37788. */
  37789. next: Nullable<IInternalTextureTracker>;
  37790. /** @hidden */
  37791. _initialSlot: number;
  37792. /** @hidden */
  37793. _designatedSlot: number;
  37794. /** @hidden */
  37795. _dataSource: number;
  37796. /** @hidden */
  37797. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37798. /** @hidden */
  37799. _bufferView: Nullable<ArrayBufferView>;
  37800. /** @hidden */
  37801. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37802. /** @hidden */
  37803. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37804. /** @hidden */
  37805. _size: number;
  37806. /** @hidden */
  37807. _extension: string;
  37808. /** @hidden */
  37809. _files: Nullable<string[]>;
  37810. /** @hidden */
  37811. _workingCanvas: HTMLCanvasElement;
  37812. /** @hidden */
  37813. _workingContext: CanvasRenderingContext2D;
  37814. /** @hidden */
  37815. _framebuffer: Nullable<WebGLFramebuffer>;
  37816. /** @hidden */
  37817. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37818. /** @hidden */
  37819. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37820. /** @hidden */
  37821. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37822. /** @hidden */
  37823. _attachments: Nullable<number[]>;
  37824. /** @hidden */
  37825. _cachedCoordinatesMode: Nullable<number>;
  37826. /** @hidden */
  37827. _cachedWrapU: Nullable<number>;
  37828. /** @hidden */
  37829. _cachedWrapV: Nullable<number>;
  37830. /** @hidden */
  37831. _cachedWrapR: Nullable<number>;
  37832. /** @hidden */
  37833. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37834. /** @hidden */
  37835. _isDisabled: boolean;
  37836. /** @hidden */
  37837. _compression: Nullable<string>;
  37838. /** @hidden */
  37839. _generateStencilBuffer: boolean;
  37840. /** @hidden */
  37841. _generateDepthBuffer: boolean;
  37842. /** @hidden */
  37843. _comparisonFunction: number;
  37844. /** @hidden */
  37845. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37846. /** @hidden */
  37847. _lodGenerationScale: number;
  37848. /** @hidden */
  37849. _lodGenerationOffset: number;
  37850. /** @hidden */
  37851. _lodTextureHigh: BaseTexture;
  37852. /** @hidden */
  37853. _lodTextureMid: BaseTexture;
  37854. /** @hidden */
  37855. _lodTextureLow: BaseTexture;
  37856. /** @hidden */
  37857. _isRGBD: boolean;
  37858. /** @hidden */
  37859. _webGLTexture: Nullable<WebGLTexture>;
  37860. /** @hidden */
  37861. _references: number;
  37862. private _engine;
  37863. /**
  37864. * Gets the Engine the texture belongs to.
  37865. * @returns The babylon engine
  37866. */
  37867. getEngine(): Engine;
  37868. /**
  37869. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  37870. */
  37871. readonly dataSource: number;
  37872. /**
  37873. * Creates a new InternalTexture
  37874. * @param engine defines the engine to use
  37875. * @param dataSource defines the type of data that will be used
  37876. */
  37877. constructor(engine: Engine, dataSource: number);
  37878. /**
  37879. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  37880. */
  37881. incrementReferences(): void;
  37882. /**
  37883. * Change the size of the texture (not the size of the content)
  37884. * @param width defines the new width
  37885. * @param height defines the new height
  37886. * @param depth defines the new depth (1 by default)
  37887. */
  37888. updateSize(width: int, height: int, depth?: int): void;
  37889. /** @hidden */
  37890. _rebuild(): void;
  37891. /** @hidden */
  37892. _swapAndDie(target: InternalTexture): void;
  37893. /**
  37894. * Dispose the current allocated resources
  37895. */
  37896. dispose(): void;
  37897. }
  37898. }
  37899. declare module BABYLON {
  37900. /**
  37901. * This represents the required contract to create a new type of texture loader.
  37902. */
  37903. interface IInternalTextureLoader {
  37904. /**
  37905. * Defines wether the loader supports cascade loading the different faces.
  37906. */
  37907. supportCascades: boolean;
  37908. /**
  37909. * This returns if the loader support the current file information.
  37910. * @param extension defines the file extension of the file being loaded
  37911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37912. * @param fallback defines the fallback internal texture if any
  37913. * @param isBase64 defines whether the texture is encoded as a base64
  37914. * @param isBuffer defines whether the texture data are stored as a buffer
  37915. * @returns true if the loader can load the specified file
  37916. */
  37917. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  37918. /**
  37919. * Transform the url before loading if required.
  37920. * @param rootUrl the url of the texture
  37921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37922. * @returns the transformed texture
  37923. */
  37924. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  37925. /**
  37926. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  37927. * @param rootUrl the url of the texture
  37928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37929. * @returns the fallback texture
  37930. */
  37931. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  37932. /**
  37933. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  37934. * @param data contains the texture data
  37935. * @param texture defines the BabylonJS internal texture
  37936. * @param createPolynomials will be true if polynomials have been requested
  37937. * @param onLoad defines the callback to trigger once the texture is ready
  37938. * @param onError defines the callback to trigger in case of error
  37939. */
  37940. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  37941. /**
  37942. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  37943. * @param data contains the texture data
  37944. * @param texture defines the BabylonJS internal texture
  37945. * @param callback defines the method to call once ready to upload
  37946. */
  37947. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  37948. }
  37949. }
  37950. declare module BABYLON {
  37951. /**
  37952. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  37953. */
  37954. interface IInternalTextureTracker {
  37955. /**
  37956. * Gets or set the previous tracker in the list
  37957. */
  37958. previous: Nullable<IInternalTextureTracker>;
  37959. /**
  37960. * Gets or set the next tracker in the list
  37961. */
  37962. next: Nullable<IInternalTextureTracker>;
  37963. }
  37964. /**
  37965. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  37966. */
  37967. class DummyInternalTextureTracker {
  37968. /**
  37969. * Gets or set the previous tracker in the list
  37970. */
  37971. previous: Nullable<IInternalTextureTracker>;
  37972. /**
  37973. * Gets or set the next tracker in the list
  37974. */
  37975. next: Nullable<IInternalTextureTracker>;
  37976. }
  37977. }
  37978. declare module BABYLON {
  37979. class MirrorTexture extends RenderTargetTexture {
  37980. private scene;
  37981. mirrorPlane: Plane;
  37982. private _transformMatrix;
  37983. private _mirrorMatrix;
  37984. private _savedViewMatrix;
  37985. private _blurX;
  37986. private _blurY;
  37987. private _adaptiveBlurKernel;
  37988. private _blurKernelX;
  37989. private _blurKernelY;
  37990. private _blurRatio;
  37991. blurRatio: number;
  37992. adaptiveBlurKernel: number;
  37993. blurKernel: number;
  37994. blurKernelX: number;
  37995. blurKernelY: number;
  37996. private _autoComputeBlurKernel;
  37997. protected _onRatioRescale(): void;
  37998. private _updateGammaSpace;
  37999. private _imageProcessingConfigChangeObserver;
  38000. constructor(name: string, size: number | {
  38001. width: number;
  38002. height: number;
  38003. } | {
  38004. ratio: number;
  38005. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  38006. private _preparePostProcesses;
  38007. clone(): MirrorTexture;
  38008. serialize(): any;
  38009. dispose(): void;
  38010. }
  38011. }
  38012. declare module BABYLON {
  38013. interface IMultiRenderTargetOptions {
  38014. generateMipMaps?: boolean;
  38015. types?: number[];
  38016. samplingModes?: number[];
  38017. generateDepthBuffer?: boolean;
  38018. generateStencilBuffer?: boolean;
  38019. generateDepthTexture?: boolean;
  38020. textureCount?: number;
  38021. doNotChangeAspectRatio?: boolean;
  38022. defaultType?: number;
  38023. }
  38024. class MultiRenderTarget extends RenderTargetTexture {
  38025. private _internalTextures;
  38026. private _textures;
  38027. readonly isSupported: boolean;
  38028. private _multiRenderTargetOptions;
  38029. readonly textures: Texture[];
  38030. readonly depthTexture: Texture;
  38031. wrapU: number;
  38032. wrapV: number;
  38033. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  38034. /** @hidden */
  38035. _rebuild(): void;
  38036. private _createInternalTextures;
  38037. private _createTextures;
  38038. samples: number;
  38039. resize(size: any): void;
  38040. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38041. dispose(): void;
  38042. releaseInternalTextures(): void;
  38043. }
  38044. }
  38045. declare module BABYLON {
  38046. /**
  38047. * Raw cube texture where the raw buffers are passed in
  38048. */
  38049. class RawCubeTexture extends CubeTexture {
  38050. /**
  38051. * Creates a cube texture where the raw buffers are passed in.
  38052. * @param scene defines the scene the texture is attached to
  38053. * @param data defines the array of data to use to create each face
  38054. * @param size defines the size of the textures
  38055. * @param format defines the format of the data
  38056. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  38057. * @param generateMipMaps defines if the engine should generate the mip levels
  38058. * @param invertY defines if data must be stored with Y axis inverted
  38059. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  38060. * @param compression defines the compression used (null by default)
  38061. */
  38062. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  38063. /**
  38064. * Updates the raw cube texture.
  38065. * @param data defines the data to store
  38066. * @param format defines the data format
  38067. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  38068. * @param invertY defines if data must be stored with Y axis inverted
  38069. * @param compression defines the compression used (null by default)
  38070. * @param level defines which level of the texture to update
  38071. */
  38072. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  38073. /**
  38074. * Updates a raw cube texture with RGBD encoded data.
  38075. * @param data defines the array of data [mipmap][face] to use to create each face
  38076. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  38077. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  38078. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  38079. * @returns a promsie that resolves when the operation is complete
  38080. */
  38081. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  38082. /**
  38083. * Clones the raw cube texture.
  38084. * @return a new cube texture
  38085. */
  38086. clone(): CubeTexture;
  38087. /** @hidden */
  38088. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  38089. }
  38090. }
  38091. declare module BABYLON {
  38092. class RawTexture extends Texture {
  38093. format: number;
  38094. private _engine;
  38095. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  38096. update(data: ArrayBufferView): void;
  38097. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38098. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38099. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38100. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38101. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38102. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38103. }
  38104. }
  38105. declare module BABYLON {
  38106. /**
  38107. * Class used to store 3D textures containing user data
  38108. */
  38109. class RawTexture3D extends Texture {
  38110. /** Gets or sets the texture format to use */
  38111. format: number;
  38112. private _engine;
  38113. /**
  38114. * Create a new RawTexture3D
  38115. * @param data defines the data of the texture
  38116. * @param width defines the width of the texture
  38117. * @param height defines the height of the texture
  38118. * @param depth defines the depth of the texture
  38119. * @param format defines the texture format to use
  38120. * @param scene defines the hosting scene
  38121. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  38122. * @param invertY defines if texture must be stored with Y axis inverted
  38123. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  38124. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  38125. */
  38126. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  38127. /** Gets or sets the texture format to use */
  38128. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  38129. /**
  38130. * Update the texture with new data
  38131. * @param data defines the data to store in the texture
  38132. */
  38133. update(data: ArrayBufferView): void;
  38134. }
  38135. }
  38136. declare module BABYLON {
  38137. /**
  38138. * Creates a refraction texture used by refraction channel of the standard material.
  38139. * @param name the texture name
  38140. * @param size size of the underlying texture
  38141. * @param scene root scene
  38142. */
  38143. class RefractionTexture extends RenderTargetTexture {
  38144. refractionPlane: Plane;
  38145. depth: number;
  38146. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  38147. clone(): RefractionTexture;
  38148. serialize(): any;
  38149. }
  38150. }
  38151. declare module BABYLON {
  38152. class RenderTargetTexture extends Texture {
  38153. isCube: boolean;
  38154. static _REFRESHRATE_RENDER_ONCE: number;
  38155. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38156. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38157. static readonly REFRESHRATE_RENDER_ONCE: number;
  38158. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38159. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38160. /**
  38161. * Use this predicate to dynamically define the list of mesh you want to render.
  38162. * If set, the renderList property will be overwritten.
  38163. */
  38164. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38165. private _renderList;
  38166. /**
  38167. * Use this list to define the list of mesh you want to render.
  38168. */
  38169. renderList: Nullable<Array<AbstractMesh>>;
  38170. private _hookArray;
  38171. renderParticles: boolean;
  38172. renderSprites: boolean;
  38173. coordinatesMode: number;
  38174. activeCamera: Nullable<Camera>;
  38175. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38176. useCameraPostProcesses: boolean;
  38177. ignoreCameraViewport: boolean;
  38178. private _postProcessManager;
  38179. private _postProcesses;
  38180. private _resizeObserver;
  38181. /**
  38182. * An event triggered when the texture is unbind.
  38183. */
  38184. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38185. /**
  38186. * An event triggered when the texture is unbind.
  38187. */
  38188. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38189. private _onAfterUnbindObserver;
  38190. onAfterUnbind: () => void;
  38191. /**
  38192. * An event triggered before rendering the texture
  38193. */
  38194. onBeforeRenderObservable: Observable<number>;
  38195. private _onBeforeRenderObserver;
  38196. onBeforeRender: (faceIndex: number) => void;
  38197. /**
  38198. * An event triggered after rendering the texture
  38199. */
  38200. onAfterRenderObservable: Observable<number>;
  38201. private _onAfterRenderObserver;
  38202. onAfterRender: (faceIndex: number) => void;
  38203. /**
  38204. * An event triggered after the texture clear
  38205. */
  38206. onClearObservable: Observable<Engine>;
  38207. private _onClearObserver;
  38208. onClear: (Engine: Engine) => void;
  38209. clearColor: Color4;
  38210. protected _size: number | {
  38211. width: number;
  38212. height: number;
  38213. };
  38214. protected _initialSizeParameter: number | {
  38215. width: number;
  38216. height: number;
  38217. } | {
  38218. ratio: number;
  38219. };
  38220. protected _sizeRatio: Nullable<number>;
  38221. /** @hidden */
  38222. _generateMipMaps: boolean;
  38223. protected _renderingManager: RenderingManager;
  38224. /** @hidden */
  38225. _waitingRenderList: string[];
  38226. protected _doNotChangeAspectRatio: boolean;
  38227. protected _currentRefreshId: number;
  38228. protected _refreshRate: number;
  38229. protected _textureMatrix: Matrix;
  38230. protected _samples: number;
  38231. protected _renderTargetOptions: RenderTargetCreationOptions;
  38232. readonly renderTargetOptions: RenderTargetCreationOptions;
  38233. protected _engine: Engine;
  38234. protected _onRatioRescale(): void;
  38235. /**
  38236. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38237. * It must define where the camera used to render the texture is set
  38238. */
  38239. boundingBoxPosition: Vector3;
  38240. private _boundingBoxSize;
  38241. /**
  38242. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38243. * When defined, the cubemap will switch to local mode
  38244. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38245. * @example https://www.babylonjs-playground.com/#RNASML
  38246. */
  38247. boundingBoxSize: Vector3;
  38248. /**
  38249. * In case the RTT has been created with a depth texture, get the associated
  38250. * depth texture.
  38251. * Otherwise, return null.
  38252. */
  38253. depthStencilTexture: Nullable<InternalTexture>;
  38254. /**
  38255. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  38256. * or used a shadow, depth texture...
  38257. * @param name The friendly name of the texture
  38258. * @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)
  38259. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38260. * @param generateMipMaps True if mip maps need to be generated after render.
  38261. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38262. * @param type The type of the buffer in the RTT (int, half float, float...)
  38263. * @param isCube True if a cube texture needs to be created
  38264. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38265. * @param generateDepthBuffer True to generate a depth buffer
  38266. * @param generateStencilBuffer True to generate a stencil buffer
  38267. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38268. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38269. */
  38270. constructor(name: string, size: number | {
  38271. width: number;
  38272. height: number;
  38273. } | {
  38274. ratio: number;
  38275. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  38276. /**
  38277. * Creates a depth stencil texture.
  38278. * This is only available in WebGL 2 or with the depth texture extension available.
  38279. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38280. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38281. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38282. */
  38283. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  38284. private _processSizeParameter;
  38285. samples: number;
  38286. resetRefreshCounter(): void;
  38287. refreshRate: number;
  38288. addPostProcess(postProcess: PostProcess): void;
  38289. clearPostProcesses(dispose?: boolean): void;
  38290. removePostProcess(postProcess: PostProcess): void;
  38291. /** @hidden */
  38292. _shouldRender(): boolean;
  38293. getRenderSize(): number;
  38294. getRenderWidth(): number;
  38295. getRenderHeight(): number;
  38296. readonly canRescale: boolean;
  38297. scale(ratio: number): void;
  38298. getReflectionTextureMatrix(): Matrix;
  38299. resize(size: number | {
  38300. width: number;
  38301. height: number;
  38302. } | {
  38303. ratio: number;
  38304. }): void;
  38305. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38306. private _bestReflectionRenderTargetDimension;
  38307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38308. private renderToTarget;
  38309. /**
  38310. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38311. * This allowed control for front to back rendering or reversly depending of the special needs.
  38312. *
  38313. * @param renderingGroupId The rendering group id corresponding to its index
  38314. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38315. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38316. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38317. */
  38318. 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;
  38319. /**
  38320. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38321. *
  38322. * @param renderingGroupId The rendering group id corresponding to its index
  38323. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38324. */
  38325. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38326. clone(): RenderTargetTexture;
  38327. serialize(): any;
  38328. disposeFramebufferObjects(): void;
  38329. dispose(): void;
  38330. /** @hidden */
  38331. _rebuild(): void;
  38332. /**
  38333. * Clear the info related to rendering groups preventing retention point in material dispose.
  38334. */
  38335. freeRenderingGroups(): void;
  38336. }
  38337. }
  38338. declare module BABYLON {
  38339. class Texture extends BaseTexture {
  38340. static NEAREST_SAMPLINGMODE: number;
  38341. static NEAREST_NEAREST_MIPLINEAR: number;
  38342. static BILINEAR_SAMPLINGMODE: number;
  38343. static LINEAR_LINEAR_MIPNEAREST: number;
  38344. static TRILINEAR_SAMPLINGMODE: number;
  38345. static LINEAR_LINEAR_MIPLINEAR: number;
  38346. static NEAREST_NEAREST_MIPNEAREST: number;
  38347. static NEAREST_LINEAR_MIPNEAREST: number;
  38348. static NEAREST_LINEAR_MIPLINEAR: number;
  38349. static NEAREST_LINEAR: number;
  38350. static NEAREST_NEAREST: number;
  38351. static LINEAR_NEAREST_MIPNEAREST: number;
  38352. static LINEAR_NEAREST_MIPLINEAR: number;
  38353. static LINEAR_LINEAR: number;
  38354. static LINEAR_NEAREST: number;
  38355. static EXPLICIT_MODE: number;
  38356. static SPHERICAL_MODE: number;
  38357. static PLANAR_MODE: number;
  38358. static CUBIC_MODE: number;
  38359. static PROJECTION_MODE: number;
  38360. static SKYBOX_MODE: number;
  38361. static INVCUBIC_MODE: number;
  38362. static EQUIRECTANGULAR_MODE: number;
  38363. static FIXED_EQUIRECTANGULAR_MODE: number;
  38364. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38365. static readonly CLAMP_ADDRESSMODE: number;
  38366. static readonly WRAP_ADDRESSMODE: number;
  38367. static readonly MIRROR_ADDRESSMODE: number;
  38368. /**
  38369. * 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
  38370. */
  38371. static UseSerializedUrlIfAny: boolean;
  38372. url: Nullable<string>;
  38373. uOffset: number;
  38374. vOffset: number;
  38375. uScale: number;
  38376. vScale: number;
  38377. uAng: number;
  38378. vAng: number;
  38379. wAng: number;
  38380. /**
  38381. * Defines the center of rotation (U)
  38382. */
  38383. uRotationCenter: number;
  38384. /**
  38385. * Defines the center of rotation (V)
  38386. */
  38387. vRotationCenter: number;
  38388. /**
  38389. * Defines the center of rotation (W)
  38390. */
  38391. wRotationCenter: number;
  38392. readonly noMipmap: boolean;
  38393. private _noMipmap;
  38394. /** @hidden */
  38395. _invertY: boolean;
  38396. private _rowGenerationMatrix;
  38397. private _cachedTextureMatrix;
  38398. private _projectionModeMatrix;
  38399. private _t0;
  38400. private _t1;
  38401. private _t2;
  38402. private _cachedUOffset;
  38403. private _cachedVOffset;
  38404. private _cachedUScale;
  38405. private _cachedVScale;
  38406. private _cachedUAng;
  38407. private _cachedVAng;
  38408. private _cachedWAng;
  38409. private _cachedProjectionMatrixId;
  38410. private _cachedCoordinatesMode;
  38411. /** @hidden */
  38412. _samplingMode: number;
  38413. /** @hidden */
  38414. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  38415. private _deleteBuffer;
  38416. protected _format: Nullable<number>;
  38417. private _delayedOnLoad;
  38418. private _delayedOnError;
  38419. protected _onLoadObservable: Nullable<Observable<Texture>>;
  38420. protected _isBlocking: boolean;
  38421. isBlocking: boolean;
  38422. readonly samplingMode: number;
  38423. 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);
  38424. /**
  38425. * Update the url (and optional buffer) of this texture if url was null during construction.
  38426. * @param url the url of the texture
  38427. * @param buffer the buffer of the texture (defaults to null)
  38428. */
  38429. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  38430. delayLoad(): void;
  38431. /**
  38432. * Default is Trilinear mode.
  38433. *
  38434. * | Value | Type | Description |
  38435. * | ----- | ------------------ | ----------- |
  38436. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38437. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38438. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38439. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38440. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38441. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38442. * | 7 | NEAREST_LINEAR | |
  38443. * | 8 | NEAREST_NEAREST | |
  38444. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38445. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38446. * | 11 | LINEAR_LINEAR | |
  38447. * | 12 | LINEAR_NEAREST | |
  38448. *
  38449. * > _mag_: magnification filter (close to the viewer)
  38450. * > _min_: minification filter (far from the viewer)
  38451. * > _mip_: filter used between mip map levels
  38452. *
  38453. */
  38454. updateSamplingMode(samplingMode: number): void;
  38455. private _prepareRowForTextureGeneration;
  38456. getTextureMatrix(): Matrix;
  38457. getReflectionTextureMatrix(): Matrix;
  38458. clone(): Texture;
  38459. readonly onLoadObservable: Observable<Texture>;
  38460. serialize(): any;
  38461. getClassName(): string;
  38462. dispose(): void;
  38463. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  38464. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  38465. 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;
  38466. }
  38467. }
  38468. declare module BABYLON {
  38469. /**
  38470. * Settings for finer control over video usage
  38471. */
  38472. interface VideoTextureSettings {
  38473. /**
  38474. * Applies `autoplay` to video, if specified
  38475. */
  38476. autoPlay?: boolean;
  38477. /**
  38478. * Applies `loop` to video, if specified
  38479. */
  38480. loop?: boolean;
  38481. /**
  38482. * Automatically updates internal texture from video at every frame in the render loop
  38483. */
  38484. autoUpdateTexture: boolean;
  38485. /**
  38486. * Image src displayed during the video loading or until the user interacts with the video.
  38487. */
  38488. poster?: string;
  38489. }
  38490. class VideoTexture extends Texture {
  38491. /**
  38492. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38493. */
  38494. readonly autoUpdateTexture: boolean;
  38495. /**
  38496. * The video instance used by the texture internally
  38497. */
  38498. readonly video: HTMLVideoElement;
  38499. private _onUserActionRequestedObservable;
  38500. readonly onUserActionRequestedObservable: Observable<Texture>;
  38501. private _generateMipMaps;
  38502. private _engine;
  38503. private _stillImageCaptured;
  38504. private _poster;
  38505. /**
  38506. * Creates a video texture.
  38507. * Sample : https://doc.babylonjs.com/how_to/video_texture
  38508. * @param {string | null} name optional name, will detect from video source, if not defined
  38509. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  38510. * @param {BABYLON.Scene} scene is obviously the current scene.
  38511. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38512. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  38513. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38514. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  38515. */
  38516. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38517. private _getName;
  38518. private _getVideo;
  38519. private _createInternalTexture;
  38520. private reset;
  38521. /**
  38522. * @hidden Internal method to initiate `update`.
  38523. */
  38524. _rebuild(): void;
  38525. /**
  38526. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38527. */
  38528. update(): void;
  38529. /**
  38530. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38531. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38532. */
  38533. updateTexture(isVisible: boolean): void;
  38534. protected _updateInternalTexture: (e?: Event | undefined) => void;
  38535. /**
  38536. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38537. * @param url New url.
  38538. */
  38539. updateURL(url: string): void;
  38540. dispose(): void;
  38541. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38542. minWidth: number;
  38543. maxWidth: number;
  38544. minHeight: number;
  38545. maxHeight: number;
  38546. deviceId: string;
  38547. }): void;
  38548. }
  38549. }
  38550. declare var DracoDecoderModule: any;
  38551. declare var WebAssembly: any;
  38552. declare module BABYLON {
  38553. /**
  38554. * Configuration for Draco compression
  38555. */
  38556. interface IDracoCompressionConfiguration {
  38557. /**
  38558. * Configuration for the decoder.
  38559. */
  38560. decoder?: {
  38561. /**
  38562. * The url to the WebAssembly module.
  38563. */
  38564. wasmUrl?: string;
  38565. /**
  38566. * The url to the WebAssembly binary.
  38567. */
  38568. wasmBinaryUrl?: string;
  38569. /**
  38570. * The url to the fallback JavaScript module.
  38571. */
  38572. fallbackUrl?: string;
  38573. };
  38574. }
  38575. /**
  38576. * Draco compression (https://google.github.io/draco/)
  38577. *
  38578. * This class wraps the Draco module.
  38579. *
  38580. * **Encoder**
  38581. *
  38582. * The encoder is not currently implemented.
  38583. *
  38584. * **Decoder**
  38585. *
  38586. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  38587. *
  38588. * To update the configuration, use the following code:
  38589. * ```javascript
  38590. * BABYLON.DracoCompression.Configuration = {
  38591. * decoder: {
  38592. * wasmUrl: "<url to the WebAssembly library>",
  38593. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  38594. * fallbackUrl: "<url to the fallback JavaScript library>",
  38595. * }
  38596. * };
  38597. * ```
  38598. *
  38599. * 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.
  38600. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  38601. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  38602. *
  38603. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  38604. * ```javascript
  38605. * var dracoCompression = new BABYLON.DracoCompression();
  38606. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  38607. * [BABYLON.VertexBuffer.PositionKind]: 0
  38608. * });
  38609. * ```
  38610. *
  38611. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  38612. */
  38613. class DracoCompression implements IDisposable {
  38614. private static _DecoderModulePromise;
  38615. /**
  38616. * The configuration. Defaults to the following urls:
  38617. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  38618. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  38619. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  38620. */
  38621. static Configuration: IDracoCompressionConfiguration;
  38622. /**
  38623. * Returns true if the decoder is available.
  38624. */
  38625. static readonly DecoderAvailable: boolean;
  38626. /**
  38627. * Constructor
  38628. */
  38629. constructor();
  38630. /**
  38631. * Stop all async operations and release resources.
  38632. */
  38633. dispose(): void;
  38634. /**
  38635. * Decode Draco compressed mesh data to vertex data.
  38636. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  38637. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  38638. * @returns A promise that resolves with the decoded vertex data
  38639. */
  38640. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  38641. [kind: string]: number;
  38642. }): Promise<VertexData>;
  38643. private static _GetDecoderModule;
  38644. private static _LoadScriptAsync;
  38645. private static _LoadFileAsync;
  38646. }
  38647. }
  38648. declare module BABYLON {
  38649. /**
  38650. * Particle emitter emitting particles from the inside of a box.
  38651. * It emits the particles randomly between 2 given directions.
  38652. */
  38653. class BoxParticleEmitter implements IParticleEmitterType {
  38654. /**
  38655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38656. */
  38657. direction1: Vector3;
  38658. /**
  38659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38660. */
  38661. direction2: Vector3;
  38662. /**
  38663. * 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.
  38664. */
  38665. minEmitBox: Vector3;
  38666. /**
  38667. * 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.
  38668. */
  38669. maxEmitBox: Vector3;
  38670. /**
  38671. * Creates a new instance BoxParticleEmitter
  38672. */
  38673. constructor();
  38674. /**
  38675. * Called by the particle System when the direction is computed for the created particle.
  38676. * @param worldMatrix is the world matrix of the particle system
  38677. * @param directionToUpdate is the direction vector to update with the result
  38678. * @param particle is the particle we are computed the direction for
  38679. */
  38680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38681. /**
  38682. * Called by the particle System when the position is computed for the created particle.
  38683. * @param worldMatrix is the world matrix of the particle system
  38684. * @param positionToUpdate is the position vector to update with the result
  38685. * @param particle is the particle we are computed the position for
  38686. */
  38687. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38688. /**
  38689. * Clones the current emitter and returns a copy of it
  38690. * @returns the new emitter
  38691. */
  38692. clone(): BoxParticleEmitter;
  38693. /**
  38694. * Called by the GPUParticleSystem to setup the update shader
  38695. * @param effect defines the update shader
  38696. */
  38697. applyToShader(effect: Effect): void;
  38698. /**
  38699. * Returns a string to use to update the GPU particles update shader
  38700. * @returns a string containng the defines string
  38701. */
  38702. getEffectDefines(): string;
  38703. /**
  38704. * Returns the string "BoxParticleEmitter"
  38705. * @returns a string containing the class name
  38706. */
  38707. getClassName(): string;
  38708. /**
  38709. * Serializes the particle system to a JSON object.
  38710. * @returns the JSON object
  38711. */
  38712. serialize(): any;
  38713. /**
  38714. * Parse properties from a JSON object
  38715. * @param serializationObject defines the JSON object
  38716. */
  38717. parse(serializationObject: any): void;
  38718. }
  38719. }
  38720. declare module BABYLON {
  38721. /**
  38722. * Particle emitter emitting particles from the inside of a cone.
  38723. * It emits the particles alongside the cone volume from the base to the particle.
  38724. * The emission direction might be randomized.
  38725. */
  38726. class ConeParticleEmitter implements IParticleEmitterType {
  38727. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38728. directionRandomizer: number;
  38729. private _radius;
  38730. private _angle;
  38731. private _height;
  38732. /**
  38733. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  38734. */
  38735. radiusRange: number;
  38736. /**
  38737. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  38738. */
  38739. heightRange: number;
  38740. /**
  38741. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  38742. */
  38743. emitFromSpawnPointOnly: boolean;
  38744. /**
  38745. * Gets or sets the radius of the emission cone
  38746. */
  38747. radius: number;
  38748. /**
  38749. * Gets or sets the angle of the emission cone
  38750. */
  38751. angle: number;
  38752. private _buildHeight;
  38753. /**
  38754. * Creates a new instance ConeParticleEmitter
  38755. * @param radius the radius of the emission cone (1 by default)
  38756. * @param angles the cone base angle (PI by default)
  38757. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  38758. */
  38759. constructor(radius?: number, angle?: number,
  38760. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38761. directionRandomizer?: number);
  38762. /**
  38763. * Called by the particle System when the direction is computed for the created particle.
  38764. * @param worldMatrix is the world matrix of the particle system
  38765. * @param directionToUpdate is the direction vector to update with the result
  38766. * @param particle is the particle we are computed the direction for
  38767. */
  38768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38769. /**
  38770. * Called by the particle System when the position is computed for the created particle.
  38771. * @param worldMatrix is the world matrix of the particle system
  38772. * @param positionToUpdate is the position vector to update with the result
  38773. * @param particle is the particle we are computed the position for
  38774. */
  38775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38776. /**
  38777. * Clones the current emitter and returns a copy of it
  38778. * @returns the new emitter
  38779. */
  38780. clone(): ConeParticleEmitter;
  38781. /**
  38782. * Called by the GPUParticleSystem to setup the update shader
  38783. * @param effect defines the update shader
  38784. */
  38785. applyToShader(effect: Effect): void;
  38786. /**
  38787. * Returns a string to use to update the GPU particles update shader
  38788. * @returns a string containng the defines string
  38789. */
  38790. getEffectDefines(): string;
  38791. /**
  38792. * Returns the string "ConeParticleEmitter"
  38793. * @returns a string containing the class name
  38794. */
  38795. getClassName(): string;
  38796. /**
  38797. * Serializes the particle system to a JSON object.
  38798. * @returns the JSON object
  38799. */
  38800. serialize(): any;
  38801. /**
  38802. * Parse properties from a JSON object
  38803. * @param serializationObject defines the JSON object
  38804. */
  38805. parse(serializationObject: any): void;
  38806. }
  38807. }
  38808. declare module BABYLON {
  38809. /**
  38810. * Particle emitter emitting particles from the inside of a cylinder.
  38811. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  38812. */
  38813. class CylinderParticleEmitter implements IParticleEmitterType {
  38814. /**
  38815. * The radius of the emission cylinder.
  38816. */
  38817. radius: number;
  38818. /**
  38819. * The height of the emission cylinder.
  38820. */
  38821. height: number;
  38822. /**
  38823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38824. */
  38825. radiusRange: number;
  38826. /**
  38827. * How much to randomize the particle direction [0-1].
  38828. */
  38829. directionRandomizer: number;
  38830. /**
  38831. * Creates a new instance CylinderParticleEmitter
  38832. * @param radius the radius of the emission cylinder (1 by default)
  38833. * @param height the height of the emission cylinder (1 by default)
  38834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38835. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38836. */
  38837. constructor(
  38838. /**
  38839. * The radius of the emission cylinder.
  38840. */
  38841. radius?: number,
  38842. /**
  38843. * The height of the emission cylinder.
  38844. */
  38845. height?: number,
  38846. /**
  38847. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38848. */
  38849. radiusRange?: number,
  38850. /**
  38851. * How much to randomize the particle direction [0-1].
  38852. */
  38853. directionRandomizer?: number);
  38854. /**
  38855. * Called by the particle System when the direction is computed for the created particle.
  38856. * @param worldMatrix is the world matrix of the particle system
  38857. * @param directionToUpdate is the direction vector to update with the result
  38858. * @param particle is the particle we are computed the direction for
  38859. */
  38860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38861. /**
  38862. * Called by the particle System when the position is computed for the created particle.
  38863. * @param worldMatrix is the world matrix of the particle system
  38864. * @param positionToUpdate is the position vector to update with the result
  38865. * @param particle is the particle we are computed the position for
  38866. */
  38867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38868. /**
  38869. * Clones the current emitter and returns a copy of it
  38870. * @returns the new emitter
  38871. */
  38872. clone(): CylinderParticleEmitter;
  38873. /**
  38874. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38875. * @param effect defines the update shader
  38876. */
  38877. applyToShader(effect: Effect): void;
  38878. /**
  38879. * Returns a string to use to update the GPU particles update shader
  38880. * @returns a string containng the defines string
  38881. */
  38882. getEffectDefines(): string;
  38883. /**
  38884. * Returns the string "CylinderParticleEmitter"
  38885. * @returns a string containing the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Serializes the particle system to a JSON object.
  38890. * @returns the JSON object
  38891. */
  38892. serialize(): any;
  38893. /**
  38894. * Parse properties from a JSON object
  38895. * @param serializationObject defines the JSON object
  38896. */
  38897. parse(serializationObject: any): void;
  38898. }
  38899. /**
  38900. * Particle emitter emitting particles from the inside of a cylinder.
  38901. * It emits the particles randomly between two vectors.
  38902. */
  38903. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  38904. /**
  38905. * The min limit of the emission direction.
  38906. */
  38907. direction1: Vector3;
  38908. /**
  38909. * The max limit of the emission direction.
  38910. */
  38911. direction2: Vector3;
  38912. /**
  38913. * Creates a new instance CylinderDirectedParticleEmitter
  38914. * @param radius the radius of the emission cylinder (1 by default)
  38915. * @param height the height of the emission cylinder (1 by default)
  38916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38917. * @param direction1 the min limit of the emission direction (up vector by default)
  38918. * @param direction2 the max limit of the emission direction (up vector by default)
  38919. */
  38920. constructor(radius?: number, height?: number, radiusRange?: number,
  38921. /**
  38922. * The min limit of the emission direction.
  38923. */
  38924. direction1?: Vector3,
  38925. /**
  38926. * The max limit of the emission direction.
  38927. */
  38928. direction2?: Vector3);
  38929. /**
  38930. * Called by the particle System when the direction is computed for the created particle.
  38931. * @param worldMatrix is the world matrix of the particle system
  38932. * @param directionToUpdate is the direction vector to update with the result
  38933. * @param particle is the particle we are computed the direction for
  38934. */
  38935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38936. /**
  38937. * Clones the current emitter and returns a copy of it
  38938. * @returns the new emitter
  38939. */
  38940. clone(): CylinderDirectedParticleEmitter;
  38941. /**
  38942. * Called by the GPUParticleSystem to setup the update shader
  38943. * @param effect defines the update shader
  38944. */
  38945. applyToShader(effect: Effect): void;
  38946. /**
  38947. * Returns a string to use to update the GPU particles update shader
  38948. * @returns a string containng the defines string
  38949. */
  38950. getEffectDefines(): string;
  38951. /**
  38952. * Returns the string "CylinderDirectedParticleEmitter"
  38953. * @returns a string containing the class name
  38954. */
  38955. getClassName(): string;
  38956. /**
  38957. * Serializes the particle system to a JSON object.
  38958. * @returns the JSON object
  38959. */
  38960. serialize(): any;
  38961. /**
  38962. * Parse properties from a JSON object
  38963. * @param serializationObject defines the JSON object
  38964. */
  38965. parse(serializationObject: any): void;
  38966. }
  38967. }
  38968. declare module BABYLON {
  38969. /**
  38970. * Particle emitter emitting particles from the inside of a hemisphere.
  38971. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  38972. */
  38973. class HemisphericParticleEmitter implements IParticleEmitterType {
  38974. /**
  38975. * The radius of the emission hemisphere.
  38976. */
  38977. radius: number;
  38978. /**
  38979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38980. */
  38981. radiusRange: number;
  38982. /**
  38983. * How much to randomize the particle direction [0-1].
  38984. */
  38985. directionRandomizer: number;
  38986. /**
  38987. * Creates a new instance HemisphericParticleEmitter
  38988. * @param radius the radius of the emission hemisphere (1 by default)
  38989. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38990. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38991. */
  38992. constructor(
  38993. /**
  38994. * The radius of the emission hemisphere.
  38995. */
  38996. radius?: number,
  38997. /**
  38998. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38999. */
  39000. radiusRange?: number,
  39001. /**
  39002. * How much to randomize the particle direction [0-1].
  39003. */
  39004. directionRandomizer?: number);
  39005. /**
  39006. * Called by the particle System when the direction is computed for the created particle.
  39007. * @param worldMatrix is the world matrix of the particle system
  39008. * @param directionToUpdate is the direction vector to update with the result
  39009. * @param particle is the particle we are computed the direction for
  39010. */
  39011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39012. /**
  39013. * Called by the particle System when the position is computed for the created particle.
  39014. * @param worldMatrix is the world matrix of the particle system
  39015. * @param positionToUpdate is the position vector to update with the result
  39016. * @param particle is the particle we are computed the position for
  39017. */
  39018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39019. /**
  39020. * Clones the current emitter and returns a copy of it
  39021. * @returns the new emitter
  39022. */
  39023. clone(): HemisphericParticleEmitter;
  39024. /**
  39025. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39026. * @param effect defines the update shader
  39027. */
  39028. applyToShader(effect: Effect): void;
  39029. /**
  39030. * Returns a string to use to update the GPU particles update shader
  39031. * @returns a string containng the defines string
  39032. */
  39033. getEffectDefines(): string;
  39034. /**
  39035. * Returns the string "HemisphericParticleEmitter"
  39036. * @returns a string containing the class name
  39037. */
  39038. getClassName(): string;
  39039. /**
  39040. * Serializes the particle system to a JSON object.
  39041. * @returns the JSON object
  39042. */
  39043. serialize(): any;
  39044. /**
  39045. * Parse properties from a JSON object
  39046. * @param serializationObject defines the JSON object
  39047. */
  39048. parse(serializationObject: any): void;
  39049. }
  39050. }
  39051. declare module BABYLON {
  39052. /**
  39053. * Particle emitter represents a volume emitting particles.
  39054. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  39055. */
  39056. interface IParticleEmitterType {
  39057. /**
  39058. * Called by the particle System when the direction is computed for the created particle.
  39059. * @param worldMatrix is the world matrix of the particle system
  39060. * @param directionToUpdate is the direction vector to update with the result
  39061. * @param particle is the particle we are computed the direction for
  39062. */
  39063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39064. /**
  39065. * Called by the particle System when the position is computed for the created particle.
  39066. * @param worldMatrix is the world matrix of the particle system
  39067. * @param positionToUpdate is the position vector to update with the result
  39068. * @param particle is the particle we are computed the position for
  39069. */
  39070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39071. /**
  39072. * Clones the current emitter and returns a copy of it
  39073. * @returns the new emitter
  39074. */
  39075. clone(): IParticleEmitterType;
  39076. /**
  39077. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39078. * @param effect defines the update shader
  39079. */
  39080. applyToShader(effect: Effect): void;
  39081. /**
  39082. * Returns a string to use to update the GPU particles update shader
  39083. * @returns the effect defines string
  39084. */
  39085. getEffectDefines(): string;
  39086. /**
  39087. * Returns a string representing the class name
  39088. * @returns a string containing the class name
  39089. */
  39090. getClassName(): string;
  39091. /**
  39092. * Serializes the particle system to a JSON object.
  39093. * @returns the JSON object
  39094. */
  39095. serialize(): any;
  39096. /**
  39097. * Parse properties from a JSON object
  39098. * @param serializationObject defines the JSON object
  39099. */
  39100. parse(serializationObject: any): void;
  39101. }
  39102. }
  39103. declare module BABYLON {
  39104. /**
  39105. * Particle emitter emitting particles from a point.
  39106. * It emits the particles randomly between 2 given directions.
  39107. */
  39108. class PointParticleEmitter implements IParticleEmitterType {
  39109. /**
  39110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  39111. */
  39112. direction1: Vector3;
  39113. /**
  39114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  39115. */
  39116. direction2: Vector3;
  39117. /**
  39118. * Creates a new instance PointParticleEmitter
  39119. */
  39120. constructor();
  39121. /**
  39122. * Called by the particle System when the direction is computed for the created particle.
  39123. * @param worldMatrix is the world matrix of the particle system
  39124. * @param directionToUpdate is the direction vector to update with the result
  39125. * @param particle is the particle we are computed the direction for
  39126. */
  39127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39128. /**
  39129. * Called by the particle System when the position is computed for the created particle.
  39130. * @param worldMatrix is the world matrix of the particle system
  39131. * @param positionToUpdate is the position vector to update with the result
  39132. * @param particle is the particle we are computed the position for
  39133. */
  39134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39135. /**
  39136. * Clones the current emitter and returns a copy of it
  39137. * @returns the new emitter
  39138. */
  39139. clone(): PointParticleEmitter;
  39140. /**
  39141. * Called by the GPUParticleSystem to setup the update shader
  39142. * @param effect defines the update shader
  39143. */
  39144. applyToShader(effect: Effect): void;
  39145. /**
  39146. * Returns a string to use to update the GPU particles update shader
  39147. * @returns a string containng the defines string
  39148. */
  39149. getEffectDefines(): string;
  39150. /**
  39151. * Returns the string "PointParticleEmitter"
  39152. * @returns a string containing the class name
  39153. */
  39154. getClassName(): string;
  39155. /**
  39156. * Serializes the particle system to a JSON object.
  39157. * @returns the JSON object
  39158. */
  39159. serialize(): any;
  39160. /**
  39161. * Parse properties from a JSON object
  39162. * @param serializationObject defines the JSON object
  39163. */
  39164. parse(serializationObject: any): void;
  39165. }
  39166. }
  39167. declare module BABYLON {
  39168. /**
  39169. * Particle emitter emitting particles from the inside of a sphere.
  39170. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  39171. */
  39172. class SphereParticleEmitter implements IParticleEmitterType {
  39173. /**
  39174. * The radius of the emission sphere.
  39175. */
  39176. radius: number;
  39177. /**
  39178. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  39179. */
  39180. radiusRange: number;
  39181. /**
  39182. * How much to randomize the particle direction [0-1].
  39183. */
  39184. directionRandomizer: number;
  39185. /**
  39186. * Creates a new instance SphereParticleEmitter
  39187. * @param radius the radius of the emission sphere (1 by default)
  39188. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  39189. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  39190. */
  39191. constructor(
  39192. /**
  39193. * The radius of the emission sphere.
  39194. */
  39195. radius?: number,
  39196. /**
  39197. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  39198. */
  39199. radiusRange?: number,
  39200. /**
  39201. * How much to randomize the particle direction [0-1].
  39202. */
  39203. directionRandomizer?: number);
  39204. /**
  39205. * Called by the particle System when the direction is computed for the created particle.
  39206. * @param worldMatrix is the world matrix of the particle system
  39207. * @param directionToUpdate is the direction vector to update with the result
  39208. * @param particle is the particle we are computed the direction for
  39209. */
  39210. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39211. /**
  39212. * Called by the particle System when the position is computed for the created particle.
  39213. * @param worldMatrix is the world matrix of the particle system
  39214. * @param positionToUpdate is the position vector to update with the result
  39215. * @param particle is the particle we are computed the position for
  39216. */
  39217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39218. /**
  39219. * Clones the current emitter and returns a copy of it
  39220. * @returns the new emitter
  39221. */
  39222. clone(): SphereParticleEmitter;
  39223. /**
  39224. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39225. * @param effect defines the update shader
  39226. */
  39227. applyToShader(effect: Effect): void;
  39228. /**
  39229. * Returns a string to use to update the GPU particles update shader
  39230. * @returns a string containng the defines string
  39231. */
  39232. getEffectDefines(): string;
  39233. /**
  39234. * Returns the string "SphereParticleEmitter"
  39235. * @returns a string containing the class name
  39236. */
  39237. getClassName(): string;
  39238. /**
  39239. * Serializes the particle system to a JSON object.
  39240. * @returns the JSON object
  39241. */
  39242. serialize(): any;
  39243. /**
  39244. * Parse properties from a JSON object
  39245. * @param serializationObject defines the JSON object
  39246. */
  39247. parse(serializationObject: any): void;
  39248. }
  39249. /**
  39250. * Particle emitter emitting particles from the inside of a sphere.
  39251. * It emits the particles randomly between two vectors.
  39252. */
  39253. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  39254. /**
  39255. * The min limit of the emission direction.
  39256. */
  39257. direction1: Vector3;
  39258. /**
  39259. * The max limit of the emission direction.
  39260. */
  39261. direction2: Vector3;
  39262. /**
  39263. * Creates a new instance SphereDirectedParticleEmitter
  39264. * @param radius the radius of the emission sphere (1 by default)
  39265. * @param direction1 the min limit of the emission direction (up vector by default)
  39266. * @param direction2 the max limit of the emission direction (up vector by default)
  39267. */
  39268. constructor(radius?: number,
  39269. /**
  39270. * The min limit of the emission direction.
  39271. */
  39272. direction1?: Vector3,
  39273. /**
  39274. * The max limit of the emission direction.
  39275. */
  39276. direction2?: Vector3);
  39277. /**
  39278. * Called by the particle System when the direction is computed for the created particle.
  39279. * @param worldMatrix is the world matrix of the particle system
  39280. * @param directionToUpdate is the direction vector to update with the result
  39281. * @param particle is the particle we are computed the direction for
  39282. */
  39283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39284. /**
  39285. * Clones the current emitter and returns a copy of it
  39286. * @returns the new emitter
  39287. */
  39288. clone(): SphereDirectedParticleEmitter;
  39289. /**
  39290. * Called by the GPUParticleSystem to setup the update shader
  39291. * @param effect defines the update shader
  39292. */
  39293. applyToShader(effect: Effect): void;
  39294. /**
  39295. * Returns a string to use to update the GPU particles update shader
  39296. * @returns a string containng the defines string
  39297. */
  39298. getEffectDefines(): string;
  39299. /**
  39300. * Returns the string "SphereDirectedParticleEmitter"
  39301. * @returns a string containing the class name
  39302. */
  39303. getClassName(): string;
  39304. /**
  39305. * Serializes the particle system to a JSON object.
  39306. * @returns the JSON object
  39307. */
  39308. serialize(): any;
  39309. /**
  39310. * Parse properties from a JSON object
  39311. * @param serializationObject defines the JSON object
  39312. */
  39313. parse(serializationObject: any): void;
  39314. }
  39315. }
  39316. declare module BABYLON {
  39317. class CannonJSPlugin implements IPhysicsEnginePlugin {
  39318. private _useDeltaForWorldStep;
  39319. world: any;
  39320. name: string;
  39321. private _physicsMaterials;
  39322. private _fixedTimeStep;
  39323. BJSCANNON: any;
  39324. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  39325. setGravity(gravity: Vector3): void;
  39326. setTimeStep(timeStep: number): void;
  39327. getTimeStep(): number;
  39328. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  39329. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39330. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39331. generatePhysicsBody(impostor: PhysicsImpostor): void;
  39332. private _processChildMeshes;
  39333. removePhysicsBody(impostor: PhysicsImpostor): void;
  39334. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  39335. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  39336. private _addMaterial;
  39337. private _checkWithEpsilon;
  39338. private _createShape;
  39339. private _createHeightmap;
  39340. private _minus90X;
  39341. private _plus90X;
  39342. private _tmpPosition;
  39343. private _tmpDeltaPosition;
  39344. private _tmpUnityRotation;
  39345. private _updatePhysicsBodyTransformation;
  39346. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  39347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  39348. isSupported(): boolean;
  39349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  39354. getBodyMass(impostor: PhysicsImpostor): number;
  39355. getBodyFriction(impostor: PhysicsImpostor): number;
  39356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  39357. getBodyRestitution(impostor: PhysicsImpostor): number;
  39358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  39359. sleepBody(impostor: PhysicsImpostor): void;
  39360. wakeUpBody(impostor: PhysicsImpostor): void;
  39361. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  39362. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  39363. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  39364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  39365. getRadius(impostor: PhysicsImpostor): number;
  39366. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  39367. dispose(): void;
  39368. private _extendNamespace;
  39369. }
  39370. }
  39371. declare module BABYLON {
  39372. class OimoJSPlugin implements IPhysicsEnginePlugin {
  39373. world: any;
  39374. name: string;
  39375. BJSOIMO: any;
  39376. constructor(iterations?: number);
  39377. setGravity(gravity: Vector3): void;
  39378. setTimeStep(timeStep: number): void;
  39379. getTimeStep(): number;
  39380. private _tmpImpostorsArray;
  39381. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  39382. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39383. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39384. generatePhysicsBody(impostor: PhysicsImpostor): void;
  39385. private _tmpPositionVector;
  39386. removePhysicsBody(impostor: PhysicsImpostor): void;
  39387. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  39388. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  39389. isSupported(): boolean;
  39390. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  39391. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  39392. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39393. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39394. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39395. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39396. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  39397. getBodyMass(impostor: PhysicsImpostor): number;
  39398. getBodyFriction(impostor: PhysicsImpostor): number;
  39399. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  39400. getBodyRestitution(impostor: PhysicsImpostor): number;
  39401. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  39402. sleepBody(impostor: PhysicsImpostor): void;
  39403. wakeUpBody(impostor: PhysicsImpostor): void;
  39404. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  39405. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  39406. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  39407. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  39408. getRadius(impostor: PhysicsImpostor): number;
  39409. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  39410. dispose(): void;
  39411. }
  39412. }
  39413. declare module BABYLON {
  39414. /**
  39415. * This represents a set of one or more post processes in Babylon.
  39416. * A post process can be used to apply a shader to a texture after it is rendered.
  39417. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  39418. */
  39419. class PostProcessRenderEffect {
  39420. private _postProcesses;
  39421. private _getPostProcesses;
  39422. private _singleInstance;
  39423. private _cameras;
  39424. private _indicesForCamera;
  39425. /**
  39426. * Name of the effect
  39427. * @hidden
  39428. */
  39429. _name: string;
  39430. /**
  39431. * Instantiates a post process render effect.
  39432. * A post process can be used to apply a shader to a texture after it is rendered.
  39433. * @param engine The engine the effect is tied to
  39434. * @param name The name of the effect
  39435. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  39436. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  39437. */
  39438. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  39439. /**
  39440. * Checks if all the post processes in the effect are supported.
  39441. */
  39442. readonly isSupported: boolean;
  39443. /**
  39444. * Updates the current state of the effect
  39445. * @hidden
  39446. */
  39447. _update(): void;
  39448. /**
  39449. * Attaches the effect on cameras
  39450. * @param cameras The camera to attach to.
  39451. * @hidden
  39452. */
  39453. _attachCameras(cameras: Camera): void;
  39454. /**
  39455. * Attaches the effect on cameras
  39456. * @param cameras The camera to attach to.
  39457. * @hidden
  39458. */
  39459. _attachCameras(cameras: Camera[]): void;
  39460. /**
  39461. * Detatches the effect on cameras
  39462. * @param cameras The camera to detatch from.
  39463. * @hidden
  39464. */
  39465. _detachCameras(cameras: Camera): void;
  39466. /**
  39467. * Detatches the effect on cameras
  39468. * @param cameras The camera to detatch from.
  39469. * @hidden
  39470. */
  39471. _detachCameras(cameras: Camera[]): void;
  39472. /**
  39473. * Enables the effect on given cameras
  39474. * @param cameras The camera to enable.
  39475. * @hidden
  39476. */
  39477. _enable(cameras: Camera): void;
  39478. /**
  39479. * Enables the effect on given cameras
  39480. * @param cameras The camera to enable.
  39481. * @hidden
  39482. */
  39483. _enable(cameras: Nullable<Camera[]>): void;
  39484. /**
  39485. * Disables the effect on the given cameras
  39486. * @param cameras The camera to disable.
  39487. * @hidden
  39488. */
  39489. _disable(cameras: Camera): void;
  39490. /**
  39491. * Disables the effect on the given cameras
  39492. * @param cameras The camera to disable.
  39493. * @hidden
  39494. */
  39495. _disable(cameras: Nullable<Camera[]>): void;
  39496. /**
  39497. * Gets a list of the post processes contained in the effect.
  39498. * @param camera The camera to get the post processes on.
  39499. * @returns The list of the post processes in the effect.
  39500. */
  39501. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  39502. }
  39503. }
  39504. declare module BABYLON {
  39505. class PostProcessRenderPipeline {
  39506. private engine;
  39507. private _renderEffects;
  39508. private _renderEffectsForIsolatedPass;
  39509. protected _cameras: Camera[];
  39510. /** @hidden */
  39511. _name: string;
  39512. constructor(engine: Engine, name: string);
  39513. getClassName(): string;
  39514. readonly isSupported: boolean;
  39515. addEffect(renderEffect: PostProcessRenderEffect): void;
  39516. /** @hidden */
  39517. _rebuild(): void;
  39518. /** @hidden */
  39519. _enableEffect(renderEffectName: string, cameras: Camera): void;
  39520. /** @hidden */
  39521. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  39522. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  39523. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  39524. /** @hidden */
  39525. _attachCameras(cameras: Camera, unique: boolean): void;
  39526. /** @hidden */
  39527. _attachCameras(cameras: Camera[], unique: boolean): void;
  39528. /** @hidden */
  39529. _detachCameras(cameras: Camera): void;
  39530. /** @hidden */
  39531. _detachCameras(cameras: Nullable<Camera[]>): void;
  39532. /** @hidden */
  39533. _update(): void;
  39534. /** @hidden */
  39535. _reset(): void;
  39536. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  39537. dispose(): void;
  39538. }
  39539. }
  39540. declare module BABYLON {
  39541. class PostProcessRenderPipelineManager {
  39542. private _renderPipelines;
  39543. constructor();
  39544. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  39545. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  39546. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  39547. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  39548. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  39549. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  39550. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  39551. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  39552. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  39553. update(): void;
  39554. /** @hidden */
  39555. _rebuild(): void;
  39556. dispose(): void;
  39557. }
  39558. }
  39559. declare module BABYLON {
  39560. interface Scene {
  39561. /** @hidden (Backing field) */
  39562. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  39563. /**
  39564. * Gets the postprocess render pipeline manager
  39565. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  39566. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39567. */
  39568. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  39569. }
  39570. /**
  39571. * Defines the Render Pipeline scene component responsible to rendering pipelines
  39572. */
  39573. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  39574. /**
  39575. * The component name helpfull to identify the component in the list of scene components.
  39576. */
  39577. readonly name: string;
  39578. /**
  39579. * The scene the component belongs to.
  39580. */
  39581. scene: Scene;
  39582. /**
  39583. * Creates a new instance of the component for the given scene
  39584. * @param scene Defines the scene to register the component in
  39585. */
  39586. constructor(scene: Scene);
  39587. /**
  39588. * Registers the component in a given scene
  39589. */
  39590. register(): void;
  39591. /**
  39592. * Rebuilds the elements related to this component in case of
  39593. * context lost for instance.
  39594. */
  39595. rebuild(): void;
  39596. /**
  39597. * Disposes the component and the associated ressources
  39598. */
  39599. dispose(): void;
  39600. private _gatherRenderTargets;
  39601. }
  39602. }
  39603. declare module BABYLON {
  39604. /**
  39605. * Helper class dealing with the extraction of spherical polynomial dataArray
  39606. * from a cube map.
  39607. */
  39608. class CubeMapToSphericalPolynomialTools {
  39609. private static FileFaces;
  39610. /**
  39611. * Converts a texture to the according Spherical Polynomial data.
  39612. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39613. *
  39614. * @param texture The texture to extract the information from.
  39615. * @return The Spherical Polynomial data.
  39616. */
  39617. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  39618. /**
  39619. * Converts a cubemap to the according Spherical Polynomial data.
  39620. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39621. *
  39622. * @param cubeInfo The Cube map to extract the information from.
  39623. * @return The Spherical Polynomial data.
  39624. */
  39625. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  39626. }
  39627. }
  39628. declare module BABYLON {
  39629. /**
  39630. * Header information of HDR texture files.
  39631. */
  39632. interface HDRInfo {
  39633. /**
  39634. * The height of the texture in pixels.
  39635. */
  39636. height: number;
  39637. /**
  39638. * The width of the texture in pixels.
  39639. */
  39640. width: number;
  39641. /**
  39642. * The index of the beginning of the data in the binary file.
  39643. */
  39644. dataPosition: number;
  39645. }
  39646. /**
  39647. * This groups tools to convert HDR texture to native colors array.
  39648. */
  39649. class HDRTools {
  39650. private static Ldexp;
  39651. private static Rgbe2float;
  39652. private static readStringLine;
  39653. /**
  39654. * Reads header information from an RGBE texture stored in a native array.
  39655. * More information on this format are available here:
  39656. * https://en.wikipedia.org/wiki/RGBE_image_format
  39657. *
  39658. * @param uint8array The binary file stored in native array.
  39659. * @return The header information.
  39660. */
  39661. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  39662. /**
  39663. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  39664. * This RGBE texture needs to store the information as a panorama.
  39665. *
  39666. * More information on this format are available here:
  39667. * https://en.wikipedia.org/wiki/RGBE_image_format
  39668. *
  39669. * @param buffer The binary file stored in an array buffer.
  39670. * @param size The expected size of the extracted cubemap.
  39671. * @return The Cube Map information.
  39672. */
  39673. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  39674. /**
  39675. * Returns the pixels data extracted from an RGBE texture.
  39676. * This pixels will be stored left to right up to down in the R G B order in one array.
  39677. *
  39678. * More information on this format are available here:
  39679. * https://en.wikipedia.org/wiki/RGBE_image_format
  39680. *
  39681. * @param uint8array The binary file stored in an array buffer.
  39682. * @param hdrInfo The header information of the file.
  39683. * @return The pixels data in RGB right to left up to down order.
  39684. */
  39685. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  39686. private static RGBE_ReadPixels_RLE;
  39687. }
  39688. }
  39689. declare module BABYLON {
  39690. /**
  39691. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  39692. */
  39693. interface CubeMapInfo {
  39694. /**
  39695. * The pixel array for the front face.
  39696. * This is stored in format, left to right, up to down format.
  39697. */
  39698. front: Nullable<ArrayBufferView>;
  39699. /**
  39700. * The pixel array for the back face.
  39701. * This is stored in format, left to right, up to down format.
  39702. */
  39703. back: Nullable<ArrayBufferView>;
  39704. /**
  39705. * The pixel array for the left face.
  39706. * This is stored in format, left to right, up to down format.
  39707. */
  39708. left: Nullable<ArrayBufferView>;
  39709. /**
  39710. * The pixel array for the right face.
  39711. * This is stored in format, left to right, up to down format.
  39712. */
  39713. right: Nullable<ArrayBufferView>;
  39714. /**
  39715. * The pixel array for the up face.
  39716. * This is stored in format, left to right, up to down format.
  39717. */
  39718. up: Nullable<ArrayBufferView>;
  39719. /**
  39720. * The pixel array for the down face.
  39721. * This is stored in format, left to right, up to down format.
  39722. */
  39723. down: Nullable<ArrayBufferView>;
  39724. /**
  39725. * The size of the cubemap stored.
  39726. *
  39727. * Each faces will be size * size pixels.
  39728. */
  39729. size: number;
  39730. /**
  39731. * The format of the texture.
  39732. *
  39733. * RGBA, RGB.
  39734. */
  39735. format: number;
  39736. /**
  39737. * The type of the texture data.
  39738. *
  39739. * UNSIGNED_INT, FLOAT.
  39740. */
  39741. type: number;
  39742. /**
  39743. * Specifies whether the texture is in gamma space.
  39744. */
  39745. gammaSpace: boolean;
  39746. }
  39747. /**
  39748. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  39749. */
  39750. class PanoramaToCubeMapTools {
  39751. private static FACE_FRONT;
  39752. private static FACE_BACK;
  39753. private static FACE_RIGHT;
  39754. private static FACE_LEFT;
  39755. private static FACE_DOWN;
  39756. private static FACE_UP;
  39757. /**
  39758. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  39759. *
  39760. * @param float32Array The source data.
  39761. * @param inputWidth The width of the input panorama.
  39762. * @param inputhHeight The height of the input panorama.
  39763. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  39764. * @return The cubemap data
  39765. */
  39766. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  39767. private static CreateCubemapTexture;
  39768. private static CalcProjectionSpherical;
  39769. }
  39770. }
  39771. declare module BABYLON {
  39772. }
  39773. declare module BABYLON {
  39774. }
  39775. declare module BABYLON {
  39776. }
  39777. declare module BABYLON {
  39778. }
  39779. declare module BABYLON {
  39780. class CustomProceduralTexture extends ProceduralTexture {
  39781. private _animate;
  39782. private _time;
  39783. private _config;
  39784. private _texturePath;
  39785. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39786. private loadJson;
  39787. isReady(): boolean;
  39788. render(useCameraPostProcess?: boolean): void;
  39789. updateTextures(): void;
  39790. updateShaderUniforms(): void;
  39791. animate: boolean;
  39792. }
  39793. }
  39794. declare module BABYLON {
  39795. /**
  39796. * Class used to generate noise procedural textures
  39797. */
  39798. class NoiseProceduralTexture extends ProceduralTexture {
  39799. private _time;
  39800. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  39801. brightness: number;
  39802. /** Defines the number of octaves to process */
  39803. octaves: number;
  39804. /** Defines the level of persistence (0.8 by default) */
  39805. persistence: number;
  39806. /** Gets or sets animation speed factor (default is 1) */
  39807. animationSpeedFactor: number;
  39808. /**
  39809. * Creates a new NoiseProceduralTexture
  39810. * @param name defines the name fo the texture
  39811. * @param size defines the size of the texture (default is 256)
  39812. * @param scene defines the hosting scene
  39813. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  39814. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  39815. */
  39816. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39817. private _updateShaderUniforms;
  39818. protected _getDefines(): string;
  39819. /** Generate the current state of the procedural texture */
  39820. render(useCameraPostProcess?: boolean): void;
  39821. /**
  39822. * Serializes this noise procedural texture
  39823. * @returns a serialized noise procedural texture object
  39824. */
  39825. serialize(): any;
  39826. /**
  39827. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  39828. * @param parsedTexture defines parsed texture data
  39829. * @param scene defines the current scene
  39830. * @param rootUrl defines the root URL containing noise procedural texture information
  39831. * @returns a parsed NoiseProceduralTexture
  39832. */
  39833. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  39834. }
  39835. }
  39836. declare module BABYLON {
  39837. class ProceduralTexture extends Texture {
  39838. isCube: boolean;
  39839. private _size;
  39840. /** @hidden */
  39841. _generateMipMaps: boolean;
  39842. isEnabled: boolean;
  39843. private _currentRefreshId;
  39844. private _refreshRate;
  39845. onGenerated: () => void;
  39846. private _vertexBuffers;
  39847. private _indexBuffer;
  39848. private _effect;
  39849. private _uniforms;
  39850. private _samplers;
  39851. private _fragment;
  39852. /** @hidden */
  39853. _textures: {
  39854. [key: string]: Texture;
  39855. };
  39856. private _floats;
  39857. private _ints;
  39858. private _floatsArrays;
  39859. private _colors3;
  39860. private _colors4;
  39861. private _vectors2;
  39862. private _vectors3;
  39863. private _matrices;
  39864. private _fallbackTexture;
  39865. private _fallbackTextureUsed;
  39866. private _engine;
  39867. private _cachedDefines;
  39868. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  39869. private _createIndexBuffer;
  39870. /** @hidden */
  39871. _rebuild(): void;
  39872. reset(): void;
  39873. protected _getDefines(): string;
  39874. isReady(): boolean;
  39875. resetRefreshCounter(): void;
  39876. setFragment(fragment: any): void;
  39877. refreshRate: number;
  39878. /** @hidden */
  39879. _shouldRender(): boolean;
  39880. getRenderSize(): number;
  39881. resize(size: number, generateMipMaps: boolean): void;
  39882. private _checkUniform;
  39883. setTexture(name: string, texture: Texture): ProceduralTexture;
  39884. setFloat(name: string, value: number): ProceduralTexture;
  39885. /**
  39886. * Set the value of an uniform to an integer value
  39887. * @param name defines the name of the uniform
  39888. * @param value defines the value to set
  39889. * @returns the current procedural texture
  39890. */
  39891. setInt(name: string, value: number): ProceduralTexture;
  39892. setFloats(name: string, value: number[]): ProceduralTexture;
  39893. setColor3(name: string, value: Color3): ProceduralTexture;
  39894. setColor4(name: string, value: Color4): ProceduralTexture;
  39895. setVector2(name: string, value: Vector2): ProceduralTexture;
  39896. setVector3(name: string, value: Vector3): ProceduralTexture;
  39897. setMatrix(name: string, value: Matrix): ProceduralTexture;
  39898. render(useCameraPostProcess?: boolean): void;
  39899. clone(): ProceduralTexture;
  39900. dispose(): void;
  39901. }
  39902. }
  39903. declare module BABYLON {
  39904. interface AbstractScene {
  39905. /**
  39906. * The list of procedural textures added to the scene
  39907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  39908. */
  39909. proceduralTextures: Array<ProceduralTexture>;
  39910. }
  39911. /**
  39912. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  39913. * in a given scene.
  39914. */
  39915. class ProceduralTextureSceneComponent implements ISceneComponent {
  39916. /**
  39917. * The component name helpfull to identify the component in the list of scene components.
  39918. */
  39919. readonly name: string;
  39920. /**
  39921. * The scene the component belongs to.
  39922. */
  39923. scene: Scene;
  39924. /**
  39925. * Creates a new instance of the component for the given scene
  39926. * @param scene Defines the scene to register the component in
  39927. */
  39928. constructor(scene: Scene);
  39929. /**
  39930. * Registers the component in a given scene
  39931. */
  39932. register(): void;
  39933. /**
  39934. * Rebuilds the elements related to this component in case of
  39935. * context lost for instance.
  39936. */
  39937. rebuild(): void;
  39938. /**
  39939. * Disposes the component and the associated ressources.
  39940. */
  39941. dispose(): void;
  39942. private _beforeClear;
  39943. }
  39944. }
  39945. declare module BABYLON {
  39946. /**
  39947. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  39948. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39949. */
  39950. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39951. private _scene;
  39952. private _camerasToBeAttached;
  39953. /**
  39954. * ID of the sharpen post process,
  39955. */
  39956. private readonly SharpenPostProcessId;
  39957. /**
  39958. * ID of the image processing post process;
  39959. */
  39960. readonly ImageProcessingPostProcessId: string;
  39961. /**
  39962. * ID of the Fast Approximate Anti-Aliasing post process;
  39963. */
  39964. readonly FxaaPostProcessId: string;
  39965. /**
  39966. * ID of the chromatic aberration post process,
  39967. */
  39968. private readonly ChromaticAberrationPostProcessId;
  39969. /**
  39970. * ID of the grain post process
  39971. */
  39972. private readonly GrainPostProcessId;
  39973. /**
  39974. * Sharpen post process which will apply a sharpen convolution to enhance edges
  39975. */
  39976. sharpen: SharpenPostProcess;
  39977. private _sharpenEffect;
  39978. private bloom;
  39979. /**
  39980. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  39981. */
  39982. depthOfField: DepthOfFieldEffect;
  39983. /**
  39984. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  39985. */
  39986. fxaa: FxaaPostProcess;
  39987. /**
  39988. * Image post processing pass used to perform operations such as tone mapping or color grading.
  39989. */
  39990. imageProcessing: ImageProcessingPostProcess;
  39991. /**
  39992. * Chromatic aberration post process which will shift rgb colors in the image
  39993. */
  39994. chromaticAberration: ChromaticAberrationPostProcess;
  39995. private _chromaticAberrationEffect;
  39996. /**
  39997. * Grain post process which add noise to the image
  39998. */
  39999. grain: GrainPostProcess;
  40000. private _grainEffect;
  40001. /**
  40002. * Glow post process which adds a glow to emmisive areas of the image
  40003. */
  40004. private _glowLayer;
  40005. /**
  40006. * Animations which can be used to tweak settings over a period of time
  40007. */
  40008. animations: Animation[];
  40009. private _imageProcessingConfigurationObserver;
  40010. private _sharpenEnabled;
  40011. private _bloomEnabled;
  40012. private _depthOfFieldEnabled;
  40013. private _depthOfFieldBlurLevel;
  40014. private _fxaaEnabled;
  40015. private _imageProcessingEnabled;
  40016. private _defaultPipelineTextureType;
  40017. private _bloomScale;
  40018. private _chromaticAberrationEnabled;
  40019. private _grainEnabled;
  40020. private _buildAllowed;
  40021. /**
  40022. * Enable or disable the sharpen process from the pipeline
  40023. */
  40024. sharpenEnabled: boolean;
  40025. private _resizeObserver;
  40026. private _hardwareScaleLevel;
  40027. private _bloomKernel;
  40028. /**
  40029. * Specifies the size of the bloom blur kernel, relative to the final output size
  40030. */
  40031. bloomKernel: number;
  40032. /**
  40033. * Specifies the weight of the bloom in the final rendering
  40034. */
  40035. private _bloomWeight;
  40036. /**
  40037. * Specifies the luma threshold for the area that will be blurred by the bloom
  40038. */
  40039. private _bloomThreshold;
  40040. private _hdr;
  40041. /**
  40042. * The strength of the bloom.
  40043. */
  40044. bloomWeight: number;
  40045. /**
  40046. * The strength of the bloom.
  40047. */
  40048. bloomThreshold: number;
  40049. /**
  40050. * The scale of the bloom, lower value will provide better performance.
  40051. */
  40052. bloomScale: number;
  40053. /**
  40054. * Enable or disable the bloom from the pipeline
  40055. */
  40056. bloomEnabled: boolean;
  40057. private _rebuildBloom;
  40058. /**
  40059. * If the depth of field is enabled.
  40060. */
  40061. depthOfFieldEnabled: boolean;
  40062. /**
  40063. * Blur level of the depth of field effect. (Higher blur will effect performance)
  40064. */
  40065. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  40066. /**
  40067. * If the anti aliasing is enabled.
  40068. */
  40069. fxaaEnabled: boolean;
  40070. private _samples;
  40071. /**
  40072. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  40073. */
  40074. samples: number;
  40075. /**
  40076. * If image processing is enabled.
  40077. */
  40078. imageProcessingEnabled: boolean;
  40079. /**
  40080. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  40081. */
  40082. glowLayerEnabled: boolean;
  40083. /**
  40084. * Enable or disable the chromaticAberration process from the pipeline
  40085. */
  40086. chromaticAberrationEnabled: boolean;
  40087. /**
  40088. * Enable or disable the grain process from the pipeline
  40089. */
  40090. grainEnabled: boolean;
  40091. /**
  40092. * @constructor
  40093. * @param {string} name - The rendering pipeline name (default: "")
  40094. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  40095. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  40096. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  40097. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  40098. */
  40099. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  40100. /**
  40101. * Force the compilation of the entire pipeline.
  40102. */
  40103. prepare(): void;
  40104. private _hasCleared;
  40105. private _prevPostProcess;
  40106. private _prevPrevPostProcess;
  40107. private _setAutoClearAndTextureSharing;
  40108. private _depthOfFieldSceneObserver;
  40109. private _buildPipeline;
  40110. private _disposePostProcesses;
  40111. /**
  40112. * Adds a camera to the pipeline
  40113. * @param camera the camera to be added
  40114. */
  40115. addCamera(camera: Camera): void;
  40116. /**
  40117. * Removes a camera from the pipeline
  40118. * @param camera the camera to remove
  40119. */
  40120. removeCamera(camera: Camera): void;
  40121. /**
  40122. * Dispose of the pipeline and stop all post processes
  40123. */
  40124. dispose(): void;
  40125. /**
  40126. * Serialize the rendering pipeline (Used when exporting)
  40127. * @returns the serialized object
  40128. */
  40129. serialize(): any;
  40130. /**
  40131. * Parse the serialized pipeline
  40132. * @param source Source pipeline.
  40133. * @param scene The scene to load the pipeline to.
  40134. * @param rootUrl The URL of the serialized pipeline.
  40135. * @returns An instantiated pipeline from the serialized object.
  40136. */
  40137. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  40138. }
  40139. }
  40140. declare module BABYLON {
  40141. class LensRenderingPipeline extends PostProcessRenderPipeline {
  40142. /**
  40143. * The chromatic aberration PostProcess id in the pipeline
  40144. */
  40145. LensChromaticAberrationEffect: string;
  40146. /**
  40147. * The highlights enhancing PostProcess id in the pipeline
  40148. */
  40149. HighlightsEnhancingEffect: string;
  40150. /**
  40151. * The depth-of-field PostProcess id in the pipeline
  40152. */
  40153. LensDepthOfFieldEffect: string;
  40154. private _scene;
  40155. private _depthTexture;
  40156. private _grainTexture;
  40157. private _chromaticAberrationPostProcess;
  40158. private _highlightsPostProcess;
  40159. private _depthOfFieldPostProcess;
  40160. private _edgeBlur;
  40161. private _grainAmount;
  40162. private _chromaticAberration;
  40163. private _distortion;
  40164. private _highlightsGain;
  40165. private _highlightsThreshold;
  40166. private _dofDistance;
  40167. private _dofAperture;
  40168. private _dofDarken;
  40169. private _dofPentagon;
  40170. private _blurNoise;
  40171. /**
  40172. * @constructor
  40173. *
  40174. * Effect parameters are as follow:
  40175. * {
  40176. * chromatic_aberration: number; // from 0 to x (1 for realism)
  40177. * edge_blur: number; // from 0 to x (1 for realism)
  40178. * distortion: number; // from 0 to x (1 for realism)
  40179. * grain_amount: number; // from 0 to 1
  40180. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  40181. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  40182. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  40183. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  40184. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  40185. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  40186. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  40187. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  40188. * }
  40189. * Note: if an effect parameter is unset, effect is disabled
  40190. *
  40191. * @param {string} name - The rendering pipeline name
  40192. * @param {object} parameters - An object containing all parameters (see above)
  40193. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40194. * @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)
  40195. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40196. */
  40197. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  40198. setEdgeBlur(amount: number): void;
  40199. disableEdgeBlur(): void;
  40200. setGrainAmount(amount: number): void;
  40201. disableGrain(): void;
  40202. setChromaticAberration(amount: number): void;
  40203. disableChromaticAberration(): void;
  40204. setEdgeDistortion(amount: number): void;
  40205. disableEdgeDistortion(): void;
  40206. setFocusDistance(amount: number): void;
  40207. disableDepthOfField(): void;
  40208. setAperture(amount: number): void;
  40209. setDarkenOutOfFocus(amount: number): void;
  40210. enablePentagonBokeh(): void;
  40211. disablePentagonBokeh(): void;
  40212. enableNoiseBlur(): void;
  40213. disableNoiseBlur(): void;
  40214. setHighlightsGain(amount: number): void;
  40215. setHighlightsThreshold(amount: number): void;
  40216. disableHighlights(): void;
  40217. /**
  40218. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  40219. */
  40220. dispose(disableDepthRender?: boolean): void;
  40221. private _createChromaticAberrationPostProcess;
  40222. private _createHighlightsPostProcess;
  40223. private _createDepthOfFieldPostProcess;
  40224. private _createGrainTexture;
  40225. }
  40226. }
  40227. declare module BABYLON {
  40228. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  40229. /**
  40230. * The PassPostProcess id in the pipeline that contains the original scene color
  40231. */
  40232. SSAOOriginalSceneColorEffect: string;
  40233. /**
  40234. * The SSAO PostProcess id in the pipeline
  40235. */
  40236. SSAORenderEffect: string;
  40237. /**
  40238. * The horizontal blur PostProcess id in the pipeline
  40239. */
  40240. SSAOBlurHRenderEffect: string;
  40241. /**
  40242. * The vertical blur PostProcess id in the pipeline
  40243. */
  40244. SSAOBlurVRenderEffect: string;
  40245. /**
  40246. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  40247. */
  40248. SSAOCombineRenderEffect: string;
  40249. /**
  40250. * The output strength of the SSAO post-process. Default value is 1.0.
  40251. */
  40252. totalStrength: number;
  40253. /**
  40254. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  40255. */
  40256. maxZ: number;
  40257. /**
  40258. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  40259. */
  40260. minZAspect: number;
  40261. private _samples;
  40262. /**
  40263. * Number of samples used for the SSAO calculations. Default value is 8
  40264. */
  40265. samples: number;
  40266. private _textureSamples;
  40267. /**
  40268. * Number of samples to use for antialiasing
  40269. */
  40270. textureSamples: number;
  40271. /**
  40272. * Ratio object used for SSAO ratio and blur ratio
  40273. */
  40274. private _ratio;
  40275. /**
  40276. * Dynamically generated sphere sampler.
  40277. */
  40278. private _sampleSphere;
  40279. /**
  40280. * Blur filter offsets
  40281. */
  40282. private _samplerOffsets;
  40283. /**
  40284. * Are we using bilateral blur ?
  40285. */
  40286. private _expensiveBlur;
  40287. expensiveBlur: boolean;
  40288. /**
  40289. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  40290. */
  40291. radius: number;
  40292. /**
  40293. * The base color of the SSAO post-process
  40294. * The final result is "base + ssao" between [0, 1]
  40295. */
  40296. base: number;
  40297. /**
  40298. * Support test.
  40299. */
  40300. static readonly IsSupported: boolean;
  40301. private _scene;
  40302. private _depthTexture;
  40303. private _normalTexture;
  40304. private _randomTexture;
  40305. private _originalColorPostProcess;
  40306. private _ssaoPostProcess;
  40307. private _blurHPostProcess;
  40308. private _blurVPostProcess;
  40309. private _ssaoCombinePostProcess;
  40310. private _firstUpdate;
  40311. /**
  40312. * @constructor
  40313. * @param {string} name - The rendering pipeline name
  40314. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40315. * @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 }
  40316. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40317. */
  40318. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  40319. /**
  40320. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  40321. */
  40322. dispose(disableGeometryBufferRenderer?: boolean): void;
  40323. private _createBlurPostProcess;
  40324. /** @hidden */
  40325. _rebuild(): void;
  40326. private _bits;
  40327. private _radicalInverse_VdC;
  40328. private _hammersley;
  40329. private _hemisphereSample_uniform;
  40330. private _generateHemisphere;
  40331. private _createSSAOPostProcess;
  40332. private _createSSAOCombinePostProcess;
  40333. private _createRandomTexture;
  40334. /**
  40335. * Serialize the rendering pipeline (Used when exporting)
  40336. * @returns the serialized object
  40337. */
  40338. serialize(): any;
  40339. /**
  40340. * Parse the serialized pipeline
  40341. * @param source Source pipeline.
  40342. * @param scene The scene to load the pipeline to.
  40343. * @param rootUrl The URL of the serialized pipeline.
  40344. * @returns An instantiated pipeline from the serialized object.
  40345. */
  40346. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  40347. }
  40348. }
  40349. declare module BABYLON {
  40350. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  40351. /**
  40352. * The PassPostProcess id in the pipeline that contains the original scene color
  40353. */
  40354. SSAOOriginalSceneColorEffect: string;
  40355. /**
  40356. * The SSAO PostProcess id in the pipeline
  40357. */
  40358. SSAORenderEffect: string;
  40359. /**
  40360. * The horizontal blur PostProcess id in the pipeline
  40361. */
  40362. SSAOBlurHRenderEffect: string;
  40363. /**
  40364. * The vertical blur PostProcess id in the pipeline
  40365. */
  40366. SSAOBlurVRenderEffect: string;
  40367. /**
  40368. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  40369. */
  40370. SSAOCombineRenderEffect: string;
  40371. /**
  40372. * The output strength of the SSAO post-process. Default value is 1.0.
  40373. */
  40374. totalStrength: number;
  40375. /**
  40376. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  40377. */
  40378. radius: number;
  40379. /**
  40380. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  40381. * Must not be equal to fallOff and superior to fallOff.
  40382. * Default value is 0.975
  40383. */
  40384. area: number;
  40385. /**
  40386. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  40387. * Must not be equal to area and inferior to area.
  40388. * Default value is 0.0
  40389. */
  40390. fallOff: number;
  40391. /**
  40392. * The base color of the SSAO post-process
  40393. * The final result is "base + ssao" between [0, 1]
  40394. */
  40395. base: number;
  40396. private _scene;
  40397. private _depthTexture;
  40398. private _randomTexture;
  40399. private _originalColorPostProcess;
  40400. private _ssaoPostProcess;
  40401. private _blurHPostProcess;
  40402. private _blurVPostProcess;
  40403. private _ssaoCombinePostProcess;
  40404. private _firstUpdate;
  40405. /**
  40406. * @constructor
  40407. * @param {string} name - The rendering pipeline name
  40408. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40409. * @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 }
  40410. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40411. */
  40412. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  40413. /**
  40414. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  40415. */
  40416. dispose(disableDepthRender?: boolean): void;
  40417. private _createBlurPostProcess;
  40418. /** @hidden */
  40419. _rebuild(): void;
  40420. private _createSSAOPostProcess;
  40421. private _createSSAOCombinePostProcess;
  40422. private _createRandomTexture;
  40423. }
  40424. }
  40425. declare module BABYLON {
  40426. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  40427. /**
  40428. * Public members
  40429. */
  40430. /**
  40431. * Post-process which contains the original scene color before the pipeline applies all the effects
  40432. */
  40433. originalPostProcess: Nullable<PostProcess>;
  40434. /**
  40435. * Post-process used to down scale an image x4
  40436. */
  40437. downSampleX4PostProcess: Nullable<PostProcess>;
  40438. /**
  40439. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  40440. */
  40441. brightPassPostProcess: Nullable<PostProcess>;
  40442. /**
  40443. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  40444. */
  40445. blurHPostProcesses: PostProcess[];
  40446. /**
  40447. * Post-process array storing all the vertical blur post-processes used by the pipeline
  40448. */
  40449. blurVPostProcesses: PostProcess[];
  40450. /**
  40451. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  40452. */
  40453. textureAdderPostProcess: Nullable<PostProcess>;
  40454. /**
  40455. * Post-process used to create volumetric lighting effect
  40456. */
  40457. volumetricLightPostProcess: Nullable<PostProcess>;
  40458. /**
  40459. * Post-process used to smooth the previous volumetric light post-process on the X axis
  40460. */
  40461. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  40462. /**
  40463. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  40464. */
  40465. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  40466. /**
  40467. * Post-process used to merge the volumetric light effect and the real scene color
  40468. */
  40469. volumetricLightMergePostProces: Nullable<PostProcess>;
  40470. /**
  40471. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  40472. */
  40473. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  40474. /**
  40475. * Base post-process used to calculate the average luminance of the final image for HDR
  40476. */
  40477. luminancePostProcess: Nullable<PostProcess>;
  40478. /**
  40479. * Post-processes used to create down sample post-processes in order to get
  40480. * the average luminance of the final image for HDR
  40481. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  40482. */
  40483. luminanceDownSamplePostProcesses: PostProcess[];
  40484. /**
  40485. * Post-process used to create a HDR effect (light adaptation)
  40486. */
  40487. hdrPostProcess: Nullable<PostProcess>;
  40488. /**
  40489. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  40490. */
  40491. textureAdderFinalPostProcess: Nullable<PostProcess>;
  40492. /**
  40493. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  40494. */
  40495. lensFlareFinalPostProcess: Nullable<PostProcess>;
  40496. /**
  40497. * Post-process used to merge the final HDR post-process and the real scene color
  40498. */
  40499. hdrFinalPostProcess: Nullable<PostProcess>;
  40500. /**
  40501. * Post-process used to create a lens flare effect
  40502. */
  40503. lensFlarePostProcess: Nullable<PostProcess>;
  40504. /**
  40505. * Post-process that merges the result of the lens flare post-process and the real scene color
  40506. */
  40507. lensFlareComposePostProcess: Nullable<PostProcess>;
  40508. /**
  40509. * Post-process used to create a motion blur effect
  40510. */
  40511. motionBlurPostProcess: Nullable<PostProcess>;
  40512. /**
  40513. * Post-process used to create a depth of field effect
  40514. */
  40515. depthOfFieldPostProcess: Nullable<PostProcess>;
  40516. /**
  40517. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  40518. */
  40519. fxaaPostProcess: Nullable<FxaaPostProcess>;
  40520. /**
  40521. * Represents the brightness threshold in order to configure the illuminated surfaces
  40522. */
  40523. brightThreshold: number;
  40524. /**
  40525. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  40526. */
  40527. blurWidth: number;
  40528. /**
  40529. * Sets if the blur for highlighted surfaces must be only horizontal
  40530. */
  40531. horizontalBlur: boolean;
  40532. /**
  40533. * Sets the overall exposure used by the pipeline
  40534. */
  40535. exposure: number;
  40536. /**
  40537. * Texture used typically to simulate "dirty" on camera lens
  40538. */
  40539. lensTexture: Nullable<Texture>;
  40540. /**
  40541. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  40542. */
  40543. volumetricLightCoefficient: number;
  40544. /**
  40545. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  40546. */
  40547. volumetricLightPower: number;
  40548. /**
  40549. * Used the set the blur intensity to smooth the volumetric lights
  40550. */
  40551. volumetricLightBlurScale: number;
  40552. /**
  40553. * Light (spot or directional) used to generate the volumetric lights rays
  40554. * The source light must have a shadow generate so the pipeline can get its
  40555. * depth map
  40556. */
  40557. sourceLight: Nullable<SpotLight | DirectionalLight>;
  40558. /**
  40559. * For eye adaptation, represents the minimum luminance the eye can see
  40560. */
  40561. hdrMinimumLuminance: number;
  40562. /**
  40563. * For eye adaptation, represents the decrease luminance speed
  40564. */
  40565. hdrDecreaseRate: number;
  40566. /**
  40567. * For eye adaptation, represents the increase luminance speed
  40568. */
  40569. hdrIncreaseRate: number;
  40570. /**
  40571. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  40572. */
  40573. lensColorTexture: Nullable<Texture>;
  40574. /**
  40575. * The overall strengh for the lens flare effect
  40576. */
  40577. lensFlareStrength: number;
  40578. /**
  40579. * Dispersion coefficient for lens flare ghosts
  40580. */
  40581. lensFlareGhostDispersal: number;
  40582. /**
  40583. * Main lens flare halo width
  40584. */
  40585. lensFlareHaloWidth: number;
  40586. /**
  40587. * Based on the lens distortion effect, defines how much the lens flare result
  40588. * is distorted
  40589. */
  40590. lensFlareDistortionStrength: number;
  40591. /**
  40592. * Lens star texture must be used to simulate rays on the flares and is available
  40593. * in the documentation
  40594. */
  40595. lensStarTexture: Nullable<Texture>;
  40596. /**
  40597. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  40598. * flare effect by taking account of the dirt texture
  40599. */
  40600. lensFlareDirtTexture: Nullable<Texture>;
  40601. /**
  40602. * Represents the focal length for the depth of field effect
  40603. */
  40604. depthOfFieldDistance: number;
  40605. /**
  40606. * Represents the blur intensity for the blurred part of the depth of field effect
  40607. */
  40608. depthOfFieldBlurWidth: number;
  40609. /**
  40610. * For motion blur, defines how much the image is blurred by the movement
  40611. */
  40612. motionStrength: number;
  40613. /**
  40614. * List of animations for the pipeline (IAnimatable implementation)
  40615. */
  40616. animations: Animation[];
  40617. /**
  40618. * Private members
  40619. */
  40620. private _scene;
  40621. private _currentDepthOfFieldSource;
  40622. private _basePostProcess;
  40623. private _hdrCurrentLuminance;
  40624. private _floatTextureType;
  40625. private _ratio;
  40626. private _bloomEnabled;
  40627. private _depthOfFieldEnabled;
  40628. private _vlsEnabled;
  40629. private _lensFlareEnabled;
  40630. private _hdrEnabled;
  40631. private _motionBlurEnabled;
  40632. private _fxaaEnabled;
  40633. private _motionBlurSamples;
  40634. private _volumetricLightStepsCount;
  40635. private _samples;
  40636. /**
  40637. * Specifies if the bloom pipeline is enabled
  40638. */
  40639. BloomEnabled: boolean;
  40640. /**
  40641. * Specifies if the depth of field pipeline is enabed
  40642. */
  40643. DepthOfFieldEnabled: boolean;
  40644. /**
  40645. * Specifies if the lens flare pipeline is enabed
  40646. */
  40647. LensFlareEnabled: boolean;
  40648. /**
  40649. * Specifies if the HDR pipeline is enabled
  40650. */
  40651. HDREnabled: boolean;
  40652. /**
  40653. * Specifies if the volumetric lights scattering effect is enabled
  40654. */
  40655. VLSEnabled: boolean;
  40656. /**
  40657. * Specifies if the motion blur effect is enabled
  40658. */
  40659. MotionBlurEnabled: boolean;
  40660. /**
  40661. * Specifies if anti-aliasing is enabled
  40662. */
  40663. fxaaEnabled: boolean;
  40664. /**
  40665. * Specifies the number of steps used to calculate the volumetric lights
  40666. * Typically in interval [50, 200]
  40667. */
  40668. volumetricLightStepsCount: number;
  40669. /**
  40670. * Specifies the number of samples used for the motion blur effect
  40671. * Typically in interval [16, 64]
  40672. */
  40673. motionBlurSamples: number;
  40674. /**
  40675. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  40676. */
  40677. samples: number;
  40678. /**
  40679. * @constructor
  40680. * @param {string} name - The rendering pipeline name
  40681. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40682. * @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)
  40683. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  40684. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40685. */
  40686. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  40687. private _buildPipeline;
  40688. private _createDownSampleX4PostProcess;
  40689. private _createBrightPassPostProcess;
  40690. private _createBlurPostProcesses;
  40691. private _createTextureAdderPostProcess;
  40692. private _createVolumetricLightPostProcess;
  40693. private _createLuminancePostProcesses;
  40694. private _createHdrPostProcess;
  40695. private _createLensFlarePostProcess;
  40696. private _createDepthOfFieldPostProcess;
  40697. private _createMotionBlurPostProcess;
  40698. private _getDepthTexture;
  40699. private _disposePostProcesses;
  40700. /**
  40701. * Dispose of the pipeline and stop all post processes
  40702. */
  40703. dispose(): void;
  40704. /**
  40705. * Serialize the rendering pipeline (Used when exporting)
  40706. * @returns the serialized object
  40707. */
  40708. serialize(): any;
  40709. /**
  40710. * Parse the serialized pipeline
  40711. * @param source Source pipeline.
  40712. * @param scene The scene to load the pipeline to.
  40713. * @param rootUrl The URL of the serialized pipeline.
  40714. * @returns An instantiated pipeline from the serialized object.
  40715. */
  40716. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  40717. static LuminanceSteps: number;
  40718. }
  40719. }