babylon.d.ts 1.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163
  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. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isParentEnabled;
  377. private _isReady;
  378. /** @hidden */
  379. _currentRenderId: number;
  380. private _parentRenderId;
  381. protected _childRenderId: number;
  382. /** @hidden */
  383. _waitingParentId: Nullable<string>;
  384. /** @hidden */
  385. _scene: Scene;
  386. /** @hidden */
  387. _cache: any;
  388. private _parentNode;
  389. private _children;
  390. /** @hidden */
  391. _worldMatrix: Matrix;
  392. /** @hidden */
  393. _worldMatrixDeterminant: number;
  394. /**
  395. * Gets a boolean indicating if the node has been disposed
  396. * @returns true if the node was disposed
  397. */
  398. isDisposed(): boolean;
  399. /**
  400. * Gets or sets the parent of the node
  401. */
  402. parent: Nullable<Node>;
  403. private _animationPropertiesOverride;
  404. /**
  405. * Gets or sets the animation properties override
  406. */
  407. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  408. /**
  409. * Gets a string idenfifying the name of the class
  410. * @returns "Node" string
  411. */
  412. getClassName(): string;
  413. /**
  414. * An event triggered when the mesh is disposed
  415. */
  416. onDisposeObservable: Observable<Node>;
  417. private _onDisposeObserver;
  418. /**
  419. * Sets a callback that will be raised when the node will be disposed
  420. */
  421. onDispose: () => void;
  422. /**
  423. * Creates a new Node
  424. * @param {string} name - the name and id to be given to this node
  425. * @param {BABYLON.Scene} the scene this node will be added to
  426. */
  427. constructor(name: string, scene?: Nullable<Scene>);
  428. /**
  429. * Gets the scene of the node
  430. * @returns a {BABYLON.Scene}
  431. */
  432. getScene(): Scene;
  433. /**
  434. * Gets the engine of the node
  435. * @returns a {BABYLON.Engine}
  436. */
  437. getEngine(): Engine;
  438. private _behaviors;
  439. /**
  440. * Attach a behavior to the node
  441. * @see http://doc.babylonjs.com/features/behaviour
  442. * @param behavior defines the behavior to attach
  443. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  444. * @returns the current Node
  445. */
  446. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  447. /**
  448. * Remove an attached behavior
  449. * @see http://doc.babylonjs.com/features/behaviour
  450. * @param behavior defines the behavior to attach
  451. * @returns the current Node
  452. */
  453. removeBehavior(behavior: Behavior<Node>): Node;
  454. /**
  455. * Gets the list of attached behaviors
  456. * @see http://doc.babylonjs.com/features/behaviour
  457. */
  458. readonly behaviors: Behavior<Node>[];
  459. /**
  460. * Gets an attached behavior by name
  461. * @param name defines the name of the behavior to look for
  462. * @see http://doc.babylonjs.com/features/behaviour
  463. * @returns null if behavior was not found else the requested behavior
  464. */
  465. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  466. /**
  467. * Returns the latest update of the World matrix
  468. * @returns a Matrix
  469. */
  470. getWorldMatrix(): Matrix;
  471. /** @hidden */
  472. _getWorldMatrixDeterminant(): number;
  473. /**
  474. * Returns directly the latest state of the mesh World matrix.
  475. * A Matrix is returned.
  476. */
  477. readonly worldMatrixFromCache: Matrix;
  478. /** @hidden */
  479. _initCache(): void;
  480. /** @hidden */
  481. updateCache(force?: boolean): void;
  482. /** @hidden */
  483. _updateCache(ignoreParentClass?: boolean): void;
  484. /** @hidden */
  485. _isSynchronized(): boolean;
  486. /** @hidden */
  487. _markSyncedWithParent(): void;
  488. /** @hidden */
  489. isSynchronizedWithParent(): boolean;
  490. /** @hidden */
  491. isSynchronized(): boolean;
  492. /**
  493. * Is this node ready to be used/rendered
  494. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  495. * @return true if the node is ready
  496. */
  497. isReady(completeCheck?: boolean): boolean;
  498. /**
  499. * Is this node enabled?
  500. * 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
  501. * @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
  502. * @return whether this node (and its parent) is enabled
  503. */
  504. isEnabled(checkAncestors?: boolean): boolean;
  505. /** @hidden */
  506. protected _syncParentEnabledState(): void;
  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 the scene is ready
  812. */
  813. onReadyObservable: Observable<Scene>;
  814. /**
  815. * An event triggered before rendering a camera
  816. */
  817. onBeforeCameraRenderObservable: Observable<Camera>;
  818. private _onBeforeCameraRenderObserver;
  819. /** Sets a function to be executed before rendering a camera*/
  820. beforeCameraRender: () => void;
  821. /**
  822. * An event triggered after rendering a camera
  823. */
  824. onAfterCameraRenderObservable: Observable<Camera>;
  825. private _onAfterCameraRenderObserver;
  826. /** Sets a function to be executed after rendering a camera*/
  827. afterCameraRender: () => void;
  828. /**
  829. * An event triggered when active meshes evaluation is about to start
  830. */
  831. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  832. /**
  833. * An event triggered when active meshes evaluation is done
  834. */
  835. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  836. /**
  837. * An event triggered when particles rendering is about to start
  838. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  839. */
  840. onBeforeParticlesRenderingObservable: Observable<Scene>;
  841. /**
  842. * An event triggered when particles rendering is done
  843. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  844. */
  845. onAfterParticlesRenderingObservable: Observable<Scene>;
  846. /**
  847. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  848. */
  849. onDataLoadedObservable: Observable<Scene>;
  850. /**
  851. * An event triggered when a camera is created
  852. */
  853. onNewCameraAddedObservable: Observable<Camera>;
  854. /**
  855. * An event triggered when a camera is removed
  856. */
  857. onCameraRemovedObservable: Observable<Camera>;
  858. /**
  859. * An event triggered when a light is created
  860. */
  861. onNewLightAddedObservable: Observable<Light>;
  862. /**
  863. * An event triggered when a light is removed
  864. */
  865. onLightRemovedObservable: Observable<Light>;
  866. /**
  867. * An event triggered when a geometry is created
  868. */
  869. onNewGeometryAddedObservable: Observable<Geometry>;
  870. /**
  871. * An event triggered when a geometry is removed
  872. */
  873. onGeometryRemovedObservable: Observable<Geometry>;
  874. /**
  875. * An event triggered when a transform node is created
  876. */
  877. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  878. /**
  879. * An event triggered when a transform node is removed
  880. */
  881. onTransformNodeRemovedObservable: Observable<TransformNode>;
  882. /**
  883. * An event triggered when a mesh is created
  884. */
  885. onNewMeshAddedObservable: Observable<AbstractMesh>;
  886. /**
  887. * An event triggered when a mesh is removed
  888. */
  889. onMeshRemovedObservable: Observable<AbstractMesh>;
  890. /**
  891. * An event triggered when a material is created
  892. */
  893. onNewMaterialAddedObservable: Observable<Material>;
  894. /**
  895. * An event triggered when a material is removed
  896. */
  897. onMaterialRemovedObservable: Observable<Material>;
  898. /**
  899. * An event triggered when a texture is created
  900. */
  901. onNewTextureAddedObservable: Observable<BaseTexture>;
  902. /**
  903. * An event triggered when a texture is removed
  904. */
  905. onTextureRemovedObservable: Observable<BaseTexture>;
  906. /**
  907. * An event triggered when render targets are about to be rendered
  908. * Can happen multiple times per frame.
  909. */
  910. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  911. /**
  912. * An event triggered when render targets were rendered.
  913. * Can happen multiple times per frame.
  914. */
  915. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  916. /**
  917. * An event triggered before calculating deterministic simulation step
  918. */
  919. onBeforeStepObservable: Observable<Scene>;
  920. /**
  921. * An event triggered after calculating deterministic simulation step
  922. */
  923. onAfterStepObservable: Observable<Scene>;
  924. /**
  925. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  926. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  927. * 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)
  928. */
  929. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  930. /**
  931. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  932. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  933. * 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)
  934. */
  935. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  936. /**
  937. * This Observable will when a mesh has been imported into the scene.
  938. */
  939. onMeshImportedObservable: Observable<AbstractMesh>;
  940. private _registeredForLateAnimationBindings;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  943. */
  944. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  945. /**
  946. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  947. */
  948. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  949. /**
  950. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  951. */
  952. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  953. private _onPointerMove;
  954. private _onPointerDown;
  955. private _onPointerUp;
  956. /** Deprecated. Use onPointerObservable instead */
  957. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  958. /** Deprecated. Use onPointerObservable instead */
  959. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  960. /** Deprecated. Use onPointerObservable instead */
  961. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  962. /** Deprecated. Use onPointerObservable instead */
  963. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  964. /**
  965. * 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).
  966. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  967. */
  968. onPrePointerObservable: Observable<PointerInfoPre>;
  969. /**
  970. * Observable event triggered each time an input event is received from the rendering canvas
  971. */
  972. onPointerObservable: Observable<PointerInfo>;
  973. /**
  974. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  975. */
  976. readonly unTranslatedPointer: Vector2;
  977. /** The distance in pixel that you have to move to prevent some events */
  978. static DragMovementThreshold: number;
  979. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  980. static LongPressDelay: number;
  981. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  982. static DoubleClickDelay: number;
  983. /** If you need to check double click without raising a single click at first click, enable this flag */
  984. static ExclusiveDoubleClickMode: boolean;
  985. private _initClickEvent;
  986. private _initActionManager;
  987. private _delayedSimpleClick;
  988. private _delayedSimpleClickTimeout;
  989. private _previousDelayedSimpleClickTimeout;
  990. private _meshPickProceed;
  991. private _previousButtonPressed;
  992. private _currentPickResult;
  993. private _previousPickResult;
  994. private _totalPointersPressed;
  995. private _doubleClickOccured;
  996. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  997. cameraToUseForPointers: Nullable<Camera>;
  998. private _pointerX;
  999. private _pointerY;
  1000. private _unTranslatedPointerX;
  1001. private _unTranslatedPointerY;
  1002. private _startingPointerPosition;
  1003. private _previousStartingPointerPosition;
  1004. private _startingPointerTime;
  1005. private _previousStartingPointerTime;
  1006. private _pointerCaptures;
  1007. private _timeAccumulator;
  1008. private _currentStepId;
  1009. private _currentInternalStep;
  1010. /** @hidden */
  1011. _mirroredCameraPosition: Nullable<Vector3>;
  1012. /**
  1013. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1014. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1015. */
  1016. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1017. /**
  1018. * Observable event triggered each time an keyboard event is received from the hosting window
  1019. */
  1020. onKeyboardObservable: Observable<KeyboardInfo>;
  1021. private _onKeyDown;
  1022. private _onKeyUp;
  1023. private _onCanvasFocusObserver;
  1024. private _onCanvasBlurObserver;
  1025. private _useRightHandedSystem;
  1026. /**
  1027. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1028. */
  1029. useRightHandedSystem: boolean;
  1030. /**
  1031. * Sets the step Id used by deterministic lock step
  1032. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1033. * @param newStepId defines the step Id
  1034. */
  1035. setStepId(newStepId: number): void;
  1036. /**
  1037. * Gets the step Id used by deterministic lock step
  1038. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1039. * @returns the step Id
  1040. */
  1041. getStepId(): number;
  1042. /**
  1043. * Gets the internal step used by deterministic lock step
  1044. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1045. * @returns the internal step
  1046. */
  1047. getInternalStep(): number;
  1048. private _fogEnabled;
  1049. /**
  1050. * Gets or sets a boolean indicating if fog is enabled on this scene
  1051. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1052. */
  1053. fogEnabled: boolean;
  1054. private _fogMode;
  1055. /**
  1056. * Gets or sets the fog mode to use
  1057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1058. */
  1059. fogMode: number;
  1060. /**
  1061. * Gets or sets the fog color to use
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. */
  1064. fogColor: Color3;
  1065. /**
  1066. * Gets or sets the fog density to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogDensity: number;
  1070. /**
  1071. * Gets or sets the fog start distance to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogStart: number;
  1075. /**
  1076. * Gets or sets the fog end distance to use
  1077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1078. */
  1079. fogEnd: number;
  1080. private _shadowsEnabled;
  1081. /**
  1082. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1083. */
  1084. shadowsEnabled: boolean;
  1085. private _lightsEnabled;
  1086. /**
  1087. * Gets or sets a boolean indicating if lights are enabled on this scene
  1088. */
  1089. lightsEnabled: boolean;
  1090. /** All of the active cameras added to this scene. */
  1091. activeCameras: Camera[];
  1092. /** The current active camera */
  1093. activeCamera: Nullable<Camera>;
  1094. private _defaultMaterial;
  1095. /** The default material used on meshes when no material is affected */
  1096. /** The default material used on meshes when no material is affected */
  1097. defaultMaterial: Material;
  1098. private _texturesEnabled;
  1099. /**
  1100. * Gets or sets a boolean indicating if textures are enabled on this scene
  1101. */
  1102. texturesEnabled: boolean;
  1103. /**
  1104. * Gets or sets a boolean indicating if particles are enabled on this scene
  1105. */
  1106. particlesEnabled: boolean;
  1107. /**
  1108. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1109. */
  1110. spritesEnabled: boolean;
  1111. private _skeletonsEnabled;
  1112. /**
  1113. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1114. */
  1115. skeletonsEnabled: boolean;
  1116. /**
  1117. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1118. */
  1119. lensFlaresEnabled: boolean;
  1120. /**
  1121. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1123. */
  1124. collisionsEnabled: boolean;
  1125. private _workerCollisions;
  1126. /** @hidden */
  1127. collisionCoordinator: ICollisionCoordinator;
  1128. /**
  1129. * Defines the gravity applied to this scene (used only for collisions)
  1130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1131. */
  1132. gravity: Vector3;
  1133. /**
  1134. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1135. */
  1136. postProcessesEnabled: boolean;
  1137. /**
  1138. * The list of postprocesses added to the scene
  1139. */
  1140. postProcesses: PostProcess[];
  1141. /**
  1142. * Gets the current postprocess manager
  1143. */
  1144. postProcessManager: PostProcessManager;
  1145. /**
  1146. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1147. */
  1148. renderTargetsEnabled: boolean;
  1149. /**
  1150. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1151. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1152. */
  1153. dumpNextRenderTargets: boolean;
  1154. /**
  1155. * The list of user defined render targets added to the scene
  1156. */
  1157. customRenderTargets: RenderTargetTexture[];
  1158. /**
  1159. * Defines if texture loading must be delayed
  1160. * If true, textures will only be loaded when they need to be rendered
  1161. */
  1162. useDelayedTextureLoading: boolean;
  1163. /**
  1164. * Gets the list of meshes imported to the scene through SceneLoader
  1165. */
  1166. importedMeshesFiles: String[];
  1167. /**
  1168. * Gets or sets a boolean indicating if probes are enabled on this scene
  1169. */
  1170. probesEnabled: boolean;
  1171. /**
  1172. * @hidden
  1173. */
  1174. database: Database;
  1175. /**
  1176. * Gets or sets the action manager associated with the scene
  1177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1178. */
  1179. actionManager: ActionManager;
  1180. private _meshesForIntersections;
  1181. /**
  1182. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1183. */
  1184. proceduralTexturesEnabled: boolean;
  1185. private _engine;
  1186. private _totalVertices;
  1187. /** @hidden */
  1188. _activeIndices: PerfCounter;
  1189. /** @hidden */
  1190. _activeParticles: PerfCounter;
  1191. /** @hidden */
  1192. _activeBones: PerfCounter;
  1193. private _animationRatio;
  1194. private _animationTimeLast;
  1195. private _animationTime;
  1196. /**
  1197. * Gets or sets a general scale for animation speed
  1198. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1199. */
  1200. animationTimeScale: number;
  1201. /** @hidden */
  1202. _cachedMaterial: Nullable<Material>;
  1203. /** @hidden */
  1204. _cachedEffect: Nullable<Effect>;
  1205. /** @hidden */
  1206. _cachedVisibility: Nullable<number>;
  1207. private _renderId;
  1208. private _frameId;
  1209. private _executeWhenReadyTimeoutId;
  1210. private _intermediateRendering;
  1211. private _viewUpdateFlag;
  1212. private _projectionUpdateFlag;
  1213. private _alternateViewUpdateFlag;
  1214. private _alternateProjectionUpdateFlag;
  1215. /** @hidden */
  1216. _toBeDisposed: Nullable<IDisposable>[];
  1217. private _activeRequests;
  1218. private _pendingData;
  1219. private _isDisposed;
  1220. /**
  1221. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1222. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1223. */
  1224. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1225. private _activeMeshes;
  1226. private _processedMaterials;
  1227. private _renderTargets;
  1228. /** @hidden */
  1229. _activeParticleSystems: SmartArray<IParticleSystem>;
  1230. private _activeSkeletons;
  1231. private _softwareSkinnedMeshes;
  1232. private _renderingManager;
  1233. /** @hidden */
  1234. _activeAnimatables: Animatable[];
  1235. private _transformMatrix;
  1236. private _sceneUbo;
  1237. private _alternateSceneUbo;
  1238. private _pickWithRayInverseMatrix;
  1239. private _viewMatrix;
  1240. private _projectionMatrix;
  1241. private _alternateViewMatrix;
  1242. private _alternateProjectionMatrix;
  1243. private _alternateTransformMatrix;
  1244. private _useAlternateCameraConfiguration;
  1245. private _alternateRendering;
  1246. /** @hidden */
  1247. _forcedViewPosition: Nullable<Vector3>;
  1248. /** @hidden */
  1249. readonly _isAlternateRenderingEnabled: boolean;
  1250. private _frustumPlanes;
  1251. /**
  1252. * Gets the list of frustum planes (built from the active camera)
  1253. */
  1254. readonly frustumPlanes: Plane[];
  1255. /**
  1256. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1257. * This is useful if there are more lights that the maximum simulteanous authorized
  1258. */
  1259. requireLightSorting: boolean;
  1260. private _pointerOverMesh;
  1261. private _pickedDownMesh;
  1262. private _pickedUpMesh;
  1263. private _externalData;
  1264. private _uid;
  1265. /**
  1266. * @hidden
  1267. * Backing store of defined scene components.
  1268. */
  1269. _components: ISceneComponent[];
  1270. /**
  1271. * @hidden
  1272. * Backing store of defined scene components.
  1273. */
  1274. _serializableComponents: ISceneSerializableComponent[];
  1275. /**
  1276. * List of components to register on the next registration step.
  1277. */
  1278. private _transientComponents;
  1279. /**
  1280. * Registers the transient components if needed.
  1281. */
  1282. private _registerTransientComponents;
  1283. /**
  1284. * @hidden
  1285. * Add a component to the scene.
  1286. * Note that the ccomponent could be registered on th next frame if this is called after
  1287. * the register component stage.
  1288. * @param component Defines the component to add to the scene
  1289. */
  1290. _addComponent(component: ISceneComponent): void;
  1291. /**
  1292. * @hidden
  1293. * Gets a component from the scene.
  1294. * @param name defines the name of the component to retrieve
  1295. * @returns the component or null if not present
  1296. */
  1297. _getComponent(name: string): Nullable<ISceneComponent>;
  1298. /**
  1299. * @hidden
  1300. * Defines the actions happening before camera updates.
  1301. */
  1302. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1303. /**
  1304. * @hidden
  1305. * Defines the actions happening before clear the canvas.
  1306. */
  1307. _beforeClearStage: Stage<SimpleStageAction>;
  1308. /**
  1309. * @hidden
  1310. * Defines the actions when collecting render targets for the frame.
  1311. */
  1312. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1313. /**
  1314. * @hidden
  1315. * Defines the actions happening for one camera in the frame.
  1316. */
  1317. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening during the per mesh ready checks.
  1321. */
  1322. _isReadyForMeshStage: Stage<MeshStageAction>;
  1323. /**
  1324. * @hidden
  1325. * Defines the actions happening before evaluate active mesh checks.
  1326. */
  1327. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening during the evaluate sub mesh checks.
  1331. */
  1332. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1333. /**
  1334. * @hidden
  1335. * Defines the actions happening during the active mesh stage.
  1336. */
  1337. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening during the per camera render target step.
  1341. */
  1342. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening just before the active camera is drawing.
  1346. */
  1347. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions happening just before a rendering group is drawing.
  1351. */
  1352. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening just before a mesh is drawing.
  1356. */
  1357. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening just after a mesh has been drawn.
  1361. */
  1362. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening just after a rendering group has been drawn.
  1366. */
  1367. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening just after the active camera has been drawn.
  1371. */
  1372. _afterCameraDrawStage: Stage<CameraStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening just after rendering all cameras and computing intersections.
  1376. */
  1377. _afterRenderStage: Stage<SimpleStageAction>;
  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 skeleton using a given id (if many are found, this function will pick the last one)
  2115. * @param id defines the id to search for
  2116. * @return the found skeleton or null if not found at all.
  2117. */
  2118. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2119. /**
  2120. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2121. * @param id defines the id to search for
  2122. * @return the found skeleton or null if not found at all.
  2123. */
  2124. getSkeletonById(id: string): Nullable<Skeleton>;
  2125. /**
  2126. * Gets a skeleton using a given name
  2127. * @param name defines the name to search for
  2128. * @return the found skeleton or null if not found at all.
  2129. */
  2130. getSkeletonByName(name: string): Nullable<Skeleton>;
  2131. /**
  2132. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2133. * @param id defines the id to search for
  2134. * @return the found morph target manager or null if not found at all.
  2135. */
  2136. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2137. /**
  2138. * Gets a boolean indicating if the given mesh is active
  2139. * @param mesh defines the mesh to look for
  2140. * @returns true if the mesh is in the active list
  2141. */
  2142. isActiveMesh(mesh: AbstractMesh): boolean;
  2143. /**
  2144. * Return a unique id as a string which can serve as an identifier for the scene
  2145. */
  2146. readonly uid: string;
  2147. /**
  2148. * Add an externaly attached data from its key.
  2149. * This method call will fail and return false, if such key already exists.
  2150. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2151. * @param key the unique key that identifies the data
  2152. * @param data the data object to associate to the key for this Engine instance
  2153. * @return true if no such key were already present and the data was added successfully, false otherwise
  2154. */
  2155. addExternalData<T>(key: string, data: T): boolean;
  2156. /**
  2157. * Get an externaly attached data from its key
  2158. * @param key the unique key that identifies the data
  2159. * @return the associated data, if present (can be null), or undefined if not present
  2160. */
  2161. getExternalData<T>(key: string): Nullable<T>;
  2162. /**
  2163. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2164. * @param key the unique key that identifies the data
  2165. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2166. * @return the associated data, can be null if the factory returned null.
  2167. */
  2168. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2169. /**
  2170. * Remove an externaly attached data from the Engine instance
  2171. * @param key the unique key that identifies the data
  2172. * @return true if the data was successfully removed, false if it doesn't exist
  2173. */
  2174. removeExternalData(key: string): boolean;
  2175. private _evaluateSubMesh;
  2176. /**
  2177. * Clear the processed materials smart array preventing retention point in material dispose.
  2178. */
  2179. freeProcessedMaterials(): void;
  2180. /**
  2181. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2182. */
  2183. freeActiveMeshes(): void;
  2184. /**
  2185. * Clear the info related to rendering groups preventing retention points during dispose.
  2186. */
  2187. freeRenderingGroups(): void;
  2188. /** @hidden */
  2189. _isInIntermediateRendering(): boolean;
  2190. /**
  2191. * Lambda returning the list of potentially active meshes.
  2192. */
  2193. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2194. /**
  2195. * Lambda returning the list of potentially active sub meshes.
  2196. */
  2197. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2198. /**
  2199. * Lambda returning the list of potentially intersecting sub meshes.
  2200. */
  2201. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2202. /**
  2203. * Lambda returning the list of potentially colliding sub meshes.
  2204. */
  2205. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2206. private _activeMeshesFrozen;
  2207. /**
  2208. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2209. * @returns the current scene
  2210. */
  2211. freezeActiveMeshes(): Scene;
  2212. /**
  2213. * Use this function to restart evaluating active meshes on every frame
  2214. * @returns the current scene
  2215. */
  2216. unfreezeActiveMeshes(): Scene;
  2217. private _evaluateActiveMeshes;
  2218. private _activeMesh;
  2219. /**
  2220. * Update the transform matrix to update from the current active camera
  2221. * @param force defines a boolean used to force the update even if cache is up to date
  2222. */
  2223. updateTransformMatrix(force?: boolean): void;
  2224. /**
  2225. * 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)
  2226. * @param alternateCamera defines the camera to use
  2227. */
  2228. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2229. /** @hidden */
  2230. _allowPostProcessClearColor: boolean;
  2231. private _renderForCamera;
  2232. private _processSubCameras;
  2233. private _checkIntersections;
  2234. /** @hidden */
  2235. _advancePhysicsEngineStep(step: number): void;
  2236. /**
  2237. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2238. */
  2239. getDeterministicFrameTime: () => number;
  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. /**
  2246. * Freeze all materials
  2247. * A frozen material will not be updatable but should be faster to render
  2248. */
  2249. freezeMaterials(): void;
  2250. /**
  2251. * Unfreeze all materials
  2252. * A frozen material will not be updatable but should be faster to render
  2253. */
  2254. unfreezeMaterials(): void;
  2255. /**
  2256. * Releases all held ressources
  2257. */
  2258. dispose(): void;
  2259. /**
  2260. * Gets if the scene is already disposed
  2261. */
  2262. readonly isDisposed: boolean;
  2263. /**
  2264. * Call this function to reduce memory footprint of the scene.
  2265. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2266. */
  2267. clearCachedVertexData(): void;
  2268. /**
  2269. * This function will remove the local cached buffer data from texture.
  2270. * It will save memory but will prevent the texture from being rebuilt
  2271. */
  2272. cleanCachedTextureBuffer(): void;
  2273. /**
  2274. * Get the world extend vectors with an optional filter
  2275. *
  2276. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2277. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2278. */
  2279. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2280. min: Vector3;
  2281. max: Vector3;
  2282. };
  2283. /**
  2284. * Creates a ray that can be used to pick in the scene
  2285. * @param x defines the x coordinate of the origin (on-screen)
  2286. * @param y defines the y coordinate of the origin (on-screen)
  2287. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2288. * @param camera defines the camera to use for the picking
  2289. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2290. * @returns a Ray
  2291. */
  2292. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2293. /**
  2294. * Creates a ray that can be used to pick in the scene
  2295. * @param x defines the x coordinate of the origin (on-screen)
  2296. * @param y defines the y coordinate of the origin (on-screen)
  2297. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2298. * @param result defines the ray where to store the picking ray
  2299. * @param camera defines the camera to use for the picking
  2300. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2301. * @returns the current scene
  2302. */
  2303. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2304. /**
  2305. * Creates a ray that can be used to pick in the scene
  2306. * @param x defines the x coordinate of the origin (on-screen)
  2307. * @param y defines the y coordinate of the origin (on-screen)
  2308. * @param camera defines the camera to use for the picking
  2309. * @returns a Ray
  2310. */
  2311. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): 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 result defines the ray where to store the picking ray
  2317. * @param camera defines the camera to use for the picking
  2318. * @returns the current scene
  2319. */
  2320. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2321. private _internalPick;
  2322. private _internalMultiPick;
  2323. private _tempPickingRay;
  2324. /** Launch a ray to try to pick a mesh in the scene
  2325. * @param x position on screen
  2326. * @param y position on screen
  2327. * @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
  2328. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2329. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2330. * @returns a PickingInfo
  2331. */
  2332. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2333. private _cachedRayForTransform;
  2334. /** Use the given ray to pick a mesh in the scene
  2335. * @param ray The ray to use to pick meshes
  2336. * @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
  2337. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2338. * @returns a PickingInfo
  2339. */
  2340. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2341. /**
  2342. * Launch a ray to try to pick a mesh in the scene
  2343. * @param x X position on screen
  2344. * @param y Y position on screen
  2345. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2346. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2347. * @returns an array of PickingInfo
  2348. */
  2349. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2350. /**
  2351. * Launch a ray to try to pick a mesh in the scene
  2352. * @param ray Ray to use
  2353. * @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
  2354. * @returns an array of PickingInfo
  2355. */
  2356. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2357. /**
  2358. * Force the value of meshUnderPointer
  2359. * @param mesh defines the mesh to use
  2360. */
  2361. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2362. /**
  2363. * Gets the mesh under the pointer
  2364. * @returns a Mesh or null if no mesh is under the pointer
  2365. */
  2366. getPointerOverMesh(): Nullable<AbstractMesh>;
  2367. /** @hidden */
  2368. _rebuildGeometries(): void;
  2369. /** @hidden */
  2370. _rebuildTextures(): void;
  2371. private _getByTags;
  2372. /**
  2373. * Get a list of meshes by tags
  2374. * @param tagsQuery defines the tags query to use
  2375. * @param forEach defines a predicate used to filter results
  2376. * @returns an array of Mesh
  2377. */
  2378. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2379. /**
  2380. * Get a list of cameras by tags
  2381. * @param tagsQuery defines the tags query to use
  2382. * @param forEach defines a predicate used to filter results
  2383. * @returns an array of Camera
  2384. */
  2385. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2386. /**
  2387. * Get a list of lights by tags
  2388. * @param tagsQuery defines the tags query to use
  2389. * @param forEach defines a predicate used to filter results
  2390. * @returns an array of Light
  2391. */
  2392. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2393. /**
  2394. * Get a list of materials by tags
  2395. * @param tagsQuery defines the tags query to use
  2396. * @param forEach defines a predicate used to filter results
  2397. * @returns an array of Material
  2398. */
  2399. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2400. /**
  2401. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2402. * This allowed control for front to back rendering or reversly depending of the special needs.
  2403. *
  2404. * @param renderingGroupId The rendering group id corresponding to its index
  2405. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2406. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2407. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2408. */
  2409. 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;
  2410. /**
  2411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2412. *
  2413. * @param renderingGroupId The rendering group id corresponding to its index
  2414. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2415. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2416. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2417. */
  2418. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2419. /**
  2420. * Gets the current auto clear configuration for one rendering group of the rendering
  2421. * manager.
  2422. * @param index the rendering group index to get the information for
  2423. * @returns The auto clear setup for the requested rendering group
  2424. */
  2425. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2426. private _blockMaterialDirtyMechanism;
  2427. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2428. blockMaterialDirtyMechanism: boolean;
  2429. /**
  2430. * Will flag all materials as dirty to trigger new shader compilation
  2431. * @param flag defines the flag used to specify which material part must be marked as dirty
  2432. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2433. */
  2434. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2435. /** @hidden */
  2436. _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;
  2437. /** @hidden */
  2438. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2439. }
  2440. }
  2441. declare module BABYLON {
  2442. /**
  2443. * Groups all the scene component constants in one place to ease maintenance.
  2444. * @hidden
  2445. */
  2446. class SceneComponentConstants {
  2447. static readonly NAME_EFFECTLAYER: string;
  2448. static readonly NAME_LAYER: string;
  2449. static readonly NAME_LENSFLARESYSTEM: string;
  2450. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2451. static readonly NAME_PARTICLESYSTEM: string;
  2452. static readonly NAME_GAMEPAD: string;
  2453. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2454. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2455. static readonly NAME_DEPTHRENDERER: string;
  2456. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2457. static readonly NAME_SPRITE: string;
  2458. static readonly NAME_OUTLINERENDERER: string;
  2459. static readonly NAME_PROCEDURALTEXTURE: string;
  2460. static readonly NAME_SHADOWGENERATOR: string;
  2461. static readonly NAME_OCTREE: string;
  2462. static readonly NAME_PHYSICSENGINE: string;
  2463. static readonly NAME_AUDIO: string;
  2464. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2465. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2466. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2467. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2468. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2469. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2470. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2471. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2472. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2473. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2474. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2475. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2476. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2477. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2478. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2479. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2480. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2481. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2482. static readonly STEP_AFTERRENDER_AUDIO: number;
  2483. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2484. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2485. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2486. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2487. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2488. static readonly STEP_POINTERMOVE_SPRITE: number;
  2489. static readonly STEP_POINTERDOWN_SPRITE: number;
  2490. static readonly STEP_POINTERUP_SPRITE: number;
  2491. }
  2492. /**
  2493. * This represents a scene component.
  2494. *
  2495. * This is used to decouple the dependency the scene is having on the different workloads like
  2496. * layers, post processes...
  2497. */
  2498. interface ISceneComponent {
  2499. /**
  2500. * The name of the component. Each component must have a unique name.
  2501. */
  2502. name: string;
  2503. /**
  2504. * The scene the component belongs to.
  2505. */
  2506. scene: Scene;
  2507. /**
  2508. * Register the component to one instance of a scene.
  2509. */
  2510. register(): void;
  2511. /**
  2512. * Rebuilds the elements related to this component in case of
  2513. * context lost for instance.
  2514. */
  2515. rebuild(): void;
  2516. /**
  2517. * Disposes the component and the associated ressources.
  2518. */
  2519. dispose(): void;
  2520. }
  2521. /**
  2522. * This represents a SERIALIZABLE scene component.
  2523. *
  2524. * This extends Scene Component to add Serialization methods on top.
  2525. */
  2526. interface ISceneSerializableComponent extends ISceneComponent {
  2527. /**
  2528. * Adds all the element from the container to the scene
  2529. * @param container the container holding the elements
  2530. */
  2531. addFromContainer(container: AbstractScene): void;
  2532. /**
  2533. * Removes all the elements in the container from the scene
  2534. * @param container contains the elements to remove
  2535. */
  2536. removeFromContainer(container: AbstractScene): void;
  2537. /**
  2538. * Serializes the component data to the specified json object
  2539. * @param serializationObject The object to serialize to
  2540. */
  2541. serialize(serializationObject: any): void;
  2542. }
  2543. /**
  2544. * Strong typing of a Mesh related stage step action
  2545. */
  2546. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2547. /**
  2548. * Strong typing of a Evaluate Sub Mesh related stage step action
  2549. */
  2550. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2551. /**
  2552. * Strong typing of a Active Mesh related stage step action
  2553. */
  2554. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2555. /**
  2556. * Strong typing of a Camera related stage step action
  2557. */
  2558. type CameraStageAction = (camera: Camera) => void;
  2559. /**
  2560. * Strong typing of a RenderingGroup related stage step action
  2561. */
  2562. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2563. /**
  2564. * Strong typing of a Mesh Render related stage step action
  2565. */
  2566. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2567. /**
  2568. * Strong typing of a simple stage step action
  2569. */
  2570. type SimpleStageAction = () => void;
  2571. /**
  2572. * Strong typing of a render target action.
  2573. */
  2574. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2575. /**
  2576. * Strong typing of a pointer move action.
  2577. */
  2578. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2579. /**
  2580. * Strong typing of a pointer up/down action.
  2581. */
  2582. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2583. /**
  2584. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2585. * @hidden
  2586. */
  2587. class Stage<T extends Function> extends Array<{
  2588. index: number;
  2589. component: ISceneComponent;
  2590. action: T;
  2591. }> {
  2592. /**
  2593. * Hide ctor from the rest of the world.
  2594. * @param items The items to add.
  2595. */
  2596. private constructor();
  2597. /**
  2598. * Creates a new Stage.
  2599. * @returns A new instance of a Stage
  2600. */
  2601. static Create<T extends Function>(): Stage<T>;
  2602. /**
  2603. * Registers a step in an ordered way in the targeted stage.
  2604. * @param index Defines the position to register the step in
  2605. * @param component Defines the component attached to the step
  2606. * @param action Defines the action to launch during the step
  2607. */
  2608. registerStep(index: number, component: ISceneComponent, action: T): void;
  2609. /**
  2610. * Clears all the steps from the stage.
  2611. */
  2612. clear(): void;
  2613. }
  2614. }
  2615. declare module BABYLON {
  2616. /** Alias type for value that can be null */
  2617. type Nullable<T> = T | null;
  2618. /**
  2619. * Alias type for number that are floats
  2620. * @ignorenaming
  2621. */
  2622. type float = number;
  2623. /**
  2624. * Alias type for number that are doubles.
  2625. * @ignorenaming
  2626. */
  2627. type double = number;
  2628. /**
  2629. * Alias type for number that are integer
  2630. * @ignorenaming
  2631. */
  2632. type int = number;
  2633. /** Alias type for number array or Float32Array */
  2634. type FloatArray = number[] | Float32Array;
  2635. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2636. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2637. /**
  2638. * Alias for types that can be used by a Buffer or VertexBuffer.
  2639. */
  2640. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2641. }
  2642. declare module BABYLON {
  2643. /**
  2644. * The action to be carried out following a trigger
  2645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2646. */
  2647. class Action {
  2648. /** the trigger, with or without parameters, for the action */
  2649. triggerOptions: any;
  2650. /**
  2651. * Trigger for the action
  2652. */
  2653. trigger: number;
  2654. /**
  2655. * Internal only - manager for action
  2656. * @hidden
  2657. */
  2658. _actionManager: ActionManager;
  2659. private _nextActiveAction;
  2660. private _child;
  2661. private _condition?;
  2662. private _triggerParameter;
  2663. /**
  2664. * An event triggered prior to action being executed.
  2665. */
  2666. onBeforeExecuteObservable: Observable<Action>;
  2667. /**
  2668. * Creates a new Action
  2669. * @param triggerOptions the trigger, with or without parameters, for the action
  2670. * @param condition an optional determinant of action
  2671. */
  2672. constructor(
  2673. /** the trigger, with or without parameters, for the action */
  2674. triggerOptions: any, condition?: Condition);
  2675. /**
  2676. * Internal only
  2677. * @hidden
  2678. */
  2679. _prepare(): void;
  2680. /**
  2681. * Gets the trigger parameters
  2682. * @returns the trigger parameters
  2683. */
  2684. getTriggerParameter(): any;
  2685. /**
  2686. * Internal only - executes current action event
  2687. * @hidden
  2688. */
  2689. _executeCurrent(evt?: ActionEvent): void;
  2690. /**
  2691. * Execute placeholder for child classes
  2692. * @param evt optional action event
  2693. */
  2694. execute(evt?: ActionEvent): void;
  2695. /**
  2696. * Skips to next active action
  2697. */
  2698. skipToNextActiveAction(): void;
  2699. /**
  2700. * Adds action to chain of actions, may be a DoNothingAction
  2701. * @param action defines the next action to execute
  2702. * @returns The action passed in
  2703. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2704. */
  2705. then(action: Action): Action;
  2706. /**
  2707. * Internal only
  2708. * @hidden
  2709. */
  2710. _getProperty(propertyPath: string): string;
  2711. /**
  2712. * Internal only
  2713. * @hidden
  2714. */
  2715. _getEffectiveTarget(target: any, propertyPath: string): any;
  2716. /**
  2717. * Serialize placeholder for child classes
  2718. * @param parent of child
  2719. * @returns the serialized object
  2720. */
  2721. serialize(parent: any): any;
  2722. /**
  2723. * Internal only called by serialize
  2724. * @hidden
  2725. */
  2726. protected _serialize(serializedAction: any, parent?: any): any;
  2727. /**
  2728. * Internal only
  2729. * @hidden
  2730. */
  2731. static _SerializeValueAsString: (value: any) => string;
  2732. /**
  2733. * Internal only
  2734. * @hidden
  2735. */
  2736. static _GetTargetProperty: (target: Scene | Node) => {
  2737. name: string;
  2738. targetType: string;
  2739. value: string;
  2740. };
  2741. }
  2742. }
  2743. declare module BABYLON {
  2744. /**
  2745. * ActionEvent is the event being sent when an action is triggered.
  2746. */
  2747. class ActionEvent {
  2748. /** The mesh or sprite that triggered the action */
  2749. source: any;
  2750. /** The X mouse cursor position at the time of the event */
  2751. pointerX: number;
  2752. /** The Y mouse cursor position at the time of the event */
  2753. pointerY: number;
  2754. /** The mesh that is currently pointed at (can be null) */
  2755. meshUnderPointer: Nullable<AbstractMesh>;
  2756. /** the original (browser) event that triggered the ActionEvent */
  2757. sourceEvent?: any;
  2758. /** additional data for the event */
  2759. additionalData?: any;
  2760. /**
  2761. * Creates a new ActionEvent
  2762. * @param source The mesh or sprite that triggered the action
  2763. * @param pointerX The X mouse cursor position at the time of the event
  2764. * @param pointerY The Y mouse cursor position at the time of the event
  2765. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2766. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2767. * @param additionalData additional data for the event
  2768. */
  2769. constructor(
  2770. /** The mesh or sprite that triggered the action */
  2771. source: any,
  2772. /** The X mouse cursor position at the time of the event */
  2773. pointerX: number,
  2774. /** The Y mouse cursor position at the time of the event */
  2775. pointerY: number,
  2776. /** The mesh that is currently pointed at (can be null) */
  2777. meshUnderPointer: Nullable<AbstractMesh>,
  2778. /** the original (browser) event that triggered the ActionEvent */
  2779. sourceEvent?: any,
  2780. /** additional data for the event */
  2781. additionalData?: any);
  2782. /**
  2783. * Helper function to auto-create an ActionEvent from a source mesh.
  2784. * @param source The source mesh that triggered the event
  2785. * @param evt The original (browser) event
  2786. * @param additionalData additional data for the event
  2787. * @returns the new ActionEvent
  2788. */
  2789. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2790. /**
  2791. * Helper function to auto-create an ActionEvent from a source sprite
  2792. * @param source The source sprite that triggered the event
  2793. * @param scene Scene associated with the sprite
  2794. * @param evt The original (browser) event
  2795. * @param additionalData additional data for the event
  2796. * @returns the new ActionEvent
  2797. */
  2798. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2799. /**
  2800. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2801. * @param scene the scene where the event occurred
  2802. * @param evt The original (browser) event
  2803. * @returns the new ActionEvent
  2804. */
  2805. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2806. /**
  2807. * Helper function to auto-create an ActionEvent from a primitive
  2808. * @param prim defines the target primitive
  2809. * @param pointerPos defines the pointer position
  2810. * @param evt The original (browser) event
  2811. * @param additionalData additional data for the event
  2812. * @returns the new ActionEvent
  2813. */
  2814. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2815. }
  2816. /**
  2817. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2818. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2820. */
  2821. class ActionManager {
  2822. /**
  2823. * Nothing
  2824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2825. */
  2826. static readonly NothingTrigger: number;
  2827. /**
  2828. * On pick
  2829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2830. */
  2831. static readonly OnPickTrigger: number;
  2832. /**
  2833. * On left pick
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2835. */
  2836. static readonly OnLeftPickTrigger: number;
  2837. /**
  2838. * On right pick
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly OnRightPickTrigger: number;
  2842. /**
  2843. * On center pick
  2844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2845. */
  2846. static readonly OnCenterPickTrigger: number;
  2847. /**
  2848. * On pick down
  2849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2850. */
  2851. static readonly OnPickDownTrigger: number;
  2852. /**
  2853. * On double pick
  2854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2855. */
  2856. static readonly OnDoublePickTrigger: number;
  2857. /**
  2858. * On pick up
  2859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2860. */
  2861. static readonly OnPickUpTrigger: number;
  2862. /**
  2863. * On pick out.
  2864. * This trigger will only be raised if you also declared a OnPickDown
  2865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2866. */
  2867. static readonly OnPickOutTrigger: number;
  2868. /**
  2869. * On long press
  2870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2871. */
  2872. static readonly OnLongPressTrigger: number;
  2873. /**
  2874. * On pointer over
  2875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2876. */
  2877. static readonly OnPointerOverTrigger: number;
  2878. /**
  2879. * On pointer out
  2880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2881. */
  2882. static readonly OnPointerOutTrigger: number;
  2883. /**
  2884. * On every frame
  2885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2886. */
  2887. static readonly OnEveryFrameTrigger: number;
  2888. /**
  2889. * On intersection enter
  2890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2891. */
  2892. static readonly OnIntersectionEnterTrigger: number;
  2893. /**
  2894. * On intersection exit
  2895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2896. */
  2897. static readonly OnIntersectionExitTrigger: number;
  2898. /**
  2899. * On key down
  2900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2901. */
  2902. static readonly OnKeyDownTrigger: number;
  2903. /**
  2904. * On key up
  2905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2906. */
  2907. static readonly OnKeyUpTrigger: number;
  2908. /** Gets the list of active triggers */
  2909. static Triggers: {
  2910. [key: string]: number;
  2911. };
  2912. /** Gets the list of actions */
  2913. actions: Action[];
  2914. /** Gets the cursor to use when hovering items */
  2915. hoverCursor: string;
  2916. private _scene;
  2917. /**
  2918. * Creates a new action manager
  2919. * @param scene defines the hosting scene
  2920. */
  2921. constructor(scene: Scene);
  2922. /**
  2923. * Releases all associated resources
  2924. */
  2925. dispose(): void;
  2926. /**
  2927. * Gets hosting scene
  2928. * @returns the hosting scene
  2929. */
  2930. getScene(): Scene;
  2931. /**
  2932. * Does this action manager handles actions of any of the given triggers
  2933. * @param triggers defines the triggers to be tested
  2934. * @return a boolean indicating whether one (or more) of the triggers is handled
  2935. */
  2936. hasSpecificTriggers(triggers: number[]): boolean;
  2937. /**
  2938. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2939. * speed.
  2940. * @param triggerA defines the trigger to be tested
  2941. * @param triggerB defines the trigger to be tested
  2942. * @return a boolean indicating whether one (or more) of the triggers is handled
  2943. */
  2944. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2945. /**
  2946. * Does this action manager handles actions of a given trigger
  2947. * @param trigger defines the trigger to be tested
  2948. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2949. * @return whether the trigger is handled
  2950. */
  2951. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2952. /**
  2953. * Does this action manager has pointer triggers
  2954. */
  2955. readonly hasPointerTriggers: boolean;
  2956. /**
  2957. * Does this action manager has pick triggers
  2958. */
  2959. readonly hasPickTriggers: boolean;
  2960. /**
  2961. * Does exist one action manager with at least one trigger
  2962. **/
  2963. static readonly HasTriggers: boolean;
  2964. /**
  2965. * Does exist one action manager with at least one pick trigger
  2966. **/
  2967. static readonly HasPickTriggers: boolean;
  2968. /**
  2969. * Does exist one action manager that handles actions of a given trigger
  2970. * @param trigger defines the trigger to be tested
  2971. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2972. **/
  2973. static HasSpecificTrigger(trigger: number): boolean;
  2974. /**
  2975. * Registers an action to this action manager
  2976. * @param action defines the action to be registered
  2977. * @return the action amended (prepared) after registration
  2978. */
  2979. registerAction(action: Action): Nullable<Action>;
  2980. /**
  2981. * Unregisters an action to this action manager
  2982. * @param action defines the action to be unregistered
  2983. * @return a boolean indicating whether the action has been unregistered
  2984. */
  2985. unregisterAction(action: Action): Boolean;
  2986. /**
  2987. * Process a specific trigger
  2988. * @param trigger defines the trigger to process
  2989. * @param evt defines the event details to be processed
  2990. */
  2991. processTrigger(trigger: number, evt?: ActionEvent): void;
  2992. /** @hidden */
  2993. _getEffectiveTarget(target: any, propertyPath: string): any;
  2994. /** @hidden */
  2995. _getProperty(propertyPath: string): string;
  2996. /**
  2997. * Serialize this manager to a JSON object
  2998. * @param name defines the property name to store this manager
  2999. * @returns a JSON representation of this manager
  3000. */
  3001. serialize(name: string): any;
  3002. /**
  3003. * Creates a new ActionManager from a JSON data
  3004. * @param parsedActions defines the JSON data to read from
  3005. * @param object defines the hosting mesh
  3006. * @param scene defines the hosting scene
  3007. */
  3008. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3009. /**
  3010. * Get a trigger name by index
  3011. * @param trigger defines the trigger index
  3012. * @returns a trigger name
  3013. */
  3014. static GetTriggerName(trigger: number): string;
  3015. }
  3016. }
  3017. declare module BABYLON {
  3018. /**
  3019. * A Condition applied to an Action
  3020. */
  3021. class Condition {
  3022. /**
  3023. * Internal only - manager for action
  3024. * @hidden
  3025. */
  3026. _actionManager: ActionManager;
  3027. /**
  3028. * Internal only
  3029. * @hidden
  3030. */
  3031. _evaluationId: number;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _currentResult: boolean;
  3037. /**
  3038. * Creates a new Condition
  3039. * @param actionManager the manager of the action the condition is applied to
  3040. */
  3041. constructor(actionManager: ActionManager);
  3042. /**
  3043. * Check if the current condition is valid
  3044. * @returns a boolean
  3045. */
  3046. isValid(): boolean;
  3047. /**
  3048. * Internal only
  3049. * @hidden
  3050. */
  3051. _getProperty(propertyPath: string): string;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getEffectiveTarget(target: any, propertyPath: string): any;
  3057. /**
  3058. * Serialize placeholder for child classes
  3059. * @returns the serialized object
  3060. */
  3061. serialize(): any;
  3062. /**
  3063. * Internal only
  3064. * @hidden
  3065. */
  3066. protected _serialize(serializedCondition: any): any;
  3067. }
  3068. /**
  3069. * Defines specific conditional operators as extensions of Condition
  3070. */
  3071. class ValueCondition extends Condition {
  3072. /** path to specify the property of the target the conditional operator uses */
  3073. propertyPath: string;
  3074. /** the value compared by the conditional operator against the current value of the property */
  3075. value: any;
  3076. /** the conditional operator, default ValueCondition.IsEqual */
  3077. operator: number;
  3078. /**
  3079. * Internal only
  3080. * @hidden
  3081. */
  3082. private static _IsEqual;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsDifferent;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsGreater;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsLesser;
  3098. /**
  3099. * returns the number for IsEqual
  3100. */
  3101. static readonly IsEqual: number;
  3102. /**
  3103. * Returns the number for IsDifferent
  3104. */
  3105. static readonly IsDifferent: number;
  3106. /**
  3107. * Returns the number for IsGreater
  3108. */
  3109. static readonly IsGreater: number;
  3110. /**
  3111. * Returns the number for IsLesser
  3112. */
  3113. static readonly IsLesser: number;
  3114. /**
  3115. * Internal only The action manager for the condition
  3116. * @hidden
  3117. */
  3118. _actionManager: ActionManager;
  3119. /**
  3120. * Internal only
  3121. * @hidden
  3122. */
  3123. private _target;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _effectiveTarget;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _property;
  3134. /**
  3135. * Creates a new ValueCondition
  3136. * @param actionManager manager for the action the condition applies to
  3137. * @param target for the action
  3138. * @param propertyPath path to specify the property of the target the conditional operator uses
  3139. * @param value the value compared by the conditional operator against the current value of the property
  3140. * @param operator the conditional operator, default ValueCondition.IsEqual
  3141. */
  3142. constructor(actionManager: ActionManager, target: any,
  3143. /** path to specify the property of the target the conditional operator uses */
  3144. propertyPath: string,
  3145. /** the value compared by the conditional operator against the current value of the property */
  3146. value: any,
  3147. /** the conditional operator, default ValueCondition.IsEqual */
  3148. operator?: number);
  3149. /**
  3150. * Compares the given value with the property value for the specified conditional operator
  3151. * @returns the result of the comparison
  3152. */
  3153. isValid(): boolean;
  3154. /**
  3155. * Serialize the ValueCondition into a JSON compatible object
  3156. * @returns serialization object
  3157. */
  3158. serialize(): any;
  3159. /**
  3160. * Gets the name of the conditional operator for the ValueCondition
  3161. * @param operator the conditional operator
  3162. * @returns the name
  3163. */
  3164. static GetOperatorName(operator: number): string;
  3165. }
  3166. /**
  3167. * Defines a predicate condition as an extension of Condition
  3168. */
  3169. class PredicateCondition extends Condition {
  3170. /** defines the predicate function used to validate the condition */
  3171. predicate: () => boolean;
  3172. /**
  3173. * Internal only - manager for action
  3174. * @hidden
  3175. */
  3176. _actionManager: ActionManager;
  3177. /**
  3178. * Creates a new PredicateCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param predicate defines the predicate function used to validate the condition
  3181. */
  3182. constructor(actionManager: ActionManager,
  3183. /** defines the predicate function used to validate the condition */
  3184. predicate: () => boolean);
  3185. /**
  3186. * @returns the validity of the predicate condition
  3187. */
  3188. isValid(): boolean;
  3189. }
  3190. /**
  3191. * Defines a state condition as an extension of Condition
  3192. */
  3193. class StateCondition extends Condition {
  3194. value: string;
  3195. /**
  3196. * Internal only - manager for action
  3197. * @hidden
  3198. */
  3199. _actionManager: ActionManager;
  3200. /**
  3201. * Internal only
  3202. * @hidden
  3203. */
  3204. private _target;
  3205. /**
  3206. * Creates a new StateCondition
  3207. * @param actionManager manager for the action the condition applies to
  3208. * @param target of the condition
  3209. * @param value to compare with target state
  3210. */
  3211. constructor(actionManager: ActionManager, target: any, value: string);
  3212. /**
  3213. * @returns the validity of the state
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Serialize the StateCondition into a JSON compatible object
  3218. * @returns serialization object
  3219. */
  3220. serialize(): any;
  3221. }
  3222. }
  3223. declare module BABYLON {
  3224. /**
  3225. * This defines an action responsible to toggle a boolean once triggered.
  3226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3227. */
  3228. class SwitchBooleanAction extends Action {
  3229. /**
  3230. * The path to the boolean property in the target object
  3231. */
  3232. propertyPath: string;
  3233. private _target;
  3234. private _effectiveTarget;
  3235. private _property;
  3236. /**
  3237. * Instantiate the action
  3238. * @param triggerOptions defines the trigger options
  3239. * @param target defines the object containing the boolean
  3240. * @param propertyPath defines the path to the boolean property in the target object
  3241. * @param condition defines the trigger related conditions
  3242. */
  3243. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3244. /** @hidden */
  3245. _prepare(): void;
  3246. /**
  3247. * Execute the action toggle the boolean value.
  3248. */
  3249. execute(): void;
  3250. /**
  3251. * Serializes the actions and its related information.
  3252. * @param parent defines the object to serialize in
  3253. * @returns the serialized object
  3254. */
  3255. serialize(parent: any): any;
  3256. }
  3257. /**
  3258. * This defines an action responsible to set a the state field of the target
  3259. * to a desired value once triggered.
  3260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3261. */
  3262. class SetStateAction extends Action {
  3263. /**
  3264. * The value to store in the state field.
  3265. */
  3266. value: string;
  3267. private _target;
  3268. /**
  3269. * Instantiate the action
  3270. * @param triggerOptions defines the trigger options
  3271. * @param target defines the object containing the state property
  3272. * @param value defines the value to store in the state field
  3273. * @param condition defines the trigger related conditions
  3274. */
  3275. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3276. /**
  3277. * Execute the action and store the value on the target state property.
  3278. */
  3279. execute(): void;
  3280. /**
  3281. * Serializes the actions and its related information.
  3282. * @param parent defines the object to serialize in
  3283. * @returns the serialized object
  3284. */
  3285. serialize(parent: any): any;
  3286. }
  3287. /**
  3288. * This defines an action responsible to set a property of the target
  3289. * to a desired value once triggered.
  3290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3291. */
  3292. class SetValueAction extends Action {
  3293. /**
  3294. * The path of the property to set in the target.
  3295. */
  3296. propertyPath: string;
  3297. /**
  3298. * The value to set in the property
  3299. */
  3300. value: any;
  3301. private _target;
  3302. private _effectiveTarget;
  3303. private _property;
  3304. /**
  3305. * Instantiate the action
  3306. * @param triggerOptions defines the trigger options
  3307. * @param target defines the object containing the property
  3308. * @param propertyPath defines the path of the property to set in the target
  3309. * @param value defines the value to set in the property
  3310. * @param condition defines the trigger related conditions
  3311. */
  3312. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3313. /** @hidden */
  3314. _prepare(): void;
  3315. /**
  3316. * Execute the action and set the targetted property to the desired value.
  3317. */
  3318. execute(): void;
  3319. /**
  3320. * Serializes the actions and its related information.
  3321. * @param parent defines the object to serialize in
  3322. * @returns the serialized object
  3323. */
  3324. serialize(parent: any): any;
  3325. }
  3326. /**
  3327. * This defines an action responsible to increment the target value
  3328. * to a desired value once triggered.
  3329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3330. */
  3331. class IncrementValueAction extends Action {
  3332. /**
  3333. * The path of the property to increment in the target.
  3334. */
  3335. propertyPath: string;
  3336. /**
  3337. * The value we should increment the property by.
  3338. */
  3339. value: any;
  3340. private _target;
  3341. private _effectiveTarget;
  3342. private _property;
  3343. /**
  3344. * Instantiate the action
  3345. * @param triggerOptions defines the trigger options
  3346. * @param target defines the object containing the property
  3347. * @param propertyPath defines the path of the property to increment in the target
  3348. * @param value defines the value value we should increment the property by
  3349. * @param condition defines the trigger related conditions
  3350. */
  3351. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3352. /** @hidden */
  3353. _prepare(): void;
  3354. /**
  3355. * Execute the action and increment the target of the value amount.
  3356. */
  3357. execute(): void;
  3358. /**
  3359. * Serializes the actions and its related information.
  3360. * @param parent defines the object to serialize in
  3361. * @returns the serialized object
  3362. */
  3363. serialize(parent: any): any;
  3364. }
  3365. /**
  3366. * This defines an action responsible to start an animation once triggered.
  3367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3368. */
  3369. class PlayAnimationAction extends Action {
  3370. /**
  3371. * Where the animation should start (animation frame)
  3372. */
  3373. from: number;
  3374. /**
  3375. * Where the animation should stop (animation frame)
  3376. */
  3377. to: number;
  3378. /**
  3379. * Define if the animation should loop or stop after the first play.
  3380. */
  3381. loop?: boolean;
  3382. private _target;
  3383. /**
  3384. * Instantiate the action
  3385. * @param triggerOptions defines the trigger options
  3386. * @param target defines the target animation or animation name
  3387. * @param from defines from where the animation should start (animation frame)
  3388. * @param end defines where the animation should stop (animation frame)
  3389. * @param loop defines if the animation should loop or stop after the first play
  3390. * @param condition defines the trigger related conditions
  3391. */
  3392. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3393. /** @hidden */
  3394. _prepare(): void;
  3395. /**
  3396. * Execute the action and play the animation.
  3397. */
  3398. execute(): void;
  3399. /**
  3400. * Serializes the actions and its related information.
  3401. * @param parent defines the object to serialize in
  3402. * @returns the serialized object
  3403. */
  3404. serialize(parent: any): any;
  3405. }
  3406. /**
  3407. * This defines an action responsible to stop an animation once triggered.
  3408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3409. */
  3410. class StopAnimationAction extends Action {
  3411. private _target;
  3412. /**
  3413. * Instantiate the action
  3414. * @param triggerOptions defines the trigger options
  3415. * @param target defines the target animation or animation name
  3416. * @param condition defines the trigger related conditions
  3417. */
  3418. constructor(triggerOptions: any, target: any, condition?: Condition);
  3419. /** @hidden */
  3420. _prepare(): void;
  3421. /**
  3422. * Execute the action and stop the animation.
  3423. */
  3424. execute(): void;
  3425. /**
  3426. * Serializes the actions and its related information.
  3427. * @param parent defines the object to serialize in
  3428. * @returns the serialized object
  3429. */
  3430. serialize(parent: any): any;
  3431. }
  3432. /**
  3433. * This defines an action responsible that does nothing once triggered.
  3434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3435. */
  3436. class DoNothingAction extends Action {
  3437. /**
  3438. * Instantiate the action
  3439. * @param triggerOptions defines the trigger options
  3440. * @param condition defines the trigger related conditions
  3441. */
  3442. constructor(triggerOptions?: any, condition?: Condition);
  3443. /**
  3444. * Execute the action and do nothing.
  3445. */
  3446. execute(): void;
  3447. /**
  3448. * Serializes the actions and its related information.
  3449. * @param parent defines the object to serialize in
  3450. * @returns the serialized object
  3451. */
  3452. serialize(parent: any): any;
  3453. }
  3454. /**
  3455. * This defines an action responsible to trigger several actions once triggered.
  3456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3457. */
  3458. class CombineAction extends Action {
  3459. /**
  3460. * The list of aggregated animations to run.
  3461. */
  3462. children: Action[];
  3463. /**
  3464. * Instantiate the action
  3465. * @param triggerOptions defines the trigger options
  3466. * @param children defines the list of aggregated animations to run
  3467. * @param condition defines the trigger related conditions
  3468. */
  3469. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3470. /** @hidden */
  3471. _prepare(): void;
  3472. /**
  3473. * Execute the action and executes all the aggregated actions.
  3474. */
  3475. execute(evt: ActionEvent): void;
  3476. /**
  3477. * Serializes the actions and its related information.
  3478. * @param parent defines the object to serialize in
  3479. * @returns the serialized object
  3480. */
  3481. serialize(parent: any): any;
  3482. }
  3483. /**
  3484. * This defines an action responsible to run code (external event) once triggered.
  3485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3486. */
  3487. class ExecuteCodeAction extends Action {
  3488. /**
  3489. * The callback function to run.
  3490. */
  3491. func: (evt: ActionEvent) => void;
  3492. /**
  3493. * Instantiate the action
  3494. * @param triggerOptions defines the trigger options
  3495. * @param func defines the callback function to run
  3496. * @param condition defines the trigger related conditions
  3497. */
  3498. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3499. /**
  3500. * Execute the action and run the attached code.
  3501. */
  3502. execute(evt: ActionEvent): void;
  3503. }
  3504. /**
  3505. * This defines an action responsible to set the parent property of the target once triggered.
  3506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3507. */
  3508. class SetParentAction extends Action {
  3509. private _parent;
  3510. private _target;
  3511. /**
  3512. * Instantiate the action
  3513. * @param triggerOptions defines the trigger options
  3514. * @param target defines the target containing the parent property
  3515. * @param parent defines from where the animation should start (animation frame)
  3516. * @param condition defines the trigger related conditions
  3517. */
  3518. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3519. /** @hidden */
  3520. _prepare(): void;
  3521. /**
  3522. * Execute the action and set the parent property.
  3523. */
  3524. execute(): void;
  3525. /**
  3526. * Serializes the actions and its related information.
  3527. * @param parent defines the object to serialize in
  3528. * @returns the serialized object
  3529. */
  3530. serialize(parent: any): any;
  3531. }
  3532. }
  3533. declare module BABYLON {
  3534. /**
  3535. * This defines an action helpful to play a defined sound on a triggered action.
  3536. */
  3537. class PlaySoundAction extends Action {
  3538. private _sound;
  3539. /**
  3540. * Instantiate the action
  3541. * @param triggerOptions defines the trigger options
  3542. * @param sound defines the sound to play
  3543. * @param condition defines the trigger related conditions
  3544. */
  3545. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3546. /** @hidden */
  3547. _prepare(): void;
  3548. /**
  3549. * Execute the action and play the sound.
  3550. */
  3551. execute(): void;
  3552. /**
  3553. * Serializes the actions and its related information.
  3554. * @param parent defines the object to serialize in
  3555. * @returns the serialized object
  3556. */
  3557. serialize(parent: any): any;
  3558. }
  3559. /**
  3560. * This defines an action helpful to stop a defined sound on a triggered action.
  3561. */
  3562. class StopSoundAction extends Action {
  3563. private _sound;
  3564. /**
  3565. * Instantiate the action
  3566. * @param triggerOptions defines the trigger options
  3567. * @param sound defines the sound to stop
  3568. * @param condition defines the trigger related conditions
  3569. */
  3570. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3571. /** @hidden */
  3572. _prepare(): void;
  3573. /**
  3574. * Execute the action and stop the sound.
  3575. */
  3576. execute(): void;
  3577. /**
  3578. * Serializes the actions and its related information.
  3579. * @param parent defines the object to serialize in
  3580. * @returns the serialized object
  3581. */
  3582. serialize(parent: any): any;
  3583. }
  3584. }
  3585. declare module BABYLON {
  3586. /**
  3587. * This defines an action responsible to change the value of a property
  3588. * by interpolating between its current value and the newly set one once triggered.
  3589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3590. */
  3591. class InterpolateValueAction extends Action {
  3592. /**
  3593. * Defines the path of the property where the value should be interpolated
  3594. */
  3595. propertyPath: string;
  3596. /**
  3597. * Defines the target value at the end of the interpolation.
  3598. */
  3599. value: any;
  3600. /**
  3601. * Defines the time it will take for the property to interpolate to the value.
  3602. */
  3603. duration: number;
  3604. /**
  3605. * Defines if the other scene animations should be stopped when the action has been triggered
  3606. */
  3607. stopOtherAnimations?: boolean;
  3608. /**
  3609. * Defines a callback raised once the interpolation animation has been done.
  3610. */
  3611. onInterpolationDone?: () => void;
  3612. /**
  3613. * Observable triggered once the interpolation animation has been done.
  3614. */
  3615. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3616. private _target;
  3617. private _effectiveTarget;
  3618. private _property;
  3619. /**
  3620. * Instantiate the action
  3621. * @param triggerOptions defines the trigger options
  3622. * @param target defines the object containing the value to interpolate
  3623. * @param propertyPath defines the path to the property in the target object
  3624. * @param value defines the target value at the end of the interpolation
  3625. * @param duration deines the time it will take for the property to interpolate to the value.
  3626. * @param condition defines the trigger related conditions
  3627. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3628. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3629. */
  3630. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3631. /** @hidden */
  3632. _prepare(): void;
  3633. /**
  3634. * Execute the action starts the value interpolation.
  3635. */
  3636. execute(): void;
  3637. /**
  3638. * Serializes the actions and its related information.
  3639. * @param parent defines the object to serialize in
  3640. * @returns the serialized object
  3641. */
  3642. serialize(parent: any): any;
  3643. }
  3644. }
  3645. declare module BABYLON {
  3646. /**
  3647. * Class used to store an actual running animation
  3648. */
  3649. class Animatable {
  3650. /** defines the target object */
  3651. target: any;
  3652. /** defines the starting frame number (default is 0) */
  3653. fromFrame: number;
  3654. /** defines the ending frame number (default is 100) */
  3655. toFrame: number;
  3656. /** defines if the animation must loop (default is false) */
  3657. loopAnimation: boolean;
  3658. /** defines a callback to call when animation ends if it is not looping */
  3659. onAnimationEnd?: (() => void) | null | undefined;
  3660. private _localDelayOffset;
  3661. private _pausedDelay;
  3662. private _runtimeAnimations;
  3663. private _paused;
  3664. private _scene;
  3665. private _speedRatio;
  3666. private _weight;
  3667. private _syncRoot;
  3668. /**
  3669. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3670. * This will only apply for non looping animation (default is true)
  3671. */
  3672. disposeOnEnd: boolean;
  3673. /**
  3674. * Gets a boolean indicating if the animation has started
  3675. */
  3676. animationStarted: boolean;
  3677. /**
  3678. * Observer raised when the animation ends
  3679. */
  3680. onAnimationEndObservable: Observable<Animatable>;
  3681. /**
  3682. * Gets the root Animatable used to synchronize and normalize animations
  3683. */
  3684. readonly syncRoot: Animatable;
  3685. /**
  3686. * Gets the current frame of the first RuntimeAnimation
  3687. * Used to synchronize Animatables
  3688. */
  3689. readonly masterFrame: number;
  3690. /**
  3691. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3692. */
  3693. weight: number;
  3694. /**
  3695. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3696. */
  3697. speedRatio: number;
  3698. /**
  3699. * Creates a new Animatable
  3700. * @param scene defines the hosting scene
  3701. * @param target defines the target object
  3702. * @param fromFrame defines the starting frame number (default is 0)
  3703. * @param toFrame defines the ending frame number (default is 100)
  3704. * @param loopAnimation defines if the animation must loop (default is false)
  3705. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3706. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3707. * @param animations defines a group of animation to add to the new Animatable
  3708. */
  3709. constructor(scene: Scene,
  3710. /** defines the target object */
  3711. target: any,
  3712. /** defines the starting frame number (default is 0) */
  3713. fromFrame?: number,
  3714. /** defines the ending frame number (default is 100) */
  3715. toFrame?: number,
  3716. /** defines if the animation must loop (default is false) */
  3717. loopAnimation?: boolean, speedRatio?: number,
  3718. /** defines a callback to call when animation ends if it is not looping */
  3719. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3720. /**
  3721. * Synchronize and normalize current Animatable with a source Animatable
  3722. * This is useful when using animation weights and when animations are not of the same length
  3723. * @param root defines the root Animatable to synchronize with
  3724. * @returns the current Animatable
  3725. */
  3726. syncWith(root: Animatable): Animatable;
  3727. /**
  3728. * Gets the list of runtime animations
  3729. * @returns an array of RuntimeAnimation
  3730. */
  3731. getAnimations(): RuntimeAnimation[];
  3732. /**
  3733. * Adds more animations to the current animatable
  3734. * @param target defines the target of the animations
  3735. * @param animations defines the new animations to add
  3736. */
  3737. appendAnimations(target: any, animations: Animation[]): void;
  3738. /**
  3739. * Gets the source animation for a specific property
  3740. * @param property defines the propertyu to look for
  3741. * @returns null or the source animation for the given property
  3742. */
  3743. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3744. /**
  3745. * Gets the runtime animation for a specific property
  3746. * @param property defines the propertyu to look for
  3747. * @returns null or the runtime animation for the given property
  3748. */
  3749. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3750. /**
  3751. * Resets the animatable to its original state
  3752. */
  3753. reset(): void;
  3754. /**
  3755. * Allows the animatable to blend with current running animations
  3756. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3757. * @param blendingSpeed defines the blending speed to use
  3758. */
  3759. enableBlending(blendingSpeed: number): void;
  3760. /**
  3761. * Disable animation blending
  3762. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3763. */
  3764. disableBlending(): void;
  3765. /**
  3766. * Jump directly to a given frame
  3767. * @param frame defines the frame to jump to
  3768. */
  3769. goToFrame(frame: number): void;
  3770. /**
  3771. * Pause the animation
  3772. */
  3773. pause(): void;
  3774. /**
  3775. * Restart the animation
  3776. */
  3777. restart(): void;
  3778. private _raiseOnAnimationEnd;
  3779. /**
  3780. * Stop and delete the current animation
  3781. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3782. * @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)
  3783. */
  3784. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3785. /**
  3786. * Wait asynchronously for the animation to end
  3787. * @returns a promise which will be fullfilled when the animation ends
  3788. */
  3789. waitAsync(): Promise<Animatable>;
  3790. /** @hidden */
  3791. _animate(delay: number): boolean;
  3792. }
  3793. }
  3794. declare module BABYLON {
  3795. /**
  3796. * Represents the range of an animation
  3797. */
  3798. class AnimationRange {
  3799. /**The name of the animation range**/
  3800. name: string;
  3801. /**The starting frame of the animation */
  3802. from: number;
  3803. /**The ending frame of the animation*/
  3804. to: number;
  3805. /**
  3806. * Initializes the range of an animation
  3807. * @param name The name of the animation range
  3808. * @param from The starting frame of the animation
  3809. * @param to The ending frame of the animation
  3810. */
  3811. constructor(
  3812. /**The name of the animation range**/
  3813. name: string,
  3814. /**The starting frame of the animation */
  3815. from: number,
  3816. /**The ending frame of the animation*/
  3817. to: number);
  3818. /**
  3819. * Makes a copy of the animation range
  3820. * @returns A copy of the animation range
  3821. */
  3822. clone(): AnimationRange;
  3823. }
  3824. /**
  3825. * Composed of a frame, and an action function
  3826. */
  3827. class AnimationEvent {
  3828. /** The frame for which the event is triggered **/
  3829. frame: number;
  3830. /** The event to perform when triggered **/
  3831. action: (currentFrame: number) => void;
  3832. /** Specifies if the event should be triggered only once**/
  3833. onlyOnce?: boolean | undefined;
  3834. /**
  3835. * Specifies if the animation event is done
  3836. */
  3837. isDone: boolean;
  3838. /**
  3839. * Initializes the animation event
  3840. * @param frame The frame for which the event is triggered
  3841. * @param action The event to perform when triggered
  3842. * @param onlyOnce Specifies if the event should be triggered only once
  3843. */
  3844. constructor(
  3845. /** The frame for which the event is triggered **/
  3846. frame: number,
  3847. /** The event to perform when triggered **/
  3848. action: (currentFrame: number) => void,
  3849. /** Specifies if the event should be triggered only once**/
  3850. onlyOnce?: boolean | undefined);
  3851. /** @hidden */
  3852. _clone(): AnimationEvent;
  3853. }
  3854. /**
  3855. * A cursor which tracks a point on a path
  3856. */
  3857. class PathCursor {
  3858. private path;
  3859. /**
  3860. * Stores path cursor callbacks for when an onchange event is triggered
  3861. */
  3862. private _onchange;
  3863. /**
  3864. * The value of the path cursor
  3865. */
  3866. value: number;
  3867. /**
  3868. * The animation array of the path cursor
  3869. */
  3870. animations: Animation[];
  3871. /**
  3872. * Initializes the path cursor
  3873. * @param path The path to track
  3874. */
  3875. constructor(path: Path2);
  3876. /**
  3877. * Gets the cursor point on the path
  3878. * @returns A point on the path cursor at the cursor location
  3879. */
  3880. getPoint(): Vector3;
  3881. /**
  3882. * Moves the cursor ahead by the step amount
  3883. * @param step The amount to move the cursor forward
  3884. * @returns This path cursor
  3885. */
  3886. moveAhead(step?: number): PathCursor;
  3887. /**
  3888. * Moves the cursor behind by the step amount
  3889. * @param step The amount to move the cursor back
  3890. * @returns This path cursor
  3891. */
  3892. moveBack(step?: number): PathCursor;
  3893. /**
  3894. * Moves the cursor by the step amount
  3895. * If the step amount is greater than one, an exception is thrown
  3896. * @param step The amount to move the cursor
  3897. * @returns This path cursor
  3898. */
  3899. move(step: number): PathCursor;
  3900. /**
  3901. * Ensures that the value is limited between zero and one
  3902. * @returns This path cursor
  3903. */
  3904. private ensureLimits;
  3905. /**
  3906. * Runs onchange callbacks on change (used by the animation engine)
  3907. * @returns This path cursor
  3908. */
  3909. private raiseOnChange;
  3910. /**
  3911. * Executes a function on change
  3912. * @param f A path cursor onchange callback
  3913. * @returns This path cursor
  3914. */
  3915. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3916. }
  3917. /**
  3918. * Defines an interface which represents an animation key frame
  3919. */
  3920. interface IAnimationKey {
  3921. /**
  3922. * Frame of the key frame
  3923. */
  3924. frame: number;
  3925. /**
  3926. * Value at the specifies key frame
  3927. */
  3928. value: any;
  3929. /**
  3930. * The input tangent for the cubic hermite spline
  3931. */
  3932. inTangent?: any;
  3933. /**
  3934. * The output tangent for the cubic hermite spline
  3935. */
  3936. outTangent?: any;
  3937. /**
  3938. * The animation interpolation type
  3939. */
  3940. interpolation?: AnimationKeyInterpolation;
  3941. }
  3942. /**
  3943. * Enum for the animation key frame interpolation type
  3944. */
  3945. enum AnimationKeyInterpolation {
  3946. /**
  3947. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3948. */
  3949. STEP = 1
  3950. }
  3951. /**
  3952. * Class used to store any kind of animation
  3953. */
  3954. class Animation {
  3955. /**Name of the animation */
  3956. name: string;
  3957. /**Property to animate */
  3958. targetProperty: string;
  3959. /**The frames per second of the animation */
  3960. framePerSecond: number;
  3961. /**The data type of the animation */
  3962. dataType: number;
  3963. /**The loop mode of the animation */
  3964. loopMode?: number | undefined;
  3965. /**Specifies if blending should be enabled */
  3966. enableBlending?: boolean | undefined;
  3967. /**
  3968. * Use matrix interpolation instead of using direct key value when animating matrices
  3969. */
  3970. static AllowMatricesInterpolation: boolean;
  3971. /**
  3972. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3973. */
  3974. static AllowMatrixDecomposeForInterpolation: boolean;
  3975. /**
  3976. * Stores the key frames of the animation
  3977. */
  3978. private _keys;
  3979. /**
  3980. * Stores the easing function of the animation
  3981. */
  3982. private _easingFunction;
  3983. /**
  3984. * @hidden Internal use only
  3985. */
  3986. _runtimeAnimations: RuntimeAnimation[];
  3987. /**
  3988. * The set of event that will be linked to this animation
  3989. */
  3990. private _events;
  3991. /**
  3992. * Stores an array of target property paths
  3993. */
  3994. targetPropertyPath: string[];
  3995. /**
  3996. * Stores the blending speed of the animation
  3997. */
  3998. blendingSpeed: number;
  3999. /**
  4000. * Stores the animation ranges for the animation
  4001. */
  4002. private _ranges;
  4003. /**
  4004. * @hidden Internal use
  4005. */
  4006. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4007. /**
  4008. * Sets up an animation
  4009. * @param property The property to animate
  4010. * @param animationType The animation type to apply
  4011. * @param framePerSecond The frames per second of the animation
  4012. * @param easingFunction The easing function used in the animation
  4013. * @returns The created animation
  4014. */
  4015. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4016. /**
  4017. * Create and start an animation on a node
  4018. * @param name defines the name of the global animation that will be run on all nodes
  4019. * @param node defines the root node where the animation will take place
  4020. * @param targetProperty defines property to animate
  4021. * @param framePerSecond defines the number of frame per second yo use
  4022. * @param totalFrame defines the number of frames in total
  4023. * @param from defines the initial value
  4024. * @param to defines the final value
  4025. * @param loopMode defines which loop mode you want to use (off by default)
  4026. * @param easingFunction defines the easing function to use (linear by default)
  4027. * @param onAnimationEnd defines the callback to call when animation end
  4028. * @returns the animatable created for this animation
  4029. */
  4030. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4031. /**
  4032. * Create and start an animation on a node and its descendants
  4033. * @param name defines the name of the global animation that will be run on all nodes
  4034. * @param node defines the root node where the animation will take place
  4035. * @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
  4036. * @param targetProperty defines property to animate
  4037. * @param framePerSecond defines the number of frame per second to use
  4038. * @param totalFrame defines the number of frames in total
  4039. * @param from defines the initial value
  4040. * @param to defines the final value
  4041. * @param loopMode defines which loop mode you want to use (off by default)
  4042. * @param easingFunction defines the easing function to use (linear by default)
  4043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4044. * @returns the list of animatables created for all nodes
  4045. * @example https://www.babylonjs-playground.com/#MH0VLI
  4046. */
  4047. 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[]>;
  4048. /**
  4049. * Creates a new animation, merges it with the existing animations and starts it
  4050. * @param name Name of the animation
  4051. * @param node Node which contains the scene that begins the animations
  4052. * @param targetProperty Specifies which property to animate
  4053. * @param framePerSecond The frames per second of the animation
  4054. * @param totalFrame The total number of frames
  4055. * @param from The frame at the beginning of the animation
  4056. * @param to The frame at the end of the animation
  4057. * @param loopMode Specifies the loop mode of the animation
  4058. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4059. * @param onAnimationEnd Callback to run once the animation is complete
  4060. * @returns Nullable animation
  4061. */
  4062. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4063. /**
  4064. * Transition property of an host to the target Value
  4065. * @param property The property to transition
  4066. * @param targetValue The target Value of the property
  4067. * @param host The object where the property to animate belongs
  4068. * @param scene Scene used to run the animation
  4069. * @param frameRate Framerate (in frame/s) to use
  4070. * @param transition The transition type we want to use
  4071. * @param duration The duration of the animation, in milliseconds
  4072. * @param onAnimationEnd Callback trigger at the end of the animation
  4073. * @returns Nullable animation
  4074. */
  4075. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4076. /**
  4077. * Return the array of runtime animations currently using this animation
  4078. */
  4079. readonly runtimeAnimations: RuntimeAnimation[];
  4080. /**
  4081. * Specifies if any of the runtime animations are currently running
  4082. */
  4083. readonly hasRunningRuntimeAnimations: boolean;
  4084. /**
  4085. * Initializes the animation
  4086. * @param name Name of the animation
  4087. * @param targetProperty Property to animate
  4088. * @param framePerSecond The frames per second of the animation
  4089. * @param dataType The data type of the animation
  4090. * @param loopMode The loop mode of the animation
  4091. * @param enableBlendings Specifies if blending should be enabled
  4092. */
  4093. constructor(
  4094. /**Name of the animation */
  4095. name: string,
  4096. /**Property to animate */
  4097. targetProperty: string,
  4098. /**The frames per second of the animation */
  4099. framePerSecond: number,
  4100. /**The data type of the animation */
  4101. dataType: number,
  4102. /**The loop mode of the animation */
  4103. loopMode?: number | undefined,
  4104. /**Specifies if blending should be enabled */
  4105. enableBlending?: boolean | undefined);
  4106. /**
  4107. * Converts the animation to a string
  4108. * @param fullDetails support for multiple levels of logging within scene loading
  4109. * @returns String form of the animation
  4110. */
  4111. toString(fullDetails?: boolean): string;
  4112. /**
  4113. * Add an event to this animation
  4114. * @param event Event to add
  4115. */
  4116. addEvent(event: AnimationEvent): void;
  4117. /**
  4118. * Remove all events found at the given frame
  4119. * @param frame The frame to remove events from
  4120. */
  4121. removeEvents(frame: number): void;
  4122. /**
  4123. * Retrieves all the events from the animation
  4124. * @returns Events from the animation
  4125. */
  4126. getEvents(): AnimationEvent[];
  4127. /**
  4128. * Creates an animation range
  4129. * @param name Name of the animation range
  4130. * @param from Starting frame of the animation range
  4131. * @param to Ending frame of the animation
  4132. */
  4133. createRange(name: string, from: number, to: number): void;
  4134. /**
  4135. * Deletes an animation range by name
  4136. * @param name Name of the animation range to delete
  4137. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4138. */
  4139. deleteRange(name: string, deleteFrames?: boolean): void;
  4140. /**
  4141. * Gets the animation range by name, or null if not defined
  4142. * @param name Name of the animation range
  4143. * @returns Nullable animation range
  4144. */
  4145. getRange(name: string): Nullable<AnimationRange>;
  4146. /**
  4147. * Gets the key frames from the animation
  4148. * @returns The key frames of the animation
  4149. */
  4150. getKeys(): Array<IAnimationKey>;
  4151. /**
  4152. * Gets the highest frame rate of the animation
  4153. * @returns Highest frame rate of the animation
  4154. */
  4155. getHighestFrame(): number;
  4156. /**
  4157. * Gets the easing function of the animation
  4158. * @returns Easing function of the animation
  4159. */
  4160. getEasingFunction(): IEasingFunction;
  4161. /**
  4162. * Sets the easing function of the animation
  4163. * @param easingFunction A custom mathematical formula for animation
  4164. */
  4165. setEasingFunction(easingFunction: EasingFunction): void;
  4166. /**
  4167. * Interpolates a scalar linearly
  4168. * @param startValue Start value of the animation curve
  4169. * @param endValue End value of the animation curve
  4170. * @param gradient Scalar amount to interpolate
  4171. * @returns Interpolated scalar value
  4172. */
  4173. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4174. /**
  4175. * Interpolates a scalar cubically
  4176. * @param startValue Start value of the animation curve
  4177. * @param outTangent End tangent of the animation
  4178. * @param endValue End value of the animation curve
  4179. * @param inTangent Start tangent of the animation curve
  4180. * @param gradient Scalar amount to interpolate
  4181. * @returns Interpolated scalar value
  4182. */
  4183. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4184. /**
  4185. * Interpolates a quaternion using a spherical linear interpolation
  4186. * @param startValue Start value of the animation curve
  4187. * @param endValue End value of the animation curve
  4188. * @param gradient Scalar amount to interpolate
  4189. * @returns Interpolated quaternion value
  4190. */
  4191. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4192. /**
  4193. * Interpolates a quaternion cubically
  4194. * @param startValue Start value of the animation curve
  4195. * @param outTangent End tangent of the animation curve
  4196. * @param endValue End value of the animation curve
  4197. * @param inTangent Start tangent of the animation curve
  4198. * @param gradient Scalar amount to interpolate
  4199. * @returns Interpolated quaternion value
  4200. */
  4201. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4202. /**
  4203. * Interpolates a Vector3 linearl
  4204. * @param startValue Start value of the animation curve
  4205. * @param endValue End value of the animation curve
  4206. * @param gradient Scalar amount to interpolate
  4207. * @returns Interpolated scalar value
  4208. */
  4209. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4210. /**
  4211. * Interpolates a Vector3 cubically
  4212. * @param startValue Start value of the animation curve
  4213. * @param outTangent End tangent of the animation
  4214. * @param endValue End value of the animation curve
  4215. * @param inTangent Start tangent of the animation curve
  4216. * @param gradient Scalar amount to interpolate
  4217. * @returns InterpolatedVector3 value
  4218. */
  4219. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4220. /**
  4221. * Interpolates a Vector2 linearly
  4222. * @param startValue Start value of the animation curve
  4223. * @param endValue End value of the animation curve
  4224. * @param gradient Scalar amount to interpolate
  4225. * @returns Interpolated Vector2 value
  4226. */
  4227. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4228. /**
  4229. * Interpolates a Vector2 cubically
  4230. * @param startValue Start value of the animation curve
  4231. * @param outTangent End tangent of the animation
  4232. * @param endValue End value of the animation curve
  4233. * @param inTangent Start tangent of the animation curve
  4234. * @param gradient Scalar amount to interpolate
  4235. * @returns Interpolated Vector2 value
  4236. */
  4237. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4238. /**
  4239. * Interpolates a size linearly
  4240. * @param startValue Start value of the animation curve
  4241. * @param endValue End value of the animation curve
  4242. * @param gradient Scalar amount to interpolate
  4243. * @returns Interpolated Size value
  4244. */
  4245. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4246. /**
  4247. * Interpolates a Color3 linearly
  4248. * @param startValue Start value of the animation curve
  4249. * @param endValue End value of the animation curve
  4250. * @param gradient Scalar amount to interpolate
  4251. * @returns Interpolated Color3 value
  4252. */
  4253. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4254. /**
  4255. * @hidden Internal use only
  4256. */
  4257. _getKeyValue(value: any): any;
  4258. /**
  4259. * @hidden Internal use only
  4260. */
  4261. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4262. /**
  4263. * Defines the function to use to interpolate matrices
  4264. * @param startValue defines the start matrix
  4265. * @param endValue defines the end matrix
  4266. * @param gradient defines the gradient between both matrices
  4267. * @param result defines an optional target matrix where to store the interpolation
  4268. * @returns the interpolated matrix
  4269. */
  4270. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4271. /**
  4272. * Makes a copy of the animation
  4273. * @returns Cloned animation
  4274. */
  4275. clone(): Animation;
  4276. /**
  4277. * Sets the key frames of the animation
  4278. * @param values The animation key frames to set
  4279. */
  4280. setKeys(values: Array<IAnimationKey>): void;
  4281. /**
  4282. * Serializes the animation to an object
  4283. * @returns Serialized object
  4284. */
  4285. serialize(): any;
  4286. /**
  4287. * Float animation type
  4288. */
  4289. private static _ANIMATIONTYPE_FLOAT;
  4290. /**
  4291. * Vector3 animation type
  4292. */
  4293. private static _ANIMATIONTYPE_VECTOR3;
  4294. /**
  4295. * Quaternion animation type
  4296. */
  4297. private static _ANIMATIONTYPE_QUATERNION;
  4298. /**
  4299. * Matrix animation type
  4300. */
  4301. private static _ANIMATIONTYPE_MATRIX;
  4302. /**
  4303. * Color3 animation type
  4304. */
  4305. private static _ANIMATIONTYPE_COLOR3;
  4306. /**
  4307. * Vector2 animation type
  4308. */
  4309. private static _ANIMATIONTYPE_VECTOR2;
  4310. /**
  4311. * Size animation type
  4312. */
  4313. private static _ANIMATIONTYPE_SIZE;
  4314. /**
  4315. * Relative Loop Mode
  4316. */
  4317. private static _ANIMATIONLOOPMODE_RELATIVE;
  4318. /**
  4319. * Cycle Loop Mode
  4320. */
  4321. private static _ANIMATIONLOOPMODE_CYCLE;
  4322. /**
  4323. * Constant Loop Mode
  4324. */
  4325. private static _ANIMATIONLOOPMODE_CONSTANT;
  4326. /**
  4327. * Get the float animation type
  4328. */
  4329. static readonly ANIMATIONTYPE_FLOAT: number;
  4330. /**
  4331. * Get the Vector3 animation type
  4332. */
  4333. static readonly ANIMATIONTYPE_VECTOR3: number;
  4334. /**
  4335. * Get the Vector2 animation type
  4336. */
  4337. static readonly ANIMATIONTYPE_VECTOR2: number;
  4338. /**
  4339. * Get the Size animation type
  4340. */
  4341. static readonly ANIMATIONTYPE_SIZE: number;
  4342. /**
  4343. * Get the Quaternion animation type
  4344. */
  4345. static readonly ANIMATIONTYPE_QUATERNION: number;
  4346. /**
  4347. * Get the Matrix animation type
  4348. */
  4349. static readonly ANIMATIONTYPE_MATRIX: number;
  4350. /**
  4351. * Get the Color3 animation type
  4352. */
  4353. static readonly ANIMATIONTYPE_COLOR3: number;
  4354. /**
  4355. * Get the Relative Loop Mode
  4356. */
  4357. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4358. /**
  4359. * Get the Cycle Loop Mode
  4360. */
  4361. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4362. /**
  4363. * Get the Constant Loop Mode
  4364. */
  4365. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4366. /** @hidden */
  4367. static _UniversalLerp(left: any, right: any, amount: number): any;
  4368. /**
  4369. * Parses an animation object and creates an animation
  4370. * @param parsedAnimation Parsed animation object
  4371. * @returns Animation object
  4372. */
  4373. static Parse(parsedAnimation: any): Animation;
  4374. /**
  4375. * Appends the serialized animations from the source animations
  4376. * @param source Source containing the animations
  4377. * @param destination Target to store the animations
  4378. */
  4379. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4380. }
  4381. }
  4382. declare module BABYLON {
  4383. /**
  4384. * This class defines the direct association between an animation and a target
  4385. */
  4386. class TargetedAnimation {
  4387. animation: Animation;
  4388. target: any;
  4389. }
  4390. /**
  4391. * Use this class to create coordinated animations on multiple targets
  4392. */
  4393. class AnimationGroup implements IDisposable {
  4394. /** The name of the animation group */
  4395. name: string;
  4396. private _scene;
  4397. private _targetedAnimations;
  4398. private _animatables;
  4399. private _from;
  4400. private _to;
  4401. private _isStarted;
  4402. private _speedRatio;
  4403. /**
  4404. * This observable will notify when one animation have ended.
  4405. */
  4406. onAnimationEndObservable: Observable<TargetedAnimation>;
  4407. /**
  4408. * This observable will notify when all animations have ended.
  4409. */
  4410. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4411. /**
  4412. * This observable will notify when all animations have paused.
  4413. */
  4414. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4415. /**
  4416. * Gets the first frame
  4417. */
  4418. readonly from: number;
  4419. /**
  4420. * Gets the last frame
  4421. */
  4422. readonly to: number;
  4423. /**
  4424. * Define if the animations are started
  4425. */
  4426. readonly isStarted: boolean;
  4427. /**
  4428. * Gets or sets the speed ratio to use for all animations
  4429. */
  4430. /**
  4431. * Gets or sets the speed ratio to use for all animations
  4432. */
  4433. speedRatio: number;
  4434. /**
  4435. * Gets the targeted animations for this animation group
  4436. */
  4437. readonly targetedAnimations: Array<TargetedAnimation>;
  4438. /**
  4439. * returning the list of animatables controlled by this animation group.
  4440. */
  4441. readonly animatables: Array<Animatable>;
  4442. /**
  4443. * Instantiates a new Animation Group.
  4444. * This helps managing several animations at once.
  4445. * @see http://doc.babylonjs.com/how_to/group
  4446. * @param name Defines the name of the group
  4447. * @param scene Defines the scene the group belongs to
  4448. */
  4449. constructor(
  4450. /** The name of the animation group */
  4451. name: string, scene?: Nullable<Scene>);
  4452. /**
  4453. * Add an animation (with its target) in the group
  4454. * @param animation defines the animation we want to add
  4455. * @param target defines the target of the animation
  4456. * @returns the {BABYLON.TargetedAnimation} object
  4457. */
  4458. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4459. /**
  4460. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4461. * It can add constant keys at begin or end
  4462. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4463. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4464. * @returns the animation group
  4465. */
  4466. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4467. /**
  4468. * Start all animations on given targets
  4469. * @param loop defines if animations must loop
  4470. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4471. * @param from defines the from key (optional)
  4472. * @param to defines the to key (optional)
  4473. * @returns the current animation group
  4474. */
  4475. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4476. /**
  4477. * Pause all animations
  4478. * @returns the animation group
  4479. */
  4480. pause(): AnimationGroup;
  4481. /**
  4482. * Play all animations to initial state
  4483. * This function will start() the animations if they were not started or will restart() them if they were paused
  4484. * @param loop defines if animations must loop
  4485. * @returns the animation group
  4486. */
  4487. play(loop?: boolean): AnimationGroup;
  4488. /**
  4489. * Reset all animations to initial state
  4490. * @returns the animation group
  4491. */
  4492. reset(): AnimationGroup;
  4493. /**
  4494. * Restart animations from key 0
  4495. * @returns the animation group
  4496. */
  4497. restart(): AnimationGroup;
  4498. /**
  4499. * Stop all animations
  4500. * @returns the animation group
  4501. */
  4502. stop(): AnimationGroup;
  4503. /**
  4504. * Set animation weight for all animatables
  4505. * @param weight defines the weight to use
  4506. * @return the animationGroup
  4507. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4508. */
  4509. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4510. /**
  4511. * Synchronize and normalize all animatables with a source animatable
  4512. * @param root defines the root animatable to synchronize with
  4513. * @return the animationGroup
  4514. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4515. */
  4516. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4517. /**
  4518. * Goes to a specific frame in this animation group
  4519. * @param frame the frame number to go to
  4520. * @return the animationGroup
  4521. */
  4522. goToFrame(frame: number): AnimationGroup;
  4523. /**
  4524. * Dispose all associated resources
  4525. */
  4526. dispose(): void;
  4527. private _checkAnimationGroupEnded;
  4528. /**
  4529. * Returns a new AnimationGroup object parsed from the source provided.
  4530. * @param parsedAnimationGroup defines the source
  4531. * @param scene defines the scene that will receive the animationGroup
  4532. * @returns a new AnimationGroup
  4533. */
  4534. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4535. /**
  4536. * Returns the string "AnimationGroup"
  4537. * @returns "AnimationGroup"
  4538. */
  4539. getClassName(): string;
  4540. /**
  4541. * Creates a detailled string about the object
  4542. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4543. * @returns a string representing the object
  4544. */
  4545. toString(fullDetails?: boolean): string;
  4546. }
  4547. }
  4548. declare module BABYLON {
  4549. /**
  4550. * Class used to override all child animations of a given target
  4551. */
  4552. class AnimationPropertiesOverride {
  4553. /**
  4554. * Gets or sets a value indicating if animation blending must be used
  4555. */
  4556. enableBlending: boolean;
  4557. /**
  4558. * Gets or sets the blending speed to use when enableBlending is true
  4559. */
  4560. blendingSpeed: number;
  4561. /**
  4562. * Gets or sets the default loop mode to use
  4563. */
  4564. loopMode: number;
  4565. }
  4566. }
  4567. declare module BABYLON {
  4568. /**
  4569. * This represents the main contract an easing function should follow.
  4570. * Easing functions are used throughout the animation system.
  4571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4572. */
  4573. interface IEasingFunction {
  4574. /**
  4575. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4576. * of the easing function.
  4577. * The link below provides some of the most common examples of easing functions.
  4578. * @see https://easings.net/
  4579. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4580. * @returns the corresponding value on the curve defined by the easing function
  4581. */
  4582. ease(gradient: number): number;
  4583. }
  4584. /**
  4585. * Base class used for every default easing function.
  4586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4587. */
  4588. class EasingFunction implements IEasingFunction {
  4589. /**
  4590. * Interpolation follows the mathematical formula associated with the easing function.
  4591. */
  4592. static readonly EASINGMODE_EASEIN: number;
  4593. /**
  4594. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4595. */
  4596. static readonly EASINGMODE_EASEOUT: number;
  4597. /**
  4598. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4599. */
  4600. static readonly EASINGMODE_EASEINOUT: number;
  4601. private _easingMode;
  4602. /**
  4603. * Sets the easing mode of the current function.
  4604. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4605. */
  4606. setEasingMode(easingMode: number): void;
  4607. /**
  4608. * Gets the current easing mode.
  4609. * @returns the easing mode
  4610. */
  4611. getEasingMode(): number;
  4612. /**
  4613. * @hidden
  4614. */
  4615. easeInCore(gradient: number): number;
  4616. /**
  4617. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4618. * of the easing function.
  4619. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4620. * @returns the corresponding value on the curve defined by the easing function
  4621. */
  4622. ease(gradient: number): number;
  4623. }
  4624. /**
  4625. * Easing function with a circle shape (see link below).
  4626. * @see https://easings.net/#easeInCirc
  4627. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4628. */
  4629. class CircleEase extends EasingFunction implements IEasingFunction {
  4630. /** @hidden */
  4631. easeInCore(gradient: number): number;
  4632. }
  4633. /**
  4634. * Easing function with a ease back shape (see link below).
  4635. * @see https://easings.net/#easeInBack
  4636. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4637. */
  4638. class BackEase extends EasingFunction implements IEasingFunction {
  4639. /** Defines the amplitude of the function */
  4640. amplitude: number;
  4641. /**
  4642. * Instantiates a back ease easing
  4643. * @see https://easings.net/#easeInBack
  4644. * @param amplitude Defines the amplitude of the function
  4645. */
  4646. constructor(
  4647. /** Defines the amplitude of the function */
  4648. amplitude?: number);
  4649. /** @hidden */
  4650. easeInCore(gradient: number): number;
  4651. }
  4652. /**
  4653. * Easing function with a bouncing shape (see link below).
  4654. * @see https://easings.net/#easeInBounce
  4655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4656. */
  4657. class BounceEase extends EasingFunction implements IEasingFunction {
  4658. /** Defines the number of bounces */
  4659. bounces: number;
  4660. /** Defines the amplitude of the bounce */
  4661. bounciness: number;
  4662. /**
  4663. * Instantiates a bounce easing
  4664. * @see https://easings.net/#easeInBounce
  4665. * @param bounces Defines the number of bounces
  4666. * @param bounciness Defines the amplitude of the bounce
  4667. */
  4668. constructor(
  4669. /** Defines the number of bounces */
  4670. bounces?: number,
  4671. /** Defines the amplitude of the bounce */
  4672. bounciness?: number);
  4673. /** @hidden */
  4674. easeInCore(gradient: number): number;
  4675. }
  4676. /**
  4677. * Easing function with a power of 3 shape (see link below).
  4678. * @see https://easings.net/#easeInCubic
  4679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4680. */
  4681. class CubicEase extends EasingFunction implements IEasingFunction {
  4682. /** @hidden */
  4683. easeInCore(gradient: number): number;
  4684. }
  4685. /**
  4686. * Easing function with an elastic shape (see link below).
  4687. * @see https://easings.net/#easeInElastic
  4688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4689. */
  4690. class ElasticEase extends EasingFunction implements IEasingFunction {
  4691. /** Defines the number of oscillations*/
  4692. oscillations: number;
  4693. /** Defines the amplitude of the oscillations*/
  4694. springiness: number;
  4695. /**
  4696. * Instantiates an elastic easing function
  4697. * @see https://easings.net/#easeInElastic
  4698. * @param oscillations Defines the number of oscillations
  4699. * @param springiness Defines the amplitude of the oscillations
  4700. */
  4701. constructor(
  4702. /** Defines the number of oscillations*/
  4703. oscillations?: number,
  4704. /** Defines the amplitude of the oscillations*/
  4705. springiness?: number);
  4706. /** @hidden */
  4707. easeInCore(gradient: number): number;
  4708. }
  4709. /**
  4710. * Easing function with an exponential shape (see link below).
  4711. * @see https://easings.net/#easeInExpo
  4712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4713. */
  4714. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4715. /** Defines the exponent of the function */
  4716. exponent: number;
  4717. /**
  4718. * Instantiates an exponential easing function
  4719. * @see https://easings.net/#easeInExpo
  4720. * @param exponent Defines the exponent of the function
  4721. */
  4722. constructor(
  4723. /** Defines the exponent of the function */
  4724. exponent?: number);
  4725. /** @hidden */
  4726. easeInCore(gradient: number): number;
  4727. }
  4728. /**
  4729. * Easing function with a power shape (see link below).
  4730. * @see https://easings.net/#easeInQuad
  4731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4732. */
  4733. class PowerEase extends EasingFunction implements IEasingFunction {
  4734. /** Defines the power of the function */
  4735. power: number;
  4736. /**
  4737. * Instantiates an power base easing function
  4738. * @see https://easings.net/#easeInQuad
  4739. * @param power Defines the power of the function
  4740. */
  4741. constructor(
  4742. /** Defines the power of the function */
  4743. power?: number);
  4744. /** @hidden */
  4745. easeInCore(gradient: number): number;
  4746. }
  4747. /**
  4748. * Easing function with a power of 2 shape (see link below).
  4749. * @see https://easings.net/#easeInQuad
  4750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4751. */
  4752. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4753. /** @hidden */
  4754. easeInCore(gradient: number): number;
  4755. }
  4756. /**
  4757. * Easing function with a power of 4 shape (see link below).
  4758. * @see https://easings.net/#easeInQuart
  4759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4760. */
  4761. class QuarticEase extends EasingFunction implements IEasingFunction {
  4762. /** @hidden */
  4763. easeInCore(gradient: number): number;
  4764. }
  4765. /**
  4766. * Easing function with a power of 5 shape (see link below).
  4767. * @see https://easings.net/#easeInQuint
  4768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4769. */
  4770. class QuinticEase extends EasingFunction implements IEasingFunction {
  4771. /** @hidden */
  4772. easeInCore(gradient: number): number;
  4773. }
  4774. /**
  4775. * Easing function with a sin shape (see link below).
  4776. * @see https://easings.net/#easeInSine
  4777. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4778. */
  4779. class SineEase extends EasingFunction implements IEasingFunction {
  4780. /** @hidden */
  4781. easeInCore(gradient: number): number;
  4782. }
  4783. /**
  4784. * Easing function with a bezier shape (see link below).
  4785. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4787. */
  4788. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4789. /** Defines the x component of the start tangent in the bezier curve */
  4790. x1: number;
  4791. /** Defines the y component of the start tangent in the bezier curve */
  4792. y1: number;
  4793. /** Defines the x component of the end tangent in the bezier curve */
  4794. x2: number;
  4795. /** Defines the y component of the end tangent in the bezier curve */
  4796. y2: number;
  4797. /**
  4798. * Instantiates a bezier function
  4799. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4800. * @param x1 Defines the x component of the start tangent in the bezier curve
  4801. * @param y1 Defines the y component of the start tangent in the bezier curve
  4802. * @param x2 Defines the x component of the end tangent in the bezier curve
  4803. * @param y2 Defines the y component of the end tangent in the bezier curve
  4804. */
  4805. constructor(
  4806. /** Defines the x component of the start tangent in the bezier curve */
  4807. x1?: number,
  4808. /** Defines the y component of the start tangent in the bezier curve */
  4809. y1?: number,
  4810. /** Defines the x component of the end tangent in the bezier curve */
  4811. x2?: number,
  4812. /** Defines the y component of the end tangent in the bezier curve */
  4813. y2?: number);
  4814. /** @hidden */
  4815. easeInCore(gradient: number): number;
  4816. }
  4817. }
  4818. declare module BABYLON {
  4819. /**
  4820. * Defines a runtime animation
  4821. */
  4822. class RuntimeAnimation {
  4823. private _events;
  4824. /**
  4825. * The current frame of the runtime animation
  4826. */
  4827. private _currentFrame;
  4828. /**
  4829. * The animation used by the runtime animation
  4830. */
  4831. private _animation;
  4832. /**
  4833. * The target of the runtime animation
  4834. */
  4835. private _target;
  4836. /**
  4837. * The initiating animatable
  4838. */
  4839. private _host;
  4840. /**
  4841. * The original value of the runtime animation
  4842. */
  4843. private _originalValue;
  4844. /**
  4845. * The original blend value of the runtime animation
  4846. */
  4847. private _originalBlendValue;
  4848. /**
  4849. * The offsets cache of the runtime animation
  4850. */
  4851. private _offsetsCache;
  4852. /**
  4853. * The high limits cache of the runtime animation
  4854. */
  4855. private _highLimitsCache;
  4856. /**
  4857. * Specifies if the runtime animation has been stopped
  4858. */
  4859. private _stopped;
  4860. /**
  4861. * The blending factor of the runtime animation
  4862. */
  4863. private _blendingFactor;
  4864. /**
  4865. * The BabylonJS scene
  4866. */
  4867. private _scene;
  4868. /**
  4869. * The current value of the runtime animation
  4870. */
  4871. private _currentValue;
  4872. /** @hidden */
  4873. _workValue: any;
  4874. /**
  4875. * The active target of the runtime animation
  4876. */
  4877. private _activeTarget;
  4878. /**
  4879. * The target path of the runtime animation
  4880. */
  4881. private _targetPath;
  4882. /**
  4883. * The weight of the runtime animation
  4884. */
  4885. private _weight;
  4886. /**
  4887. * The ratio offset of the runtime animation
  4888. */
  4889. private _ratioOffset;
  4890. /**
  4891. * The previous delay of the runtime animation
  4892. */
  4893. private _previousDelay;
  4894. /**
  4895. * The previous ratio of the runtime animation
  4896. */
  4897. private _previousRatio;
  4898. /**
  4899. * Gets the current frame of the runtime animation
  4900. */
  4901. readonly currentFrame: number;
  4902. /**
  4903. * Gets the weight of the runtime animation
  4904. */
  4905. readonly weight: number;
  4906. /**
  4907. * Gets the current value of the runtime animation
  4908. */
  4909. readonly currentValue: any;
  4910. /**
  4911. * Gets the target path of the runtime animation
  4912. */
  4913. readonly targetPath: string;
  4914. /**
  4915. * Gets the actual target of the runtime animation
  4916. */
  4917. readonly target: any;
  4918. /**
  4919. * Create a new RuntimeAnimation object
  4920. * @param target defines the target of the animation
  4921. * @param animation defines the source animation object
  4922. * @param scene defines the hosting scene
  4923. * @param host defines the initiating Animatable
  4924. */
  4925. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4926. /**
  4927. * Gets the animation from the runtime animation
  4928. */
  4929. readonly animation: Animation;
  4930. /**
  4931. * Resets the runtime animation to the beginning
  4932. * @param restoreOriginal defines whether to restore the target property to the original value
  4933. */
  4934. reset(restoreOriginal?: boolean): void;
  4935. /**
  4936. * Specifies if the runtime animation is stopped
  4937. * @returns Boolean specifying if the runtime animation is stopped
  4938. */
  4939. isStopped(): boolean;
  4940. /**
  4941. * Disposes of the runtime animation
  4942. */
  4943. dispose(): void;
  4944. /**
  4945. * Interpolates the animation from the current frame
  4946. * @param currentFrame The frame to interpolate the animation to
  4947. * @param repeatCount The number of times that the animation should loop
  4948. * @param loopMode The type of looping mode to use
  4949. * @param offsetValue Animation offset value
  4950. * @param highLimitValue The high limit value
  4951. * @returns The interpolated value
  4952. */
  4953. private _interpolate;
  4954. /**
  4955. * Apply the interpolated value to the target
  4956. * @param currentValue defines the value computed by the animation
  4957. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4958. */
  4959. setValue(currentValue: any, weight?: number): void;
  4960. private _setValue;
  4961. /**
  4962. * Gets the loop pmode of the runtime animation
  4963. * @returns Loop Mode
  4964. */
  4965. private _getCorrectLoopMode;
  4966. /**
  4967. * Move the current animation to a given frame
  4968. * @param frame defines the frame to move to
  4969. */
  4970. goToFrame(frame: number): void;
  4971. /**
  4972. * @hidden Internal use only
  4973. */
  4974. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4975. /**
  4976. * Execute the current animation
  4977. * @param delay defines the delay to add to the current frame
  4978. * @param from defines the lower bound of the animation range
  4979. * @param to defines the upper bound of the animation range
  4980. * @param loop defines if the current animation must loop
  4981. * @param speedRatio defines the current speed ratio
  4982. * @param weight defines the weight of the animation (default is -1 so no weight)
  4983. * @returns a boolean indicating if the animation is running
  4984. */
  4985. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4986. }
  4987. }
  4988. declare module BABYLON {
  4989. /**
  4990. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4992. */
  4993. class Analyser {
  4994. /**
  4995. * Gets or sets the smoothing
  4996. * @ignorenaming
  4997. */
  4998. SMOOTHING: number;
  4999. /**
  5000. * Gets or sets the FFT table size
  5001. * @ignorenaming
  5002. */
  5003. FFT_SIZE: number;
  5004. /**
  5005. * Gets or sets the bar graph amplitude
  5006. * @ignorenaming
  5007. */
  5008. BARGRAPHAMPLITUDE: number;
  5009. /**
  5010. * Gets or sets the position of the debug canvas
  5011. * @ignorenaming
  5012. */
  5013. DEBUGCANVASPOS: {
  5014. x: number;
  5015. y: number;
  5016. };
  5017. /**
  5018. * Gets or sets the debug canvas size
  5019. * @ignorenaming
  5020. */
  5021. DEBUGCANVASSIZE: {
  5022. width: number;
  5023. height: number;
  5024. };
  5025. private _byteFreqs;
  5026. private _byteTime;
  5027. private _floatFreqs;
  5028. private _webAudioAnalyser;
  5029. private _debugCanvas;
  5030. private _debugCanvasContext;
  5031. private _scene;
  5032. private _registerFunc;
  5033. private _audioEngine;
  5034. /**
  5035. * Creates a new analyser
  5036. * @param scene defines hosting scene
  5037. */
  5038. constructor(scene: Scene);
  5039. /**
  5040. * Get the number of data values you will have to play with for the visualization
  5041. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5042. * @returns a number
  5043. */
  5044. getFrequencyBinCount(): number;
  5045. /**
  5046. * Gets the current frequency data as a byte array
  5047. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5048. * @returns a Uint8Array
  5049. */
  5050. getByteFrequencyData(): Uint8Array;
  5051. /**
  5052. * Gets the current waveform as a byte array
  5053. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5054. * @returns a Uint8Array
  5055. */
  5056. getByteTimeDomainData(): Uint8Array;
  5057. /**
  5058. * Gets the current frequency data as a float array
  5059. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5060. * @returns a Float32Array
  5061. */
  5062. getFloatFrequencyData(): Float32Array;
  5063. /**
  5064. * Renders the debug canvas
  5065. */
  5066. drawDebugCanvas(): void;
  5067. /**
  5068. * Stops rendering the debug canvas and removes it
  5069. */
  5070. stopDebugCanvas(): void;
  5071. /**
  5072. * Connects two audio nodes
  5073. * @param inputAudioNode defines first node to connect
  5074. * @param outputAudioNode defines second node to connect
  5075. */
  5076. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5077. /**
  5078. * Releases all associated resources
  5079. */
  5080. dispose(): void;
  5081. }
  5082. }
  5083. declare module BABYLON {
  5084. /**
  5085. * This represents an audio engine and it is responsible
  5086. * to play, synchronize and analyse sounds throughout the application.
  5087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5088. */
  5089. interface IAudioEngine extends IDisposable {
  5090. /**
  5091. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5092. */
  5093. readonly canUseWebAudio: boolean;
  5094. /**
  5095. * Gets the current AudioContext if available.
  5096. */
  5097. readonly audioContext: Nullable<AudioContext>;
  5098. /**
  5099. * The master gain node defines the global audio volume of your audio engine.
  5100. */
  5101. readonly masterGain: GainNode;
  5102. /**
  5103. * Gets whether or not mp3 are supported by your browser.
  5104. */
  5105. readonly isMP3supported: boolean;
  5106. /**
  5107. * Gets whether or not ogg are supported by your browser.
  5108. */
  5109. readonly isOGGsupported: boolean;
  5110. /**
  5111. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5112. * @ignoreNaming
  5113. */
  5114. WarnedWebAudioUnsupported: boolean;
  5115. /**
  5116. * Defines if the audio engine relies on a custom unlocked button.
  5117. * In this case, the embedded button will not be displayed.
  5118. */
  5119. useCustomUnlockedButton: boolean;
  5120. /**
  5121. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5122. */
  5123. readonly unlocked: boolean;
  5124. /**
  5125. * Event raised when audio has been unlocked on the browser.
  5126. */
  5127. onAudioUnlockedObservable: Observable<AudioEngine>;
  5128. /**
  5129. * Event raised when audio has been locked on the browser.
  5130. */
  5131. onAudioLockedObservable: Observable<AudioEngine>;
  5132. /**
  5133. * Flags the audio engine in Locked state.
  5134. * This happens due to new browser policies preventing audio to autoplay.
  5135. */
  5136. lock(): void;
  5137. /**
  5138. * Unlocks the audio engine once a user action has been done on the dom.
  5139. * This is helpful to resume play once browser policies have been satisfied.
  5140. */
  5141. unlock(): void;
  5142. }
  5143. /**
  5144. * This represents the default audio engine used in babylon.
  5145. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5147. */
  5148. class AudioEngine implements IAudioEngine {
  5149. private _audioContext;
  5150. private _audioContextInitialized;
  5151. private _muteButton;
  5152. private _engine;
  5153. /**
  5154. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5155. */
  5156. canUseWebAudio: boolean;
  5157. /**
  5158. * The master gain node defines the global audio volume of your audio engine.
  5159. */
  5160. masterGain: GainNode;
  5161. /**
  5162. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5163. * @ignoreNaming
  5164. */
  5165. WarnedWebAudioUnsupported: boolean;
  5166. /**
  5167. * Gets whether or not mp3 are supported by your browser.
  5168. */
  5169. isMP3supported: boolean;
  5170. /**
  5171. * Gets whether or not ogg are supported by your browser.
  5172. */
  5173. isOGGsupported: boolean;
  5174. private _canvas;
  5175. /**
  5176. * Gets whether audio has been unlocked on the device.
  5177. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5178. * a user interaction has happened.
  5179. */
  5180. unlocked: boolean;
  5181. /**
  5182. * Defines if the audio engine relies on a custom unlocked button.
  5183. * In this case, the embedded button will not be displayed.
  5184. */
  5185. useCustomUnlockedButton: boolean;
  5186. /**
  5187. * Event raised when audio has been unlocked on the browser.
  5188. */
  5189. onAudioUnlockedObservable: Observable<AudioEngine>;
  5190. /**
  5191. * Event raised when audio has been locked on the browser.
  5192. */
  5193. onAudioLockedObservable: Observable<AudioEngine>;
  5194. /**
  5195. * Gets the current AudioContext if available.
  5196. */
  5197. readonly audioContext: Nullable<AudioContext>;
  5198. private _connectedAnalyser;
  5199. /**
  5200. * Instantiates a new audio engine.
  5201. *
  5202. * There should be only one per page as some browsers restrict the number
  5203. * of audio contexts you can create.
  5204. * @param engine defines the hosting engine
  5205. */
  5206. constructor(engine?: Nullable<Engine>);
  5207. /**
  5208. * Flags the audio engine in Locked state.
  5209. * This happens due to new browser policies preventing audio to autoplay.
  5210. */
  5211. lock(): void;
  5212. /**
  5213. * Unlocks the audio engine once a user action has been done on the dom.
  5214. * This is helpful to resume play once browser policies have been satisfied.
  5215. */
  5216. unlock(): void;
  5217. private _resumeAudioContext;
  5218. private _initializeAudioContext;
  5219. private _tryToRun;
  5220. private _triggerRunningState;
  5221. private _triggerSuspendedState;
  5222. private _displayMuteButton;
  5223. private _moveButtonToTopLeft;
  5224. private _onResize;
  5225. private _hideMuteButton;
  5226. /**
  5227. * Destroy and release the resources associated with the audio ccontext.
  5228. */
  5229. dispose(): void;
  5230. /**
  5231. * Gets the global volume sets on the master gain.
  5232. * @returns the global volume if set or -1 otherwise
  5233. */
  5234. getGlobalVolume(): number;
  5235. /**
  5236. * Sets the global volume of your experience (sets on the master gain).
  5237. * @param newVolume Defines the new global volume of the application
  5238. */
  5239. setGlobalVolume(newVolume: number): void;
  5240. /**
  5241. * Connect the audio engine to an audio analyser allowing some amazing
  5242. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5244. * @param analyser The analyser to connect to the engine
  5245. */
  5246. connectToAnalyser(analyser: Analyser): void;
  5247. }
  5248. }
  5249. declare module BABYLON {
  5250. interface AbstractScene {
  5251. /**
  5252. * The list of sounds used in the scene.
  5253. */
  5254. sounds: Nullable<Array<Sound>>;
  5255. }
  5256. interface Scene {
  5257. /**
  5258. * @hidden
  5259. * Backing field
  5260. */
  5261. _mainSoundTrack: SoundTrack;
  5262. /**
  5263. * The main sound track played by the scene.
  5264. * It cotains your primary collection of sounds.
  5265. */
  5266. mainSoundTrack: SoundTrack;
  5267. /**
  5268. * The list of sound tracks added to the scene
  5269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5270. */
  5271. soundTracks: Nullable<Array<SoundTrack>>;
  5272. /**
  5273. * Gets a sound using a given name
  5274. * @param name defines the name to search for
  5275. * @return the found sound or null if not found at all.
  5276. */
  5277. getSoundByName(name: string): Nullable<Sound>;
  5278. /**
  5279. * Gets or sets if audio support is enabled
  5280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5281. */
  5282. audioEnabled: boolean;
  5283. /**
  5284. * Gets or sets if audio will be output to headphones
  5285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5286. */
  5287. headphone: boolean;
  5288. }
  5289. /**
  5290. * Defines the sound scene component responsible to manage any sounds
  5291. * in a given scene.
  5292. */
  5293. class AudioSceneComponent implements ISceneSerializableComponent {
  5294. /**
  5295. * The component name helpfull to identify the component in the list of scene components.
  5296. */
  5297. readonly name: string;
  5298. /**
  5299. * The scene the component belongs to.
  5300. */
  5301. scene: Scene;
  5302. private _audioEnabled;
  5303. /**
  5304. * Gets whether audio is enabled or not.
  5305. * Please use related enable/disable method to switch state.
  5306. */
  5307. readonly audioEnabled: boolean;
  5308. private _headphone;
  5309. /**
  5310. * Gets whether audio is outputing to headphone or not.
  5311. * Please use the according Switch methods to change output.
  5312. */
  5313. readonly headphone: boolean;
  5314. /**
  5315. * Creates a new instance of the component for the given scene
  5316. * @param scene Defines the scene to register the component in
  5317. */
  5318. constructor(scene: Scene);
  5319. /**
  5320. * Registers the component in a given scene
  5321. */
  5322. register(): void;
  5323. /**
  5324. * Rebuilds the elements related to this component in case of
  5325. * context lost for instance.
  5326. */
  5327. rebuild(): void;
  5328. /**
  5329. * Serializes the component data to the specified json object
  5330. * @param serializationObject The object to serialize to
  5331. */
  5332. serialize(serializationObject: any): void;
  5333. /**
  5334. * Adds all the element from the container to the scene
  5335. * @param container the container holding the elements
  5336. */
  5337. addFromContainer(container: AbstractScene): void;
  5338. /**
  5339. * Removes all the elements in the container from the scene
  5340. * @param container contains the elements to remove
  5341. */
  5342. removeFromContainer(container: AbstractScene): void;
  5343. /**
  5344. * Disposes the component and the associated ressources.
  5345. */
  5346. dispose(): void;
  5347. /**
  5348. * Disables audio in the associated scene.
  5349. */
  5350. disableAudio(): void;
  5351. /**
  5352. * Enables audio in the associated scene.
  5353. */
  5354. enableAudio(): void;
  5355. /**
  5356. * Switch audio to headphone output.
  5357. */
  5358. switchAudioModeForHeadphones(): void;
  5359. /**
  5360. * Switch audio to normal speakers.
  5361. */
  5362. switchAudioModeForNormalSpeakers(): void;
  5363. private _afterRender;
  5364. }
  5365. }
  5366. declare module BABYLON {
  5367. /**
  5368. * Defines a sound that can be played in the application.
  5369. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5371. */
  5372. class Sound {
  5373. /**
  5374. * The name of the sound in the scene.
  5375. */
  5376. name: string;
  5377. /**
  5378. * Does the sound autoplay once loaded.
  5379. */
  5380. autoplay: boolean;
  5381. /**
  5382. * Does the sound loop after it finishes playing once.
  5383. */
  5384. loop: boolean;
  5385. /**
  5386. * Does the sound use a custom attenuation curve to simulate the falloff
  5387. * happening when the source gets further away from the camera.
  5388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5389. */
  5390. useCustomAttenuation: boolean;
  5391. /**
  5392. * The sound track id this sound belongs to.
  5393. */
  5394. soundTrackId: number;
  5395. /**
  5396. * Is this sound currently played.
  5397. */
  5398. isPlaying: boolean;
  5399. /**
  5400. * Is this sound currently paused.
  5401. */
  5402. isPaused: boolean;
  5403. /**
  5404. * Does this sound enables spatial sound.
  5405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5406. */
  5407. spatialSound: boolean;
  5408. /**
  5409. * Define the reference distance the sound should be heard perfectly.
  5410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5411. */
  5412. refDistance: number;
  5413. /**
  5414. * Define the roll off factor of spatial sounds.
  5415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5416. */
  5417. rolloffFactor: number;
  5418. /**
  5419. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5421. */
  5422. maxDistance: number;
  5423. /**
  5424. * Define the distance attenuation model the sound will follow.
  5425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5426. */
  5427. distanceModel: string;
  5428. /**
  5429. * @hidden
  5430. * Back Compat
  5431. **/
  5432. onended: () => any;
  5433. /**
  5434. * Observable event when the current playing sound finishes.
  5435. */
  5436. onEndedObservable: Observable<Sound>;
  5437. private _panningModel;
  5438. private _playbackRate;
  5439. private _streaming;
  5440. private _startTime;
  5441. private _startOffset;
  5442. private _position;
  5443. /** @hidden */
  5444. _positionInEmitterSpace: boolean;
  5445. private _localDirection;
  5446. private _volume;
  5447. private _isReadyToPlay;
  5448. private _isDirectional;
  5449. private _readyToPlayCallback;
  5450. private _audioBuffer;
  5451. private _soundSource;
  5452. private _streamingSource;
  5453. private _soundPanner;
  5454. private _soundGain;
  5455. private _inputAudioNode;
  5456. private _outputAudioNode;
  5457. private _coneInnerAngle;
  5458. private _coneOuterAngle;
  5459. private _coneOuterGain;
  5460. private _scene;
  5461. private _connectedMesh;
  5462. private _customAttenuationFunction;
  5463. private _registerFunc;
  5464. private _isOutputConnected;
  5465. private _htmlAudioElement;
  5466. private _urlType;
  5467. /**
  5468. * Create a sound and attach it to a scene
  5469. * @param name Name of your sound
  5470. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5471. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5472. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5473. */
  5474. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5475. /**
  5476. * Release the sound and its associated resources
  5477. */
  5478. dispose(): void;
  5479. /**
  5480. * Gets if the sounds is ready to be played or not.
  5481. * @returns true if ready, otherwise false
  5482. */
  5483. isReady(): boolean;
  5484. private _soundLoaded;
  5485. /**
  5486. * Sets the data of the sound from an audiobuffer
  5487. * @param audioBuffer The audioBuffer containing the data
  5488. */
  5489. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5490. /**
  5491. * Updates the current sounds options such as maxdistance, loop...
  5492. * @param options A JSON object containing values named as the object properties
  5493. */
  5494. updateOptions(options: any): void;
  5495. private _createSpatialParameters;
  5496. private _updateSpatialParameters;
  5497. /**
  5498. * Switch the panning model to HRTF:
  5499. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5501. */
  5502. switchPanningModelToHRTF(): void;
  5503. /**
  5504. * Switch the panning model to Equal Power:
  5505. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5507. */
  5508. switchPanningModelToEqualPower(): void;
  5509. private _switchPanningModel;
  5510. /**
  5511. * Connect this sound to a sound track audio node like gain...
  5512. * @param soundTrackAudioNode the sound track audio node to connect to
  5513. */
  5514. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5515. /**
  5516. * Transform this sound into a directional source
  5517. * @param coneInnerAngle Size of the inner cone in degree
  5518. * @param coneOuterAngle Size of the outer cone in degree
  5519. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5520. */
  5521. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5522. /**
  5523. * Gets or sets the inner angle for the directional cone.
  5524. */
  5525. /**
  5526. * Gets or sets the inner angle for the directional cone.
  5527. */
  5528. directionalConeInnerAngle: number;
  5529. /**
  5530. * Gets or sets the outer angle for the directional cone.
  5531. */
  5532. /**
  5533. * Gets or sets the outer angle for the directional cone.
  5534. */
  5535. directionalConeOuterAngle: number;
  5536. /**
  5537. * Sets the position of the emitter if spatial sound is enabled
  5538. * @param newPosition Defines the new posisiton
  5539. */
  5540. setPosition(newPosition: Vector3): void;
  5541. /**
  5542. * Sets the local direction of the emitter if spatial sound is enabled
  5543. * @param newLocalDirection Defines the new local direction
  5544. */
  5545. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5546. private _updateDirection;
  5547. /** @hidden */
  5548. updateDistanceFromListener(): void;
  5549. /**
  5550. * Sets a new custom attenuation function for the sound.
  5551. * @param callback Defines the function used for the attenuation
  5552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5553. */
  5554. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5555. /**
  5556. * Play the sound
  5557. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5558. * @param offset (optional) Start the sound setting it at a specific time
  5559. */
  5560. play(time?: number, offset?: number): void;
  5561. private _onended;
  5562. /**
  5563. * Stop the sound
  5564. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5565. */
  5566. stop(time?: number): void;
  5567. /**
  5568. * Put the sound in pause
  5569. */
  5570. pause(): void;
  5571. /**
  5572. * Sets a dedicated volume for this sounds
  5573. * @param newVolume Define the new volume of the sound
  5574. * @param time Define in how long the sound should be at this value
  5575. */
  5576. setVolume(newVolume: number, time?: number): void;
  5577. /**
  5578. * Set the sound play back rate
  5579. * @param newPlaybackRate Define the playback rate the sound should be played at
  5580. */
  5581. setPlaybackRate(newPlaybackRate: number): void;
  5582. /**
  5583. * Gets the volume of the sound.
  5584. * @returns the volume of the sound
  5585. */
  5586. getVolume(): number;
  5587. /**
  5588. * Attach the sound to a dedicated mesh
  5589. * @param meshToConnectTo The mesh to connect the sound with
  5590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5591. */
  5592. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5593. /**
  5594. * Detach the sound from the previously attached mesh
  5595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5596. */
  5597. detachFromMesh(): void;
  5598. private _onRegisterAfterWorldMatrixUpdate;
  5599. /**
  5600. * Clone the current sound in the scene.
  5601. * @returns the new sound clone
  5602. */
  5603. clone(): Nullable<Sound>;
  5604. /**
  5605. * Gets the current underlying audio buffer containing the data
  5606. * @returns the audio buffer
  5607. */
  5608. getAudioBuffer(): Nullable<AudioBuffer>;
  5609. /**
  5610. * Serializes the Sound in a JSON representation
  5611. * @returns the JSON representation of the sound
  5612. */
  5613. serialize(): any;
  5614. /**
  5615. * Parse a JSON representation of a sound to innstantiate in a given scene
  5616. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5617. * @param scene Define the scene the new parsed sound should be created in
  5618. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5619. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5620. * @returns the newly parsed sound
  5621. */
  5622. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5623. }
  5624. }
  5625. declare module BABYLON {
  5626. /**
  5627. * Options allowed during the creation of a sound track.
  5628. */
  5629. interface ISoundTrackOptions {
  5630. /**
  5631. * The volume the sound track should take during creation
  5632. */
  5633. volume?: number;
  5634. /**
  5635. * Define if the sound track is the main sound track of the scene
  5636. */
  5637. mainTrack?: boolean;
  5638. }
  5639. /**
  5640. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5641. * It will be also used in a future release to apply effects on a specific track.
  5642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5643. */
  5644. class SoundTrack {
  5645. /**
  5646. * The unique identifier of the sound track in the scene.
  5647. */
  5648. id: number;
  5649. /**
  5650. * The list of sounds included in the sound track.
  5651. */
  5652. soundCollection: Array<Sound>;
  5653. private _outputAudioNode;
  5654. private _scene;
  5655. private _isMainTrack;
  5656. private _connectedAnalyser;
  5657. private _options;
  5658. private _isInitialized;
  5659. /**
  5660. * Creates a new sound track.
  5661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5662. * @param scene Define the scene the sound track belongs to
  5663. * @param options
  5664. */
  5665. constructor(scene: Scene, options?: ISoundTrackOptions);
  5666. private _initializeSoundTrackAudioGraph;
  5667. /**
  5668. * Release the sound track and its associated resources
  5669. */
  5670. dispose(): void;
  5671. /**
  5672. * Adds a sound to this sound track
  5673. * @param sound define the cound to add
  5674. * @ignoreNaming
  5675. */
  5676. AddSound(sound: Sound): void;
  5677. /**
  5678. * Removes a sound to this sound track
  5679. * @param sound define the cound to remove
  5680. * @ignoreNaming
  5681. */
  5682. RemoveSound(sound: Sound): void;
  5683. /**
  5684. * Set a global volume for the full sound track.
  5685. * @param newVolume Define the new volume of the sound track
  5686. */
  5687. setVolume(newVolume: number): void;
  5688. /**
  5689. * Switch the panning model to HRTF:
  5690. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5692. */
  5693. switchPanningModelToHRTF(): void;
  5694. /**
  5695. * Switch the panning model to Equal Power:
  5696. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5698. */
  5699. switchPanningModelToEqualPower(): void;
  5700. /**
  5701. * Connect the sound track to an audio analyser allowing some amazing
  5702. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5704. * @param analyser The analyser to connect to the engine
  5705. */
  5706. connectToAnalyser(analyser: Analyser): void;
  5707. }
  5708. }
  5709. declare module BABYLON {
  5710. /**
  5711. * Wraps one or more Sound objects and selects one with random weight for playback.
  5712. */
  5713. class WeightedSound {
  5714. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5715. loop: boolean;
  5716. private _coneInnerAngle;
  5717. private _coneOuterAngle;
  5718. private _volume;
  5719. /** A Sound is currently playing. */
  5720. isPlaying: boolean;
  5721. /** A Sound is currently paused. */
  5722. isPaused: boolean;
  5723. private _sounds;
  5724. private _weights;
  5725. private _currentIndex?;
  5726. /**
  5727. * Creates a new WeightedSound from the list of sounds given.
  5728. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5729. * @param sounds Array of Sounds that will be selected from.
  5730. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5731. */
  5732. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5733. /**
  5734. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5735. */
  5736. /**
  5737. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5738. */
  5739. directionalConeInnerAngle: number;
  5740. /**
  5741. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5742. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5743. */
  5744. /**
  5745. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5746. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5747. */
  5748. directionalConeOuterAngle: number;
  5749. /**
  5750. * Playback volume.
  5751. */
  5752. /**
  5753. * Playback volume.
  5754. */
  5755. volume: number;
  5756. private _onended;
  5757. /**
  5758. * Suspend playback
  5759. */
  5760. pause(): void;
  5761. /**
  5762. * Stop playback
  5763. */
  5764. stop(): void;
  5765. /**
  5766. * Start playback.
  5767. * @param startOffset Position the clip head at a specific time in seconds.
  5768. */
  5769. play(startOffset?: number): void;
  5770. }
  5771. }
  5772. declare module BABYLON {
  5773. /**
  5774. * Interface used to define a behavior
  5775. */
  5776. interface Behavior<T> {
  5777. /** gets or sets behavior's name */
  5778. name: string;
  5779. /**
  5780. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5781. */
  5782. init(): void;
  5783. /**
  5784. * Called when the behavior is attached to a target
  5785. * @param target defines the target where the behavior is attached to
  5786. */
  5787. attach(target: T): void;
  5788. /**
  5789. * Called when the behavior is detached from its target
  5790. */
  5791. detach(): void;
  5792. }
  5793. /**
  5794. * Interface implemented by classes supporting behaviors
  5795. */
  5796. interface IBehaviorAware<T> {
  5797. /**
  5798. * Attach a behavior
  5799. * @param behavior defines the behavior to attach
  5800. * @returns the current host
  5801. */
  5802. addBehavior(behavior: Behavior<T>): T;
  5803. /**
  5804. * Remove a behavior from the current object
  5805. * @param behavior defines the behavior to detach
  5806. * @returns the current host
  5807. */
  5808. removeBehavior(behavior: Behavior<T>): T;
  5809. /**
  5810. * Gets a behavior using its name to search
  5811. * @param name defines the name to search
  5812. * @returns the behavior or null if not found
  5813. */
  5814. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5815. }
  5816. }
  5817. declare module BABYLON {
  5818. /**
  5819. * Class used to store bone information
  5820. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5821. */
  5822. class Bone extends Node {
  5823. /**
  5824. * defines the bone name
  5825. */
  5826. name: string;
  5827. private static _tmpVecs;
  5828. private static _tmpQuat;
  5829. private static _tmpMats;
  5830. /**
  5831. * Gets the list of child bones
  5832. */
  5833. children: Bone[];
  5834. /** Gets the animations associated with this bone */
  5835. animations: Animation[];
  5836. /**
  5837. * Gets or sets bone length
  5838. */
  5839. length: number;
  5840. /**
  5841. * @hidden Internal only
  5842. * Set this value to map this bone to a different index in the transform matrices
  5843. * Set this value to -1 to exclude the bone from the transform matrices
  5844. */
  5845. _index: Nullable<number>;
  5846. private _skeleton;
  5847. private _localMatrix;
  5848. private _restPose;
  5849. private _baseMatrix;
  5850. private _absoluteTransform;
  5851. private _invertedAbsoluteTransform;
  5852. private _parent;
  5853. private _scalingDeterminant;
  5854. private _worldTransform;
  5855. private _localScaling;
  5856. private _localRotation;
  5857. private _localPosition;
  5858. private _needToDecompose;
  5859. private _needToCompose;
  5860. /** @hidden */
  5861. /** @hidden */
  5862. _matrix: Matrix;
  5863. /**
  5864. * Create a new bone
  5865. * @param name defines the bone name
  5866. * @param skeleton defines the parent skeleton
  5867. * @param parentBone defines the parent (can be null if the bone is the root)
  5868. * @param localMatrix defines the local matrix
  5869. * @param restPose defines the rest pose matrix
  5870. * @param baseMatrix defines the base matrix
  5871. * @param index defines index of the bone in the hiearchy
  5872. */
  5873. constructor(
  5874. /**
  5875. * defines the bone name
  5876. */
  5877. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5878. /**
  5879. * Gets the parent skeleton
  5880. * @returns a skeleton
  5881. */
  5882. getSkeleton(): Skeleton;
  5883. /**
  5884. * Gets parent bone
  5885. * @returns a bone or null if the bone is the root of the bone hierarchy
  5886. */
  5887. getParent(): Nullable<Bone>;
  5888. /**
  5889. * Sets the parent bone
  5890. * @param parent defines the parent (can be null if the bone is the root)
  5891. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5892. */
  5893. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5894. /**
  5895. * Gets the local matrix
  5896. * @returns a matrix
  5897. */
  5898. getLocalMatrix(): Matrix;
  5899. /**
  5900. * Gets the base matrix (initial matrix which remains unchanged)
  5901. * @returns a matrix
  5902. */
  5903. getBaseMatrix(): Matrix;
  5904. /**
  5905. * Gets the rest pose matrix
  5906. * @returns a matrix
  5907. */
  5908. getRestPose(): Matrix;
  5909. /**
  5910. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5911. */
  5912. getWorldMatrix(): Matrix;
  5913. /**
  5914. * Sets the local matrix to rest pose matrix
  5915. */
  5916. returnToRest(): void;
  5917. /**
  5918. * Gets the inverse of the absolute transform matrix.
  5919. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5920. * @returns a matrix
  5921. */
  5922. getInvertedAbsoluteTransform(): Matrix;
  5923. /**
  5924. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5925. * @returns a matrix
  5926. */
  5927. getAbsoluteTransform(): Matrix;
  5928. /** Gets or sets current position (in local space) */
  5929. position: Vector3;
  5930. /** Gets or sets current rotation (in local space) */
  5931. rotation: Vector3;
  5932. /** Gets or sets current rotation quaternion (in local space) */
  5933. rotationQuaternion: Quaternion;
  5934. /** Gets or sets current scaling (in local space) */
  5935. scaling: Vector3;
  5936. /**
  5937. * Gets the animation properties override
  5938. */
  5939. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5940. private _decompose;
  5941. private _compose;
  5942. /**
  5943. * Update the base and local matrices
  5944. * @param matrix defines the new base or local matrix
  5945. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5946. * @param updateLocalMatrix defines if the local matrix should be updated
  5947. */
  5948. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5949. /** @hidden */
  5950. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5951. /**
  5952. * Flag the bone as dirty (Forcing it to update everything)
  5953. */
  5954. markAsDirty(): void;
  5955. private _markAsDirtyAndCompose;
  5956. private _markAsDirtyAndDecompose;
  5957. /**
  5958. * Copy an animation range from another bone
  5959. * @param source defines the source bone
  5960. * @param rangeName defines the range name to copy
  5961. * @param frameOffset defines the frame offset
  5962. * @param rescaleAsRequired defines if rescaling must be applied if required
  5963. * @param skelDimensionsRatio defines the scaling ratio
  5964. * @returns true if operation was successful
  5965. */
  5966. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5967. /**
  5968. * Translate the bone in local or world space
  5969. * @param vec The amount to translate the bone
  5970. * @param space The space that the translation is in
  5971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5972. */
  5973. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5974. /**
  5975. * Set the postion of the bone in local or world space
  5976. * @param position The position to set the bone
  5977. * @param space The space that the position is in
  5978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5979. */
  5980. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5981. /**
  5982. * Set the absolute position of the bone (world space)
  5983. * @param position The position to set the bone
  5984. * @param mesh The mesh that this bone is attached to
  5985. */
  5986. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5987. /**
  5988. * Scale the bone on the x, y and z axes (in local space)
  5989. * @param x The amount to scale the bone on the x axis
  5990. * @param y The amount to scale the bone on the y axis
  5991. * @param z The amount to scale the bone on the z axis
  5992. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5993. */
  5994. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5995. /**
  5996. * Set the bone scaling in local space
  5997. * @param scale defines the scaling vector
  5998. */
  5999. setScale(scale: Vector3): void;
  6000. /**
  6001. * Gets the current scaling in local space
  6002. * @returns the current scaling vector
  6003. */
  6004. getScale(): Vector3;
  6005. /**
  6006. * Gets the current scaling in local space and stores it in a target vector
  6007. * @param result defines the target vector
  6008. */
  6009. getScaleToRef(result: Vector3): void;
  6010. /**
  6011. * Set the yaw, pitch, and roll of the bone in local or world space
  6012. * @param yaw The rotation of the bone on the y axis
  6013. * @param pitch The rotation of the bone on the x axis
  6014. * @param roll The rotation of the bone on the z axis
  6015. * @param space The space that the axes of rotation are in
  6016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6017. */
  6018. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6019. /**
  6020. * Add a rotation to the bone on an axis in local or world space
  6021. * @param axis The axis to rotate the bone on
  6022. * @param amount The amount to rotate the bone
  6023. * @param space The space that the axis is in
  6024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6025. */
  6026. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6027. /**
  6028. * Set the rotation of the bone to a particular axis angle in local or world space
  6029. * @param axis The axis to rotate the bone on
  6030. * @param angle The angle that the bone should be rotated to
  6031. * @param space The space that the axis is in
  6032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6033. */
  6034. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6035. /**
  6036. * Set the euler rotation of the bone in local of world space
  6037. * @param rotation The euler rotation that the bone should be set to
  6038. * @param space The space that the rotation is in
  6039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6040. */
  6041. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6042. /**
  6043. * Set the quaternion rotation of the bone in local of world space
  6044. * @param quat The quaternion rotation that the bone should be set to
  6045. * @param space The space that the rotation is in
  6046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6047. */
  6048. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6049. /**
  6050. * Set the rotation matrix of the bone in local of world space
  6051. * @param rotMat The rotation matrix that the bone should be set to
  6052. * @param space The space that the rotation is in
  6053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6054. */
  6055. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6056. private _rotateWithMatrix;
  6057. private _getNegativeRotationToRef;
  6058. /**
  6059. * Get the position of the bone in local or world space
  6060. * @param space The space that the returned position is in
  6061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6062. * @returns The position of the bone
  6063. */
  6064. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6065. /**
  6066. * Copy the position of the bone to a vector3 in local or world space
  6067. * @param space The space that the returned position is in
  6068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6069. * @param result The vector3 to copy the position to
  6070. */
  6071. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6072. /**
  6073. * Get the absolute position of the bone (world space)
  6074. * @param mesh The mesh that this bone is attached to
  6075. * @returns The absolute position of the bone
  6076. */
  6077. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6078. /**
  6079. * Copy the absolute position of the bone (world space) to the result param
  6080. * @param mesh The mesh that this bone is attached to
  6081. * @param result The vector3 to copy the absolute position to
  6082. */
  6083. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6084. /**
  6085. * Compute the absolute transforms of this bone and its children
  6086. */
  6087. computeAbsoluteTransforms(): void;
  6088. /**
  6089. * Get the world direction from an axis that is in the local space of the bone
  6090. * @param localAxis The local direction that is used to compute the world direction
  6091. * @param mesh The mesh that this bone is attached to
  6092. * @returns The world direction
  6093. */
  6094. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6095. /**
  6096. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6097. * @param localAxis The local direction that is used to compute the world direction
  6098. * @param mesh The mesh that this bone is attached to
  6099. * @param result The vector3 that the world direction will be copied to
  6100. */
  6101. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6102. /**
  6103. * Get the euler rotation of the bone in local or world space
  6104. * @param space The space that the rotation should be in
  6105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6106. * @returns The euler rotation
  6107. */
  6108. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6109. /**
  6110. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6111. * @param space The space that the rotation should be in
  6112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6113. * @param result The vector3 that the rotation should be copied to
  6114. */
  6115. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6116. /**
  6117. * Get the quaternion rotation of the bone in either local or world space
  6118. * @param space The space that the rotation should be in
  6119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6120. * @returns The quaternion rotation
  6121. */
  6122. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6123. /**
  6124. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6125. * @param space The space that the rotation should be in
  6126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6127. * @param result The quaternion that the rotation should be copied to
  6128. */
  6129. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6130. /**
  6131. * Get the rotation matrix of the bone in local or world space
  6132. * @param space The space that the rotation should be in
  6133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6134. * @returns The rotation matrix
  6135. */
  6136. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6137. /**
  6138. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6139. * @param space The space that the rotation should be in
  6140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6141. * @param result The quaternion that the rotation should be copied to
  6142. */
  6143. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6144. /**
  6145. * Get the world position of a point that is in the local space of the bone
  6146. * @param position The local position
  6147. * @param mesh The mesh that this bone is attached to
  6148. * @returns The world position
  6149. */
  6150. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6151. /**
  6152. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6153. * @param position The local position
  6154. * @param mesh The mesh that this bone is attached to
  6155. * @param result The vector3 that the world position should be copied to
  6156. */
  6157. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6158. /**
  6159. * Get the local position of a point that is in world space
  6160. * @param position The world position
  6161. * @param mesh The mesh that this bone is attached to
  6162. * @returns The local position
  6163. */
  6164. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6165. /**
  6166. * Get the local position of a point that is in world space and copy it to the result param
  6167. * @param position The world position
  6168. * @param mesh The mesh that this bone is attached to
  6169. * @param result The vector3 that the local position should be copied to
  6170. */
  6171. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6172. }
  6173. }
  6174. declare module BABYLON {
  6175. /**
  6176. * Class used to apply inverse kinematics to bones
  6177. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6178. */
  6179. class BoneIKController {
  6180. private static _tmpVecs;
  6181. private static _tmpQuat;
  6182. private static _tmpMats;
  6183. /**
  6184. * Gets or sets the target mesh
  6185. */
  6186. targetMesh: AbstractMesh;
  6187. /** Gets or sets the mesh used as pole */
  6188. poleTargetMesh: AbstractMesh;
  6189. /**
  6190. * Gets or sets the bone used as pole
  6191. */
  6192. poleTargetBone: Nullable<Bone>;
  6193. /**
  6194. * Gets or sets the target position
  6195. */
  6196. targetPosition: Vector3;
  6197. /**
  6198. * Gets or sets the pole target position
  6199. */
  6200. poleTargetPosition: Vector3;
  6201. /**
  6202. * Gets or sets the pole target local offset
  6203. */
  6204. poleTargetLocalOffset: Vector3;
  6205. /**
  6206. * Gets or sets the pole angle
  6207. */
  6208. poleAngle: number;
  6209. /**
  6210. * Gets or sets the mesh associated with the controller
  6211. */
  6212. mesh: AbstractMesh;
  6213. /**
  6214. * 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)
  6215. */
  6216. slerpAmount: number;
  6217. private _bone1Quat;
  6218. private _bone1Mat;
  6219. private _bone2Ang;
  6220. private _bone1;
  6221. private _bone2;
  6222. private _bone1Length;
  6223. private _bone2Length;
  6224. private _maxAngle;
  6225. private _maxReach;
  6226. private _rightHandedSystem;
  6227. private _bendAxis;
  6228. private _slerping;
  6229. private _adjustRoll;
  6230. /**
  6231. * Gets or sets maximum allowed angle
  6232. */
  6233. maxAngle: number;
  6234. /**
  6235. * Creates a new BoneIKController
  6236. * @param mesh defines the mesh to control
  6237. * @param bone defines the bone to control
  6238. * @param options defines options to set up the controller
  6239. */
  6240. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6241. targetMesh?: AbstractMesh;
  6242. poleTargetMesh?: AbstractMesh;
  6243. poleTargetBone?: Bone;
  6244. poleTargetLocalOffset?: Vector3;
  6245. poleAngle?: number;
  6246. bendAxis?: Vector3;
  6247. maxAngle?: number;
  6248. slerpAmount?: number;
  6249. });
  6250. private _setMaxAngle;
  6251. /**
  6252. * Force the controller to update the bones
  6253. */
  6254. update(): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * Class used to make a bone look toward a point in space
  6260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6261. */
  6262. class BoneLookController {
  6263. private static _tmpVecs;
  6264. private static _tmpQuat;
  6265. private static _tmpMats;
  6266. /**
  6267. * The target Vector3 that the bone will look at
  6268. */
  6269. target: Vector3;
  6270. /**
  6271. * The mesh that the bone is attached to
  6272. */
  6273. mesh: AbstractMesh;
  6274. /**
  6275. * The bone that will be looking to the target
  6276. */
  6277. bone: Bone;
  6278. /**
  6279. * The up axis of the coordinate system that is used when the bone is rotated
  6280. */
  6281. upAxis: Vector3;
  6282. /**
  6283. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6284. */
  6285. upAxisSpace: Space;
  6286. /**
  6287. * Used to make an adjustment to the yaw of the bone
  6288. */
  6289. adjustYaw: number;
  6290. /**
  6291. * Used to make an adjustment to the pitch of the bone
  6292. */
  6293. adjustPitch: number;
  6294. /**
  6295. * Used to make an adjustment to the roll of the bone
  6296. */
  6297. adjustRoll: number;
  6298. /**
  6299. * 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)
  6300. */
  6301. slerpAmount: number;
  6302. private _minYaw;
  6303. private _maxYaw;
  6304. private _minPitch;
  6305. private _maxPitch;
  6306. private _minYawSin;
  6307. private _minYawCos;
  6308. private _maxYawSin;
  6309. private _maxYawCos;
  6310. private _midYawConstraint;
  6311. private _minPitchTan;
  6312. private _maxPitchTan;
  6313. private _boneQuat;
  6314. private _slerping;
  6315. private _transformYawPitch;
  6316. private _transformYawPitchInv;
  6317. private _firstFrameSkipped;
  6318. private _yawRange;
  6319. private _fowardAxis;
  6320. /**
  6321. * Gets or sets the minimum yaw angle that the bone can look to
  6322. */
  6323. minYaw: number;
  6324. /**
  6325. * Gets or sets the maximum yaw angle that the bone can look to
  6326. */
  6327. maxYaw: number;
  6328. /**
  6329. * Gets or sets the minimum pitch angle that the bone can look to
  6330. */
  6331. minPitch: number;
  6332. /**
  6333. * Gets or sets the maximum pitch angle that the bone can look to
  6334. */
  6335. maxPitch: number;
  6336. /**
  6337. * Create a BoneLookController
  6338. * @param mesh the mesh that the bone belongs to
  6339. * @param bone the bone that will be looking to the target
  6340. * @param target the target Vector3 to look at
  6341. * @param settings optional settings:
  6342. * * maxYaw: the maximum angle the bone will yaw to
  6343. * * minYaw: the minimum angle the bone will yaw to
  6344. * * maxPitch: the maximum angle the bone will pitch to
  6345. * * minPitch: the minimum angle the bone will yaw to
  6346. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6347. * * upAxis: the up axis of the coordinate system
  6348. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6349. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6350. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6351. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6352. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6353. * * adjustRoll: used to make an adjustment to the roll of the bone
  6354. **/
  6355. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6356. maxYaw?: number;
  6357. minYaw?: number;
  6358. maxPitch?: number;
  6359. minPitch?: number;
  6360. slerpAmount?: number;
  6361. upAxis?: Vector3;
  6362. upAxisSpace?: Space;
  6363. yawAxis?: Vector3;
  6364. pitchAxis?: Vector3;
  6365. adjustYaw?: number;
  6366. adjustPitch?: number;
  6367. adjustRoll?: number;
  6368. });
  6369. /**
  6370. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6371. */
  6372. update(): void;
  6373. private _getAngleDiff;
  6374. private _getAngleBetween;
  6375. private _isAngleBetween;
  6376. }
  6377. }
  6378. declare module BABYLON {
  6379. /**
  6380. * Class used to handle skinning animations
  6381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6382. */
  6383. class Skeleton implements IAnimatable {
  6384. /** defines the skeleton name */
  6385. name: string;
  6386. /** defines the skeleton Id */
  6387. id: string;
  6388. /**
  6389. * Gets the list of child bones
  6390. */
  6391. bones: Bone[];
  6392. /**
  6393. * Gets an estimate of the dimension of the skeleton at rest
  6394. */
  6395. dimensionsAtRest: Vector3;
  6396. /**
  6397. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6398. */
  6399. needInitialSkinMatrix: boolean;
  6400. /**
  6401. * Gets the list of animations attached to this skeleton
  6402. */
  6403. animations: Array<Animation>;
  6404. private _scene;
  6405. private _isDirty;
  6406. private _transformMatrices;
  6407. private _meshesWithPoseMatrix;
  6408. private _animatables;
  6409. private _identity;
  6410. private _synchronizedWithMesh;
  6411. private _ranges;
  6412. private _lastAbsoluteTransformsUpdateId;
  6413. /**
  6414. * Specifies if the skeleton should be serialized
  6415. */
  6416. doNotSerialize: boolean;
  6417. private _animationPropertiesOverride;
  6418. /**
  6419. * Gets or sets the animation properties override
  6420. */
  6421. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6422. /**
  6423. * An observable triggered before computing the skeleton's matrices
  6424. */
  6425. onBeforeComputeObservable: Observable<Skeleton>;
  6426. /**
  6427. * Creates a new skeleton
  6428. * @param name defines the skeleton name
  6429. * @param id defines the skeleton Id
  6430. * @param scene defines the hosting scene
  6431. */
  6432. constructor(
  6433. /** defines the skeleton name */
  6434. name: string,
  6435. /** defines the skeleton Id */
  6436. id: string, scene: Scene);
  6437. /**
  6438. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6439. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6440. * @returns a Float32Array containing matrices data
  6441. */
  6442. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6443. /**
  6444. * Gets the current hosting scene
  6445. * @returns a scene object
  6446. */
  6447. getScene(): Scene;
  6448. /**
  6449. * Gets a string representing the current skeleton data
  6450. * @param fullDetails defines a boolean indicating if we want a verbose version
  6451. * @returns a string representing the current skeleton data
  6452. */
  6453. toString(fullDetails?: boolean): string;
  6454. /**
  6455. * Get bone's index searching by name
  6456. * @param name defines bone's name to search for
  6457. * @return the indice of the bone. Returns -1 if not found
  6458. */
  6459. getBoneIndexByName(name: string): number;
  6460. /**
  6461. * Creater a new animation range
  6462. * @param name defines the name of the range
  6463. * @param from defines the start key
  6464. * @param to defines the end key
  6465. */
  6466. createAnimationRange(name: string, from: number, to: number): void;
  6467. /**
  6468. * Delete a specific animation range
  6469. * @param name defines the name of the range
  6470. * @param deleteFrames defines if frames must be removed as well
  6471. */
  6472. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6473. /**
  6474. * Gets a specific animation range
  6475. * @param name defines the name of the range to look for
  6476. * @returns the requested animation range or null if not found
  6477. */
  6478. getAnimationRange(name: string): Nullable<AnimationRange>;
  6479. /**
  6480. * Gets the list of all animation ranges defined on this skeleton
  6481. * @returns an array
  6482. */
  6483. getAnimationRanges(): Nullable<AnimationRange>[];
  6484. /**
  6485. * Copy animation range from a source skeleton.
  6486. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6487. * @param source defines the source skeleton
  6488. * @param name defines the name of the range to copy
  6489. * @param rescaleAsRequired defines if rescaling must be applied if required
  6490. * @returns true if operation was successful
  6491. */
  6492. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6493. /**
  6494. * Forces the skeleton to go to rest pose
  6495. */
  6496. returnToRest(): void;
  6497. private _getHighestAnimationFrame;
  6498. /**
  6499. * Begin a specific animation range
  6500. * @param name defines the name of the range to start
  6501. * @param loop defines if looping must be turned on (false by default)
  6502. * @param speedRatio defines the speed ratio to apply (1 by default)
  6503. * @param onAnimationEnd defines a callback which will be called when animation will end
  6504. * @returns a new animatable
  6505. */
  6506. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6507. /** @hidden */
  6508. _markAsDirty(): void;
  6509. /** @hidden */
  6510. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6511. /** @hidden */
  6512. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6513. /** @hidden */
  6514. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6515. /**
  6516. * Build all resources required to render a skeleton
  6517. */
  6518. prepare(): void;
  6519. /**
  6520. * Gets the list of animatables currently running for this skeleton
  6521. * @returns an array of animatables
  6522. */
  6523. getAnimatables(): IAnimatable[];
  6524. /**
  6525. * Clone the current skeleton
  6526. * @param name defines the name of the new skeleton
  6527. * @param id defines the id of the enw skeleton
  6528. * @returns the new skeleton
  6529. */
  6530. clone(name: string, id: string): Skeleton;
  6531. /**
  6532. * Enable animation blending for this skeleton
  6533. * @param blendingSpeed defines the blending speed to apply
  6534. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6535. */
  6536. enableBlending(blendingSpeed?: number): void;
  6537. /**
  6538. * Releases all resources associated with the current skeleton
  6539. */
  6540. dispose(): void;
  6541. /**
  6542. * Serialize the skeleton in a JSON object
  6543. * @returns a JSON object
  6544. */
  6545. serialize(): any;
  6546. /**
  6547. * Creates a new skeleton from serialized data
  6548. * @param parsedSkeleton defines the serialized data
  6549. * @param scene defines the hosting scene
  6550. * @returns a new skeleton
  6551. */
  6552. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6553. /**
  6554. * Compute all node absolute transforms
  6555. * @param forceUpdate defines if computation must be done even if cache is up to date
  6556. */
  6557. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6558. /**
  6559. * Gets the root pose matrix
  6560. * @returns a matrix
  6561. */
  6562. getPoseMatrix(): Nullable<Matrix>;
  6563. /**
  6564. * Sorts bones per internal index
  6565. */
  6566. sortBones(): void;
  6567. private _sortBones;
  6568. }
  6569. }
  6570. declare module BABYLON {
  6571. /** @hidden */
  6572. class Collider {
  6573. /** Define if a collision was found */
  6574. collisionFound: boolean;
  6575. /**
  6576. * Define last intersection point in local space
  6577. */
  6578. intersectionPoint: Vector3;
  6579. /**
  6580. * Define last collided mesh
  6581. */
  6582. collidedMesh: Nullable<AbstractMesh>;
  6583. private _collisionPoint;
  6584. private _planeIntersectionPoint;
  6585. private _tempVector;
  6586. private _tempVector2;
  6587. private _tempVector3;
  6588. private _tempVector4;
  6589. private _edge;
  6590. private _baseToVertex;
  6591. private _destinationPoint;
  6592. private _slidePlaneNormal;
  6593. private _displacementVector;
  6594. /** @hidden */
  6595. _radius: Vector3;
  6596. /** @hidden */
  6597. _retry: number;
  6598. private _velocity;
  6599. private _basePoint;
  6600. private _epsilon;
  6601. /** @hidden */
  6602. _velocityWorldLength: number;
  6603. /** @hidden */
  6604. _basePointWorld: Vector3;
  6605. private _velocityWorld;
  6606. private _normalizedVelocity;
  6607. /** @hidden */
  6608. _initialVelocity: Vector3;
  6609. /** @hidden */
  6610. _initialPosition: Vector3;
  6611. private _nearestDistance;
  6612. private _collisionMask;
  6613. collisionMask: number;
  6614. /**
  6615. * Gets the plane normal used to compute the sliding response (in local space)
  6616. */
  6617. readonly slidePlaneNormal: Vector3;
  6618. /** @hidden */
  6619. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6620. /** @hidden */
  6621. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6622. /** @hidden */
  6623. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6624. /** @hidden */
  6625. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6626. /** @hidden */
  6627. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6628. /** @hidden */
  6629. _getResponse(pos: Vector3, vel: Vector3): void;
  6630. }
  6631. }
  6632. declare module BABYLON {
  6633. /** @hidden */
  6634. var CollisionWorker: string;
  6635. /** @hidden */
  6636. interface ICollisionCoordinator {
  6637. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6638. init(scene: Scene): void;
  6639. destroy(): void;
  6640. onMeshAdded(mesh: AbstractMesh): void;
  6641. onMeshUpdated(mesh: AbstractMesh): void;
  6642. onMeshRemoved(mesh: AbstractMesh): void;
  6643. onGeometryAdded(geometry: Geometry): void;
  6644. onGeometryUpdated(geometry: Geometry): void;
  6645. onGeometryDeleted(geometry: Geometry): void;
  6646. }
  6647. /** @hidden */
  6648. interface SerializedMesh {
  6649. id: string;
  6650. name: string;
  6651. uniqueId: number;
  6652. geometryId: Nullable<string>;
  6653. sphereCenter: Array<number>;
  6654. sphereRadius: number;
  6655. boxMinimum: Array<number>;
  6656. boxMaximum: Array<number>;
  6657. worldMatrixFromCache: any;
  6658. subMeshes: Array<SerializedSubMesh>;
  6659. checkCollisions: boolean;
  6660. }
  6661. /** @hidden */
  6662. interface SerializedSubMesh {
  6663. position: number;
  6664. verticesStart: number;
  6665. verticesCount: number;
  6666. indexStart: number;
  6667. indexCount: number;
  6668. hasMaterial: boolean;
  6669. sphereCenter: Array<number>;
  6670. sphereRadius: number;
  6671. boxMinimum: Array<number>;
  6672. boxMaximum: Array<number>;
  6673. }
  6674. /**
  6675. * Interface describing the value associated with a geometry.
  6676. * @hidden
  6677. */
  6678. interface SerializedGeometry {
  6679. /**
  6680. * Defines the unique ID of the geometry
  6681. */
  6682. id: string;
  6683. /**
  6684. * Defines the array containing the positions
  6685. */
  6686. positions: Float32Array;
  6687. /**
  6688. * Defines the array containing the indices
  6689. */
  6690. indices: Uint32Array;
  6691. /**
  6692. * Defines the array containing the normals
  6693. */
  6694. normals: Float32Array;
  6695. }
  6696. /** @hidden */
  6697. interface BabylonMessage {
  6698. taskType: WorkerTaskType;
  6699. payload: InitPayload | CollidePayload | UpdatePayload;
  6700. }
  6701. /** @hidden */
  6702. interface SerializedColliderToWorker {
  6703. position: Array<number>;
  6704. velocity: Array<number>;
  6705. radius: Array<number>;
  6706. }
  6707. /** Defines supported task for worker process */
  6708. enum WorkerTaskType {
  6709. /** Initialization */
  6710. INIT = 0,
  6711. /** Update of geometry */
  6712. UPDATE = 1,
  6713. /** Evaluate collision */
  6714. COLLIDE = 2
  6715. }
  6716. /** @hidden */
  6717. interface WorkerReply {
  6718. error: WorkerReplyType;
  6719. taskType: WorkerTaskType;
  6720. payload?: any;
  6721. }
  6722. /** @hidden */
  6723. interface CollisionReplyPayload {
  6724. newPosition: Array<number>;
  6725. collisionId: number;
  6726. collidedMeshUniqueId: number;
  6727. }
  6728. /** @hidden */
  6729. interface InitPayload {
  6730. }
  6731. /** @hidden */
  6732. interface CollidePayload {
  6733. collisionId: number;
  6734. collider: SerializedColliderToWorker;
  6735. maximumRetry: number;
  6736. excludedMeshUniqueId: Nullable<number>;
  6737. }
  6738. /** @hidden */
  6739. interface UpdatePayload {
  6740. updatedMeshes: {
  6741. [n: number]: SerializedMesh;
  6742. };
  6743. updatedGeometries: {
  6744. [s: string]: SerializedGeometry;
  6745. };
  6746. removedMeshes: Array<number>;
  6747. removedGeometries: Array<string>;
  6748. }
  6749. /** Defines kind of replies returned by worker */
  6750. enum WorkerReplyType {
  6751. /** Success */
  6752. SUCCESS = 0,
  6753. /** Unkown error */
  6754. UNKNOWN_ERROR = 1
  6755. }
  6756. /** @hidden */
  6757. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6758. private _scene;
  6759. private _scaledPosition;
  6760. private _scaledVelocity;
  6761. private _collisionsCallbackArray;
  6762. private _init;
  6763. private _runningUpdated;
  6764. private _worker;
  6765. private _addUpdateMeshesList;
  6766. private _addUpdateGeometriesList;
  6767. private _toRemoveMeshesArray;
  6768. private _toRemoveGeometryArray;
  6769. constructor();
  6770. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6771. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6772. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6773. init(scene: Scene): void;
  6774. destroy(): void;
  6775. onMeshAdded(mesh: AbstractMesh): void;
  6776. onMeshUpdated: (transformNode: TransformNode) => void;
  6777. onMeshRemoved(mesh: AbstractMesh): void;
  6778. onGeometryAdded(geometry: Geometry): void;
  6779. onGeometryUpdated: (geometry: Geometry) => void;
  6780. onGeometryDeleted(geometry: Geometry): void;
  6781. private _afterRender;
  6782. private _onMessageFromWorker;
  6783. }
  6784. /** @hidden */
  6785. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6786. private _scene;
  6787. private _scaledPosition;
  6788. private _scaledVelocity;
  6789. private _finalPosition;
  6790. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6791. init(scene: Scene): void;
  6792. destroy(): void;
  6793. onMeshAdded(mesh: AbstractMesh): void;
  6794. onMeshUpdated(mesh: AbstractMesh): void;
  6795. onMeshRemoved(mesh: AbstractMesh): void;
  6796. onGeometryAdded(geometry: Geometry): void;
  6797. onGeometryUpdated(geometry: Geometry): void;
  6798. onGeometryDeleted(geometry: Geometry): void;
  6799. private _collideWithWorld;
  6800. }
  6801. }
  6802. declare function importScripts(...urls: string[]): void;
  6803. declare const safePostMessage: any;
  6804. declare module BABYLON {
  6805. /** @hidden */
  6806. var WorkerIncluded: boolean;
  6807. /** @hidden */
  6808. class CollisionCache {
  6809. private _meshes;
  6810. private _geometries;
  6811. getMeshes(): {
  6812. [n: number]: SerializedMesh;
  6813. };
  6814. getGeometries(): {
  6815. [s: number]: SerializedGeometry;
  6816. };
  6817. getMesh(id: any): SerializedMesh;
  6818. addMesh(mesh: SerializedMesh): void;
  6819. removeMesh(uniqueId: number): void;
  6820. getGeometry(id: string): SerializedGeometry;
  6821. addGeometry(geometry: SerializedGeometry): void;
  6822. removeGeometry(id: string): void;
  6823. }
  6824. /** @hidden */
  6825. class CollideWorker {
  6826. collider: Collider;
  6827. private _collisionCache;
  6828. private finalPosition;
  6829. private collisionsScalingMatrix;
  6830. private collisionTranformationMatrix;
  6831. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6832. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6833. private checkCollision;
  6834. private processCollisionsForSubMeshes;
  6835. private collideForSubMesh;
  6836. private checkSubmeshCollision;
  6837. }
  6838. /** @hidden */
  6839. interface ICollisionDetector {
  6840. onInit(payload: InitPayload): void;
  6841. onUpdate(payload: UpdatePayload): void;
  6842. onCollision(payload: CollidePayload): void;
  6843. }
  6844. /** @hidden */
  6845. class CollisionDetectorTransferable implements ICollisionDetector {
  6846. private _collisionCache;
  6847. onInit(payload: InitPayload): void;
  6848. onUpdate(payload: UpdatePayload): void;
  6849. onCollision(payload: CollidePayload): void;
  6850. }
  6851. }
  6852. declare module BABYLON {
  6853. /**
  6854. * @hidden
  6855. */
  6856. class IntersectionInfo {
  6857. bu: Nullable<number>;
  6858. bv: Nullable<number>;
  6859. distance: number;
  6860. faceId: number;
  6861. subMeshId: number;
  6862. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6863. }
  6864. /**
  6865. * Information about the result of picking within a scene
  6866. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6867. */
  6868. class PickingInfo {
  6869. /**
  6870. * If the pick collided with an object
  6871. */
  6872. hit: boolean;
  6873. /**
  6874. * Distance away where the pick collided
  6875. */
  6876. distance: number;
  6877. /**
  6878. * The location of pick collision
  6879. */
  6880. pickedPoint: Nullable<Vector3>;
  6881. /**
  6882. * The mesh corresponding the the pick collision
  6883. */
  6884. pickedMesh: Nullable<AbstractMesh>;
  6885. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6886. bu: number;
  6887. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6888. bv: number;
  6889. /** The id of the face on the mesh that was picked */
  6890. faceId: number;
  6891. /** Id of the the submesh that was picked */
  6892. subMeshId: number;
  6893. /** If a sprite was picked, this will be the sprite the pick collided with */
  6894. pickedSprite: Nullable<Sprite>;
  6895. /**
  6896. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6897. */
  6898. originMesh: Nullable<AbstractMesh>;
  6899. /**
  6900. * The ray that was used to perform the picking.
  6901. */
  6902. ray: Nullable<Ray>;
  6903. /**
  6904. * Gets the normal correspodning to the face the pick collided with
  6905. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6906. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6907. * @returns The normal correspodning to the face the pick collided with
  6908. */
  6909. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6910. /**
  6911. * Gets the texture coordinates of where the pick occured
  6912. * @returns the vector containing the coordnates of the texture
  6913. */
  6914. getTextureCoordinates(): Nullable<Vector2>;
  6915. }
  6916. }
  6917. declare module BABYLON {
  6918. /**
  6919. * This represents an orbital type of camera.
  6920. *
  6921. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  6922. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  6923. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6924. */
  6925. class ArcRotateCamera extends TargetCamera {
  6926. /**
  6927. * Defines the rotation angle of the camera along the longitudinal axis.
  6928. */
  6929. alpha: number;
  6930. /**
  6931. * Defines the rotation angle of the camera along the latitudinal axis.
  6932. */
  6933. beta: number;
  6934. /**
  6935. * Defines the radius of the camera from it s target point.
  6936. */
  6937. radius: number;
  6938. protected _target: Vector3;
  6939. protected _targetHost: Nullable<AbstractMesh>;
  6940. /**
  6941. * Defines the target point of the camera.
  6942. * The camera looks towards it form the radius distance.
  6943. */
  6944. target: Vector3;
  6945. /**
  6946. * Current inertia value on the longitudinal axis.
  6947. * The bigger this number the longer it will take for the camera to stop.
  6948. */
  6949. inertialAlphaOffset: number;
  6950. /**
  6951. * Current inertia value on the latitudinal axis.
  6952. * The bigger this number the longer it will take for the camera to stop.
  6953. */
  6954. inertialBetaOffset: number;
  6955. /**
  6956. * Current inertia value on the radius axis.
  6957. * The bigger this number the longer it will take for the camera to stop.
  6958. */
  6959. inertialRadiusOffset: number;
  6960. /**
  6961. * Minimum allowed angle on the longitudinal axis.
  6962. * This can help limiting how the Camera is able to move in the scene.
  6963. */
  6964. lowerAlphaLimit: Nullable<number>;
  6965. /**
  6966. * Maximum allowed angle on the longitudinal axis.
  6967. * This can help limiting how the Camera is able to move in the scene.
  6968. */
  6969. upperAlphaLimit: Nullable<number>;
  6970. /**
  6971. * Minimum allowed angle on the latitudinal axis.
  6972. * This can help limiting how the Camera is able to move in the scene.
  6973. */
  6974. lowerBetaLimit: number;
  6975. /**
  6976. * Maximum allowed angle on the latitudinal axis.
  6977. * This can help limiting how the Camera is able to move in the scene.
  6978. */
  6979. upperBetaLimit: number;
  6980. /**
  6981. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6982. * This can help limiting how the Camera is able to move in the scene.
  6983. */
  6984. lowerRadiusLimit: Nullable<number>;
  6985. /**
  6986. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6987. * This can help limiting how the Camera is able to move in the scene.
  6988. */
  6989. upperRadiusLimit: Nullable<number>;
  6990. /**
  6991. * Defines the current inertia value used during panning of the camera along the X axis.
  6992. */
  6993. inertialPanningX: number;
  6994. /**
  6995. * Defines the current inertia value used during panning of the camera along the Y axis.
  6996. */
  6997. inertialPanningY: number;
  6998. /**
  6999. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7000. * Basically if your fingers moves away from more than this distance you will be considered
  7001. * in pinch mode.
  7002. */
  7003. pinchToPanMaxDistance: number;
  7004. /**
  7005. * Defines the maximum distance the camera can pan.
  7006. * This could help keeping the cammera always in your scene.
  7007. */
  7008. panningDistanceLimit: Nullable<number>;
  7009. /**
  7010. * Defines the target of the camera before paning.
  7011. */
  7012. panningOriginTarget: Vector3;
  7013. /**
  7014. * Defines the value of the inertia used during panning.
  7015. * 0 would mean stop inertia and one would mean no decelleration at all.
  7016. */
  7017. panningInertia: number;
  7018. /**
  7019. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7020. */
  7021. angularSensibilityX: number;
  7022. /**
  7023. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7024. */
  7025. angularSensibilityY: number;
  7026. /**
  7027. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7028. */
  7029. pinchPrecision: number;
  7030. /**
  7031. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7032. * It will be used instead of pinchDeltaPrecision if different from 0.
  7033. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7034. */
  7035. pinchDeltaPercentage: number;
  7036. /**
  7037. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7038. */
  7039. panningSensibility: number;
  7040. /**
  7041. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7042. */
  7043. keysUp: number[];
  7044. /**
  7045. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7046. */
  7047. keysDown: number[];
  7048. /**
  7049. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7050. */
  7051. keysLeft: number[];
  7052. /**
  7053. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7054. */
  7055. keysRight: number[];
  7056. /**
  7057. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7058. */
  7059. wheelPrecision: number;
  7060. /**
  7061. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7062. * It will be used instead of pinchDeltaPrecision if different from 0.
  7063. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7064. */
  7065. wheelDeltaPercentage: number;
  7066. /**
  7067. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7068. */
  7069. zoomOnFactor: number;
  7070. /**
  7071. * Defines a screen offset for the camera position.
  7072. */
  7073. targetScreenOffset: Vector2;
  7074. /**
  7075. * Allows the camera to be completely reversed.
  7076. * If false the camera can not arrive upside down.
  7077. */
  7078. allowUpsideDown: boolean;
  7079. /**
  7080. * Define if double tap/click is used to restore the previously saved state of the camera.
  7081. */
  7082. useInputToRestoreState: boolean;
  7083. /** @hidden */
  7084. _viewMatrix: Matrix;
  7085. /** @hidden */
  7086. _useCtrlForPanning: boolean;
  7087. /** @hidden */
  7088. _panningMouseButton: number;
  7089. /**
  7090. * Defines the inpute associated to the camera.
  7091. */
  7092. inputs: ArcRotateCameraInputsManager;
  7093. /** @hidden */
  7094. _reset: () => void;
  7095. /**
  7096. * Defines the allowed panning axis.
  7097. */
  7098. panningAxis: Vector3;
  7099. protected _localDirection: Vector3;
  7100. protected _transformedDirection: Vector3;
  7101. private _bouncingBehavior;
  7102. /**
  7103. * Gets the bouncing behavior of the camera if it has been enabled.
  7104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7105. */
  7106. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7107. /**
  7108. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7110. */
  7111. useBouncingBehavior: boolean;
  7112. private _framingBehavior;
  7113. /**
  7114. * Gets the framing behavior of the camera if it has been enabled.
  7115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7116. */
  7117. readonly framingBehavior: Nullable<FramingBehavior>;
  7118. /**
  7119. * Defines if the framing behavior of the camera is enabled on the camera.
  7120. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7121. */
  7122. useFramingBehavior: boolean;
  7123. private _autoRotationBehavior;
  7124. /**
  7125. * Gets the auto rotation behavior of the camera if it has been enabled.
  7126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7127. */
  7128. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7129. /**
  7130. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7132. */
  7133. useAutoRotationBehavior: boolean;
  7134. /**
  7135. * Observable triggered when the mesh target has been changed on the camera.
  7136. */
  7137. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7138. /**
  7139. * Event raised when the camera is colliding with a mesh.
  7140. */
  7141. onCollide: (collidedMesh: AbstractMesh) => void;
  7142. /**
  7143. * Defines whether the camera should check collision with the objects oh the scene.
  7144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7145. */
  7146. checkCollisions: boolean;
  7147. /**
  7148. * Defines the collision radius of the camera.
  7149. * This simulates a sphere around the camera.
  7150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7151. */
  7152. collisionRadius: Vector3;
  7153. protected _collider: Collider;
  7154. protected _previousPosition: Vector3;
  7155. protected _collisionVelocity: Vector3;
  7156. protected _newPosition: Vector3;
  7157. protected _previousAlpha: number;
  7158. protected _previousBeta: number;
  7159. protected _previousRadius: number;
  7160. protected _collisionTriggered: boolean;
  7161. protected _targetBoundingCenter: Nullable<Vector3>;
  7162. private _computationVector;
  7163. /**
  7164. * Instantiates a new ArcRotateCamera in a given scene
  7165. * @param name Defines the name of the camera
  7166. * @param alpha Defines the camera rotation along the logitudinal axis
  7167. * @param beta Defines the camera rotation along the latitudinal axis
  7168. * @param radius Defines the camera distance from its target
  7169. * @param target Defines the camera target
  7170. * @param scene Defines the scene the camera belongs to
  7171. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7172. */
  7173. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7174. /** @hidden */
  7175. _initCache(): void;
  7176. /** @hidden */
  7177. _updateCache(ignoreParentClass?: boolean): void;
  7178. protected _getTargetPosition(): Vector3;
  7179. private _storedAlpha;
  7180. private _storedBeta;
  7181. private _storedRadius;
  7182. private _storedTarget;
  7183. /**
  7184. * Stores the current state of the camera (alpha, beta, radius and target)
  7185. * @returns the camera itself
  7186. */
  7187. storeState(): Camera;
  7188. /**
  7189. * @hidden
  7190. * Restored camera state. You must call storeState() first
  7191. */
  7192. _restoreStateValues(): boolean;
  7193. /** @hidden */
  7194. _isSynchronizedViewMatrix(): boolean;
  7195. /**
  7196. * Attached controls to the current camera.
  7197. * @param element Defines the element the controls should be listened from
  7198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7199. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7200. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7201. */
  7202. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7203. /**
  7204. * Detach the current controls from the camera.
  7205. * The camera will stop reacting to inputs.
  7206. * @param element Defines the element to stop listening the inputs from
  7207. */
  7208. detachControl(element: HTMLElement): void;
  7209. /** @hidden */
  7210. _checkInputs(): void;
  7211. protected _checkLimits(): void;
  7212. /**
  7213. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7214. */
  7215. rebuildAnglesAndRadius(): void;
  7216. /**
  7217. * Use a position to define the current camera related information like aplha, beta and radius
  7218. * @param position Defines the position to set the camera at
  7219. */
  7220. setPosition(position: Vector3): void;
  7221. /**
  7222. * Defines the target the camera should look at.
  7223. * This will automatically adapt alpha beta and radius to fit within the new target.
  7224. * @param target Defines the new target as a Vector or a mesh
  7225. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7226. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7227. */
  7228. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7229. /** @hidden */
  7230. _getViewMatrix(): Matrix;
  7231. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7232. /**
  7233. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7234. * @param meshes Defines the mesh to zoom on
  7235. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  7236. */
  7237. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7238. /**
  7239. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7240. * The target will be changed but the radius
  7241. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7242. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  7243. */
  7244. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7245. min: Vector3;
  7246. max: Vector3;
  7247. distance: number;
  7248. }, doNotUpdateMaxZ?: boolean): void;
  7249. /**
  7250. * @override
  7251. * Override Camera.createRigCamera
  7252. */
  7253. createRigCamera(name: string, cameraIndex: number): Camera;
  7254. /**
  7255. * @hidden
  7256. * @override
  7257. * Override Camera._updateRigCameras
  7258. */
  7259. _updateRigCameras(): void;
  7260. /**
  7261. * Destroy the camera and release the current resources hold by it.
  7262. */
  7263. dispose(): void;
  7264. /**
  7265. * Gets the current object class name.
  7266. * @return the class name
  7267. */
  7268. getClassName(): string;
  7269. }
  7270. }
  7271. declare module BABYLON {
  7272. /**
  7273. * Default Inputs manager for the ArcRotateCamera.
  7274. * It groups all the default supported inputs for ease of use.
  7275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7276. */
  7277. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7278. /**
  7279. * Instantiates a new ArcRotateCameraInputsManager.
  7280. * @param camera Defines the camera the inputs belong to
  7281. */
  7282. constructor(camera: ArcRotateCamera);
  7283. /**
  7284. * Add mouse wheel input support to the input manager.
  7285. * @returns the current input manager
  7286. */
  7287. addMouseWheel(): ArcRotateCameraInputsManager;
  7288. /**
  7289. * Add pointers input support to the input manager.
  7290. * @returns the current input manager
  7291. */
  7292. addPointers(): ArcRotateCameraInputsManager;
  7293. /**
  7294. * Add keyboard input support to the input manager.
  7295. * @returns the current input manager
  7296. */
  7297. addKeyboard(): ArcRotateCameraInputsManager;
  7298. /**
  7299. * Add orientation input support to the input manager.
  7300. * @returns the current input manager
  7301. */
  7302. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7303. }
  7304. }
  7305. declare module BABYLON {
  7306. /**
  7307. * This is the base class of all the camera used in the application.
  7308. * @see http://doc.babylonjs.com/features/cameras
  7309. */
  7310. class Camera extends Node {
  7311. /**
  7312. * This is the default projection mode used by the cameras.
  7313. * It helps recreating a feeling of perspective and better appreciate depth.
  7314. * This is the best way to simulate real life cameras.
  7315. */
  7316. static readonly PERSPECTIVE_CAMERA: number;
  7317. /**
  7318. * This helps creating camera with an orthographic mode.
  7319. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  7320. */
  7321. static readonly ORTHOGRAPHIC_CAMERA: number;
  7322. /**
  7323. * This is the default FOV mode for perspective cameras.
  7324. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7325. */
  7326. static readonly FOVMODE_VERTICAL_FIXED: number;
  7327. /**
  7328. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7329. */
  7330. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7331. /**
  7332. * This specifies ther is no need for a camera rig.
  7333. * Basically only one eye is rendered corresponding to the camera.
  7334. */
  7335. static readonly RIG_MODE_NONE: number;
  7336. /**
  7337. * Simulates a camera Rig with one blue eye and one red eye.
  7338. * This can be use with 3d blue and red glasses.
  7339. */
  7340. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7341. /**
  7342. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7343. */
  7344. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7345. /**
  7346. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7347. */
  7348. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7349. /**
  7350. * Defines that both eyes of the camera will be rendered over under each other.
  7351. */
  7352. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7353. /**
  7354. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7355. */
  7356. static readonly RIG_MODE_VR: number;
  7357. /**
  7358. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7359. */
  7360. static readonly RIG_MODE_WEBVR: number;
  7361. /**
  7362. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7363. */
  7364. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7365. /**
  7366. * @hidden
  7367. * Might be removed once multiview will be a thing
  7368. */
  7369. static UseAlternateWebVRRendering: boolean;
  7370. /**
  7371. * Define the input manager associated with the camera.
  7372. */
  7373. inputs: CameraInputsManager<Camera>;
  7374. /**
  7375. * Define the current local position of the camera in the scene
  7376. */
  7377. position: Vector3;
  7378. /**
  7379. * The vector the camera should consider as up.
  7380. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7381. */
  7382. upVector: Vector3;
  7383. /**
  7384. * Define the current limit on the left side for an orthographic camera
  7385. * In scene unit
  7386. */
  7387. orthoLeft: Nullable<number>;
  7388. /**
  7389. * Define the current limit on the right side for an orthographic camera
  7390. * In scene unit
  7391. */
  7392. orthoRight: Nullable<number>;
  7393. /**
  7394. * Define the current limit on the bottom side for an orthographic camera
  7395. * In scene unit
  7396. */
  7397. orthoBottom: Nullable<number>;
  7398. /**
  7399. * Define the current limit on the top side for an orthographic camera
  7400. * In scene unit
  7401. */
  7402. orthoTop: Nullable<number>;
  7403. /**
  7404. * Field Of View is set in Radians. (default is 0.8)
  7405. */
  7406. fov: number;
  7407. /**
  7408. * Define the minimum distance the camera can see from.
  7409. * This is important to note that the depth buffer are not infinite and the closer it starts
  7410. * the more your scene might encounter depth fighting issue.
  7411. */
  7412. minZ: number;
  7413. /**
  7414. * Define the maximum distance the camera can see to.
  7415. * This is important to note that the depth buffer are not infinite and the further it end
  7416. * the more your scene might encounter depth fighting issue.
  7417. */
  7418. maxZ: number;
  7419. /**
  7420. * Define the default inertia of the camera.
  7421. * This helps giving a smooth feeling to the camera movement.
  7422. */
  7423. inertia: number;
  7424. /**
  7425. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7426. */
  7427. mode: number;
  7428. /**
  7429. * Define wether the camera is intermediate.
  7430. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7431. */
  7432. isIntermediate: boolean;
  7433. /**
  7434. * Define the viewport of the camera.
  7435. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7436. */
  7437. viewport: Viewport;
  7438. /**
  7439. * Restricts the camera to viewing objects with the same layerMask.
  7440. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7441. */
  7442. layerMask: number;
  7443. /**
  7444. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7445. */
  7446. fovMode: number;
  7447. /**
  7448. * Rig mode of the camera.
  7449. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7450. * This is normally controlled byt the camera themselves as internal use.
  7451. */
  7452. cameraRigMode: number;
  7453. /**
  7454. * Defines the distance between both "eyes" in case of a RIG
  7455. */
  7456. interaxialDistance: number;
  7457. /**
  7458. * Defines if stereoscopic rendering is done side by side or over under.
  7459. */
  7460. isStereoscopicSideBySide: boolean;
  7461. /**
  7462. * Defines the list of custom render target the camera should render to.
  7463. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7464. * else in the scene.
  7465. */
  7466. customRenderTargets: RenderTargetTexture[];
  7467. /**
  7468. * Observable triggered when the camera view matrix has changed.
  7469. */
  7470. onViewMatrixChangedObservable: Observable<Camera>;
  7471. /**
  7472. * Observable triggered when the camera Projection matrix has changed.
  7473. */
  7474. onProjectionMatrixChangedObservable: Observable<Camera>;
  7475. /**
  7476. * Observable triggered when the inputs have been processed.
  7477. */
  7478. onAfterCheckInputsObservable: Observable<Camera>;
  7479. /**
  7480. * Observable triggered when reset has been called and applied to the camera.
  7481. */
  7482. onRestoreStateObservable: Observable<Camera>;
  7483. /** @hidden */
  7484. _cameraRigParams: any;
  7485. /** @hidden */
  7486. _rigCameras: Camera[];
  7487. /** @hidden */
  7488. _rigPostProcess: Nullable<PostProcess>;
  7489. protected _webvrViewMatrix: Matrix;
  7490. /** @hidden */
  7491. _skipRendering: boolean;
  7492. /** @hidden */
  7493. _alternateCamera: Camera;
  7494. /** @hidden */
  7495. _projectionMatrix: Matrix;
  7496. /** @hidden */
  7497. _postProcesses: Nullable<PostProcess>[];
  7498. /** @hidden */
  7499. _activeMeshes: SmartArray<AbstractMesh>;
  7500. protected _globalPosition: Vector3;
  7501. private _computedViewMatrix;
  7502. private _doNotComputeProjectionMatrix;
  7503. private _transformMatrix;
  7504. private _frustumPlanes;
  7505. private _refreshFrustumPlanes;
  7506. private _storedFov;
  7507. private _stateStored;
  7508. /**
  7509. * Instantiates a new camera object.
  7510. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7511. * @see http://doc.babylonjs.com/features/cameras
  7512. * @param name Defines the name of the camera in the scene
  7513. * @param position Defines the position of the camera
  7514. * @param scene Defines the scene the camera belongs too
  7515. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7516. */
  7517. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7518. /**
  7519. * Store current camera state (fov, position, etc..)
  7520. * @returns the camera
  7521. */
  7522. storeState(): Camera;
  7523. /**
  7524. * Restores the camera state values if it has been stored. You must call storeState() first
  7525. */
  7526. protected _restoreStateValues(): boolean;
  7527. /**
  7528. * Restored camera state. You must call storeState() first.
  7529. * @returns true if restored and false otherwise
  7530. */
  7531. restoreState(): boolean;
  7532. /**
  7533. * Gets the class name of the camera.
  7534. * @returns the class name
  7535. */
  7536. getClassName(): string;
  7537. /**
  7538. * Gets a string representation of the camera usefull for debug purpose.
  7539. * @param fullDetails Defines that a more verboe level of logging is required
  7540. * @returns the string representation
  7541. */
  7542. toString(fullDetails?: boolean): string;
  7543. /**
  7544. * Gets the current world space position of the camera.
  7545. */
  7546. readonly globalPosition: Vector3;
  7547. /**
  7548. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7549. * @returns the active meshe list
  7550. */
  7551. getActiveMeshes(): SmartArray<AbstractMesh>;
  7552. /**
  7553. * Check wether a mesh is part of the current active mesh list of the camera
  7554. * @param mesh Defines the mesh to check
  7555. * @returns true if active, false otherwise
  7556. */
  7557. isActiveMesh(mesh: Mesh): boolean;
  7558. /**
  7559. * Is this camera ready to be used/rendered
  7560. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7561. * @return true if the camera is ready
  7562. */
  7563. isReady(completeCheck?: boolean): boolean;
  7564. /** @hidden */
  7565. _initCache(): void;
  7566. /** @hidden */
  7567. _updateCache(ignoreParentClass?: boolean): void;
  7568. /** @hidden */
  7569. _isSynchronized(): boolean;
  7570. /** @hidden */
  7571. _isSynchronizedViewMatrix(): boolean;
  7572. /** @hidden */
  7573. _isSynchronizedProjectionMatrix(): boolean;
  7574. /**
  7575. * Attach the input controls to a specific dom element to get the input from.
  7576. * @param element Defines the element the controls should be listened from
  7577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7578. */
  7579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7580. /**
  7581. * Detach the current controls from the specified dom element.
  7582. * @param element Defines the element to stop listening the inputs from
  7583. */
  7584. detachControl(element: HTMLElement): void;
  7585. /**
  7586. * Update the camera state according to the different inputs gathered during the frame.
  7587. */
  7588. update(): void;
  7589. /** @hidden */
  7590. _checkInputs(): void;
  7591. /** @hidden */
  7592. readonly rigCameras: Camera[];
  7593. readonly rigPostProcess: Nullable<PostProcess>;
  7594. /**
  7595. * Internal, gets the first post proces.
  7596. * @returns the first post process to be run on this camera.
  7597. */
  7598. _getFirstPostProcess(): Nullable<PostProcess>;
  7599. private _cascadePostProcessesToRigCams;
  7600. /**
  7601. * Attach a post process to the camera.
  7602. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7603. * @param postProcess The post process to attach to the camera
  7604. * @param insertAt The position of the post process in case several of them are in use in the scene
  7605. * @returns the position the post process has been inserted at
  7606. */
  7607. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7608. /**
  7609. * Detach a post process to the camera.
  7610. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7611. * @param postProcess The post process to detach from the camera
  7612. */
  7613. detachPostProcess(postProcess: PostProcess): void;
  7614. /**
  7615. * Gets the current world matrix of the camera
  7616. */
  7617. getWorldMatrix(): Matrix;
  7618. /** @hidden */
  7619. protected _getViewMatrix(): Matrix;
  7620. /**
  7621. * Gets the current view matrix of the camera.
  7622. * @param force forces the camera to recompute the matrix without looking at the cached state
  7623. * @returns the view matrix
  7624. */
  7625. getViewMatrix(force?: boolean): Matrix;
  7626. /**
  7627. * Freeze the projection matrix.
  7628. * It will prevent the cache check of the camera projection compute and can speed up perf
  7629. * if no parameter of the camera are meant to change
  7630. * @param projection Defines manually a projection if necessary
  7631. */
  7632. freezeProjectionMatrix(projection?: Matrix): void;
  7633. /**
  7634. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7635. */
  7636. unfreezeProjectionMatrix(): void;
  7637. /**
  7638. * Gets the current projection matrix of the camera.
  7639. * @param force forces the camera to recompute the matrix without looking at the cached state
  7640. * @returns the projection matrix
  7641. */
  7642. getProjectionMatrix(force?: boolean): Matrix;
  7643. /**
  7644. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7645. * @returns a Matrix
  7646. */
  7647. getTransformationMatrix(): Matrix;
  7648. private _updateFrustumPlanes;
  7649. /**
  7650. * Checks if a cullable object (mesh...) is in the camera frustum
  7651. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7652. * @param target The object to check
  7653. * @returns true if the object is in frustum otherwise false
  7654. */
  7655. isInFrustum(target: ICullable): boolean;
  7656. /**
  7657. * Checks if a cullable object (mesh...) is in the camera frustum
  7658. * Unlike isInFrustum this cheks the full bounding box
  7659. * @param target The object to check
  7660. * @returns true if the object is in frustum otherwise false
  7661. */
  7662. isCompletelyInFrustum(target: ICullable): boolean;
  7663. /**
  7664. * Gets a ray in the forward direction from the camera.
  7665. * @param length Defines the length of the ray to create
  7666. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7667. * @param origin Defines the start point of the ray which defaults to the camera position
  7668. * @returns the forward ray
  7669. */
  7670. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7671. /**
  7672. * Releases resources associated with this node.
  7673. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7674. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7675. */
  7676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7677. /**
  7678. * Gets the left camera of a rig setup in case of Rigged Camera
  7679. */
  7680. readonly leftCamera: Nullable<FreeCamera>;
  7681. /**
  7682. * Gets the right camera of a rig setup in case of Rigged Camera
  7683. */
  7684. readonly rightCamera: Nullable<FreeCamera>;
  7685. /**
  7686. * Gets the left camera target of a rig setup in case of Rigged Camera
  7687. * @returns the target position
  7688. */
  7689. getLeftTarget(): Nullable<Vector3>;
  7690. /**
  7691. * Gets the right camera target of a rig setup in case of Rigged Camera
  7692. * @returns the target position
  7693. */
  7694. getRightTarget(): Nullable<Vector3>;
  7695. /**
  7696. * @hidden
  7697. */
  7698. setCameraRigMode(mode: number, rigParams: any): void;
  7699. private _getVRProjectionMatrix;
  7700. protected _updateCameraRotationMatrix(): void;
  7701. protected _updateWebVRCameraRotationMatrix(): void;
  7702. /**
  7703. * This function MUST be overwritten by the different WebVR cameras available.
  7704. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7705. */
  7706. protected _getWebVRProjectionMatrix(): Matrix;
  7707. /**
  7708. * This function MUST be overwritten by the different WebVR cameras available.
  7709. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7710. */
  7711. protected _getWebVRViewMatrix(): Matrix;
  7712. /** @hidden */
  7713. setCameraRigParameter(name: string, value: any): void;
  7714. /**
  7715. * needs to be overridden by children so sub has required properties to be copied
  7716. * @hidden
  7717. */
  7718. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7719. /**
  7720. * May need to be overridden by children
  7721. * @hidden
  7722. */
  7723. _updateRigCameras(): void;
  7724. /** @hidden */
  7725. _setupInputs(): void;
  7726. /**
  7727. * Serialiaze the camera setup to a json represention
  7728. * @returns the JSON representation
  7729. */
  7730. serialize(): any;
  7731. /**
  7732. * Clones the current camera.
  7733. * @param name The cloned camera name
  7734. * @returns the cloned camera
  7735. */
  7736. clone(name: string): Camera;
  7737. /**
  7738. * Gets the direction of the camera relative to a given local axis.
  7739. * @param localAxis Defines the reference axis to provide a relative direction.
  7740. * @return the direction
  7741. */
  7742. getDirection(localAxis: Vector3): Vector3;
  7743. /**
  7744. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7745. * @param localAxis Defines the reference axis to provide a relative direction.
  7746. * @param result Defines the vector to store the result in
  7747. */
  7748. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7749. /**
  7750. * Gets a camera constructor for a given camera type
  7751. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7752. * @param name The name of the camera the result will be able to instantiate
  7753. * @param scene The scene the result will construct the camera in
  7754. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7755. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7756. * @returns a factory method to construc the camera
  7757. */
  7758. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7759. /**
  7760. * Compute the world matrix of the camera.
  7761. * @returns the camera workd matrix
  7762. */
  7763. computeWorldMatrix(): Matrix;
  7764. /**
  7765. * Parse a JSON and creates the camera from the parsed information
  7766. * @param parsedCamera The JSON to parse
  7767. * @param scene The scene to instantiate the camera in
  7768. * @returns the newly constructed camera
  7769. */
  7770. static Parse(parsedCamera: any, scene: Scene): Camera;
  7771. }
  7772. }
  7773. declare module BABYLON {
  7774. /**
  7775. * This is a list of all the different input types that are available in the application.
  7776. * Fo instance: ArcRotateCameraGamepadInput...
  7777. */
  7778. var CameraInputTypes: {};
  7779. /**
  7780. * This is the contract to implement in order to create a new input class.
  7781. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7782. */
  7783. interface ICameraInput<TCamera extends Camera> {
  7784. /**
  7785. * Defines the camera the input is attached to.
  7786. */
  7787. camera: Nullable<TCamera>;
  7788. /**
  7789. * Gets the class name of the current intput.
  7790. * @returns the class name
  7791. */
  7792. getClassName(): string;
  7793. /**
  7794. * Get the friendly name associated with the input class.
  7795. * @returns the input friendly name
  7796. */
  7797. getSimpleName(): string;
  7798. /**
  7799. * Attach the input controls to a specific dom element to get the input from.
  7800. * @param element Defines the element the controls should be listened from
  7801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7802. */
  7803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7804. /**
  7805. * Detach the current controls from the specified dom element.
  7806. * @param element Defines the element to stop listening the inputs from
  7807. */
  7808. detachControl(element: Nullable<HTMLElement>): void;
  7809. /**
  7810. * Update the current camera state depending on the inputs that have been used this frame.
  7811. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7812. */
  7813. checkInputs?: () => void;
  7814. }
  7815. /**
  7816. * Represents a map of input types to input instance or input index to input instance.
  7817. */
  7818. interface CameraInputsMap<TCamera extends Camera> {
  7819. /**
  7820. * Accessor to the input by input type.
  7821. */
  7822. [name: string]: ICameraInput<TCamera>;
  7823. /**
  7824. * Accessor to the input by input index.
  7825. */
  7826. [idx: number]: ICameraInput<TCamera>;
  7827. }
  7828. /**
  7829. * This represents the input manager used within a camera.
  7830. * It helps dealing with all the different kind of input attached to a camera.
  7831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7832. */
  7833. class CameraInputsManager<TCamera extends Camera> {
  7834. /**
  7835. * Defines the list of inputs attahed to the camera.
  7836. */
  7837. attached: CameraInputsMap<TCamera>;
  7838. /**
  7839. * Defines the dom element the camera is collecting inputs from.
  7840. * This is null if the controls have not been attached.
  7841. */
  7842. attachedElement: Nullable<HTMLElement>;
  7843. /**
  7844. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7845. */
  7846. noPreventDefault: boolean;
  7847. /**
  7848. * Defined the camera the input manager belongs to.
  7849. */
  7850. camera: TCamera;
  7851. /**
  7852. * Update the current camera state depending on the inputs that have been used this frame.
  7853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7854. */
  7855. checkInputs: () => void;
  7856. /**
  7857. * Instantiate a new Camera Input Manager.
  7858. * @param camera Defines the camera the input manager blongs to
  7859. */
  7860. constructor(camera: TCamera);
  7861. /**
  7862. * Add an input method to a camera
  7863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7864. * @param input camera input method
  7865. */
  7866. add(input: ICameraInput<TCamera>): void;
  7867. /**
  7868. * Remove a specific input method from a camera
  7869. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7870. * @param inputToRemove camera input method
  7871. */
  7872. remove(inputToRemove: ICameraInput<TCamera>): void;
  7873. /**
  7874. * Remove a specific input type from a camera
  7875. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7876. * @param inputType the type of the input to remove
  7877. */
  7878. removeByType(inputType: string): void;
  7879. private _addCheckInputs;
  7880. /**
  7881. * Attach the input controls to the currently attached dom element to listen the events from.
  7882. * @param input Defines the input to attach
  7883. */
  7884. attachInput(input: ICameraInput<TCamera>): void;
  7885. /**
  7886. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7887. * @param element Defines the dom element to collect the events from
  7888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7889. */
  7890. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7891. /**
  7892. * Detach the current manager inputs controls from a specific dom element.
  7893. * @param element Defines the dom element to collect the events from
  7894. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7895. */
  7896. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7897. /**
  7898. * Rebuild the dynamic inputCheck function from the current list of
  7899. * defined inputs in the manager.
  7900. */
  7901. rebuildInputCheck(): void;
  7902. /**
  7903. * Remove all attached input methods from a camera
  7904. */
  7905. clear(): void;
  7906. /**
  7907. * Serialize the current input manager attached to a camera.
  7908. * This ensures than once parsed,
  7909. * the input associated to the camera will be identical to the current ones
  7910. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7911. */
  7912. serialize(serializedCamera: any): void;
  7913. /**
  7914. * Parses an input manager serialized JSON to restore the previous list of inputs
  7915. * and states associated to a camera.
  7916. * @param parsedCamera Defines the JSON to parse
  7917. */
  7918. parse(parsedCamera: any): void;
  7919. }
  7920. }
  7921. declare module BABYLON {
  7922. /**
  7923. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7924. * being tilted forward or back and left or right.
  7925. */
  7926. class DeviceOrientationCamera extends FreeCamera {
  7927. private _initialQuaternion;
  7928. private _quaternionCache;
  7929. /**
  7930. * Creates a new device orientation camera
  7931. * @param name The name of the camera
  7932. * @param position The start position camera
  7933. * @param scene The scene the camera belongs to
  7934. */
  7935. constructor(name: string, position: Vector3, scene: Scene);
  7936. /**
  7937. * Gets the current instance class name ("DeviceOrientationCamera").
  7938. * This helps avoiding instanceof at run time.
  7939. * @returns the class name
  7940. */
  7941. getClassName(): string;
  7942. /**
  7943. * @hidden
  7944. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7945. */
  7946. _checkInputs(): void;
  7947. /**
  7948. * Reset the camera to its default orientation on the specified axis only.
  7949. * @param axis The axis to reset
  7950. */
  7951. resetToCurrentRotation(axis?: Axis): void;
  7952. }
  7953. }
  7954. declare module BABYLON {
  7955. /**
  7956. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7957. * an arc rotate version arcFollowCamera are available.
  7958. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7959. */
  7960. class FollowCamera extends TargetCamera {
  7961. /**
  7962. * Distance the follow camera should follow an object at
  7963. */
  7964. radius: number;
  7965. /**
  7966. * Define a rotation offset between the camera and the object it follows
  7967. */
  7968. rotationOffset: number;
  7969. /**
  7970. * Define a height offset between the camera and the object it follows.
  7971. * It can help following an object from the top (like a car chaing a plane)
  7972. */
  7973. heightOffset: number;
  7974. /**
  7975. * Define how fast the camera can accelerate to follow it s target.
  7976. */
  7977. cameraAcceleration: number;
  7978. /**
  7979. * Define the speed limit of the camera following an object.
  7980. */
  7981. maxCameraSpeed: number;
  7982. /**
  7983. * Define the target of the camera.
  7984. */
  7985. lockedTarget: Nullable<AbstractMesh>;
  7986. /**
  7987. * Instantiates the follow camera.
  7988. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7989. * @param name Define the name of the camera in the scene
  7990. * @param position Define the position of the camera
  7991. * @param scene Define the scene the camera belong to
  7992. * @param lockedTarget Define the target of the camera
  7993. */
  7994. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7995. private _follow;
  7996. /** @hidden */
  7997. _checkInputs(): void;
  7998. /**
  7999. * Gets the camera class name.
  8000. * @returns the class name
  8001. */
  8002. getClassName(): string;
  8003. }
  8004. /**
  8005. * Arc Rotate version of the follow camera.
  8006. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8008. */
  8009. class ArcFollowCamera extends TargetCamera {
  8010. /** The longitudinal angle of the camera */
  8011. alpha: number;
  8012. /** The latitudinal angle of the camera */
  8013. beta: number;
  8014. /** The radius of the camera from its target */
  8015. radius: number;
  8016. /** Define the camera target (the messh it should follow) */
  8017. target: Nullable<AbstractMesh>;
  8018. private _cartesianCoordinates;
  8019. /**
  8020. * Instantiates a new ArcFollowCamera
  8021. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8022. * @param name Define the name of the camera
  8023. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8024. * @param beta Define the rotation angle of the camera around the elevation axis
  8025. * @param radius Define the radius of the camera from its target point
  8026. * @param target Define the target of the camera
  8027. * @param scene Define the scene the camera belongs to
  8028. */
  8029. constructor(name: string,
  8030. /** The longitudinal angle of the camera */
  8031. alpha: number,
  8032. /** The latitudinal angle of the camera */
  8033. beta: number,
  8034. /** The radius of the camera from its target */
  8035. radius: number,
  8036. /** Define the camera target (the messh it should follow) */
  8037. target: Nullable<AbstractMesh>, scene: Scene);
  8038. private _follow;
  8039. /** @hidden */
  8040. _checkInputs(): void;
  8041. /**
  8042. * Returns the class name of the object.
  8043. * It is mostly used internally for serialization purposes.
  8044. */
  8045. getClassName(): string;
  8046. }
  8047. }
  8048. declare module BABYLON {
  8049. /**
  8050. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8051. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8052. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8053. */
  8054. class FreeCamera extends TargetCamera {
  8055. /**
  8056. * Define the collision ellipsoid of the camera.
  8057. * This is helpful to simulate a camera body like the player body around the camera
  8058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8059. */
  8060. ellipsoid: Vector3;
  8061. /**
  8062. * Define an offset for the position of the ellipsoid around the camera.
  8063. * This can be helpful to determine the center of the body near the gravity center of the body
  8064. * instead of its head.
  8065. */
  8066. ellipsoidOffset: Vector3;
  8067. /**
  8068. * Enable or disable collisions of the camera with the rest of the scene objects.
  8069. */
  8070. checkCollisions: boolean;
  8071. /**
  8072. * Enable or disable gravity on the camera.
  8073. */
  8074. applyGravity: boolean;
  8075. /**
  8076. * Define the input manager associated to the camera.
  8077. */
  8078. inputs: FreeCameraInputsManager;
  8079. /**
  8080. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8081. * Higher values reduce sensitivity.
  8082. */
  8083. /**
  8084. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8085. * Higher values reduce sensitivity.
  8086. */
  8087. angularSensibility: number;
  8088. /**
  8089. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8090. */
  8091. keysUp: number[];
  8092. /**
  8093. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8094. */
  8095. keysDown: number[];
  8096. /**
  8097. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8098. */
  8099. keysLeft: number[];
  8100. /**
  8101. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8102. */
  8103. keysRight: number[];
  8104. /**
  8105. * Event raised when the camera collide with a mesh in the scene.
  8106. */
  8107. onCollide: (collidedMesh: AbstractMesh) => void;
  8108. private _collider;
  8109. private _needMoveForGravity;
  8110. private _oldPosition;
  8111. private _diffPosition;
  8112. private _newPosition;
  8113. /** @hidden */
  8114. _localDirection: Vector3;
  8115. /** @hidden */
  8116. _transformedDirection: Vector3;
  8117. /**
  8118. * Instantiates a Free Camera.
  8119. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8120. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8121. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8122. * @param name Define the name of the camera in the scene
  8123. * @param position Define the start position of the camera in the scene
  8124. * @param scene Define the scene the camera belongs to
  8125. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8126. */
  8127. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8128. /**
  8129. * Attached controls to the current camera.
  8130. * @param element Defines the element the controls should be listened from
  8131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8132. */
  8133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8134. /**
  8135. * Detach the current controls from the camera.
  8136. * The camera will stop reacting to inputs.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: HTMLElement): void;
  8140. private _collisionMask;
  8141. /**
  8142. * Define a collision mask to limit the list of object the camera can collide with
  8143. */
  8144. collisionMask: number;
  8145. /** @hidden */
  8146. _collideWithWorld(displacement: Vector3): void;
  8147. private _onCollisionPositionChange;
  8148. /** @hidden */
  8149. _checkInputs(): void;
  8150. /** @hidden */
  8151. _decideIfNeedsToMove(): boolean;
  8152. /** @hidden */
  8153. _updatePosition(): void;
  8154. /**
  8155. * Destroy the camera and release the current resources hold by it.
  8156. */
  8157. dispose(): void;
  8158. /**
  8159. * Gets the current object class name.
  8160. * @return the class name
  8161. */
  8162. getClassName(): string;
  8163. }
  8164. }
  8165. declare module BABYLON {
  8166. /**
  8167. * Default Inputs manager for the FreeCamera.
  8168. * It groups all the default supported inputs for ease of use.
  8169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8170. */
  8171. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8172. /**
  8173. * Instantiates a new FreeCameraInputsManager.
  8174. * @param camera Defines the camera the inputs belong to
  8175. */
  8176. constructor(camera: FreeCamera);
  8177. /**
  8178. * Add keyboard input support to the input manager.
  8179. * @returns the current input manager
  8180. */
  8181. addKeyboard(): FreeCameraInputsManager;
  8182. /**
  8183. * Add mouse input support to the input manager.
  8184. * @returns the current input manager
  8185. */
  8186. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8187. /**
  8188. * Add orientation input support to the input manager.
  8189. * @returns the current input manager
  8190. */
  8191. addDeviceOrientation(): FreeCameraInputsManager;
  8192. /**
  8193. * Add touch input support to the input manager.
  8194. * @returns the current input manager
  8195. */
  8196. addTouch(): FreeCameraInputsManager;
  8197. /**
  8198. * Add virtual joystick input support to the input manager.
  8199. * @returns the current input manager
  8200. */
  8201. addVirtualJoystick(): FreeCameraInputsManager;
  8202. }
  8203. }
  8204. declare module BABYLON {
  8205. /**
  8206. * This represents a FPS type of camera. This is only here for back compat purpose.
  8207. * Please use the UniversalCamera instead as both are identical.
  8208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8209. */
  8210. class GamepadCamera extends UniversalCamera {
  8211. /**
  8212. * Instantiates a new Gamepad Camera
  8213. * This represents a FPS type of camera. This is only here for back compat purpose.
  8214. * Please use the UniversalCamera instead as both are identical.
  8215. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8216. * @param name Define the name of the camera in the scene
  8217. * @param position Define the start position of the camera in the scene
  8218. * @param scene Define the scene the camera belongs to
  8219. */
  8220. constructor(name: string, position: Vector3, scene: Scene);
  8221. /**
  8222. * Gets the current object class name.
  8223. * @return the class name
  8224. */
  8225. getClassName(): string;
  8226. }
  8227. }
  8228. declare module BABYLON {
  8229. /**
  8230. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8231. * This is the base of the follow, arc rotate cameras and Free camera
  8232. * @see http://doc.babylonjs.com/features/cameras
  8233. */
  8234. class TargetCamera extends Camera {
  8235. /**
  8236. * Define the current direction the camera is moving to
  8237. */
  8238. cameraDirection: Vector3;
  8239. /**
  8240. * Define the current rotation the camera is rotating to
  8241. */
  8242. cameraRotation: Vector2;
  8243. /**
  8244. * Define the current rotation of the camera
  8245. */
  8246. rotation: Vector3;
  8247. /**
  8248. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8249. */
  8250. rotationQuaternion: Quaternion;
  8251. /**
  8252. * Define the current speed of the camera
  8253. */
  8254. speed: number;
  8255. /**
  8256. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8257. * around all axis.
  8258. */
  8259. noRotationConstraint: boolean;
  8260. /**
  8261. * Define the current target of the camera as an object or a position.
  8262. */
  8263. lockedTarget: any;
  8264. /** @hidden */
  8265. _currentTarget: Vector3;
  8266. /** @hidden */
  8267. _viewMatrix: Matrix;
  8268. /** @hidden */
  8269. _camMatrix: Matrix;
  8270. /** @hidden */
  8271. _cameraTransformMatrix: Matrix;
  8272. /** @hidden */
  8273. _cameraRotationMatrix: Matrix;
  8274. private _rigCamTransformMatrix;
  8275. /** @hidden */
  8276. _referencePoint: Vector3;
  8277. /** @hidden */
  8278. _transformedReferencePoint: Vector3;
  8279. protected _globalCurrentTarget: Vector3;
  8280. protected _globalCurrentUpVector: Vector3;
  8281. /** @hidden */
  8282. _reset: () => void;
  8283. private _defaultUp;
  8284. /**
  8285. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8286. * This is the base of the follow, arc rotate cameras and Free camera
  8287. * @see http://doc.babylonjs.com/features/cameras
  8288. * @param name Defines the name of the camera in the scene
  8289. * @param position Defines the start position of the camera in the scene
  8290. * @param scene Defines the scene the camera belongs to
  8291. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8292. */
  8293. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8294. /**
  8295. * Gets the position in front of the camera at a given distance.
  8296. * @param distance The distance from the camera we want the position to be
  8297. * @returns the position
  8298. */
  8299. getFrontPosition(distance: number): Vector3;
  8300. /** @hidden */
  8301. _getLockedTargetPosition(): Nullable<Vector3>;
  8302. private _storedPosition;
  8303. private _storedRotation;
  8304. private _storedRotationQuaternion;
  8305. /**
  8306. * Store current camera state of the camera (fov, position, rotation, etc..)
  8307. * @returns the camera
  8308. */
  8309. storeState(): Camera;
  8310. /**
  8311. * Restored camera state. You must call storeState() first
  8312. * @returns whether it was successful or not
  8313. * @hidden
  8314. */
  8315. _restoreStateValues(): boolean;
  8316. /** @hidden */
  8317. _initCache(): void;
  8318. /** @hidden */
  8319. _updateCache(ignoreParentClass?: boolean): void;
  8320. /** @hidden */
  8321. _isSynchronizedViewMatrix(): boolean;
  8322. /** @hidden */
  8323. _computeLocalCameraSpeed(): number;
  8324. /** @hidden */
  8325. setTarget(target: Vector3): void;
  8326. /**
  8327. * Return the current target position of the camera. This value is expressed in local space.
  8328. * @returns the target position
  8329. */
  8330. getTarget(): Vector3;
  8331. /** @hidden */
  8332. _decideIfNeedsToMove(): boolean;
  8333. /** @hidden */
  8334. _updatePosition(): void;
  8335. /** @hidden */
  8336. _checkInputs(): void;
  8337. protected _updateCameraRotationMatrix(): void;
  8338. /**
  8339. * 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)
  8340. * @returns the current camera
  8341. */
  8342. private _rotateUpVectorWithCameraRotationMatrix;
  8343. private _cachedRotationZ;
  8344. /** @hidden */
  8345. _getViewMatrix(): Matrix;
  8346. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8347. /**
  8348. * @hidden
  8349. */
  8350. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8351. /**
  8352. * @hidden
  8353. */
  8354. _updateRigCameras(): void;
  8355. private _getRigCamPosition;
  8356. /**
  8357. * Gets the current object class name.
  8358. * @return the class name
  8359. */
  8360. getClassName(): string;
  8361. }
  8362. }
  8363. declare module BABYLON {
  8364. /**
  8365. * This represents a FPS type of camera controlled by touch.
  8366. * This is like a universal camera minus the Gamepad controls.
  8367. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8368. */
  8369. class TouchCamera extends FreeCamera {
  8370. /**
  8371. * Defines the touch sensibility for rotation.
  8372. * The higher the faster.
  8373. */
  8374. touchAngularSensibility: number;
  8375. /**
  8376. * Defines the touch sensibility for move.
  8377. * The higher the faster.
  8378. */
  8379. touchMoveSensibility: number;
  8380. /**
  8381. * Instantiates a new touch camera.
  8382. * This represents a FPS type of camera controlled by touch.
  8383. * This is like a universal camera minus the Gamepad controls.
  8384. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8385. * @param name Define the name of the camera in the scene
  8386. * @param position Define the start position of the camera in the scene
  8387. * @param scene Define the scene the camera belongs to
  8388. */
  8389. constructor(name: string, position: Vector3, scene: Scene);
  8390. /**
  8391. * Gets the current object class name.
  8392. * @return the class name
  8393. */
  8394. getClassName(): string;
  8395. /** @hidden */
  8396. _setupInputs(): void;
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /**
  8401. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  8402. * which still works and will still be found in many Playgrounds.
  8403. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8404. */
  8405. class UniversalCamera extends TouchCamera {
  8406. /**
  8407. * Defines the gamepad rotation sensiblity.
  8408. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8409. */
  8410. gamepadAngularSensibility: number;
  8411. /**
  8412. * Defines the gamepad move sensiblity.
  8413. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8414. */
  8415. gamepadMoveSensibility: number;
  8416. /**
  8417. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  8418. * which still works and will still be found in many Playgrounds.
  8419. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8420. * @param name Define the name of the camera in the scene
  8421. * @param position Define the start position of the camera in the scene
  8422. * @param scene Define the scene the camera belongs to
  8423. */
  8424. constructor(name: string, position: Vector3, scene: Scene);
  8425. /**
  8426. * Gets the current object class name.
  8427. * @return the class name
  8428. */
  8429. getClassName(): string;
  8430. }
  8431. }
  8432. declare module BABYLON {
  8433. /**
  8434. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8435. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8436. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8437. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8438. */
  8439. class VirtualJoysticksCamera extends FreeCamera {
  8440. /**
  8441. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8442. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8443. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8444. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8445. * @param name Define the name of the camera in the scene
  8446. * @param position Define the start position of the camera in the scene
  8447. * @param scene Define the scene the camera belongs to
  8448. */
  8449. constructor(name: string, position: Vector3, scene: Scene);
  8450. /**
  8451. * Gets the current object class name.
  8452. * @return the class name
  8453. */
  8454. getClassName(): string;
  8455. }
  8456. }
  8457. interface VRDisplay extends EventTarget {
  8458. /**
  8459. * Dictionary of capabilities describing the VRDisplay.
  8460. */
  8461. readonly capabilities: VRDisplayCapabilities;
  8462. /**
  8463. * z-depth defining the far plane of the eye view frustum
  8464. * enables mapping of values in the render target depth
  8465. * attachment to scene coordinates. Initially set to 10000.0.
  8466. */
  8467. depthFar: number;
  8468. /**
  8469. * z-depth defining the near plane of the eye view frustum
  8470. * enables mapping of values in the render target depth
  8471. * attachment to scene coordinates. Initially set to 0.01.
  8472. */
  8473. depthNear: number;
  8474. /**
  8475. * An identifier for this distinct VRDisplay. Used as an
  8476. * association point in the Gamepad API.
  8477. */
  8478. readonly displayId: number;
  8479. /**
  8480. * A display name, a user-readable name identifying it.
  8481. */
  8482. readonly displayName: string;
  8483. readonly isConnected: boolean;
  8484. readonly isPresenting: boolean;
  8485. /**
  8486. * If this VRDisplay supports room-scale experiences, the optional
  8487. * stage attribute contains details on the room-scale parameters.
  8488. */
  8489. readonly stageParameters: VRStageParameters | null;
  8490. /**
  8491. * Passing the value returned by `requestAnimationFrame` to
  8492. * `cancelAnimationFrame` will unregister the callback.
  8493. * @param handle Define the hanle of the request to cancel
  8494. */
  8495. cancelAnimationFrame(handle: number): void;
  8496. /**
  8497. * Stops presenting to the VRDisplay.
  8498. * @returns a promise to know when it stopped
  8499. */
  8500. exitPresent(): Promise<void>;
  8501. /**
  8502. * Return the current VREyeParameters for the given eye.
  8503. * @param whichEye Define the eye we want the parameter for
  8504. * @returns the eye parameters
  8505. */
  8506. getEyeParameters(whichEye: string): VREyeParameters;
  8507. /**
  8508. * Populates the passed VRFrameData with the information required to render
  8509. * the current frame.
  8510. * @param frameData Define the data structure to populate
  8511. * @returns true if ok otherwise false
  8512. */
  8513. getFrameData(frameData: VRFrameData): boolean;
  8514. /**
  8515. * Get the layers currently being presented.
  8516. * @returns the list of VR layers
  8517. */
  8518. getLayers(): VRLayer[];
  8519. /**
  8520. * Return a VRPose containing the future predicted pose of the VRDisplay
  8521. * when the current frame will be presented. The value returned will not
  8522. * change until JavaScript has returned control to the browser.
  8523. *
  8524. * The VRPose will contain the position, orientation, velocity,
  8525. * and acceleration of each of these properties.
  8526. * @returns the pose object
  8527. */
  8528. getPose(): VRPose;
  8529. /**
  8530. * Return the current instantaneous pose of the VRDisplay, with no
  8531. * prediction applied.
  8532. * @returns the current instantaneous pose
  8533. */
  8534. getImmediatePose(): VRPose;
  8535. /**
  8536. * The callback passed to `requestAnimationFrame` will be called
  8537. * any time a new frame should be rendered. When the VRDisplay is
  8538. * presenting the callback will be called at the native refresh
  8539. * rate of the HMD. When not presenting this function acts
  8540. * identically to how window.requestAnimationFrame acts. Content should
  8541. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8542. * asynchronously from other displays and at differing refresh rates.
  8543. * @param callback Define the eaction to run next frame
  8544. * @returns the request handle it
  8545. */
  8546. requestAnimationFrame(callback: FrameRequestCallback): number;
  8547. /**
  8548. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8549. * Repeat calls while already presenting will update the VRLayers being displayed.
  8550. * @param layers Define the list of layer to present
  8551. * @returns a promise to know when the request has been fulfilled
  8552. */
  8553. requestPresent(layers: VRLayer[]): Promise<void>;
  8554. /**
  8555. * Reset the pose for this display, treating its current position and
  8556. * orientation as the "origin/zero" values. VRPose.position,
  8557. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8558. * updated when calling resetPose(). This should be called in only
  8559. * sitting-space experiences.
  8560. */
  8561. resetPose(): void;
  8562. /**
  8563. * The VRLayer provided to the VRDisplay will be captured and presented
  8564. * in the HMD. Calling this function has the same effect on the source
  8565. * canvas as any other operation that uses its source image, and canvases
  8566. * created without preserveDrawingBuffer set to true will be cleared.
  8567. * @param pose Define the pose to submit
  8568. */
  8569. submitFrame(pose?: VRPose): void;
  8570. }
  8571. declare var VRDisplay: {
  8572. prototype: VRDisplay;
  8573. new (): VRDisplay;
  8574. };
  8575. interface VRLayer {
  8576. leftBounds?: number[] | Float32Array | null;
  8577. rightBounds?: number[] | Float32Array | null;
  8578. source?: HTMLCanvasElement | null;
  8579. }
  8580. interface VRDisplayCapabilities {
  8581. readonly canPresent: boolean;
  8582. readonly hasExternalDisplay: boolean;
  8583. readonly hasOrientation: boolean;
  8584. readonly hasPosition: boolean;
  8585. readonly maxLayers: number;
  8586. }
  8587. interface VREyeParameters {
  8588. /** @deprecated */
  8589. readonly fieldOfView: VRFieldOfView;
  8590. readonly offset: Float32Array;
  8591. readonly renderHeight: number;
  8592. readonly renderWidth: number;
  8593. }
  8594. interface VRFieldOfView {
  8595. readonly downDegrees: number;
  8596. readonly leftDegrees: number;
  8597. readonly rightDegrees: number;
  8598. readonly upDegrees: number;
  8599. }
  8600. interface VRFrameData {
  8601. readonly leftProjectionMatrix: Float32Array;
  8602. readonly leftViewMatrix: Float32Array;
  8603. readonly pose: VRPose;
  8604. readonly rightProjectionMatrix: Float32Array;
  8605. readonly rightViewMatrix: Float32Array;
  8606. readonly timestamp: number;
  8607. }
  8608. interface VRPose {
  8609. readonly angularAcceleration: Float32Array | null;
  8610. readonly angularVelocity: Float32Array | null;
  8611. readonly linearAcceleration: Float32Array | null;
  8612. readonly linearVelocity: Float32Array | null;
  8613. readonly orientation: Float32Array | null;
  8614. readonly position: Float32Array | null;
  8615. readonly timestamp: number;
  8616. }
  8617. interface VRStageParameters {
  8618. sittingToStandingTransform?: Float32Array;
  8619. sizeX?: number;
  8620. sizeY?: number;
  8621. }
  8622. interface Navigator {
  8623. getVRDisplays(): Promise<VRDisplay[]>;
  8624. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8625. }
  8626. interface Window {
  8627. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8628. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8629. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8630. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8631. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8632. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8633. }
  8634. interface Gamepad {
  8635. readonly displayId: number;
  8636. }
  8637. /**
  8638. * Module Debug contains the (visual) components to debug a scene correctly
  8639. */
  8640. declare module BABYLON.Debug {
  8641. /**
  8642. * The Axes viewer will show 3 axes in a specific point in space
  8643. */
  8644. class AxesViewer {
  8645. private _xline;
  8646. private _yline;
  8647. private _zline;
  8648. private _xmesh;
  8649. private _ymesh;
  8650. private _zmesh;
  8651. /**
  8652. * Gets the hosting scene
  8653. */
  8654. scene: Nullable<Scene>;
  8655. /**
  8656. * Gets or sets a number used to scale line length
  8657. */
  8658. scaleLines: number;
  8659. /**
  8660. * Creates a new AxesViewer
  8661. * @param scene defines the hosting scene
  8662. * @param scaleLines defines a number used to scale line length (1 by default)
  8663. */
  8664. constructor(scene: Scene, scaleLines?: number);
  8665. /**
  8666. * Force the viewer to update
  8667. * @param position defines the position of the viewer
  8668. * @param xaxis defines the x axis of the viewer
  8669. * @param yaxis defines the y axis of the viewer
  8670. * @param zaxis defines the z axis of the viewer
  8671. */
  8672. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8673. /** Releases resources */
  8674. dispose(): void;
  8675. }
  8676. }
  8677. declare module BABYLON.Debug {
  8678. /**
  8679. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8680. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8681. */
  8682. class BoneAxesViewer extends AxesViewer {
  8683. /**
  8684. * Gets or sets the target mesh where to display the axes viewer
  8685. */
  8686. mesh: Nullable<Mesh>;
  8687. /**
  8688. * Gets or sets the target bone where to display the axes viewer
  8689. */
  8690. bone: Nullable<Bone>;
  8691. /** Gets current position */
  8692. pos: Vector3;
  8693. /** Gets direction of X axis */
  8694. xaxis: Vector3;
  8695. /** Gets direction of Y axis */
  8696. yaxis: Vector3;
  8697. /** Gets direction of Z axis */
  8698. zaxis: Vector3;
  8699. /**
  8700. * Creates a new BoneAxesViewer
  8701. * @param scene defines the hosting scene
  8702. * @param bone defines the target bone
  8703. * @param mesh defines the target mesh
  8704. * @param scaleLines defines a scaling factor for line length (1 by default)
  8705. */
  8706. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8707. /**
  8708. * Force the viewer to update
  8709. */
  8710. update(): void;
  8711. /** Releases resources */
  8712. dispose(): void;
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. interface Scene {
  8717. /**
  8718. * @hidden
  8719. * Backing field
  8720. */
  8721. _debugLayer: DebugLayer;
  8722. /**
  8723. * Gets the debug layer (aka Inspector) associated with the scene
  8724. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8725. */
  8726. debugLayer: DebugLayer;
  8727. }
  8728. /**
  8729. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8730. * what is happening in your scene
  8731. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8732. */
  8733. class DebugLayer {
  8734. /**
  8735. * Define the url to get the inspector script from.
  8736. * By default it uses the babylonjs CDN.
  8737. * @ignoreNaming
  8738. */
  8739. static InspectorURL: string;
  8740. private _scene;
  8741. private _inspector;
  8742. private BJSINSPECTOR;
  8743. /**
  8744. * Observable triggered when a property is changed through the inspector.
  8745. */
  8746. onPropertyChangedObservable: Observable<{
  8747. object: any;
  8748. property: string;
  8749. value: any;
  8750. initialValue: any;
  8751. }>;
  8752. /**
  8753. * Instantiates a new debug layer.
  8754. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8755. * what is happening in your scene
  8756. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8757. * @param scene Defines the scene to inspect
  8758. */
  8759. constructor(scene: Scene);
  8760. /** Creates the inspector window. */
  8761. private _createInspector;
  8762. /**
  8763. * Get if the inspector is visible or not.
  8764. * @returns true if visible otherwise, false
  8765. */
  8766. isVisible(): boolean;
  8767. /**
  8768. * Hide the inspector and close its window.
  8769. */
  8770. hide(): void;
  8771. /**
  8772. *
  8773. * Launch the debugLayer.
  8774. *
  8775. * initialTab:
  8776. * | Value | Tab Name |
  8777. * | --- | --- |
  8778. * | 0 | Scene |
  8779. * | 1 | Console |
  8780. * | 2 | Stats |
  8781. * | 3 | Textures |
  8782. * | 4 | Mesh |
  8783. * | 5 | Light |
  8784. * | 6 | Material |
  8785. * | 7 | GLTF |
  8786. * | 8 | GUI |
  8787. * | 9 | Physics |
  8788. * | 10 | Camera |
  8789. * | 11 | Audio |
  8790. *
  8791. * @param config Define the configuration of the inspector
  8792. */
  8793. show(config?: {
  8794. popup?: boolean;
  8795. initialTab?: number | string;
  8796. parentElement?: HTMLElement;
  8797. newColors?: {
  8798. backgroundColor?: string;
  8799. backgroundColorLighter?: string;
  8800. backgroundColorLighter2?: string;
  8801. backgroundColorLighter3?: string;
  8802. color?: string;
  8803. colorTop?: string;
  8804. colorBot?: string;
  8805. };
  8806. }): void;
  8807. /**
  8808. * Gets the active tab
  8809. * @return the index of the active tab or -1 if the inspector is hidden
  8810. */
  8811. getActiveTab(): number;
  8812. }
  8813. }
  8814. declare module BABYLON.Debug {
  8815. /**
  8816. * Used to show the physics impostor around the specific mesh
  8817. */
  8818. class PhysicsViewer {
  8819. /** @hidden */
  8820. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  8821. /** @hidden */
  8822. protected _meshes: Array<Nullable<AbstractMesh>>;
  8823. /** @hidden */
  8824. protected _scene: Nullable<Scene>;
  8825. /** @hidden */
  8826. protected _numMeshes: number;
  8827. /** @hidden */
  8828. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  8829. private _renderFunction;
  8830. private _debugBoxMesh;
  8831. private _debugSphereMesh;
  8832. private _debugMaterial;
  8833. /**
  8834. * Creates a new PhysicsViewer
  8835. * @param scene defines the hosting scene
  8836. */
  8837. constructor(scene: Scene);
  8838. /** @hidden */
  8839. protected _updateDebugMeshes(): void;
  8840. /**
  8841. * Renders a specified physic impostor
  8842. * @param impostor defines the impostor to render
  8843. */
  8844. showImpostor(impostor: PhysicsImpostor): void;
  8845. /**
  8846. * Hides a specified physic impostor
  8847. * @param impostor defines the impostor to hide
  8848. */
  8849. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  8850. private _getDebugMaterial;
  8851. private _getDebugBoxMesh;
  8852. private _getDebugSphereMesh;
  8853. private _getDebugMesh;
  8854. /** Releases all resources */
  8855. dispose(): void;
  8856. }
  8857. }
  8858. declare module BABYLON {
  8859. /**
  8860. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8861. * in order to better appreciate the issue one might have.
  8862. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8863. */
  8864. class RayHelper {
  8865. /**
  8866. * Defines the ray we are currently tryin to visualize.
  8867. */
  8868. ray: Nullable<Ray>;
  8869. private _renderPoints;
  8870. private _renderLine;
  8871. private _renderFunction;
  8872. private _scene;
  8873. private _updateToMeshFunction;
  8874. private _attachedToMesh;
  8875. private _meshSpaceDirection;
  8876. private _meshSpaceOrigin;
  8877. /**
  8878. * Helper function to create a colored helper in a scene in one line.
  8879. * @param ray Defines the ray we are currently tryin to visualize
  8880. * @param scene Defines the scene the ray is used in
  8881. * @param color Defines the color we want to see the ray in
  8882. * @returns The newly created ray helper.
  8883. */
  8884. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  8885. /**
  8886. * Instantiate a new ray helper.
  8887. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8888. * in order to better appreciate the issue one might have.
  8889. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8890. * @param ray Defines the ray we are currently tryin to visualize
  8891. */
  8892. constructor(ray: Ray);
  8893. /**
  8894. * Shows the ray we are willing to debug.
  8895. * @param scene Defines the scene the ray needs to be rendered in
  8896. * @param color Defines the color the ray needs to be rendered in
  8897. */
  8898. show(scene: Scene, color?: Color3): void;
  8899. /**
  8900. * Hides the ray we are debugging.
  8901. */
  8902. hide(): void;
  8903. private _render;
  8904. /**
  8905. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  8906. * @param mesh Defines the mesh we want the helper attached to
  8907. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  8908. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  8909. * @param length Defines the length of the ray
  8910. */
  8911. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  8912. /**
  8913. * Detach the ray helper from the mesh it has previously been attached to.
  8914. */
  8915. detachFromMesh(): void;
  8916. private _updateToMesh;
  8917. /**
  8918. * Dispose the helper and release its associated resources.
  8919. */
  8920. dispose(): void;
  8921. }
  8922. }
  8923. declare module BABYLON.Debug {
  8924. /**
  8925. * Class used to render a debug view of a given skeleton
  8926. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  8927. */
  8928. class SkeletonViewer {
  8929. /** defines the skeleton to render */
  8930. skeleton: Skeleton;
  8931. /** defines the mesh attached to the skeleton */
  8932. mesh: AbstractMesh;
  8933. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8934. autoUpdateBonesMatrices: boolean;
  8935. /** defines the rendering group id to use with the viewer */
  8936. renderingGroupId: number;
  8937. /** Gets or sets the color used to render the skeleton */
  8938. color: Color3;
  8939. private _scene;
  8940. private _debugLines;
  8941. private _debugMesh;
  8942. private _isEnabled;
  8943. private _renderFunction;
  8944. /**
  8945. * Creates a new SkeletonViewer
  8946. * @param skeleton defines the skeleton to render
  8947. * @param mesh defines the mesh attached to the skeleton
  8948. * @param scene defines the hosting scene
  8949. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  8950. * @param renderingGroupId defines the rendering group id to use with the viewer
  8951. */
  8952. constructor(
  8953. /** defines the skeleton to render */
  8954. skeleton: Skeleton,
  8955. /** defines the mesh attached to the skeleton */
  8956. mesh: AbstractMesh, scene: Scene,
  8957. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8958. autoUpdateBonesMatrices?: boolean,
  8959. /** defines the rendering group id to use with the viewer */
  8960. renderingGroupId?: number);
  8961. /** Gets or sets a boolean indicating if the viewer is enabled */
  8962. isEnabled: boolean;
  8963. private _getBonePosition;
  8964. private _getLinesForBonesWithLength;
  8965. private _getLinesForBonesNoLength;
  8966. /** Update the viewer to sync with current skeleton state */
  8967. update(): void;
  8968. /** Release associated resources */
  8969. dispose(): void;
  8970. }
  8971. }
  8972. declare module BABYLON {
  8973. /**
  8974. * Interface for attribute information associated with buffer instanciation
  8975. */
  8976. class InstancingAttributeInfo {
  8977. /**
  8978. * Index/offset of the attribute in the vertex shader
  8979. */
  8980. index: number;
  8981. /**
  8982. * size of the attribute, 1, 2, 3 or 4
  8983. */
  8984. attributeSize: number;
  8985. /**
  8986. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  8987. * default is FLOAT
  8988. */
  8989. attribyteType: number;
  8990. /**
  8991. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  8992. */
  8993. normalized: boolean;
  8994. /**
  8995. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  8996. */
  8997. offset: number;
  8998. /**
  8999. * Name of the GLSL attribute, for debugging purpose only
  9000. */
  9001. attributeName: string;
  9002. }
  9003. /**
  9004. * Define options used to create a render target texture
  9005. */
  9006. class RenderTargetCreationOptions {
  9007. /**
  9008. * Specifies is mipmaps must be generated
  9009. */
  9010. generateMipMaps?: boolean;
  9011. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9012. generateDepthBuffer?: boolean;
  9013. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9014. generateStencilBuffer?: boolean;
  9015. /** Defines texture type (int by default) */
  9016. type?: number;
  9017. /** Defines sampling mode (trilinear by default) */
  9018. samplingMode?: number;
  9019. /** Defines format (RGBA by default) */
  9020. format?: number;
  9021. }
  9022. /**
  9023. * Define options used to create a depth texture
  9024. */
  9025. class DepthTextureCreationOptions {
  9026. /** Specifies whether or not a stencil should be allocated in the texture */
  9027. generateStencil?: boolean;
  9028. /** Specifies whether or not bilinear filtering is enable on the texture */
  9029. bilinearFiltering?: boolean;
  9030. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9031. comparisonFunction?: number;
  9032. /** Specifies if the created texture is a cube texture */
  9033. isCube?: boolean;
  9034. }
  9035. /**
  9036. * Class used to describe the capabilities of the engine relatively to the current browser
  9037. */
  9038. class EngineCapabilities {
  9039. /** Maximum textures units per fragment shader */
  9040. maxTexturesImageUnits: number;
  9041. /** Maximum texture units per vertex shader */
  9042. maxVertexTextureImageUnits: number;
  9043. /** Maximum textures units in the entire pipeline */
  9044. maxCombinedTexturesImageUnits: number;
  9045. /** Maximum texture size */
  9046. maxTextureSize: number;
  9047. /** Maximum cube texture size */
  9048. maxCubemapTextureSize: number;
  9049. /** Maximum render texture size */
  9050. maxRenderTextureSize: number;
  9051. /** Maximum number of vertex attributes */
  9052. maxVertexAttribs: number;
  9053. /** Maximum number of varyings */
  9054. maxVaryingVectors: number;
  9055. /** Maximum number of uniforms per vertex shader */
  9056. maxVertexUniformVectors: number;
  9057. /** Maximum number of uniforms per fragment shader */
  9058. maxFragmentUniformVectors: number;
  9059. /** Defines if standard derivates (dx/dy) are supported */
  9060. standardDerivatives: boolean;
  9061. /** Defines if s3tc texture compression is supported */
  9062. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9063. /** Defines if pvrtc texture compression is supported */
  9064. pvrtc: any;
  9065. /** Defines if etc1 texture compression is supported */
  9066. etc1: any;
  9067. /** Defines if etc2 texture compression is supported */
  9068. etc2: any;
  9069. /** Defines if astc texture compression is supported */
  9070. astc: any;
  9071. /** Defines if float textures are supported */
  9072. textureFloat: boolean;
  9073. /** Defines if vertex array objects are supported */
  9074. vertexArrayObject: boolean;
  9075. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9076. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9077. /** Gets the maximum level of anisotropy supported */
  9078. maxAnisotropy: number;
  9079. /** Defines if instancing is supported */
  9080. instancedArrays: boolean;
  9081. /** Defines if 32 bits indices are supported */
  9082. uintIndices: boolean;
  9083. /** Defines if high precision shaders are supported */
  9084. highPrecisionShaderSupported: boolean;
  9085. /** Defines if depth reading in the fragment shader is supported */
  9086. fragmentDepthSupported: boolean;
  9087. /** Defines if float texture linear filtering is supported*/
  9088. textureFloatLinearFiltering: boolean;
  9089. /** Defines if rendering to float textures is supported */
  9090. textureFloatRender: boolean;
  9091. /** Defines if half float textures are supported*/
  9092. textureHalfFloat: boolean;
  9093. /** Defines if half float texture linear filtering is supported*/
  9094. textureHalfFloatLinearFiltering: boolean;
  9095. /** Defines if rendering to half float textures is supported */
  9096. textureHalfFloatRender: boolean;
  9097. /** Defines if textureLOD shader command is supported */
  9098. textureLOD: boolean;
  9099. /** Defines if draw buffers extension is supported */
  9100. drawBuffersExtension: boolean;
  9101. /** Defines if depth textures are supported */
  9102. depthTextureExtension: boolean;
  9103. /** Defines if float color buffer are supported */
  9104. colorBufferFloat: boolean;
  9105. /** Gets disjoint timer query extension (null if not supported) */
  9106. timerQuery: EXT_disjoint_timer_query;
  9107. /** Defines if timestamp can be used with timer query */
  9108. canUseTimestampForTimerQuery: boolean;
  9109. }
  9110. /** Interface defining initialization parameters for Engine class */
  9111. interface EngineOptions extends WebGLContextAttributes {
  9112. /**
  9113. * Defines if the engine should no exceed a specified device ratio
  9114. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9115. */
  9116. limitDeviceRatio?: number;
  9117. /**
  9118. * Defines if webvr should be enabled automatically
  9119. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9120. */
  9121. autoEnableWebVR?: boolean;
  9122. /**
  9123. * Defines if webgl2 should be turned off even if supported
  9124. * @see http://doc.babylonjs.com/features/webgl2
  9125. */
  9126. disableWebGL2Support?: boolean;
  9127. /**
  9128. * Defines if webaudio should be initialized as well
  9129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9130. */
  9131. audioEngine?: boolean;
  9132. /**
  9133. * Defines if animations should run using a deterministic lock step
  9134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9135. */
  9136. deterministicLockstep?: boolean;
  9137. /** Defines the maximum steps to use with deterministic lock step mode */
  9138. lockstepMaxSteps?: number;
  9139. /**
  9140. * Defines that engine should ignore context lost events
  9141. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9142. */
  9143. doNotHandleContextLost?: boolean;
  9144. }
  9145. /**
  9146. * Defines the interface used by display changed events
  9147. */
  9148. interface IDisplayChangedEventArgs {
  9149. /** Gets the vrDisplay object (if any) */
  9150. vrDisplay: Nullable<any>;
  9151. /** Gets a boolean indicating if webVR is supported */
  9152. vrSupported: boolean;
  9153. }
  9154. /**
  9155. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9156. */
  9157. class Engine {
  9158. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9159. static ExceptionList: ({
  9160. key: string;
  9161. capture: string;
  9162. captureConstraint: number;
  9163. targets: string[];
  9164. } | {
  9165. key: string;
  9166. capture: null;
  9167. captureConstraint: null;
  9168. targets: string[];
  9169. })[];
  9170. /** Gets the list of created engines */
  9171. static Instances: Engine[];
  9172. /**
  9173. * Gets the latest created engine
  9174. */
  9175. static readonly LastCreatedEngine: Nullable<Engine>;
  9176. /**
  9177. * Gets the latest created scene
  9178. */
  9179. static readonly LastCreatedScene: Nullable<Scene>;
  9180. /**
  9181. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9182. * @param flag defines which part of the materials must be marked as dirty
  9183. * @param predicate defines a predicate used to filter which materials should be affected
  9184. */
  9185. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9186. /**
  9187. * Hidden
  9188. */
  9189. static _TextureLoaders: IInternalTextureLoader[];
  9190. /** Defines that alpha blending is disabled */
  9191. static readonly ALPHA_DISABLE: number;
  9192. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9193. static readonly ALPHA_ADD: number;
  9194. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9195. static readonly ALPHA_COMBINE: number;
  9196. /** Defines that alpha blending to DEST - SRC * DEST */
  9197. static readonly ALPHA_SUBTRACT: number;
  9198. /** Defines that alpha blending to SRC * DEST */
  9199. static readonly ALPHA_MULTIPLY: number;
  9200. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9201. static readonly ALPHA_MAXIMIZED: number;
  9202. /** Defines that alpha blending to SRC + DEST */
  9203. static readonly ALPHA_ONEONE: number;
  9204. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9205. static readonly ALPHA_PREMULTIPLIED: number;
  9206. /**
  9207. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9208. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9209. */
  9210. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9211. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9212. static readonly ALPHA_INTERPOLATE: number;
  9213. /**
  9214. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9215. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9216. */
  9217. static readonly ALPHA_SCREENMODE: number;
  9218. /** Defines that the ressource is not delayed*/
  9219. static readonly DELAYLOADSTATE_NONE: number;
  9220. /** Defines that the ressource was successfully delay loaded */
  9221. static readonly DELAYLOADSTATE_LOADED: number;
  9222. /** Defines that the ressource is currently delay loading */
  9223. static readonly DELAYLOADSTATE_LOADING: number;
  9224. /** Defines that the ressource is delayed and has not started loading */
  9225. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9226. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9227. static readonly NEVER: number;
  9228. /** 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 */
  9229. static readonly ALWAYS: number;
  9230. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9231. static readonly LESS: number;
  9232. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9233. static readonly EQUAL: number;
  9234. /** 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 */
  9235. static readonly LEQUAL: number;
  9236. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9237. static readonly GREATER: number;
  9238. /** 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 */
  9239. static readonly GEQUAL: number;
  9240. /** 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 */
  9241. static readonly NOTEQUAL: number;
  9242. /** Passed to stencilOperation to specify that stencil value must be kept */
  9243. static readonly KEEP: number;
  9244. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9245. static readonly REPLACE: number;
  9246. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9247. static readonly INCR: number;
  9248. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9249. static readonly DECR: number;
  9250. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9251. static readonly INVERT: number;
  9252. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9253. static readonly INCR_WRAP: number;
  9254. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9255. static readonly DECR_WRAP: number;
  9256. /** Texture is not repeating outside of 0..1 UVs */
  9257. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9258. /** Texture is repeating outside of 0..1 UVs */
  9259. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9260. /** Texture is repeating and mirrored */
  9261. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9262. /** ALPHA */
  9263. static readonly TEXTUREFORMAT_ALPHA: number;
  9264. /** LUMINANCE */
  9265. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9266. /** LUMINANCE_ALPHA */
  9267. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9268. /** RGB */
  9269. static readonly TEXTUREFORMAT_RGB: number;
  9270. /** RGBA */
  9271. static readonly TEXTUREFORMAT_RGBA: number;
  9272. /** RED */
  9273. static readonly TEXTUREFORMAT_RED: number;
  9274. /** RED (2nd reference) */
  9275. static readonly TEXTUREFORMAT_R: number;
  9276. /** RG */
  9277. static readonly TEXTUREFORMAT_RG: number;
  9278. /** RED_INTEGER */
  9279. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9280. /** RED_INTEGER (2nd reference) */
  9281. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9282. /** RG_INTEGER */
  9283. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9284. /** RGB_INTEGER */
  9285. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9286. /** RGBA_INTEGER */
  9287. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9288. /** UNSIGNED_BYTE */
  9289. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9290. /** UNSIGNED_BYTE (2nd reference) */
  9291. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9292. /** FLOAT */
  9293. static readonly TEXTURETYPE_FLOAT: number;
  9294. /** HALF_FLOAT */
  9295. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9296. /** BYTE */
  9297. static readonly TEXTURETYPE_BYTE: number;
  9298. /** SHORT */
  9299. static readonly TEXTURETYPE_SHORT: number;
  9300. /** UNSIGNED_SHORT */
  9301. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9302. /** INT */
  9303. static readonly TEXTURETYPE_INT: number;
  9304. /** UNSIGNED_INT */
  9305. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9306. /** UNSIGNED_SHORT_4_4_4_4 */
  9307. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9308. /** UNSIGNED_SHORT_5_5_5_1 */
  9309. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9310. /** UNSIGNED_SHORT_5_6_5 */
  9311. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9312. /** UNSIGNED_INT_2_10_10_10_REV */
  9313. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9314. /** UNSIGNED_INT_24_8 */
  9315. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9316. /** UNSIGNED_INT_10F_11F_11F_REV */
  9317. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9318. /** UNSIGNED_INT_5_9_9_9_REV */
  9319. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9320. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9321. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9322. /** nearest is mag = nearest and min = nearest and mip = linear */
  9323. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9324. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9325. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9326. /** Trilinear is mag = linear and min = linear and mip = linear */
  9327. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9328. /** nearest is mag = nearest and min = nearest and mip = linear */
  9329. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9330. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9331. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9332. /** Trilinear is mag = linear and min = linear and mip = linear */
  9333. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9334. /** mag = nearest and min = nearest and mip = nearest */
  9335. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9336. /** mag = nearest and min = linear and mip = nearest */
  9337. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9338. /** mag = nearest and min = linear and mip = linear */
  9339. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9340. /** mag = nearest and min = linear and mip = none */
  9341. static readonly TEXTURE_NEAREST_LINEAR: number;
  9342. /** mag = nearest and min = nearest and mip = none */
  9343. static readonly TEXTURE_NEAREST_NEAREST: number;
  9344. /** mag = linear and min = nearest and mip = nearest */
  9345. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9346. /** mag = linear and min = nearest and mip = linear */
  9347. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9348. /** mag = linear and min = linear and mip = none */
  9349. static readonly TEXTURE_LINEAR_LINEAR: number;
  9350. /** mag = linear and min = nearest and mip = none */
  9351. static readonly TEXTURE_LINEAR_NEAREST: number;
  9352. /** Explicit coordinates mode */
  9353. static readonly TEXTURE_EXPLICIT_MODE: number;
  9354. /** Spherical coordinates mode */
  9355. static readonly TEXTURE_SPHERICAL_MODE: number;
  9356. /** Planar coordinates mode */
  9357. static readonly TEXTURE_PLANAR_MODE: number;
  9358. /** Cubic coordinates mode */
  9359. static readonly TEXTURE_CUBIC_MODE: number;
  9360. /** Projection coordinates mode */
  9361. static readonly TEXTURE_PROJECTION_MODE: number;
  9362. /** Skybox coordinates mode */
  9363. static readonly TEXTURE_SKYBOX_MODE: number;
  9364. /** Inverse Cubic coordinates mode */
  9365. static readonly TEXTURE_INVCUBIC_MODE: number;
  9366. /** Equirectangular coordinates mode */
  9367. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9368. /** Equirectangular Fixed coordinates mode */
  9369. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9370. /** Equirectangular Fixed Mirrored coordinates mode */
  9371. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9372. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9373. static readonly SCALEMODE_FLOOR: number;
  9374. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9375. static readonly SCALEMODE_NEAREST: number;
  9376. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9377. static readonly SCALEMODE_CEILING: number;
  9378. /**
  9379. * Returns the current version of the framework
  9380. */
  9381. static readonly Version: string;
  9382. /**
  9383. * Gets or sets the epsilon value used by collision engine
  9384. */
  9385. static CollisionsEpsilon: number;
  9386. /**
  9387. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9388. */
  9389. static CodeRepository: string;
  9390. /**
  9391. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9392. */
  9393. static ShadersRepository: string;
  9394. /**
  9395. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9396. */
  9397. forcePOTTextures: boolean;
  9398. /**
  9399. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9400. */
  9401. isFullscreen: boolean;
  9402. /**
  9403. * Gets a boolean indicating if the pointer is currently locked
  9404. */
  9405. isPointerLock: boolean;
  9406. /**
  9407. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9408. */
  9409. cullBackFaces: boolean;
  9410. /**
  9411. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9412. */
  9413. renderEvenInBackground: boolean;
  9414. /**
  9415. * Gets or sets a boolean indicating that cache can be kept between frames
  9416. */
  9417. preventCacheWipeBetweenFrames: boolean;
  9418. /**
  9419. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9420. **/
  9421. enableOfflineSupport: boolean;
  9422. /**
  9423. * 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)
  9424. **/
  9425. disableManifestCheck: boolean;
  9426. /**
  9427. * Gets the list of created scenes
  9428. */
  9429. scenes: Scene[];
  9430. /**
  9431. * Gets the list of created postprocesses
  9432. */
  9433. postProcesses: PostProcess[];
  9434. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9435. validateShaderPrograms: boolean;
  9436. /**
  9437. * Observable event triggered each time the rendering canvas is resized
  9438. */
  9439. onResizeObservable: Observable<Engine>;
  9440. /**
  9441. * Observable event triggered each time the canvas loses focus
  9442. */
  9443. onCanvasBlurObservable: Observable<Engine>;
  9444. /**
  9445. * Observable event triggered each time the canvas gains focus
  9446. */
  9447. onCanvasFocusObservable: Observable<Engine>;
  9448. /**
  9449. * Observable event triggered each time the canvas receives pointerout event
  9450. */
  9451. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9452. /**
  9453. * Observable event triggered before each texture is initialized
  9454. */
  9455. onBeforeTextureInitObservable: Observable<Texture>;
  9456. private _vrDisplay;
  9457. private _vrSupported;
  9458. private _oldSize;
  9459. private _oldHardwareScaleFactor;
  9460. private _vrExclusivePointerMode;
  9461. private _webVRInitPromise;
  9462. /**
  9463. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9464. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9465. */
  9466. readonly isInVRExclusivePointerMode: boolean;
  9467. /**
  9468. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9469. */
  9470. disableUniformBuffers: boolean;
  9471. /** @hidden */
  9472. _uniformBuffers: UniformBuffer[];
  9473. /**
  9474. * Gets a boolean indicating that the engine supports uniform buffers
  9475. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9476. */
  9477. readonly supportsUniformBuffers: boolean;
  9478. /**
  9479. * Observable raised when the engine begins a new frame
  9480. */
  9481. onBeginFrameObservable: Observable<Engine>;
  9482. /**
  9483. * Observable raised when the engine ends the current frame
  9484. */
  9485. onEndFrameObservable: Observable<Engine>;
  9486. /**
  9487. * Observable raised when the engine is about to compile a shader
  9488. */
  9489. onBeforeShaderCompilationObservable: Observable<Engine>;
  9490. /**
  9491. * Observable raised when the engine has jsut compiled a shader
  9492. */
  9493. onAfterShaderCompilationObservable: Observable<Engine>;
  9494. /** @hidden */
  9495. _gl: WebGLRenderingContext;
  9496. private _renderingCanvas;
  9497. private _windowIsBackground;
  9498. private _webGLVersion;
  9499. /**
  9500. * Gets a boolean indicating that only power of 2 textures are supported
  9501. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9502. */
  9503. readonly needPOTTextures: boolean;
  9504. /** @hidden */
  9505. _badOS: boolean;
  9506. /** @hidden */
  9507. _badDesktopOS: boolean;
  9508. /**
  9509. * Gets or sets a value indicating if we want to disable texture binding optmization.
  9510. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  9511. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  9512. */
  9513. disableTextureBindingOptimization: boolean;
  9514. /**
  9515. * Gets the audio engine
  9516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9517. * @ignorenaming
  9518. */
  9519. static audioEngine: IAudioEngine;
  9520. /**
  9521. * Default AudioEngine Factory responsible of creating the Audio Engine.
  9522. * By default, this will create a BabylonJS Audio Engine if the workload
  9523. * has been embedded.
  9524. */
  9525. static AudioEngineFactory: (engine: Engine) => IAudioEngine;
  9526. private _onFocus;
  9527. private _onBlur;
  9528. private _onCanvasPointerOut;
  9529. private _onCanvasBlur;
  9530. private _onCanvasFocus;
  9531. private _onFullscreenChange;
  9532. private _onPointerLockChange;
  9533. private _onVRDisplayPointerRestricted;
  9534. private _onVRDisplayPointerUnrestricted;
  9535. private _onVrDisplayConnect;
  9536. private _onVrDisplayDisconnect;
  9537. private _onVrDisplayPresentChange;
  9538. /**
  9539. * Observable signaled when VR display mode changes
  9540. */
  9541. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  9542. /**
  9543. * Observable signaled when VR request present is complete
  9544. */
  9545. onVRRequestPresentComplete: Observable<boolean>;
  9546. /**
  9547. * Observable signaled when VR request present starts
  9548. */
  9549. onVRRequestPresentStart: Observable<Engine>;
  9550. private _hardwareScalingLevel;
  9551. /** @hidden */
  9552. protected _caps: EngineCapabilities;
  9553. private _pointerLockRequested;
  9554. private _isStencilEnable;
  9555. private _colorWrite;
  9556. private _loadingScreen;
  9557. /** @hidden */
  9558. _drawCalls: PerfCounter;
  9559. /** @hidden */
  9560. _textureCollisions: PerfCounter;
  9561. private _glVersion;
  9562. private _glRenderer;
  9563. private _glVendor;
  9564. private _videoTextureSupported;
  9565. private _renderingQueueLaunched;
  9566. private _activeRenderLoops;
  9567. private _deterministicLockstep;
  9568. private _lockstepMaxSteps;
  9569. /**
  9570. * Observable signaled when a context lost event is raised
  9571. */
  9572. onContextLostObservable: Observable<Engine>;
  9573. /**
  9574. * Observable signaled when a context restored event is raised
  9575. */
  9576. onContextRestoredObservable: Observable<Engine>;
  9577. private _onContextLost;
  9578. private _onContextRestored;
  9579. private _contextWasLost;
  9580. private _doNotHandleContextLost;
  9581. /**
  9582. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  9583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  9584. */
  9585. doNotHandleContextLost: boolean;
  9586. private _performanceMonitor;
  9587. private _fps;
  9588. private _deltaTime;
  9589. /**
  9590. * Turn this value on if you want to pause FPS computation when in background
  9591. */
  9592. disablePerformanceMonitorInBackground: boolean;
  9593. /**
  9594. * Gets the performance monitor attached to this engine
  9595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  9596. */
  9597. readonly performanceMonitor: PerformanceMonitor;
  9598. /** @hidden */
  9599. protected _depthCullingState: _DepthCullingState;
  9600. /** @hidden */
  9601. protected _stencilState: _StencilState;
  9602. /** @hidden */
  9603. protected _alphaState: _AlphaState;
  9604. /** @hidden */
  9605. protected _alphaMode: number;
  9606. protected _internalTexturesCache: InternalTexture[];
  9607. /** @hidden */
  9608. protected _activeChannel: number;
  9609. private _currentTextureChannel;
  9610. /** @hidden */
  9611. protected _boundTexturesCache: {
  9612. [key: string]: Nullable<InternalTexture>;
  9613. };
  9614. /** @hidden */
  9615. protected _currentEffect: Nullable<Effect>;
  9616. /** @hidden */
  9617. protected _currentProgram: Nullable<WebGLProgram>;
  9618. private _compiledEffects;
  9619. private _vertexAttribArraysEnabled;
  9620. /** @hidden */
  9621. protected _cachedViewport: Nullable<Viewport>;
  9622. private _cachedVertexArrayObject;
  9623. /** @hidden */
  9624. protected _cachedVertexBuffers: any;
  9625. /** @hidden */
  9626. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  9627. /** @hidden */
  9628. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  9629. /** @hidden */
  9630. protected _currentRenderTarget: Nullable<InternalTexture>;
  9631. private _uintIndicesCurrentlySet;
  9632. private _currentBoundBuffer;
  9633. /** @hidden */
  9634. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  9635. private _currentBufferPointers;
  9636. private _currentInstanceLocations;
  9637. private _currentInstanceBuffers;
  9638. private _textureUnits;
  9639. private _firstBoundInternalTextureTracker;
  9640. private _lastBoundInternalTextureTracker;
  9641. private _workingCanvas;
  9642. private _workingContext;
  9643. private _rescalePostProcess;
  9644. private _dummyFramebuffer;
  9645. private _externalData;
  9646. private _bindedRenderFunction;
  9647. private _vaoRecordInProgress;
  9648. private _mustWipeVertexAttributes;
  9649. private _emptyTexture;
  9650. private _emptyCubeTexture;
  9651. private _emptyTexture3D;
  9652. private _frameHandler;
  9653. private _nextFreeTextureSlots;
  9654. private _maxSimultaneousTextures;
  9655. private _activeRequests;
  9656. private _texturesSupported;
  9657. private _textureFormatInUse;
  9658. /**
  9659. * Gets the list of texture formats supported
  9660. */
  9661. readonly texturesSupported: Array<string>;
  9662. /**
  9663. * Gets the list of texture formats in use
  9664. */
  9665. readonly textureFormatInUse: Nullable<string>;
  9666. /**
  9667. * Gets the current viewport
  9668. */
  9669. readonly currentViewport: Nullable<Viewport>;
  9670. /**
  9671. * Gets the default empty texture
  9672. */
  9673. readonly emptyTexture: InternalTexture;
  9674. /**
  9675. * Gets the default empty 3D texture
  9676. */
  9677. readonly emptyTexture3D: InternalTexture;
  9678. /**
  9679. * Gets the default empty cube texture
  9680. */
  9681. readonly emptyCubeTexture: InternalTexture;
  9682. /**
  9683. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  9684. */
  9685. readonly premultipliedAlpha: boolean;
  9686. /**
  9687. * Creates a new engine
  9688. * @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
  9689. * @param antialias defines enable antialiasing (default: false)
  9690. * @param options defines further options to be sent to the getContext() function
  9691. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  9692. */
  9693. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  9694. private _rebuildInternalTextures;
  9695. private _rebuildEffects;
  9696. private _rebuildBuffers;
  9697. private _initGLContext;
  9698. /**
  9699. * Gets version of the current webGL context
  9700. */
  9701. readonly webGLVersion: number;
  9702. /**
  9703. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  9704. */
  9705. readonly isStencilEnable: boolean;
  9706. private _prepareWorkingCanvas;
  9707. /**
  9708. * Reset the texture cache to empty state
  9709. */
  9710. resetTextureCache(): void;
  9711. /**
  9712. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  9713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9714. * @returns true if engine is in deterministic lock step mode
  9715. */
  9716. isDeterministicLockStep(): boolean;
  9717. /**
  9718. * Gets the max steps when engine is running in deterministic lock step
  9719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9720. * @returns the max steps
  9721. */
  9722. getLockstepMaxSteps(): number;
  9723. /**
  9724. * Gets an object containing information about the current webGL context
  9725. * @returns an object containing the vender, the renderer and the version of the current webGL context
  9726. */
  9727. getGlInfo(): {
  9728. vendor: string;
  9729. renderer: string;
  9730. version: string;
  9731. };
  9732. /**
  9733. * Gets current aspect ratio
  9734. * @param camera defines the camera to use to get the aspect ratio
  9735. * @param useScreen defines if screen size must be used (or the current render target if any)
  9736. * @returns a number defining the aspect ratio
  9737. */
  9738. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  9739. /**
  9740. * Gets current screen aspect ratio
  9741. * @returns a number defining the aspect ratio
  9742. */
  9743. getScreenAspectRatio(): number;
  9744. /**
  9745. * Gets the current render width
  9746. * @param useScreen defines if screen size must be used (or the current render target if any)
  9747. * @returns a number defining the current render width
  9748. */
  9749. getRenderWidth(useScreen?: boolean): number;
  9750. /**
  9751. * Gets the current render height
  9752. * @param useScreen defines if screen size must be used (or the current render target if any)
  9753. * @returns a number defining the current render height
  9754. */
  9755. getRenderHeight(useScreen?: boolean): number;
  9756. /**
  9757. * Gets the HTML canvas attached with the current webGL context
  9758. * @returns a HTML canvas
  9759. */
  9760. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  9761. /**
  9762. * Gets the client rect of the HTML canvas attached with the current webGL context
  9763. * @returns a client rectanglee
  9764. */
  9765. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  9766. /**
  9767. * Defines the hardware scaling level.
  9768. * By default the hardware scaling level is computed from the window device ratio.
  9769. * 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.
  9770. * @param level defines the level to use
  9771. */
  9772. setHardwareScalingLevel(level: number): void;
  9773. /**
  9774. * Gets the current hardware scaling level.
  9775. * By default the hardware scaling level is computed from the window device ratio.
  9776. * 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.
  9777. * @returns a number indicating the current hardware scaling level
  9778. */
  9779. getHardwareScalingLevel(): number;
  9780. /**
  9781. * Gets the list of loaded textures
  9782. * @returns an array containing all loaded textures
  9783. */
  9784. getLoadedTexturesCache(): InternalTexture[];
  9785. /**
  9786. * Gets the object containing all engine capabilities
  9787. * @returns the EngineCapabilities object
  9788. */
  9789. getCaps(): EngineCapabilities;
  9790. /** @hidden */
  9791. readonly drawCalls: number;
  9792. /** @hidden */
  9793. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  9794. /**
  9795. * Gets the current depth function
  9796. * @returns a number defining the depth function
  9797. */
  9798. getDepthFunction(): Nullable<number>;
  9799. /**
  9800. * Sets the current depth function
  9801. * @param depthFunc defines the function to use
  9802. */
  9803. setDepthFunction(depthFunc: number): void;
  9804. /**
  9805. * Sets the current depth function to GREATER
  9806. */
  9807. setDepthFunctionToGreater(): void;
  9808. /**
  9809. * Sets the current depth function to GEQUAL
  9810. */
  9811. setDepthFunctionToGreaterOrEqual(): void;
  9812. /**
  9813. * Sets the current depth function to LESS
  9814. */
  9815. setDepthFunctionToLess(): void;
  9816. /**
  9817. * Sets the current depth function to LEQUAL
  9818. */
  9819. setDepthFunctionToLessOrEqual(): void;
  9820. /**
  9821. * Gets a boolean indicating if stencil buffer is enabled
  9822. * @returns the current stencil buffer state
  9823. */
  9824. getStencilBuffer(): boolean;
  9825. /**
  9826. * Enable or disable the stencil buffer
  9827. * @param enable defines if the stencil buffer must be enabled or disabled
  9828. */
  9829. setStencilBuffer(enable: boolean): void;
  9830. /**
  9831. * Gets the current stencil mask
  9832. * @returns a number defining the new stencil mask to use
  9833. */
  9834. getStencilMask(): number;
  9835. /**
  9836. * Sets the current stencil mask
  9837. * @param mask defines the new stencil mask to use
  9838. */
  9839. setStencilMask(mask: number): void;
  9840. /**
  9841. * Gets the current stencil function
  9842. * @returns a number defining the stencil function to use
  9843. */
  9844. getStencilFunction(): number;
  9845. /**
  9846. * Gets the current stencil reference value
  9847. * @returns a number defining the stencil reference value to use
  9848. */
  9849. getStencilFunctionReference(): number;
  9850. /**
  9851. * Gets the current stencil mask
  9852. * @returns a number defining the stencil mask to use
  9853. */
  9854. getStencilFunctionMask(): number;
  9855. /**
  9856. * Sets the current stencil function
  9857. * @param stencilFunc defines the new stencil function to use
  9858. */
  9859. setStencilFunction(stencilFunc: number): void;
  9860. /**
  9861. * Sets the current stencil reference
  9862. * @param reference defines the new stencil reference to use
  9863. */
  9864. setStencilFunctionReference(reference: number): void;
  9865. /**
  9866. * Sets the current stencil mask
  9867. * @param mask defines the new stencil mask to use
  9868. */
  9869. setStencilFunctionMask(mask: number): void;
  9870. /**
  9871. * Gets the current stencil operation when stencil fails
  9872. * @returns a number defining stencil operation to use when stencil fails
  9873. */
  9874. getStencilOperationFail(): number;
  9875. /**
  9876. * Gets the current stencil operation when depth fails
  9877. * @returns a number defining stencil operation to use when depth fails
  9878. */
  9879. getStencilOperationDepthFail(): number;
  9880. /**
  9881. * Gets the current stencil operation when stencil passes
  9882. * @returns a number defining stencil operation to use when stencil passes
  9883. */
  9884. getStencilOperationPass(): number;
  9885. /**
  9886. * Sets the stencil operation to use when stencil fails
  9887. * @param operation defines the stencil operation to use when stencil fails
  9888. */
  9889. setStencilOperationFail(operation: number): void;
  9890. /**
  9891. * Sets the stencil operation to use when depth fails
  9892. * @param operation defines the stencil operation to use when depth fails
  9893. */
  9894. setStencilOperationDepthFail(operation: number): void;
  9895. /**
  9896. * Sets the stencil operation to use when stencil passes
  9897. * @param operation defines the stencil operation to use when stencil passes
  9898. */
  9899. setStencilOperationPass(operation: number): void;
  9900. /**
  9901. * Sets a boolean indicating if the dithering state is enabled or disabled
  9902. * @param value defines the dithering state
  9903. */
  9904. setDitheringState(value: boolean): void;
  9905. /**
  9906. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  9907. * @param value defines the rasterizer state
  9908. */
  9909. setRasterizerState(value: boolean): void;
  9910. /**
  9911. * stop executing a render loop function and remove it from the execution array
  9912. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  9913. */
  9914. stopRenderLoop(renderFunction?: () => void): void;
  9915. /** @hidden */
  9916. _renderLoop(): void;
  9917. /**
  9918. * Register and execute a render loop. The engine can have more than one render function
  9919. * @param renderFunction defines the function to continuously execute
  9920. */
  9921. runRenderLoop(renderFunction: () => void): void;
  9922. /**
  9923. * Toggle full screen mode
  9924. * @param requestPointerLock defines if a pointer lock should be requested from the user
  9925. * @param options defines an option object to be sent to the requestFullscreen function
  9926. */
  9927. switchFullscreen(requestPointerLock: boolean): void;
  9928. /**
  9929. * Clear the current render buffer or the current render target (if any is set up)
  9930. * @param color defines the color to use
  9931. * @param backBuffer defines if the back buffer must be cleared
  9932. * @param depth defines if the depth buffer must be cleared
  9933. * @param stencil defines if the stencil buffer must be cleared
  9934. */
  9935. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9936. /**
  9937. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  9938. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  9939. * @param y defines the y-coordinate of the corner of the clear rectangle
  9940. * @param width defines the width of the clear rectangle
  9941. * @param height defines the height of the clear rectangle
  9942. * @param clearColor defines the clear color
  9943. */
  9944. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  9945. private _viewportCached;
  9946. /** @hidden */
  9947. _viewport(x: number, y: number, width: number, height: number): void;
  9948. /**
  9949. * Set the WebGL's viewport
  9950. * @param viewport defines the viewport element to be used
  9951. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  9952. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  9953. */
  9954. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9955. /**
  9956. * Directly set the WebGL Viewport
  9957. * @param x defines the x coordinate of the viewport (in screen space)
  9958. * @param y defines the y coordinate of the viewport (in screen space)
  9959. * @param width defines the width of the viewport (in screen space)
  9960. * @param height defines the height of the viewport (in screen space)
  9961. * @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
  9962. */
  9963. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  9964. /**
  9965. * Begin a new frame
  9966. */
  9967. beginFrame(): void;
  9968. /**
  9969. * Enf the current frame
  9970. */
  9971. endFrame(): void;
  9972. /**
  9973. * Resize the view according to the canvas' size
  9974. */
  9975. resize(): void;
  9976. /**
  9977. * Force a specific size of the canvas
  9978. * @param width defines the new canvas' width
  9979. * @param height defines the new canvas' height
  9980. */
  9981. setSize(width: number, height: number): void;
  9982. /**
  9983. * Gets a boolean indicating if a webVR device was detected
  9984. * @returns true if a webVR device was detected
  9985. */
  9986. isVRDevicePresent(): boolean;
  9987. /**
  9988. * Gets the current webVR device
  9989. * @returns the current webVR device (or null)
  9990. */
  9991. getVRDevice(): any;
  9992. /**
  9993. * Initializes a webVR display and starts listening to display change events
  9994. * The onVRDisplayChangedObservable will be notified upon these changes
  9995. * @returns The onVRDisplayChangedObservable
  9996. */
  9997. initWebVR(): Observable<IDisplayChangedEventArgs>;
  9998. /**
  9999. * Initializes a webVR display and starts listening to display change events
  10000. * The onVRDisplayChangedObservable will be notified upon these changes
  10001. * @returns A promise containing a VRDisplay and if vr is supported
  10002. */
  10003. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10004. /**
  10005. * Call this function to switch to webVR mode
  10006. * Will do nothing if webVR is not supported or if there is no webVR device
  10007. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10008. */
  10009. enableVR(): void;
  10010. /**
  10011. * Call this function to leave webVR mode
  10012. * Will do nothing if webVR is not supported or if there is no webVR device
  10013. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10014. */
  10015. disableVR(): void;
  10016. private _onVRFullScreenTriggered;
  10017. private _getVRDisplaysAsync;
  10018. /**
  10019. * Binds the frame buffer to the specified texture.
  10020. * @param texture The texture to render to or null for the default canvas
  10021. * @param faceIndex The face of the texture to render to in case of cube texture
  10022. * @param requiredWidth The width of the target to render to
  10023. * @param requiredHeight The height of the target to render to
  10024. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10025. * @param depthStencilTexture The depth stencil texture to use to render
  10026. * @param lodLevel defines le lod level to bind to the frame buffer
  10027. */
  10028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10029. private bindUnboundFramebuffer;
  10030. /**
  10031. * Unbind the current render target texture from the webGL context
  10032. * @param texture defines the render target texture to unbind
  10033. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10034. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10035. */
  10036. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10037. /**
  10038. * Unbind a list of render target textures from the webGL context
  10039. * This is used only when drawBuffer extension or webGL2 are active
  10040. * @param textures defines the render target textures to unbind
  10041. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10042. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10043. */
  10044. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10045. /**
  10046. * Force the mipmap generation for the given render target texture
  10047. * @param texture defines the render target texture to use
  10048. */
  10049. generateMipMapsForCubemap(texture: InternalTexture): void;
  10050. /**
  10051. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10052. */
  10053. flushFramebuffer(): void;
  10054. /**
  10055. * Unbind the current render target and bind the default framebuffer
  10056. */
  10057. restoreDefaultFramebuffer(): void;
  10058. /**
  10059. * Create an uniform buffer
  10060. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10061. * @param elements defines the content of the uniform buffer
  10062. * @returns the webGL uniform buffer
  10063. */
  10064. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10065. /**
  10066. * Create a dynamic uniform buffer
  10067. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10068. * @param elements defines the content of the uniform buffer
  10069. * @returns the webGL uniform buffer
  10070. */
  10071. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10072. /**
  10073. * Update an existing uniform buffer
  10074. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10075. * @param uniformBuffer defines the target uniform buffer
  10076. * @param elements defines the content to update
  10077. * @param offset defines the offset in the uniform buffer where update should start
  10078. * @param count defines the size of the data to update
  10079. */
  10080. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10081. private _resetVertexBufferBinding;
  10082. /**
  10083. * Creates a vertex buffer
  10084. * @param data the data for the vertex buffer
  10085. * @returns the new WebGL static buffer
  10086. */
  10087. createVertexBuffer(data: DataArray): WebGLBuffer;
  10088. /**
  10089. * Creates a dynamic vertex buffer
  10090. * @param data the data for the dynamic vertex buffer
  10091. * @returns the new WebGL dynamic buffer
  10092. */
  10093. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10094. /**
  10095. * Update a dynamic index buffer
  10096. * @param indexBuffer defines the target index buffer
  10097. * @param indices defines the data to update
  10098. * @param offset defines the offset in the target index buffer where update should start
  10099. */
  10100. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10101. /**
  10102. * Updates a dynamic vertex buffer.
  10103. * @param vertexBuffer the vertex buffer to update
  10104. * @param data the data used to update the vertex buffer
  10105. * @param byteOffset the byte offset of the data
  10106. * @param byteLength the byte length of the data
  10107. */
  10108. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10109. private _resetIndexBufferBinding;
  10110. /**
  10111. * Creates a new index buffer
  10112. * @param indices defines the content of the index buffer
  10113. * @param updatable defines if the index buffer must be updatable
  10114. * @returns a new webGL buffer
  10115. */
  10116. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10117. /**
  10118. * Bind a webGL buffer to the webGL context
  10119. * @param buffer defines the buffer to bind
  10120. */
  10121. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10122. /**
  10123. * Bind an uniform buffer to the current webGL context
  10124. * @param buffer defines the buffer to bind
  10125. */
  10126. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10127. /**
  10128. * Bind a buffer to the current webGL context at a given location
  10129. * @param buffer defines the buffer to bind
  10130. * @param location defines the index where to bind the buffer
  10131. */
  10132. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10133. /**
  10134. * Bind a specific block at a given index in a specific shader program
  10135. * @param shaderProgram defines the shader program
  10136. * @param blockName defines the block name
  10137. * @param index defines the index where to bind the block
  10138. */
  10139. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10140. private bindIndexBuffer;
  10141. private bindBuffer;
  10142. /**
  10143. * update the bound buffer with the given data
  10144. * @param data defines the data to update
  10145. */
  10146. updateArrayBuffer(data: Float32Array): void;
  10147. private _vertexAttribPointer;
  10148. private _bindIndexBufferWithCache;
  10149. private _bindVertexBuffersAttributes;
  10150. /**
  10151. * Records a vertex array object
  10152. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10153. * @param vertexBuffers defines the list of vertex buffers to store
  10154. * @param indexBuffer defines the index buffer to store
  10155. * @param effect defines the effect to store
  10156. * @returns the new vertex array object
  10157. */
  10158. recordVertexArrayObject(vertexBuffers: {
  10159. [key: string]: VertexBuffer;
  10160. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10161. /**
  10162. * Bind a specific vertex array object
  10163. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10164. * @param vertexArrayObject defines the vertex array object to bind
  10165. * @param indexBuffer defines the index buffer to bind
  10166. */
  10167. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10168. /**
  10169. * Bind webGl buffers directly to the webGL context
  10170. * @param vertexBuffer defines the vertex buffer to bind
  10171. * @param indexBuffer defines the index buffer to bind
  10172. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10173. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10174. * @param effect defines the effect associated with the vertex buffer
  10175. */
  10176. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10177. private _unbindVertexArrayObject;
  10178. /**
  10179. * Bind a list of vertex buffers to the webGL context
  10180. * @param vertexBuffers defines the list of vertex buffers to bind
  10181. * @param indexBuffer defines the index buffer to bind
  10182. * @param effect defines the effect associated with the vertex buffers
  10183. */
  10184. bindBuffers(vertexBuffers: {
  10185. [key: string]: Nullable<VertexBuffer>;
  10186. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10187. /**
  10188. * Unbind all instance attributes
  10189. */
  10190. unbindInstanceAttributes(): void;
  10191. /**
  10192. * Release and free the memory of a vertex array object
  10193. * @param vao defines the vertex array object to delete
  10194. */
  10195. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10196. /** @hidden */
  10197. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10198. /**
  10199. * Creates a webGL buffer to use with instanciation
  10200. * @param capacity defines the size of the buffer
  10201. * @returns the webGL buffer
  10202. */
  10203. createInstancesBuffer(capacity: number): WebGLBuffer;
  10204. /**
  10205. * Delete a webGL buffer used with instanciation
  10206. * @param buffer defines the webGL buffer to delete
  10207. */
  10208. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10209. /**
  10210. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10211. * @param instancesBuffer defines the webGL buffer to update and bind
  10212. * @param data defines the data to store in the buffer
  10213. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10214. */
  10215. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10216. /**
  10217. * Apply all cached states (depth, culling, stencil and alpha)
  10218. */
  10219. applyStates(): void;
  10220. /**
  10221. * Send a draw order
  10222. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10223. * @param indexStart defines the starting index
  10224. * @param indexCount defines the number of index to draw
  10225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10226. */
  10227. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10228. /**
  10229. * Draw a list of points
  10230. * @param verticesStart defines the index of first vertex to draw
  10231. * @param verticesCount defines the count of vertices to draw
  10232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10233. */
  10234. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10235. /**
  10236. * Draw a list of unindexed primitives
  10237. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10238. * @param verticesStart defines the index of first vertex to draw
  10239. * @param verticesCount defines the count of vertices to draw
  10240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10241. */
  10242. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10243. /**
  10244. * Draw a list of indexed primitives
  10245. * @param fillMode defines the primitive to use
  10246. * @param indexStart defines the starting index
  10247. * @param indexCount defines the number of index to draw
  10248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10249. */
  10250. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10251. /**
  10252. * Draw a list of unindexed primitives
  10253. * @param fillMode defines the primitive to use
  10254. * @param verticesStart defines the index of first vertex to draw
  10255. * @param verticesCount defines the count of vertices to draw
  10256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10257. */
  10258. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10259. private _drawMode;
  10260. /** @hidden */
  10261. _releaseEffect(effect: Effect): void;
  10262. /** @hidden */
  10263. _deleteProgram(program: WebGLProgram): void;
  10264. /**
  10265. * Create a new effect (used to store vertex/fragment shaders)
  10266. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10267. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10268. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10269. * @param samplers defines an array of string used to represent textures
  10270. * @param defines defines the string containing the defines to use to compile the shaders
  10271. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10272. * @param onCompiled defines a function to call when the effect creation is successful
  10273. * @param onError defines a function to call when the effect creation has failed
  10274. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10275. * @returns the new Effect
  10276. */
  10277. 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;
  10278. private _compileShader;
  10279. private _compileRawShader;
  10280. /**
  10281. * Directly creates a webGL program
  10282. * @param vertexCode defines the vertex shader code to use
  10283. * @param fragmentCode defines the fragment shader code to use
  10284. * @param context defines the webGL context to use (if not set, the current one will be used)
  10285. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10286. * @returns the new webGL program
  10287. */
  10288. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10289. /**
  10290. * Creates a webGL program
  10291. * @param vertexCode defines the vertex shader code to use
  10292. * @param fragmentCode defines the fragment shader code to use
  10293. * @param defines defines the string containing the defines to use to compile the shaders
  10294. * @param context defines the webGL context to use (if not set, the current one will be used)
  10295. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10296. * @returns the new webGL program
  10297. */
  10298. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10299. private _createShaderProgram;
  10300. /**
  10301. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10302. * @param shaderProgram defines the webGL program to use
  10303. * @param uniformsNames defines the list of uniform names
  10304. * @returns an array of webGL uniform locations
  10305. */
  10306. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10307. /**
  10308. * Gets the lsit of active attributes for a given webGL program
  10309. * @param shaderProgram defines the webGL program to use
  10310. * @param attributesNames defines the list of attribute names to get
  10311. * @returns an array of indices indicating the offset of each attribute
  10312. */
  10313. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10314. /**
  10315. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10316. * @param effect defines the effect to activate
  10317. */
  10318. enableEffect(effect: Nullable<Effect>): void;
  10319. /**
  10320. * Set the value of an uniform to an array of int32
  10321. * @param uniform defines the webGL uniform location where to store the value
  10322. * @param array defines the array of int32 to store
  10323. */
  10324. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10325. /**
  10326. * Set the value of an uniform to an array of int32 (stored as vec2)
  10327. * @param uniform defines the webGL uniform location where to store the value
  10328. * @param array defines the array of int32 to store
  10329. */
  10330. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10331. /**
  10332. * Set the value of an uniform to an array of int32 (stored as vec3)
  10333. * @param uniform defines the webGL uniform location where to store the value
  10334. * @param array defines the array of int32 to store
  10335. */
  10336. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10337. /**
  10338. * Set the value of an uniform to an array of int32 (stored as vec4)
  10339. * @param uniform defines the webGL uniform location where to store the value
  10340. * @param array defines the array of int32 to store
  10341. */
  10342. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10343. /**
  10344. * Set the value of an uniform to an array of float32
  10345. * @param uniform defines the webGL uniform location where to store the value
  10346. * @param array defines the array of float32 to store
  10347. */
  10348. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10349. /**
  10350. * Set the value of an uniform to an array of float32 (stored as vec2)
  10351. * @param uniform defines the webGL uniform location where to store the value
  10352. * @param array defines the array of float32 to store
  10353. */
  10354. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10355. /**
  10356. * Set the value of an uniform to an array of float32 (stored as vec3)
  10357. * @param uniform defines the webGL uniform location where to store the value
  10358. * @param array defines the array of float32 to store
  10359. */
  10360. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10361. /**
  10362. * Set the value of an uniform to an array of float32 (stored as vec4)
  10363. * @param uniform defines the webGL uniform location where to store the value
  10364. * @param array defines the array of float32 to store
  10365. */
  10366. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10367. /**
  10368. * Set the value of an uniform to an array of number
  10369. * @param uniform defines the webGL uniform location where to store the value
  10370. * @param array defines the array of number to store
  10371. */
  10372. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10373. /**
  10374. * Set the value of an uniform to an array of number (stored as vec2)
  10375. * @param uniform defines the webGL uniform location where to store the value
  10376. * @param array defines the array of number to store
  10377. */
  10378. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10379. /**
  10380. * Set the value of an uniform to an array of number (stored as vec3)
  10381. * @param uniform defines the webGL uniform location where to store the value
  10382. * @param array defines the array of number to store
  10383. */
  10384. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10385. /**
  10386. * Set the value of an uniform to an array of number (stored as vec4)
  10387. * @param uniform defines the webGL uniform location where to store the value
  10388. * @param array defines the array of number to store
  10389. */
  10390. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10391. /**
  10392. * Set the value of an uniform to an array of float32 (stored as matrices)
  10393. * @param uniform defines the webGL uniform location where to store the value
  10394. * @param matrices defines the array of float32 to store
  10395. */
  10396. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10397. /**
  10398. * Set the value of an uniform to a matrix
  10399. * @param uniform defines the webGL uniform location where to store the value
  10400. * @param matrix defines the matrix to store
  10401. */
  10402. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10403. /**
  10404. * Set the value of an uniform to a matrix (3x3)
  10405. * @param uniform defines the webGL uniform location where to store the value
  10406. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10407. */
  10408. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10409. /**
  10410. * Set the value of an uniform to a matrix (2x2)
  10411. * @param uniform defines the webGL uniform location where to store the value
  10412. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10413. */
  10414. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10415. /**
  10416. * Set the value of an uniform to a number (int)
  10417. * @param uniform defines the webGL uniform location where to store the value
  10418. * @param value defines the int number to store
  10419. */
  10420. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10421. /**
  10422. * Set the value of an uniform to a number (float)
  10423. * @param uniform defines the webGL uniform location where to store the value
  10424. * @param value defines the float number to store
  10425. */
  10426. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10427. /**
  10428. * Set the value of an uniform to a vec2
  10429. * @param uniform defines the webGL uniform location where to store the value
  10430. * @param x defines the 1st component of the value
  10431. * @param y defines the 2nd component of the value
  10432. */
  10433. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10434. /**
  10435. * Set the value of an uniform to a vec3
  10436. * @param uniform defines the webGL uniform location where to store the value
  10437. * @param x defines the 1st component of the value
  10438. * @param y defines the 2nd component of the value
  10439. * @param z defines the 3rd component of the value
  10440. */
  10441. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10442. /**
  10443. * Set the value of an uniform to a boolean
  10444. * @param uniform defines the webGL uniform location where to store the value
  10445. * @param bool defines the boolean to store
  10446. */
  10447. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10448. /**
  10449. * Set the value of an uniform to a vec4
  10450. * @param uniform defines the webGL uniform location where to store the value
  10451. * @param x defines the 1st component of the value
  10452. * @param y defines the 2nd component of the value
  10453. * @param z defines the 3rd component of the value
  10454. * @param w defines the 4th component of the value
  10455. */
  10456. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10457. /**
  10458. * Set the value of an uniform to a Color3
  10459. * @param uniform defines the webGL uniform location where to store the value
  10460. * @param color3 defines the color to store
  10461. */
  10462. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10463. /**
  10464. * Set the value of an uniform to a Color3 and an alpha value
  10465. * @param uniform defines the webGL uniform location where to store the value
  10466. * @param color3 defines the color to store
  10467. * @param alpha defines the alpha component to store
  10468. */
  10469. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10470. /**
  10471. * Sets a Color4 on a uniform variable
  10472. * @param uniform defines the uniform location
  10473. * @param color4 defines the value to be set
  10474. */
  10475. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10476. /**
  10477. * Set various states to the webGL context
  10478. * @param culling defines backface culling state
  10479. * @param zOffset defines the value to apply to zOffset (0 by default)
  10480. * @param force defines if states must be applied even if cache is up to date
  10481. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10482. */
  10483. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10484. /**
  10485. * Set the z offset to apply to current rendering
  10486. * @param value defines the offset to apply
  10487. */
  10488. setZOffset(value: number): void;
  10489. /**
  10490. * Gets the current value of the zOffset
  10491. * @returns the current zOffset state
  10492. */
  10493. getZOffset(): number;
  10494. /**
  10495. * Enable or disable depth buffering
  10496. * @param enable defines the state to set
  10497. */
  10498. setDepthBuffer(enable: boolean): void;
  10499. /**
  10500. * Gets a boolean indicating if depth writing is enabled
  10501. * @returns the current depth writing state
  10502. */
  10503. getDepthWrite(): boolean;
  10504. /**
  10505. * Enable or disable depth writing
  10506. * @param enable defines the state to set
  10507. */
  10508. setDepthWrite(enable: boolean): void;
  10509. /**
  10510. * Enable or disable color writing
  10511. * @param enable defines the state to set
  10512. */
  10513. setColorWrite(enable: boolean): void;
  10514. /**
  10515. * Gets a boolean indicating if color writing is enabled
  10516. * @returns the current color writing state
  10517. */
  10518. getColorWrite(): boolean;
  10519. /**
  10520. * Sets alpha constants used by some alpha blending modes
  10521. * @param r defines the red component
  10522. * @param g defines the green component
  10523. * @param b defines the blue component
  10524. * @param a defines the alpha component
  10525. */
  10526. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  10527. /**
  10528. * Sets the current alpha mode
  10529. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  10530. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  10531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10532. */
  10533. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  10534. /**
  10535. * Gets the current alpha mode
  10536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10537. * @returns the current alpha mode
  10538. */
  10539. getAlphaMode(): number;
  10540. /**
  10541. * Clears the list of texture accessible through engine.
  10542. * This can help preventing texture load conflict due to name collision.
  10543. */
  10544. clearInternalTexturesCache(): void;
  10545. /**
  10546. * Force the entire cache to be cleared
  10547. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  10548. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  10549. */
  10550. wipeCaches(bruteForce?: boolean): void;
  10551. /**
  10552. * Set the compressed texture format to use, based on the formats you have, and the formats
  10553. * supported by the hardware / browser.
  10554. *
  10555. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  10556. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  10557. * to API arguments needed to compressed textures. This puts the burden on the container
  10558. * generator to house the arcane code for determining these for current & future formats.
  10559. *
  10560. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  10561. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  10562. *
  10563. * Note: The result of this call is not taken into account when a texture is base64.
  10564. *
  10565. * @param formatsAvailable defines the list of those format families you have created
  10566. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  10567. *
  10568. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  10569. * @returns The extension selected.
  10570. */
  10571. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  10572. private _getSamplingParameters;
  10573. private _partialLoadImg;
  10574. private _cascadeLoadImgs;
  10575. /** @hidden */
  10576. _createTexture(): WebGLTexture;
  10577. /**
  10578. * Usually called from BABYLON.Texture.ts.
  10579. * Passed information to create a WebGLTexture
  10580. * @param urlArg defines a value which contains one of the following:
  10581. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  10582. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  10583. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  10584. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  10585. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  10586. * @param scene needed for loading to the correct scene
  10587. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  10588. * @param onLoad optional callback to be called upon successful completion
  10589. * @param onError optional callback to be called upon failure
  10590. * @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
  10591. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  10592. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  10593. * @param forcedExtension defines the extension to use to pick the right loader
  10594. * @returns a InternalTexture for assignment back into BABYLON.Texture
  10595. */
  10596. 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;
  10597. private _rescaleTexture;
  10598. /**
  10599. * Update a raw texture
  10600. * @param texture defines the texture to update
  10601. * @param data defines the data to store in the texture
  10602. * @param format defines the format of the data
  10603. * @param invertY defines if data must be stored with Y axis inverted
  10604. * @param compression defines the compression used (null by default)
  10605. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10606. */
  10607. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  10608. /**
  10609. * Creates a raw texture
  10610. * @param data defines the data to store in the texture
  10611. * @param width defines the width of the texture
  10612. * @param height defines the height of the texture
  10613. * @param format defines the format of the data
  10614. * @param generateMipMaps defines if the engine should generate the mip levels
  10615. * @param invertY defines if data must be stored with Y axis inverted
  10616. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10617. * @param compression defines the compression used (null by default)
  10618. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10619. * @returns the raw texture inside an InternalTexture
  10620. */
  10621. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  10622. private _unpackFlipYCached;
  10623. /**
  10624. * In case you are sharing the context with other applications, it might
  10625. * be interested to not cache the unpack flip y state to ensure a consistent
  10626. * value would be set.
  10627. */
  10628. enableUnpackFlipYCached: boolean;
  10629. /** @hidden */
  10630. _unpackFlipY(value: boolean): void;
  10631. /** @hidden */
  10632. _getUnpackAlignement(): number;
  10633. /**
  10634. * Creates a dynamic texture
  10635. * @param width defines the width of the texture
  10636. * @param height defines the height of the texture
  10637. * @param generateMipMaps defines if the engine should generate the mip levels
  10638. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10639. * @returns the dynamic texture inside an InternalTexture
  10640. */
  10641. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10642. /**
  10643. * Update the sampling mode of a given texture
  10644. * @param samplingMode defines the required sampling mode
  10645. * @param texture defines the texture to update
  10646. */
  10647. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  10648. /**
  10649. * Update the content of a dynamic texture
  10650. * @param texture defines the texture to update
  10651. * @param canvas defines the canvas containing the source
  10652. * @param invertY defines if data must be stored with Y axis inverted
  10653. * @param premulAlpha defines if alpha is stored as premultiplied
  10654. * @param format defines the format of the data
  10655. */
  10656. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  10657. /**
  10658. * Update a video texture
  10659. * @param texture defines the texture to update
  10660. * @param video defines the video element to use
  10661. * @param invertY defines if data must be stored with Y axis inverted
  10662. */
  10663. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  10664. /**
  10665. * Updates a depth texture Comparison Mode and Function.
  10666. * If the comparison Function is equal to 0, the mode will be set to none.
  10667. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  10668. * @param texture The texture to set the comparison function for
  10669. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  10670. */
  10671. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  10672. private _setupDepthStencilTexture;
  10673. /**
  10674. * Creates a depth stencil texture.
  10675. * This is only available in WebGL 2 or with the depth texture extension available.
  10676. * @param size The size of face edge in the texture.
  10677. * @param options The options defining the texture.
  10678. * @returns The texture
  10679. */
  10680. createDepthStencilTexture(size: number | {
  10681. width: number;
  10682. height: number;
  10683. }, options: DepthTextureCreationOptions): InternalTexture;
  10684. /**
  10685. * Creates a depth stencil texture.
  10686. * This is only available in WebGL 2 or with the depth texture extension available.
  10687. * @param size The size of face edge in the texture.
  10688. * @param options The options defining the texture.
  10689. * @returns The texture
  10690. */
  10691. private _createDepthStencilTexture;
  10692. /**
  10693. * Creates a depth stencil cube texture.
  10694. * This is only available in WebGL 2.
  10695. * @param size The size of face edge in the cube texture.
  10696. * @param options The options defining the cube texture.
  10697. * @returns The cube texture
  10698. */
  10699. private _createDepthStencilCubeTexture;
  10700. /**
  10701. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  10702. * @param renderTarget The render target to set the frame buffer for
  10703. */
  10704. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  10705. /**
  10706. * Creates a new render target texture
  10707. * @param size defines the size of the texture
  10708. * @param options defines the options used to create the texture
  10709. * @returns a new render target texture stored in an InternalTexture
  10710. */
  10711. createRenderTargetTexture(size: number | {
  10712. width: number;
  10713. height: number;
  10714. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  10715. /**
  10716. * Create a multi render target texture
  10717. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  10718. * @param size defines the size of the texture
  10719. * @param options defines the creation options
  10720. * @returns the cube texture as an InternalTexture
  10721. */
  10722. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  10723. private _setupFramebufferDepthAttachments;
  10724. /**
  10725. * Updates the sample count of a render target texture
  10726. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10727. * @param texture defines the texture to update
  10728. * @param samples defines the sample count to set
  10729. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10730. */
  10731. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  10732. /**
  10733. * Update the sample count for a given multiple render target texture
  10734. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10735. * @param textures defines the textures to update
  10736. * @param samples defines the sample count to set
  10737. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10738. */
  10739. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  10740. /** @hidden */
  10741. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10742. /** @hidden */
  10743. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10744. /** @hidden */
  10745. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10746. /** @hidden */
  10747. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  10748. /**
  10749. * Creates a new render target cube texture
  10750. * @param size defines the size of the texture
  10751. * @param options defines the options used to create the texture
  10752. * @returns a new render target cube texture stored in an InternalTexture
  10753. */
  10754. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10755. /**
  10756. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  10757. * @param rootUrl defines the url where the file to load is located
  10758. * @param scene defines the current scene
  10759. * @param lodScale defines scale to apply to the mip map selection
  10760. * @param lodOffset defines offset to apply to the mip map selection
  10761. * @param onLoad defines an optional callback raised when the texture is loaded
  10762. * @param onError defines an optional callback raised if there is an issue to load the texture
  10763. * @param format defines the format of the data
  10764. * @param forcedExtension defines the extension to use to pick the right loader
  10765. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  10766. * @returns the cube texture as an InternalTexture
  10767. */
  10768. 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;
  10769. /**
  10770. * Creates a cube texture
  10771. * @param rootUrl defines the url where the files to load is located
  10772. * @param scene defines the current scene
  10773. * @param files defines the list of files to load (1 per face)
  10774. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10775. * @param onLoad defines an optional callback raised when the texture is loaded
  10776. * @param onError defines an optional callback raised if there is an issue to load the texture
  10777. * @param format defines the format of the data
  10778. * @param forcedExtension defines the extension to use to pick the right loader
  10779. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10780. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10781. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10782. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10783. * @returns the cube texture as an InternalTexture
  10784. */
  10785. 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;
  10786. /**
  10787. * @hidden
  10788. */
  10789. _setCubeMapTextureParams(loadMipmap: boolean): void;
  10790. /**
  10791. * Update a raw cube texture
  10792. * @param texture defines the texture to udpdate
  10793. * @param data defines the data to store
  10794. * @param format defines the data format
  10795. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10796. * @param invertY defines if data must be stored with Y axis inverted
  10797. * @param compression defines the compression used (null by default)
  10798. * @param level defines which level of the texture to update
  10799. */
  10800. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  10801. /**
  10802. * Creates a new raw cube texture
  10803. * @param data defines the array of data to use to create each face
  10804. * @param size defines the size of the textures
  10805. * @param format defines the format of the data
  10806. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10807. * @param generateMipMaps defines if the engine should generate the mip levels
  10808. * @param invertY defines if data must be stored with Y axis inverted
  10809. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10810. * @param compression defines the compression used (null by default)
  10811. * @returns the cube texture as an InternalTexture
  10812. */
  10813. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  10814. /**
  10815. * Creates a new raw cube texture from a specified url
  10816. * @param url defines the url where the data is located
  10817. * @param scene defines the current scene
  10818. * @param size defines the size of the textures
  10819. * @param format defines the format of the data
  10820. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10821. * @param noMipmap defines if the engine should avoid generating the mip levels
  10822. * @param callback defines a callback used to extract texture data from loaded data
  10823. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10824. * @param onLoad defines a callback called when texture is loaded
  10825. * @param onError defines a callback called if there is an error
  10826. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10827. * @param invertY defines if data must be stored with Y axis inverted
  10828. * @returns the cube texture as an InternalTexture
  10829. */
  10830. 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;
  10831. /**
  10832. * Update a raw 3D texture
  10833. * @param texture defines the texture to update
  10834. * @param data defines the data to store
  10835. * @param format defines the data format
  10836. * @param invertY defines if data must be stored with Y axis inverted
  10837. * @param compression defines the used compression (can be null)
  10838. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10839. */
  10840. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  10841. /**
  10842. * Creates a new raw 3D texture
  10843. * @param data defines the data used to create the texture
  10844. * @param width defines the width of the texture
  10845. * @param height defines the height of the texture
  10846. * @param depth defines the depth of the texture
  10847. * @param format defines the format of the texture
  10848. * @param generateMipMaps defines if the engine must generate mip levels
  10849. * @param invertY defines if data must be stored with Y axis inverted
  10850. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10851. * @param compression defines the compressed used (can be null)
  10852. * @param textureType defines the compressed used (can be null)
  10853. * @returns a new raw 3D texture (stored in an InternalTexture)
  10854. */
  10855. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  10856. private _prepareWebGLTextureContinuation;
  10857. private _prepareWebGLTexture;
  10858. private _convertRGBtoRGBATextureData;
  10859. /** @hidden */
  10860. _releaseFramebufferObjects(texture: InternalTexture): void;
  10861. /** @hidden */
  10862. _releaseTexture(texture: InternalTexture): void;
  10863. private setProgram;
  10864. private _boundUniforms;
  10865. /**
  10866. * Binds an effect to the webGL context
  10867. * @param effect defines the effect to bind
  10868. */
  10869. bindSamplers(effect: Effect): void;
  10870. private _moveBoundTextureOnTop;
  10871. private _getCorrectTextureChannel;
  10872. private _linkTrackers;
  10873. private _removeDesignatedSlot;
  10874. private _activateCurrentTexture;
  10875. /** @hidden */
  10876. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  10877. /** @hidden */
  10878. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  10879. /**
  10880. * Sets a texture to the webGL context from a postprocess
  10881. * @param channel defines the channel to use
  10882. * @param postProcess defines the source postprocess
  10883. */
  10884. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  10885. /**
  10886. * Binds the output of the passed in post process to the texture channel specified
  10887. * @param channel The channel the texture should be bound to
  10888. * @param postProcess The post process which's output should be bound
  10889. */
  10890. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  10891. /**
  10892. * Unbind all textures from the webGL context
  10893. */
  10894. unbindAllTextures(): void;
  10895. /**
  10896. * Sets a texture to the according uniform.
  10897. * @param channel The texture channel
  10898. * @param uniform The uniform to set
  10899. * @param texture The texture to apply
  10900. */
  10901. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  10902. /**
  10903. * Sets a depth stencil texture from a render target to the according uniform.
  10904. * @param channel The texture channel
  10905. * @param uniform The uniform to set
  10906. * @param texture The render target texture containing the depth stencil texture to apply
  10907. */
  10908. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  10909. private _bindSamplerUniformToChannel;
  10910. private _getTextureWrapMode;
  10911. private _setTexture;
  10912. /**
  10913. * Sets an array of texture to the webGL context
  10914. * @param channel defines the channel where the texture array must be set
  10915. * @param uniform defines the associated uniform location
  10916. * @param textures defines the array of textures to bind
  10917. */
  10918. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  10919. /** @hidden */
  10920. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  10921. private _setTextureParameterFloat;
  10922. private _setTextureParameterInteger;
  10923. /**
  10924. * Reads pixels from the current frame buffer. Please note that this function can be slow
  10925. * @param x defines the x coordinate of the rectangle where pixels must be read
  10926. * @param y defines the y coordinate of the rectangle where pixels must be read
  10927. * @param width defines the width of the rectangle where pixels must be read
  10928. * @param height defines the height of the rectangle where pixels must be read
  10929. * @returns a Uint8Array containing RGBA colors
  10930. */
  10931. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  10932. /**
  10933. * Add an externaly attached data from its key.
  10934. * This method call will fail and return false, if such key already exists.
  10935. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  10936. * @param key the unique key that identifies the data
  10937. * @param data the data object to associate to the key for this Engine instance
  10938. * @return true if no such key were already present and the data was added successfully, false otherwise
  10939. */
  10940. addExternalData<T>(key: string, data: T): boolean;
  10941. /**
  10942. * Get an externaly attached data from its key
  10943. * @param key the unique key that identifies the data
  10944. * @return the associated data, if present (can be null), or undefined if not present
  10945. */
  10946. getExternalData<T>(key: string): T;
  10947. /**
  10948. * Get an externaly attached data from its key, create it using a factory if it's not already present
  10949. * @param key the unique key that identifies the data
  10950. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  10951. * @return the associated data, can be null if the factory returned null.
  10952. */
  10953. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  10954. /**
  10955. * Remove an externaly attached data from the Engine instance
  10956. * @param key the unique key that identifies the data
  10957. * @return true if the data was successfully removed, false if it doesn't exist
  10958. */
  10959. removeExternalData(key: string): boolean;
  10960. /**
  10961. * Unbind all vertex attributes from the webGL context
  10962. */
  10963. unbindAllAttributes(): void;
  10964. /**
  10965. * 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
  10966. */
  10967. releaseEffects(): void;
  10968. /**
  10969. * Dispose and release all associated resources
  10970. */
  10971. dispose(): void;
  10972. /**
  10973. * Display the loading screen
  10974. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10975. */
  10976. displayLoadingUI(): void;
  10977. /**
  10978. * Hide the loading screen
  10979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10980. */
  10981. hideLoadingUI(): void;
  10982. /**
  10983. * Gets the current loading screen object
  10984. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10985. */
  10986. /**
  10987. * Sets the current loading screen object
  10988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10989. */
  10990. loadingScreen: ILoadingScreen;
  10991. /**
  10992. * Sets the current loading screen text
  10993. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10994. */
  10995. loadingUIText: string;
  10996. /**
  10997. * Sets the current loading screen background color
  10998. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10999. */
  11000. loadingUIBackgroundColor: string;
  11001. /**
  11002. * Attach a new callback raised when context lost event is fired
  11003. * @param callback defines the callback to call
  11004. */
  11005. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11006. /**
  11007. * Attach a new callback raised when context restored event is fired
  11008. * @param callback defines the callback to call
  11009. */
  11010. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11011. /**
  11012. * Gets the source code of the vertex shader associated with a specific webGL program
  11013. * @param program defines the program to use
  11014. * @returns a string containing the source code of the vertex shader associated with the program
  11015. */
  11016. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11017. /**
  11018. * Gets the source code of the fragment shader associated with a specific webGL program
  11019. * @param program defines the program to use
  11020. * @returns a string containing the source code of the fragment shader associated with the program
  11021. */
  11022. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11023. /**
  11024. * Get the current error code of the webGL context
  11025. * @returns the error code
  11026. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11027. */
  11028. getError(): number;
  11029. /**
  11030. * Gets the current framerate
  11031. * @returns a number representing the framerate
  11032. */
  11033. getFps(): number;
  11034. /**
  11035. * Gets the time spent between current and previous frame
  11036. * @returns a number representing the delta time in ms
  11037. */
  11038. getDeltaTime(): number;
  11039. private _measureFps;
  11040. /** @hidden */
  11041. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11042. private _canRenderToFloatFramebuffer;
  11043. private _canRenderToHalfFloatFramebuffer;
  11044. private _canRenderToFramebuffer;
  11045. /** @hidden */
  11046. _getWebGLTextureType(type: number): number;
  11047. private _getInternalFormat;
  11048. /** @hidden */
  11049. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11050. /** @hidden */
  11051. _getRGBAMultiSampleBufferFormat(type: number): number;
  11052. /** @hidden */
  11053. _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;
  11054. /** @hidden */
  11055. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11056. private _partialLoadFile;
  11057. private _cascadeLoadFiles;
  11058. /**
  11059. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11060. * @returns true if the engine can be created
  11061. * @ignorenaming
  11062. */
  11063. static isSupported(): boolean;
  11064. }
  11065. }
  11066. declare module BABYLON {
  11067. class NullEngineOptions {
  11068. renderWidth: number;
  11069. renderHeight: number;
  11070. textureSize: number;
  11071. deterministicLockstep: boolean;
  11072. lockstepMaxSteps: number;
  11073. }
  11074. /**
  11075. * The null engine class provides support for headless version of babylon.js.
  11076. * This can be used in server side scenario or for testing purposes
  11077. */
  11078. class NullEngine extends Engine {
  11079. private _options;
  11080. isDeterministicLockStep(): boolean;
  11081. getLockstepMaxSteps(): number;
  11082. getHardwareScalingLevel(): number;
  11083. constructor(options?: NullEngineOptions);
  11084. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11085. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11086. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11087. getRenderWidth(useScreen?: boolean): number;
  11088. getRenderHeight(useScreen?: boolean): number;
  11089. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11090. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11091. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11092. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11093. bindSamplers(effect: Effect): void;
  11094. enableEffect(effect: Effect): void;
  11095. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11096. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11097. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11098. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11099. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11100. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11101. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11102. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11103. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11104. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11105. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11106. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11107. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11108. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11109. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11110. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11111. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11112. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11113. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11114. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11115. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11116. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11117. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11118. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11119. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11120. bindBuffers(vertexBuffers: {
  11121. [key: string]: VertexBuffer;
  11122. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11123. wipeCaches(bruteForce?: boolean): void;
  11124. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11125. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11126. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11127. /** @hidden */
  11128. _createTexture(): WebGLTexture;
  11129. /** @hidden */
  11130. _releaseTexture(texture: InternalTexture): void;
  11131. 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;
  11132. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11133. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11134. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11135. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11136. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11137. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11138. /**
  11139. * @hidden
  11140. * Get the current error code of the webGL context
  11141. * @returns the error code
  11142. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11143. */
  11144. getError(): number;
  11145. /** @hidden */
  11146. _getUnpackAlignement(): number;
  11147. /** @hidden */
  11148. _unpackFlipY(value: boolean): void;
  11149. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11150. /**
  11151. * Updates a dynamic vertex buffer.
  11152. * @param vertexBuffer the vertex buffer to update
  11153. * @param data the data used to update the vertex buffer
  11154. * @param byteOffset the byte offset of the data (optional)
  11155. * @param byteLength the byte length of the data (optional)
  11156. */
  11157. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11158. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11159. /** @hidden */
  11160. _bindTexture(channel: number, texture: InternalTexture): void;
  11161. /** @hidden */
  11162. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11163. releaseEffects(): void;
  11164. displayLoadingUI(): void;
  11165. hideLoadingUI(): void;
  11166. /** @hidden */
  11167. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11168. /** @hidden */
  11169. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11170. /** @hidden */
  11171. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11172. /** @hidden */
  11173. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11174. }
  11175. }
  11176. interface WebGLRenderingContext {
  11177. readonly RASTERIZER_DISCARD: number;
  11178. readonly DEPTH_COMPONENT24: number;
  11179. readonly TEXTURE_3D: number;
  11180. readonly TEXTURE_2D_ARRAY: number;
  11181. readonly TEXTURE_COMPARE_FUNC: number;
  11182. readonly TEXTURE_COMPARE_MODE: number;
  11183. readonly COMPARE_REF_TO_TEXTURE: number;
  11184. readonly TEXTURE_WRAP_R: number;
  11185. readonly HALF_FLOAT: number;
  11186. readonly RGB8: number;
  11187. readonly RED_INTEGER: number;
  11188. readonly RG_INTEGER: number;
  11189. readonly RGB_INTEGER: number;
  11190. readonly RGBA_INTEGER: number;
  11191. readonly R8_SNORM: number;
  11192. readonly RG8_SNORM: number;
  11193. readonly RGB8_SNORM: number;
  11194. readonly RGBA8_SNORM: number;
  11195. readonly R8I: number;
  11196. readonly RG8I: number;
  11197. readonly RGB8I: number;
  11198. readonly RGBA8I: number;
  11199. readonly R8UI: number;
  11200. readonly RG8UI: number;
  11201. readonly RGB8UI: number;
  11202. readonly RGBA8UI: number;
  11203. readonly R16I: number;
  11204. readonly RG16I: number;
  11205. readonly RGB16I: number;
  11206. readonly RGBA16I: number;
  11207. readonly R16UI: number;
  11208. readonly RG16UI: number;
  11209. readonly RGB16UI: number;
  11210. readonly RGBA16UI: number;
  11211. readonly R32I: number;
  11212. readonly RG32I: number;
  11213. readonly RGB32I: number;
  11214. readonly RGBA32I: number;
  11215. readonly R32UI: number;
  11216. readonly RG32UI: number;
  11217. readonly RGB32UI: number;
  11218. readonly RGBA32UI: number;
  11219. readonly RGB10_A2UI: number;
  11220. readonly R11F_G11F_B10F: number;
  11221. readonly RGB9_E5: number;
  11222. readonly RGB10_A2: number;
  11223. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11224. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11225. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11226. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11227. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11228. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11229. 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;
  11230. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11231. readonly TRANSFORM_FEEDBACK: number;
  11232. readonly INTERLEAVED_ATTRIBS: number;
  11233. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11234. createTransformFeedback(): WebGLTransformFeedback;
  11235. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11236. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11237. beginTransformFeedback(primitiveMode: number): void;
  11238. endTransformFeedback(): void;
  11239. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11240. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11241. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11242. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11243. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11244. }
  11245. interface ImageBitmap {
  11246. readonly width: number;
  11247. readonly height: number;
  11248. close(): void;
  11249. }
  11250. interface WebGLQuery extends WebGLObject {
  11251. }
  11252. declare var WebGLQuery: {
  11253. prototype: WebGLQuery;
  11254. new (): WebGLQuery;
  11255. };
  11256. interface WebGLSampler extends WebGLObject {
  11257. }
  11258. declare var WebGLSampler: {
  11259. prototype: WebGLSampler;
  11260. new (): WebGLSampler;
  11261. };
  11262. interface WebGLSync extends WebGLObject {
  11263. }
  11264. declare var WebGLSync: {
  11265. prototype: WebGLSync;
  11266. new (): WebGLSync;
  11267. };
  11268. interface WebGLTransformFeedback extends WebGLObject {
  11269. }
  11270. declare var WebGLTransformFeedback: {
  11271. prototype: WebGLTransformFeedback;
  11272. new (): WebGLTransformFeedback;
  11273. };
  11274. interface WebGLVertexArrayObject extends WebGLObject {
  11275. }
  11276. declare var WebGLVertexArrayObject: {
  11277. prototype: WebGLVertexArrayObject;
  11278. new (): WebGLVertexArrayObject;
  11279. };
  11280. declare module BABYLON {
  11281. /**
  11282. * Class used to store bounding box information
  11283. */
  11284. class BoundingBox implements ICullable {
  11285. /**
  11286. * Gets the 8 vectors representing the bounding box in local space
  11287. */
  11288. vectors: Vector3[];
  11289. /**
  11290. * Gets the center of the bounding box in local space
  11291. */
  11292. center: Vector3;
  11293. /**
  11294. * Gets the center of the bounding box in world space
  11295. */
  11296. centerWorld: Vector3;
  11297. /**
  11298. * Gets the extend size in local space
  11299. */
  11300. extendSize: Vector3;
  11301. /**
  11302. * Gets the extend size in world space
  11303. */
  11304. extendSizeWorld: Vector3;
  11305. /**
  11306. * Gets the OBB (object bounding box) directions
  11307. */
  11308. directions: Vector3[];
  11309. /**
  11310. * Gets the 8 vectors representing the bounding box in world space
  11311. */
  11312. vectorsWorld: Vector3[];
  11313. /**
  11314. * Gets the minimum vector in world space
  11315. */
  11316. minimumWorld: Vector3;
  11317. /**
  11318. * Gets the maximum vector in world space
  11319. */
  11320. maximumWorld: Vector3;
  11321. /**
  11322. * Gets the minimum vector in local space
  11323. */
  11324. minimum: Vector3;
  11325. /**
  11326. * Gets the maximum vector in local space
  11327. */
  11328. maximum: Vector3;
  11329. private _worldMatrix;
  11330. /**
  11331. * @hidden
  11332. */
  11333. _tag: number;
  11334. /**
  11335. * Creates a new bounding box
  11336. * @param min defines the minimum vector (in local space)
  11337. * @param max defines the maximum vector (in local space)
  11338. */
  11339. constructor(min: Vector3, max: Vector3);
  11340. /**
  11341. * Recreates the entire bounding box from scratch
  11342. * @param min defines the new minimum vector (in local space)
  11343. * @param max defines the new maximum vector (in local space)
  11344. */
  11345. reConstruct(min: Vector3, max: Vector3): void;
  11346. /**
  11347. * Scale the current bounding box by applying a scale factor
  11348. * @param factor defines the scale factor to apply
  11349. * @returns the current bounding box
  11350. */
  11351. scale(factor: number): BoundingBox;
  11352. /**
  11353. * Gets the world matrix of the bounding box
  11354. * @returns a matrix
  11355. */
  11356. getWorldMatrix(): Matrix;
  11357. /**
  11358. * Sets the world matrix stored in the bounding box
  11359. * @param matrix defines the matrix to store
  11360. * @returns current bounding box
  11361. */
  11362. setWorldMatrix(matrix: Matrix): BoundingBox;
  11363. /** @hidden */
  11364. _update(world: Matrix): void;
  11365. /**
  11366. * Tests if the bounding box is intersecting the frustum planes
  11367. * @param frustumPlanes defines the frustum planes to test
  11368. * @returns true if there is an intersection
  11369. */
  11370. isInFrustum(frustumPlanes: Plane[]): boolean;
  11371. /**
  11372. * Tests if the bounding box is entirely inside the frustum planes
  11373. * @param frustumPlanes defines the frustum planes to test
  11374. * @returns true if there is an inclusion
  11375. */
  11376. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11377. /**
  11378. * Tests if a point is inside the bounding box
  11379. * @param point defines the point to test
  11380. * @returns true if the point is inside the bounding box
  11381. */
  11382. intersectsPoint(point: Vector3): boolean;
  11383. /**
  11384. * Tests if the bounding box intersects with a bounding sphere
  11385. * @param sphere defines the sphere to test
  11386. * @returns true if there is an intersection
  11387. */
  11388. intersectsSphere(sphere: BoundingSphere): boolean;
  11389. /**
  11390. * Tests if the bounding box intersects with a box defined by a min and max vectors
  11391. * @param min defines the min vector to use
  11392. * @param max defines the max vector to use
  11393. * @returns true if there is an intersection
  11394. */
  11395. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  11396. /**
  11397. * Tests if two bounding boxes are intersections
  11398. * @param box0 defines the first box to test
  11399. * @param box1 defines the second box to test
  11400. * @returns true if there is an intersection
  11401. */
  11402. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  11403. /**
  11404. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  11405. * @param minPoint defines the minimum vector of the bounding box
  11406. * @param maxPoint defines the maximum vector of the bounding box
  11407. * @param sphereCenter defines the sphere center
  11408. * @param sphereRadius defines the sphere radius
  11409. * @returns true if there is an intersection
  11410. */
  11411. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  11412. /**
  11413. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  11414. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  11415. * @param frustumPlanes defines the frustum planes to test
  11416. * @return true if there is an inclusion
  11417. */
  11418. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  11419. /**
  11420. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  11421. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  11422. * @param frustumPlanes defines the frustum planes to test
  11423. * @return true if there is an intersection
  11424. */
  11425. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  11426. }
  11427. }
  11428. declare module BABYLON {
  11429. interface ICullable {
  11430. isInFrustum(frustumPlanes: Plane[]): boolean;
  11431. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11432. }
  11433. class BoundingInfo implements ICullable {
  11434. minimum: Vector3;
  11435. maximum: Vector3;
  11436. boundingBox: BoundingBox;
  11437. boundingSphere: BoundingSphere;
  11438. private _isLocked;
  11439. constructor(minimum: Vector3, maximum: Vector3);
  11440. isLocked: boolean;
  11441. update(world: Matrix): void;
  11442. /**
  11443. * Recreate the bounding info to be centered around a specific point given a specific extend.
  11444. * @param center New center of the bounding info
  11445. * @param extend New extend of the bounding info
  11446. */
  11447. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  11448. /**
  11449. * Scale the current bounding info by applying a scale factor
  11450. * @param factor defines the scale factor to apply
  11451. * @returns the current bounding info
  11452. */
  11453. scale(factor: number): BoundingInfo;
  11454. /**
  11455. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  11456. * @param frustumPlanes defines the frustum to test
  11457. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  11458. * @returns true if the bounding info is in the frustum planes
  11459. */
  11460. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  11461. /**
  11462. * Gets the world distance between the min and max points of the bounding box
  11463. */
  11464. readonly diagonalLength: number;
  11465. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11466. /** @hidden */
  11467. _checkCollision(collider: Collider): boolean;
  11468. intersectsPoint(point: Vector3): boolean;
  11469. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  11470. }
  11471. }
  11472. declare module BABYLON {
  11473. class BoundingSphere {
  11474. center: Vector3;
  11475. radius: number;
  11476. centerWorld: Vector3;
  11477. radiusWorld: number;
  11478. minimum: Vector3;
  11479. maximum: Vector3;
  11480. /**
  11481. * Creates a new bounding sphere
  11482. * @param min defines the minimum vector (in local space)
  11483. * @param max defines the maximum vector (in local space)
  11484. */
  11485. constructor(min: Vector3, max: Vector3);
  11486. /**
  11487. * Recreates the entire bounding sphere from scratch
  11488. * @param min defines the new minimum vector (in local space)
  11489. * @param max defines the new maximum vector (in local space)
  11490. */
  11491. reConstruct(min: Vector3, max: Vector3): void;
  11492. /**
  11493. * Scale the current bounding sphere by applying a scale factor
  11494. * @param factor defines the scale factor to apply
  11495. * @returns the current bounding box
  11496. */
  11497. scale(factor: number): BoundingSphere;
  11498. /** @hidden */
  11499. _update(world: Matrix): void;
  11500. isInFrustum(frustumPlanes: Plane[]): boolean;
  11501. intersectsPoint(point: Vector3): boolean;
  11502. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  11503. }
  11504. }
  11505. declare module BABYLON {
  11506. class Ray {
  11507. origin: Vector3;
  11508. direction: Vector3;
  11509. length: number;
  11510. private _edge1;
  11511. private _edge2;
  11512. private _pvec;
  11513. private _tvec;
  11514. private _qvec;
  11515. private _tmpRay;
  11516. constructor(origin: Vector3, direction: Vector3, length?: number);
  11517. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  11518. intersectsBox(box: BoundingBox): boolean;
  11519. intersectsSphere(sphere: BoundingSphere): boolean;
  11520. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  11521. intersectsPlane(plane: Plane): Nullable<number>;
  11522. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  11523. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11524. private _comparePickingInfo;
  11525. private static smallnum;
  11526. private static rayl;
  11527. /**
  11528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11529. * @param sega the first point of the segment to test the intersection against
  11530. * @param segb the second point of the segment to test the intersection against
  11531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11533. */
  11534. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  11535. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  11536. static Zero(): Ray;
  11537. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  11538. /**
  11539. * 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
  11540. * transformed to the given world matrix.
  11541. * @param origin The origin point
  11542. * @param end The end point
  11543. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11544. */
  11545. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  11546. static Transform(ray: Ray, matrix: Matrix): Ray;
  11547. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  11548. }
  11549. }
  11550. declare module BABYLON {
  11551. /**
  11552. * Gather the list of keyboard event types as constants.
  11553. */
  11554. class KeyboardEventTypes {
  11555. /**
  11556. * The keydown event is fired when a key becomes active (pressed).
  11557. */
  11558. static readonly KEYDOWN: number;
  11559. /**
  11560. * The keyup event is fired when a key has been released.
  11561. */
  11562. static readonly KEYUP: number;
  11563. }
  11564. /**
  11565. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11566. */
  11567. class KeyboardInfo {
  11568. /**
  11569. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11570. */
  11571. type: number;
  11572. /**
  11573. * Defines the related dom event
  11574. */
  11575. event: KeyboardEvent;
  11576. /**
  11577. * Instantiates a new keyboard info.
  11578. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11579. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11580. * @param event Defines the related dom event
  11581. */
  11582. constructor(
  11583. /**
  11584. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11585. */
  11586. type: number,
  11587. /**
  11588. * Defines the related dom event
  11589. */
  11590. event: KeyboardEvent);
  11591. }
  11592. /**
  11593. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11594. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  11595. */
  11596. class KeyboardInfoPre extends KeyboardInfo {
  11597. /**
  11598. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11599. */
  11600. type: number;
  11601. /**
  11602. * Defines the related dom event
  11603. */
  11604. event: KeyboardEvent;
  11605. /**
  11606. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  11607. */
  11608. skipOnPointerObservable: boolean;
  11609. /**
  11610. * Instantiates a new keyboard pre info.
  11611. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11612. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11613. * @param event Defines the related dom event
  11614. */
  11615. constructor(
  11616. /**
  11617. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11618. */
  11619. type: number,
  11620. /**
  11621. * Defines the related dom event
  11622. */
  11623. event: KeyboardEvent);
  11624. }
  11625. }
  11626. declare module BABYLON {
  11627. /**
  11628. * Gather the list of pointer event types as constants.
  11629. */
  11630. class PointerEventTypes {
  11631. /**
  11632. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11633. */
  11634. static readonly POINTERDOWN: number;
  11635. /**
  11636. * The pointerup event is fired when a pointer is no longer active.
  11637. */
  11638. static readonly POINTERUP: number;
  11639. /**
  11640. * The pointermove event is fired when a pointer changes coordinates.
  11641. */
  11642. static readonly POINTERMOVE: number;
  11643. /**
  11644. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11645. */
  11646. static readonly POINTERWHEEL: number;
  11647. /**
  11648. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11649. */
  11650. static readonly POINTERPICK: number;
  11651. /**
  11652. * The pointertap event is fired when a the object has been touched and released without drag.
  11653. */
  11654. static readonly POINTERTAP: number;
  11655. /**
  11656. * The pointertap event is fired when a the object has been touched and released twice without drag.
  11657. */
  11658. static readonly POINTERDOUBLETAP: number;
  11659. }
  11660. /**
  11661. * Base class of pointer info types.
  11662. */
  11663. class PointerInfoBase {
  11664. /**
  11665. * Defines the type of event (BABYLON.PointerEventTypes)
  11666. */
  11667. type: number;
  11668. /**
  11669. * Defines the related dom event
  11670. */
  11671. event: PointerEvent | MouseWheelEvent;
  11672. /**
  11673. * Instantiates the base class of pointers info.
  11674. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11675. * @param event Defines the related dom event
  11676. */
  11677. constructor(
  11678. /**
  11679. * Defines the type of event (BABYLON.PointerEventTypes)
  11680. */
  11681. type: number,
  11682. /**
  11683. * Defines the related dom event
  11684. */
  11685. event: PointerEvent | MouseWheelEvent);
  11686. }
  11687. /**
  11688. * This class is used to store pointer related info for the onPrePointerObservable event.
  11689. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11690. */
  11691. class PointerInfoPre extends PointerInfoBase {
  11692. /**
  11693. * Ray from a pointer if availible (eg. 6dof controller)
  11694. */
  11695. ray: Nullable<Ray>;
  11696. /**
  11697. * Defines the local position of the pointer on the canvas.
  11698. */
  11699. localPosition: Vector2;
  11700. /**
  11701. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11702. */
  11703. skipOnPointerObservable: boolean;
  11704. /**
  11705. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11706. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11707. * @param event Defines the related dom event
  11708. * @param localX Defines the local x coordinates of the pointer when the event occured
  11709. * @param localY Defines the local y coordinates of the pointer when the event occured
  11710. */
  11711. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11712. }
  11713. /**
  11714. * This type contains all the data related to a pointer event in Babylon.js.
  11715. * 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.
  11716. */
  11717. class PointerInfo extends PointerInfoBase {
  11718. /**
  11719. * Defines the picking info associated to the info (if any)\
  11720. */
  11721. pickInfo: Nullable<PickingInfo>;
  11722. /**
  11723. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11724. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11725. * @param event Defines the related dom event
  11726. * @param pickInfo Defines the picking info associated to the info (if any)\
  11727. */
  11728. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11729. /**
  11730. * Defines the picking info associated to the info (if any)\
  11731. */
  11732. pickInfo: Nullable<PickingInfo>);
  11733. }
  11734. }
  11735. declare module BABYLON {
  11736. /**
  11737. * Represents a gamepad control stick position
  11738. */
  11739. class StickValues {
  11740. /**
  11741. * The x component of the control stick
  11742. */
  11743. x: number;
  11744. /**
  11745. * The y component of the control stick
  11746. */
  11747. y: number;
  11748. /**
  11749. * Initializes the gamepad x and y control stick values
  11750. * @param x The x component of the gamepad control stick value
  11751. * @param y The y component of the gamepad control stick value
  11752. */
  11753. constructor(
  11754. /**
  11755. * The x component of the control stick
  11756. */
  11757. x: number,
  11758. /**
  11759. * The y component of the control stick
  11760. */
  11761. y: number);
  11762. }
  11763. /**
  11764. * An interface which manages callbacks for gamepad button changes
  11765. */
  11766. interface GamepadButtonChanges {
  11767. /**
  11768. * Called when a gamepad has been changed
  11769. */
  11770. changed: boolean;
  11771. /**
  11772. * Called when a gamepad press event has been triggered
  11773. */
  11774. pressChanged: boolean;
  11775. /**
  11776. * Called when a touch event has been triggered
  11777. */
  11778. touchChanged: boolean;
  11779. /**
  11780. * Called when a value has changed
  11781. */
  11782. valueChanged: boolean;
  11783. }
  11784. /**
  11785. * Represents a gamepad
  11786. */
  11787. class Gamepad {
  11788. /**
  11789. * The id of the gamepad
  11790. */
  11791. id: string;
  11792. /**
  11793. * The index of the gamepad
  11794. */
  11795. index: number;
  11796. /**
  11797. * The browser gamepad
  11798. */
  11799. browserGamepad: any;
  11800. /**
  11801. * Specifies what type of gamepad this represents
  11802. */
  11803. type: number;
  11804. private _leftStick;
  11805. private _rightStick;
  11806. /** @hidden */
  11807. _isConnected: boolean;
  11808. private _leftStickAxisX;
  11809. private _leftStickAxisY;
  11810. private _rightStickAxisX;
  11811. private _rightStickAxisY;
  11812. /**
  11813. * Triggered when the left control stick has been changed
  11814. */
  11815. private _onleftstickchanged;
  11816. /**
  11817. * Triggered when the right control stick has been changed
  11818. */
  11819. private _onrightstickchanged;
  11820. /**
  11821. * Represents a gamepad controller
  11822. */
  11823. static GAMEPAD: number;
  11824. /**
  11825. * Represents a generic controller
  11826. */
  11827. static GENERIC: number;
  11828. /**
  11829. * Represents an XBox controller
  11830. */
  11831. static XBOX: number;
  11832. /**
  11833. * Represents a pose-enabled controller
  11834. */
  11835. static POSE_ENABLED: number;
  11836. /**
  11837. * Specifies whether the left control stick should be Y-inverted
  11838. */
  11839. protected _invertLeftStickY: boolean;
  11840. /**
  11841. * Specifies if the gamepad has been connected
  11842. */
  11843. readonly isConnected: boolean;
  11844. /**
  11845. * Initializes the gamepad
  11846. * @param id The id of the gamepad
  11847. * @param index The index of the gamepad
  11848. * @param browserGamepad The browser gamepad
  11849. * @param leftStickX The x component of the left joystick
  11850. * @param leftStickY The y component of the left joystick
  11851. * @param rightStickX The x component of the right joystick
  11852. * @param rightStickY The y component of the right joystick
  11853. */
  11854. constructor(
  11855. /**
  11856. * The id of the gamepad
  11857. */
  11858. id: string,
  11859. /**
  11860. * The index of the gamepad
  11861. */
  11862. index: number,
  11863. /**
  11864. * The browser gamepad
  11865. */
  11866. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11867. /**
  11868. * Callback triggered when the left joystick has changed
  11869. * @param callback
  11870. */
  11871. onleftstickchanged(callback: (values: StickValues) => void): void;
  11872. /**
  11873. * Callback triggered when the right joystick has changed
  11874. * @param callback
  11875. */
  11876. onrightstickchanged(callback: (values: StickValues) => void): void;
  11877. /**
  11878. * Gets the left joystick
  11879. */
  11880. /**
  11881. * Sets the left joystick values
  11882. */
  11883. leftStick: StickValues;
  11884. /**
  11885. * Gets the right joystick
  11886. */
  11887. /**
  11888. * Sets the right joystick value
  11889. */
  11890. rightStick: StickValues;
  11891. /**
  11892. * Updates the gamepad joystick positions
  11893. */
  11894. update(): void;
  11895. /**
  11896. * Disposes the gamepad
  11897. */
  11898. dispose(): void;
  11899. }
  11900. /**
  11901. * Represents a generic gamepad
  11902. */
  11903. class GenericPad extends Gamepad {
  11904. private _buttons;
  11905. private _onbuttondown;
  11906. private _onbuttonup;
  11907. /**
  11908. * Observable triggered when a button has been pressed
  11909. */
  11910. onButtonDownObservable: Observable<number>;
  11911. /**
  11912. * Observable triggered when a button has been released
  11913. */
  11914. onButtonUpObservable: Observable<number>;
  11915. /**
  11916. * Callback triggered when a button has been pressed
  11917. * @param callback Called when a button has been pressed
  11918. */
  11919. onbuttondown(callback: (buttonPressed: number) => void): void;
  11920. /**
  11921. * Callback triggered when a button has been released
  11922. * @param callback Called when a button has been released
  11923. */
  11924. onbuttonup(callback: (buttonReleased: number) => void): void;
  11925. /**
  11926. * Initializes the generic gamepad
  11927. * @param id The id of the generic gamepad
  11928. * @param index The index of the generic gamepad
  11929. * @param browserGamepad The browser gamepad
  11930. */
  11931. constructor(id: string, index: number, browserGamepad: any);
  11932. private _setButtonValue;
  11933. /**
  11934. * Updates the generic gamepad
  11935. */
  11936. update(): void;
  11937. /**
  11938. * Disposes the generic gamepad
  11939. */
  11940. dispose(): void;
  11941. }
  11942. }
  11943. declare module BABYLON {
  11944. /**
  11945. * Manager for handling gamepads
  11946. */
  11947. class GamepadManager {
  11948. private _scene?;
  11949. private _babylonGamepads;
  11950. private _oneGamepadConnected;
  11951. /** @hidden */
  11952. _isMonitoring: boolean;
  11953. private _gamepadEventSupported;
  11954. private _gamepadSupport;
  11955. /**
  11956. * observable to be triggered when the gamepad controller has been connected
  11957. */
  11958. onGamepadConnectedObservable: Observable<Gamepad>;
  11959. /**
  11960. * observable to be triggered when the gamepad controller has been disconnected
  11961. */
  11962. onGamepadDisconnectedObservable: Observable<Gamepad>;
  11963. private _onGamepadConnectedEvent;
  11964. private _onGamepadDisconnectedEvent;
  11965. /**
  11966. * Initializes the gamepad manager
  11967. * @param _scene BabylonJS scene
  11968. */
  11969. constructor(_scene?: Scene | undefined);
  11970. /**
  11971. * The gamepads in the game pad manager
  11972. */
  11973. readonly gamepads: Gamepad[];
  11974. /**
  11975. * Get the gamepad controllers based on type
  11976. * @param type The type of gamepad controller
  11977. * @returns Nullable gamepad
  11978. */
  11979. getGamepadByType(type?: number): Nullable<Gamepad>;
  11980. /**
  11981. * Disposes the gamepad manager
  11982. */
  11983. dispose(): void;
  11984. private _addNewGamepad;
  11985. private _startMonitoringGamepads;
  11986. private _stopMonitoringGamepads;
  11987. /** @hidden */
  11988. _checkGamepadsStatus(): void;
  11989. private _updateGamepadObjects;
  11990. }
  11991. }
  11992. declare module BABYLON {
  11993. interface Scene {
  11994. /** @hidden */
  11995. _gamepadManager: Nullable<GamepadManager>;
  11996. /**
  11997. * Gets the gamepad manager associated with the scene
  11998. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  11999. */
  12000. gamepadManager: GamepadManager;
  12001. }
  12002. /**
  12003. * Interface representing a free camera inputs manager
  12004. */
  12005. interface FreeCameraInputsManager {
  12006. addGamepad(): FreeCameraInputsManager;
  12007. }
  12008. /**
  12009. * Interface representing an arc rotate camera inputs manager
  12010. */
  12011. interface ArcRotateCameraInputsManager {
  12012. /**
  12013. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12014. * @returns the camera inputs manager
  12015. */
  12016. addGamepad(): ArcRotateCameraInputsManager;
  12017. }
  12018. /**
  12019. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12020. */
  12021. class GamepadSystemSceneComponent implements ISceneComponent {
  12022. /**
  12023. * The component name helpfull to identify the component in the list of scene components.
  12024. */
  12025. readonly name: string;
  12026. /**
  12027. * The scene the component belongs to.
  12028. */
  12029. scene: Scene;
  12030. /**
  12031. * Creates a new instance of the component for the given scene
  12032. * @param scene Defines the scene to register the component in
  12033. */
  12034. constructor(scene: Scene);
  12035. /**
  12036. * Registers the component in a given scene
  12037. */
  12038. register(): void;
  12039. /**
  12040. * Rebuilds the elements related to this component in case of
  12041. * context lost for instance.
  12042. */
  12043. rebuild(): void;
  12044. /**
  12045. * Disposes the component and the associated ressources
  12046. */
  12047. dispose(): void;
  12048. private _beforeCameraUpdate;
  12049. }
  12050. }
  12051. declare module BABYLON {
  12052. /**
  12053. * Defines supported buttons for XBox360 compatible gamepads
  12054. */
  12055. enum Xbox360Button {
  12056. /** A */
  12057. A = 0,
  12058. /** B */
  12059. B = 1,
  12060. /** X */
  12061. X = 2,
  12062. /** Y */
  12063. Y = 3,
  12064. /** Start */
  12065. Start = 4,
  12066. /** Back */
  12067. Back = 5,
  12068. /** Left button */
  12069. LB = 6,
  12070. /** Right button */
  12071. RB = 7,
  12072. /** Left stick */
  12073. LeftStick = 8,
  12074. /** Right stick */
  12075. RightStick = 9
  12076. }
  12077. /** Defines values for XBox360 DPad */
  12078. enum Xbox360Dpad {
  12079. /** Up */
  12080. Up = 0,
  12081. /** Down */
  12082. Down = 1,
  12083. /** Left */
  12084. Left = 2,
  12085. /** Right */
  12086. Right = 3
  12087. }
  12088. /**
  12089. * Defines a XBox360 gamepad
  12090. */
  12091. class Xbox360Pad extends Gamepad {
  12092. private _leftTrigger;
  12093. private _rightTrigger;
  12094. private _onlefttriggerchanged;
  12095. private _onrighttriggerchanged;
  12096. private _onbuttondown;
  12097. private _onbuttonup;
  12098. private _ondpaddown;
  12099. private _ondpadup;
  12100. /** Observable raised when a button is pressed */
  12101. onButtonDownObservable: Observable<Xbox360Button>;
  12102. /** Observable raised when a button is released */
  12103. onButtonUpObservable: Observable<Xbox360Button>;
  12104. /** Observable raised when a pad is pressed */
  12105. onPadDownObservable: Observable<Xbox360Dpad>;
  12106. /** Observable raised when a pad is released */
  12107. onPadUpObservable: Observable<Xbox360Dpad>;
  12108. private _buttonA;
  12109. private _buttonB;
  12110. private _buttonX;
  12111. private _buttonY;
  12112. private _buttonBack;
  12113. private _buttonStart;
  12114. private _buttonLB;
  12115. private _buttonRB;
  12116. private _buttonLeftStick;
  12117. private _buttonRightStick;
  12118. private _dPadUp;
  12119. private _dPadDown;
  12120. private _dPadLeft;
  12121. private _dPadRight;
  12122. private _isXboxOnePad;
  12123. /**
  12124. * Creates a new XBox360 gamepad object
  12125. * @param id defines the id of this gamepad
  12126. * @param index defines its index
  12127. * @param gamepad defines the internal HTML gamepad object
  12128. * @param xboxOne defines if it is a XBox One gamepad
  12129. */
  12130. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12131. /**
  12132. * Defines the callback to call when left trigger is pressed
  12133. * @param callback defines the callback to use
  12134. */
  12135. onlefttriggerchanged(callback: (value: number) => void): void;
  12136. /**
  12137. * Defines the callback to call when right trigger is pressed
  12138. * @param callback defines the callback to use
  12139. */
  12140. onrighttriggerchanged(callback: (value: number) => void): void;
  12141. /**
  12142. * Gets the left trigger value
  12143. */
  12144. /**
  12145. * Sets the left trigger value
  12146. */
  12147. leftTrigger: number;
  12148. /**
  12149. * Gets the right trigger value
  12150. */
  12151. /**
  12152. * Sets the right trigger value
  12153. */
  12154. rightTrigger: number;
  12155. /**
  12156. * Defines the callback to call when a button is pressed
  12157. * @param callback defines the callback to use
  12158. */
  12159. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12160. /**
  12161. * Defines the callback to call when a button is released
  12162. * @param callback defines the callback to use
  12163. */
  12164. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12165. /**
  12166. * Defines the callback to call when a pad is pressed
  12167. * @param callback defines the callback to use
  12168. */
  12169. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12170. /**
  12171. * Defines the callback to call when a pad is released
  12172. * @param callback defines the callback to use
  12173. */
  12174. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12175. private _setButtonValue;
  12176. private _setDPadValue;
  12177. /**
  12178. * Gets the value of the `A` button
  12179. */
  12180. /**
  12181. * Sets the value of the `A` button
  12182. */
  12183. buttonA: number;
  12184. /**
  12185. * Gets the value of the `B` button
  12186. */
  12187. /**
  12188. * Sets the value of the `B` button
  12189. */
  12190. buttonB: number;
  12191. /**
  12192. * Gets the value of the `X` button
  12193. */
  12194. /**
  12195. * Sets the value of the `X` button
  12196. */
  12197. buttonX: number;
  12198. /**
  12199. * Gets the value of the `Y` button
  12200. */
  12201. /**
  12202. * Sets the value of the `Y` button
  12203. */
  12204. buttonY: number;
  12205. /**
  12206. * Gets the value of the `Start` button
  12207. */
  12208. /**
  12209. * Sets the value of the `Start` button
  12210. */
  12211. buttonStart: number;
  12212. /**
  12213. * Gets the value of the `Back` button
  12214. */
  12215. /**
  12216. * Sets the value of the `Back` button
  12217. */
  12218. buttonBack: number;
  12219. /**
  12220. * Gets the value of the `Left` button
  12221. */
  12222. /**
  12223. * Sets the value of the `Left` button
  12224. */
  12225. buttonLB: number;
  12226. /**
  12227. * Gets the value of the `Right` button
  12228. */
  12229. /**
  12230. * Sets the value of the `Right` button
  12231. */
  12232. buttonRB: number;
  12233. /**
  12234. * Gets the value of the Left joystick
  12235. */
  12236. /**
  12237. * Sets the value of the Left joystick
  12238. */
  12239. buttonLeftStick: number;
  12240. /**
  12241. * Gets the value of the Right joystick
  12242. */
  12243. /**
  12244. * Sets the value of the Right joystick
  12245. */
  12246. buttonRightStick: number;
  12247. /**
  12248. * Gets the value of D-pad up
  12249. */
  12250. /**
  12251. * Sets the value of D-pad up
  12252. */
  12253. dPadUp: number;
  12254. /**
  12255. * Gets the value of D-pad down
  12256. */
  12257. /**
  12258. * Sets the value of D-pad down
  12259. */
  12260. dPadDown: number;
  12261. /**
  12262. * Gets the value of D-pad left
  12263. */
  12264. /**
  12265. * Sets the value of D-pad left
  12266. */
  12267. dPadLeft: number;
  12268. /**
  12269. * Gets the value of D-pad right
  12270. */
  12271. /**
  12272. * Sets the value of D-pad right
  12273. */
  12274. dPadRight: number;
  12275. /**
  12276. * Force the gamepad to synchronize with device values
  12277. */
  12278. update(): void;
  12279. /**
  12280. * Disposes the gamepad
  12281. */
  12282. dispose(): void;
  12283. }
  12284. }
  12285. declare module BABYLON {
  12286. /**
  12287. * Single axis drag gizmo
  12288. */
  12289. class AxisDragGizmo extends Gizmo {
  12290. /**
  12291. * Drag behavior responsible for the gizmos dragging interactions
  12292. */
  12293. dragBehavior: PointerDragBehavior;
  12294. private _pointerObserver;
  12295. /**
  12296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12297. */
  12298. snapDistance: number;
  12299. /**
  12300. * Event that fires each time the gizmo snaps to a new location.
  12301. * * snapDistance is the the change in distance
  12302. */
  12303. onSnapObservable: Observable<{
  12304. snapDistance: number;
  12305. }>;
  12306. /**
  12307. * Creates an AxisDragGizmo
  12308. * @param gizmoLayer The utility layer the gizmo will be added to
  12309. * @param dragAxis The axis which the gizmo will be able to drag on
  12310. * @param color The color of the gizmo
  12311. */
  12312. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12313. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12314. /**
  12315. * Disposes of the gizmo
  12316. */
  12317. dispose(): void;
  12318. }
  12319. }
  12320. declare module BABYLON {
  12321. /**
  12322. * Single axis scale gizmo
  12323. */
  12324. class AxisScaleGizmo extends Gizmo {
  12325. private _coloredMaterial;
  12326. /**
  12327. * Drag behavior responsible for the gizmos dragging interactions
  12328. */
  12329. dragBehavior: PointerDragBehavior;
  12330. private _pointerObserver;
  12331. /**
  12332. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12333. */
  12334. snapDistance: number;
  12335. /**
  12336. * Event that fires each time the gizmo snaps to a new location.
  12337. * * snapDistance is the the change in distance
  12338. */
  12339. onSnapObservable: Observable<{
  12340. snapDistance: number;
  12341. }>;
  12342. /**
  12343. * If the scaling operation should be done on all axis (default: false)
  12344. */
  12345. uniformScaling: boolean;
  12346. /**
  12347. * Creates an AxisScaleGizmo
  12348. * @param gizmoLayer The utility layer the gizmo will be added to
  12349. * @param dragAxis The axis which the gizmo will be able to scale on
  12350. * @param color The color of the gizmo
  12351. */
  12352. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12353. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12354. /**
  12355. * Disposes of the gizmo
  12356. */
  12357. dispose(): void;
  12358. /**
  12359. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12360. * @param mesh The mesh to replace the default mesh of the gizmo
  12361. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12362. */
  12363. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12364. }
  12365. }
  12366. declare module BABYLON {
  12367. /**
  12368. * Bounding box gizmo
  12369. */
  12370. class BoundingBoxGizmo extends Gizmo {
  12371. private _lineBoundingBox;
  12372. private _rotateSpheresParent;
  12373. private _scaleBoxesParent;
  12374. private _boundingDimensions;
  12375. private _renderObserver;
  12376. private _pointerObserver;
  12377. private _scaleDragSpeed;
  12378. private _tmpQuaternion;
  12379. private _tmpVector;
  12380. private _tmpRotationMatrix;
  12381. /**
  12382. * 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)
  12383. */
  12384. ignoreChildren: boolean;
  12385. /**
  12386. * 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)
  12387. */
  12388. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12389. /**
  12390. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12391. */
  12392. rotationSphereSize: number;
  12393. /**
  12394. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12395. */
  12396. scaleBoxSize: number;
  12397. /**
  12398. * 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)
  12399. */
  12400. fixedDragMeshScreenSize: boolean;
  12401. /**
  12402. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12403. */
  12404. fixedDragMeshScreenSizeDistanceFactor: number;
  12405. /**
  12406. * Fired when a rotation sphere or scale box is dragged
  12407. */
  12408. onDragStartObservable: Observable<{}>;
  12409. /**
  12410. * Fired when a scale box is dragged
  12411. */
  12412. onScaleBoxDragObservable: Observable<{}>;
  12413. /**
  12414. * Fired when a scale box drag is ended
  12415. */
  12416. onScaleBoxDragEndObservable: Observable<{}>;
  12417. /**
  12418. * Fired when a rotation sphere is dragged
  12419. */
  12420. onRotationSphereDragObservable: Observable<{}>;
  12421. /**
  12422. * Fired when a rotation sphere drag is ended
  12423. */
  12424. onRotationSphereDragEndObservable: Observable<{}>;
  12425. /**
  12426. * 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)
  12427. */
  12428. scalePivot: Nullable<Vector3>;
  12429. private _anchorMesh;
  12430. private _existingMeshScale;
  12431. private static _PivotCached;
  12432. private static _OldPivotPoint;
  12433. private static _PivotTranslation;
  12434. private static _PivotTmpVector;
  12435. /** @hidden */
  12436. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12437. /** @hidden */
  12438. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12439. /**
  12440. * Creates an BoundingBoxGizmo
  12441. * @param gizmoLayer The utility layer the gizmo will be added to
  12442. * @param color The color of the gizmo
  12443. */
  12444. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12445. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12446. private _selectNode;
  12447. /**
  12448. * Updates the bounding box information for the Gizmo
  12449. */
  12450. updateBoundingBox(): void;
  12451. /**
  12452. * Enables rotation on the specified axis and disables rotation on the others
  12453. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12454. */
  12455. setEnabledRotationAxis(axis: string): void;
  12456. /**
  12457. * Disposes of the gizmo
  12458. */
  12459. dispose(): void;
  12460. /**
  12461. * 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)
  12462. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12463. * @returns the bounding box mesh with the passed in mesh as a child
  12464. */
  12465. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12466. /**
  12467. * CustomMeshes are not supported by this gizmo
  12468. * @param mesh The mesh to replace the default mesh of the gizmo
  12469. */
  12470. setCustomMesh(mesh: Mesh): void;
  12471. }
  12472. }
  12473. declare module BABYLON {
  12474. /**
  12475. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12476. */
  12477. class Gizmo implements IDisposable {
  12478. /** The utility layer the gizmo will be added to */
  12479. gizmoLayer: UtilityLayerRenderer;
  12480. /**
  12481. * The root mesh of the gizmo
  12482. */
  12483. protected _rootMesh: Mesh;
  12484. private _attachedMesh;
  12485. /**
  12486. * Ratio for the scale of the gizmo (Default: 1)
  12487. */
  12488. scaleRatio: number;
  12489. private _tmpMatrix;
  12490. /**
  12491. * If a custom mesh has been set (Default: false)
  12492. */
  12493. protected _customMeshSet: boolean;
  12494. /**
  12495. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  12496. * * When set, interactions will be enabled
  12497. */
  12498. attachedMesh: Nullable<AbstractMesh>;
  12499. /**
  12500. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12501. * @param mesh The mesh to replace the default mesh of the gizmo
  12502. */
  12503. setCustomMesh(mesh: Mesh): void;
  12504. /**
  12505. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  12506. */
  12507. updateGizmoRotationToMatchAttachedMesh: boolean;
  12508. /**
  12509. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  12510. */
  12511. updateGizmoPositionToMatchAttachedMesh: boolean;
  12512. /**
  12513. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  12514. */
  12515. protected _updateScale: boolean;
  12516. protected _interactionsEnabled: boolean;
  12517. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12518. private _beforeRenderObserver;
  12519. /**
  12520. * Creates a gizmo
  12521. * @param gizmoLayer The utility layer the gizmo will be added to
  12522. */
  12523. constructor(
  12524. /** The utility layer the gizmo will be added to */
  12525. gizmoLayer?: UtilityLayerRenderer);
  12526. private _tempVector;
  12527. /**
  12528. * @hidden
  12529. * Updates the gizmo to match the attached mesh's position/rotation
  12530. */
  12531. protected _update(): void;
  12532. /**
  12533. * Disposes of the gizmo
  12534. */
  12535. dispose(): void;
  12536. }
  12537. }
  12538. declare module BABYLON {
  12539. /**
  12540. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  12541. */
  12542. class GizmoManager implements IDisposable {
  12543. private scene;
  12544. /**
  12545. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  12546. */
  12547. gizmos: {
  12548. positionGizmo: Nullable<PositionGizmo>;
  12549. rotationGizmo: Nullable<RotationGizmo>;
  12550. scaleGizmo: Nullable<ScaleGizmo>;
  12551. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  12552. };
  12553. private _gizmosEnabled;
  12554. private _pointerObserver;
  12555. private _attachedMesh;
  12556. private _boundingBoxColor;
  12557. /**
  12558. * When bounding box gizmo is enabled, this can be used to track drag/end events
  12559. */
  12560. boundingBoxDragBehavior: SixDofDragBehavior;
  12561. /**
  12562. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  12563. */
  12564. attachableMeshes: Nullable<Array<AbstractMesh>>;
  12565. /**
  12566. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  12567. */
  12568. usePointerToAttachGizmos: boolean;
  12569. /**
  12570. * Instatiates a gizmo manager
  12571. * @param scene the scene to overlay the gizmos on top of
  12572. */
  12573. constructor(scene: Scene);
  12574. /**
  12575. * Attaches a set of gizmos to the specified mesh
  12576. * @param mesh The mesh the gizmo's should be attached to
  12577. */
  12578. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  12579. /**
  12580. * If the position gizmo is enabled
  12581. */
  12582. positionGizmoEnabled: boolean;
  12583. /**
  12584. * If the rotation gizmo is enabled
  12585. */
  12586. rotationGizmoEnabled: boolean;
  12587. /**
  12588. * If the scale gizmo is enabled
  12589. */
  12590. scaleGizmoEnabled: boolean;
  12591. /**
  12592. * If the boundingBox gizmo is enabled
  12593. */
  12594. boundingBoxGizmoEnabled: boolean;
  12595. /**
  12596. * Disposes of the gizmo manager
  12597. */
  12598. dispose(): void;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * Single plane rotation gizmo
  12604. */
  12605. class PlaneRotationGizmo extends Gizmo {
  12606. /**
  12607. * Drag behavior responsible for the gizmos dragging interactions
  12608. */
  12609. dragBehavior: PointerDragBehavior;
  12610. private _pointerObserver;
  12611. /**
  12612. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  12613. */
  12614. snapDistance: number;
  12615. /**
  12616. * Event that fires each time the gizmo snaps to a new location.
  12617. * * snapDistance is the the change in distance
  12618. */
  12619. onSnapObservable: Observable<{
  12620. snapDistance: number;
  12621. }>;
  12622. /**
  12623. * Creates a PlaneRotationGizmo
  12624. * @param gizmoLayer The utility layer the gizmo will be added to
  12625. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  12626. * @param color The color of the gizmo
  12627. */
  12628. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12629. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12630. /**
  12631. * Disposes of the gizmo
  12632. */
  12633. dispose(): void;
  12634. }
  12635. }
  12636. declare module BABYLON {
  12637. /**
  12638. * Gizmo that enables dragging a mesh along 3 axis
  12639. */
  12640. class PositionGizmo extends Gizmo {
  12641. /**
  12642. * Internal gizmo used for interactions on the x axis
  12643. */
  12644. xGizmo: AxisDragGizmo;
  12645. /**
  12646. * Internal gizmo used for interactions on the y axis
  12647. */
  12648. yGizmo: AxisDragGizmo;
  12649. /**
  12650. * Internal gizmo used for interactions on the z axis
  12651. */
  12652. zGizmo: AxisDragGizmo;
  12653. attachedMesh: Nullable<AbstractMesh>;
  12654. /**
  12655. * Creates a PositionGizmo
  12656. * @param gizmoLayer The utility layer the gizmo will be added to
  12657. */
  12658. constructor(gizmoLayer?: UtilityLayerRenderer);
  12659. updateGizmoRotationToMatchAttachedMesh: boolean;
  12660. /**
  12661. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12662. */
  12663. snapDistance: number;
  12664. /**
  12665. * Ratio for the scale of the gizmo (Default: 1)
  12666. */
  12667. scaleRatio: number;
  12668. /**
  12669. * Disposes of the gizmo
  12670. */
  12671. dispose(): void;
  12672. /**
  12673. * CustomMeshes are not supported by this gizmo
  12674. * @param mesh The mesh to replace the default mesh of the gizmo
  12675. */
  12676. setCustomMesh(mesh: Mesh): void;
  12677. }
  12678. }
  12679. declare module BABYLON {
  12680. /**
  12681. * Gizmo that enables rotating a mesh along 3 axis
  12682. */
  12683. class RotationGizmo extends Gizmo {
  12684. /**
  12685. * Internal gizmo used for interactions on the x axis
  12686. */
  12687. xGizmo: PlaneRotationGizmo;
  12688. /**
  12689. * Internal gizmo used for interactions on the y axis
  12690. */
  12691. yGizmo: PlaneRotationGizmo;
  12692. /**
  12693. * Internal gizmo used for interactions on the z axis
  12694. */
  12695. zGizmo: PlaneRotationGizmo;
  12696. attachedMesh: Nullable<AbstractMesh>;
  12697. /**
  12698. * Creates a RotationGizmo
  12699. * @param gizmoLayer The utility layer the gizmo will be added to
  12700. */
  12701. constructor(gizmoLayer?: UtilityLayerRenderer);
  12702. updateGizmoRotationToMatchAttachedMesh: boolean;
  12703. /**
  12704. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12705. */
  12706. snapDistance: number;
  12707. /**
  12708. * Ratio for the scale of the gizmo (Default: 1)
  12709. */
  12710. scaleRatio: number;
  12711. /**
  12712. * Disposes of the gizmo
  12713. */
  12714. dispose(): void;
  12715. /**
  12716. * CustomMeshes are not supported by this gizmo
  12717. * @param mesh The mesh to replace the default mesh of the gizmo
  12718. */
  12719. setCustomMesh(mesh: Mesh): void;
  12720. }
  12721. }
  12722. declare module BABYLON {
  12723. /**
  12724. * Gizmo that enables scaling a mesh along 3 axis
  12725. */
  12726. class ScaleGizmo extends Gizmo {
  12727. /**
  12728. * Internal gizmo used for interactions on the x axis
  12729. */
  12730. xGizmo: AxisScaleGizmo;
  12731. /**
  12732. * Internal gizmo used for interactions on the y axis
  12733. */
  12734. yGizmo: AxisScaleGizmo;
  12735. /**
  12736. * Internal gizmo used for interactions on the z axis
  12737. */
  12738. zGizmo: AxisScaleGizmo;
  12739. /**
  12740. * Internal gizmo used to scale all axis equally
  12741. */
  12742. uniformScaleGizmo: AxisScaleGizmo;
  12743. attachedMesh: Nullable<AbstractMesh>;
  12744. /**
  12745. * Creates a ScaleGizmo
  12746. * @param gizmoLayer The utility layer the gizmo will be added to
  12747. */
  12748. constructor(gizmoLayer?: UtilityLayerRenderer);
  12749. updateGizmoRotationToMatchAttachedMesh: boolean;
  12750. /**
  12751. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12752. */
  12753. snapDistance: number;
  12754. /**
  12755. * Ratio for the scale of the gizmo (Default: 1)
  12756. */
  12757. scaleRatio: number;
  12758. /**
  12759. * Disposes of the gizmo
  12760. */
  12761. dispose(): void;
  12762. }
  12763. }
  12764. declare module BABYLON {
  12765. /**
  12766. * This class can be used to get instrumentation data from a Babylon engine
  12767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  12768. */
  12769. class EngineInstrumentation implements IDisposable {
  12770. /**
  12771. * Define the instrumented engine.
  12772. */
  12773. engine: Engine;
  12774. private _captureGPUFrameTime;
  12775. private _gpuFrameTimeToken;
  12776. private _gpuFrameTime;
  12777. private _captureShaderCompilationTime;
  12778. private _shaderCompilationTime;
  12779. private _onBeginFrameObserver;
  12780. private _onEndFrameObserver;
  12781. private _onBeforeShaderCompilationObserver;
  12782. private _onAfterShaderCompilationObserver;
  12783. /**
  12784. * Gets the perf counter used for GPU frame time
  12785. */
  12786. readonly gpuFrameTimeCounter: PerfCounter;
  12787. /**
  12788. * Gets the GPU frame time capture status
  12789. */
  12790. /**
  12791. * Enable or disable the GPU frame time capture
  12792. */
  12793. captureGPUFrameTime: boolean;
  12794. /**
  12795. * Gets the perf counter used for shader compilation time
  12796. */
  12797. readonly shaderCompilationTimeCounter: PerfCounter;
  12798. /**
  12799. * Gets the shader compilation time capture status
  12800. */
  12801. /**
  12802. * Enable or disable the shader compilation time capture
  12803. */
  12804. captureShaderCompilationTime: boolean;
  12805. /**
  12806. * Instantiates a new engine instrumentation.
  12807. * This class can be used to get instrumentation data from a Babylon engine
  12808. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  12809. * @param engine Defines the engine to instrument
  12810. */
  12811. constructor(
  12812. /**
  12813. * Define the instrumented engine.
  12814. */
  12815. engine: Engine);
  12816. /**
  12817. * Dispose and release associated resources.
  12818. */
  12819. dispose(): void;
  12820. }
  12821. }
  12822. declare module BABYLON {
  12823. /**
  12824. * This class can be used to get instrumentation data from a Babylon engine
  12825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  12826. */
  12827. class SceneInstrumentation implements IDisposable {
  12828. /**
  12829. * Defines the scene to instrument
  12830. */
  12831. scene: Scene;
  12832. private _captureActiveMeshesEvaluationTime;
  12833. private _activeMeshesEvaluationTime;
  12834. private _captureRenderTargetsRenderTime;
  12835. private _renderTargetsRenderTime;
  12836. private _captureFrameTime;
  12837. private _frameTime;
  12838. private _captureRenderTime;
  12839. private _renderTime;
  12840. private _captureInterFrameTime;
  12841. private _interFrameTime;
  12842. private _captureParticlesRenderTime;
  12843. private _particlesRenderTime;
  12844. private _captureSpritesRenderTime;
  12845. private _spritesRenderTime;
  12846. private _capturePhysicsTime;
  12847. private _physicsTime;
  12848. private _captureAnimationsTime;
  12849. private _animationsTime;
  12850. private _captureCameraRenderTime;
  12851. private _cameraRenderTime;
  12852. private _onBeforeActiveMeshesEvaluationObserver;
  12853. private _onAfterActiveMeshesEvaluationObserver;
  12854. private _onBeforeRenderTargetsRenderObserver;
  12855. private _onAfterRenderTargetsRenderObserver;
  12856. private _onAfterRenderObserver;
  12857. private _onBeforeDrawPhaseObserver;
  12858. private _onAfterDrawPhaseObserver;
  12859. private _onBeforeAnimationsObserver;
  12860. private _onBeforeParticlesRenderingObserver;
  12861. private _onAfterParticlesRenderingObserver;
  12862. private _onBeforeSpritesRenderingObserver;
  12863. private _onAfterSpritesRenderingObserver;
  12864. private _onBeforePhysicsObserver;
  12865. private _onAfterPhysicsObserver;
  12866. private _onAfterAnimationsObserver;
  12867. private _onBeforeCameraRenderObserver;
  12868. private _onAfterCameraRenderObserver;
  12869. /**
  12870. * Gets the perf counter used for active meshes evaluation time
  12871. */
  12872. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  12873. /**
  12874. * Gets the active meshes evaluation time capture status
  12875. */
  12876. /**
  12877. * Enable or disable the active meshes evaluation time capture
  12878. */
  12879. captureActiveMeshesEvaluationTime: boolean;
  12880. /**
  12881. * Gets the perf counter used for render targets render time
  12882. */
  12883. readonly renderTargetsRenderTimeCounter: PerfCounter;
  12884. /**
  12885. * Gets the render targets render time capture status
  12886. */
  12887. /**
  12888. * Enable or disable the render targets render time capture
  12889. */
  12890. captureRenderTargetsRenderTime: boolean;
  12891. /**
  12892. * Gets the perf counter used for particles render time
  12893. */
  12894. readonly particlesRenderTimeCounter: PerfCounter;
  12895. /**
  12896. * Gets the particles render time capture status
  12897. */
  12898. /**
  12899. * Enable or disable the particles render time capture
  12900. */
  12901. captureParticlesRenderTime: boolean;
  12902. /**
  12903. * Gets the perf counter used for sprites render time
  12904. */
  12905. readonly spritesRenderTimeCounter: PerfCounter;
  12906. /**
  12907. * Gets the sprites render time capture status
  12908. */
  12909. /**
  12910. * Enable or disable the sprites render time capture
  12911. */
  12912. captureSpritesRenderTime: boolean;
  12913. /**
  12914. * Gets the perf counter used for physics time
  12915. */
  12916. readonly physicsTimeCounter: PerfCounter;
  12917. /**
  12918. * Gets the physics time capture status
  12919. */
  12920. /**
  12921. * Enable or disable the physics time capture
  12922. */
  12923. capturePhysicsTime: boolean;
  12924. /**
  12925. * Gets the perf counter used for animations time
  12926. */
  12927. readonly animationsTimeCounter: PerfCounter;
  12928. /**
  12929. * Gets the animations time capture status
  12930. */
  12931. /**
  12932. * Enable or disable the animations time capture
  12933. */
  12934. captureAnimationsTime: boolean;
  12935. /**
  12936. * Gets the perf counter used for frame time capture
  12937. */
  12938. readonly frameTimeCounter: PerfCounter;
  12939. /**
  12940. * Gets the frame time capture status
  12941. */
  12942. /**
  12943. * Enable or disable the frame time capture
  12944. */
  12945. captureFrameTime: boolean;
  12946. /**
  12947. * Gets the perf counter used for inter-frames time capture
  12948. */
  12949. readonly interFrameTimeCounter: PerfCounter;
  12950. /**
  12951. * Gets the inter-frames time capture status
  12952. */
  12953. /**
  12954. * Enable or disable the inter-frames time capture
  12955. */
  12956. captureInterFrameTime: boolean;
  12957. /**
  12958. * Gets the perf counter used for render time capture
  12959. */
  12960. readonly renderTimeCounter: PerfCounter;
  12961. /**
  12962. * Gets the render time capture status
  12963. */
  12964. /**
  12965. * Enable or disable the render time capture
  12966. */
  12967. captureRenderTime: boolean;
  12968. /**
  12969. * Gets the perf counter used for camera render time capture
  12970. */
  12971. readonly cameraRenderTimeCounter: PerfCounter;
  12972. /**
  12973. * Gets the camera render time capture status
  12974. */
  12975. /**
  12976. * Enable or disable the camera render time capture
  12977. */
  12978. captureCameraRenderTime: boolean;
  12979. /**
  12980. * Gets the perf counter used for draw calls
  12981. */
  12982. readonly drawCallsCounter: PerfCounter;
  12983. /**
  12984. * Gets the perf counter used for texture collisions
  12985. */
  12986. readonly textureCollisionsCounter: PerfCounter;
  12987. /**
  12988. * Instantiates a new scene instrumentation.
  12989. * This class can be used to get instrumentation data from a Babylon engine
  12990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  12991. * @param scene Defines the scene to instrument
  12992. */
  12993. constructor(
  12994. /**
  12995. * Defines the scene to instrument
  12996. */
  12997. scene: Scene);
  12998. /**
  12999. * Dispose and release associated resources.
  13000. */
  13001. dispose(): void;
  13002. }
  13003. }
  13004. declare module BABYLON {
  13005. /**
  13006. * @hidden
  13007. **/
  13008. class _TimeToken {
  13009. _startTimeQuery: Nullable<WebGLQuery>;
  13010. _endTimeQuery: Nullable<WebGLQuery>;
  13011. _timeElapsedQuery: Nullable<WebGLQuery>;
  13012. _timeElapsedQueryEnded: boolean;
  13013. }
  13014. }
  13015. declare module BABYLON {
  13016. /**
  13017. * Represents the different options available during the creation of
  13018. * a Environment helper.
  13019. *
  13020. * This can control the default ground, skybox and image processing setup of your scene.
  13021. */
  13022. interface IEnvironmentHelperOptions {
  13023. /**
  13024. * Specifies wether or not to create a ground.
  13025. * True by default.
  13026. */
  13027. createGround: boolean;
  13028. /**
  13029. * Specifies the ground size.
  13030. * 15 by default.
  13031. */
  13032. groundSize: number;
  13033. /**
  13034. * The texture used on the ground for the main color.
  13035. * Comes from the BabylonJS CDN by default.
  13036. *
  13037. * Remarks: Can be either a texture or a url.
  13038. */
  13039. groundTexture: string | BaseTexture;
  13040. /**
  13041. * The color mixed in the ground texture by default.
  13042. * BabylonJS clearColor by default.
  13043. */
  13044. groundColor: Color3;
  13045. /**
  13046. * Specifies the ground opacity.
  13047. * 1 by default.
  13048. */
  13049. groundOpacity: number;
  13050. /**
  13051. * Enables the ground to receive shadows.
  13052. * True by default.
  13053. */
  13054. enableGroundShadow: boolean;
  13055. /**
  13056. * Helps preventing the shadow to be fully black on the ground.
  13057. * 0.5 by default.
  13058. */
  13059. groundShadowLevel: number;
  13060. /**
  13061. * Creates a mirror texture attach to the ground.
  13062. * false by default.
  13063. */
  13064. enableGroundMirror: boolean;
  13065. /**
  13066. * Specifies the ground mirror size ratio.
  13067. * 0.3 by default as the default kernel is 64.
  13068. */
  13069. groundMirrorSizeRatio: number;
  13070. /**
  13071. * Specifies the ground mirror blur kernel size.
  13072. * 64 by default.
  13073. */
  13074. groundMirrorBlurKernel: number;
  13075. /**
  13076. * Specifies the ground mirror visibility amount.
  13077. * 1 by default
  13078. */
  13079. groundMirrorAmount: number;
  13080. /**
  13081. * Specifies the ground mirror reflectance weight.
  13082. * This uses the standard weight of the background material to setup the fresnel effect
  13083. * of the mirror.
  13084. * 1 by default.
  13085. */
  13086. groundMirrorFresnelWeight: number;
  13087. /**
  13088. * Specifies the ground mirror Falloff distance.
  13089. * This can helps reducing the size of the reflection.
  13090. * 0 by Default.
  13091. */
  13092. groundMirrorFallOffDistance: number;
  13093. /**
  13094. * Specifies the ground mirror texture type.
  13095. * Unsigned Int by Default.
  13096. */
  13097. groundMirrorTextureType: number;
  13098. /**
  13099. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13100. * the shown objects.
  13101. */
  13102. groundYBias: number;
  13103. /**
  13104. * Specifies wether or not to create a skybox.
  13105. * True by default.
  13106. */
  13107. createSkybox: boolean;
  13108. /**
  13109. * Specifies the skybox size.
  13110. * 20 by default.
  13111. */
  13112. skyboxSize: number;
  13113. /**
  13114. * The texture used on the skybox for the main color.
  13115. * Comes from the BabylonJS CDN by default.
  13116. *
  13117. * Remarks: Can be either a texture or a url.
  13118. */
  13119. skyboxTexture: string | BaseTexture;
  13120. /**
  13121. * The color mixed in the skybox texture by default.
  13122. * BabylonJS clearColor by default.
  13123. */
  13124. skyboxColor: Color3;
  13125. /**
  13126. * The background rotation around the Y axis of the scene.
  13127. * This helps aligning the key lights of your scene with the background.
  13128. * 0 by default.
  13129. */
  13130. backgroundYRotation: number;
  13131. /**
  13132. * Compute automatically the size of the elements to best fit with the scene.
  13133. */
  13134. sizeAuto: boolean;
  13135. /**
  13136. * Default position of the rootMesh if autoSize is not true.
  13137. */
  13138. rootPosition: Vector3;
  13139. /**
  13140. * Sets up the image processing in the scene.
  13141. * true by default.
  13142. */
  13143. setupImageProcessing: boolean;
  13144. /**
  13145. * The texture used as your environment texture in the scene.
  13146. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13147. *
  13148. * Remarks: Can be either a texture or a url.
  13149. */
  13150. environmentTexture: string | BaseTexture;
  13151. /**
  13152. * The value of the exposure to apply to the scene.
  13153. * 0.6 by default if setupImageProcessing is true.
  13154. */
  13155. cameraExposure: number;
  13156. /**
  13157. * The value of the contrast to apply to the scene.
  13158. * 1.6 by default if setupImageProcessing is true.
  13159. */
  13160. cameraContrast: number;
  13161. /**
  13162. * Specifies wether or not tonemapping should be enabled in the scene.
  13163. * true by default if setupImageProcessing is true.
  13164. */
  13165. toneMappingEnabled: boolean;
  13166. }
  13167. /**
  13168. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13169. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13170. * It also helps with the default setup of your imageProcessing configuration.
  13171. */
  13172. class EnvironmentHelper {
  13173. /**
  13174. * Default ground texture URL.
  13175. */
  13176. private static _groundTextureCDNUrl;
  13177. /**
  13178. * Default skybox texture URL.
  13179. */
  13180. private static _skyboxTextureCDNUrl;
  13181. /**
  13182. * Default environment texture URL.
  13183. */
  13184. private static _environmentTextureCDNUrl;
  13185. /**
  13186. * Creates the default options for the helper.
  13187. */
  13188. private static _getDefaultOptions;
  13189. private _rootMesh;
  13190. /**
  13191. * Gets the root mesh created by the helper.
  13192. */
  13193. readonly rootMesh: Mesh;
  13194. private _skybox;
  13195. /**
  13196. * Gets the skybox created by the helper.
  13197. */
  13198. readonly skybox: Nullable<Mesh>;
  13199. private _skyboxTexture;
  13200. /**
  13201. * Gets the skybox texture created by the helper.
  13202. */
  13203. readonly skyboxTexture: Nullable<BaseTexture>;
  13204. private _skyboxMaterial;
  13205. /**
  13206. * Gets the skybox material created by the helper.
  13207. */
  13208. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13209. private _ground;
  13210. /**
  13211. * Gets the ground mesh created by the helper.
  13212. */
  13213. readonly ground: Nullable<Mesh>;
  13214. private _groundTexture;
  13215. /**
  13216. * Gets the ground texture created by the helper.
  13217. */
  13218. readonly groundTexture: Nullable<BaseTexture>;
  13219. private _groundMirror;
  13220. /**
  13221. * Gets the ground mirror created by the helper.
  13222. */
  13223. readonly groundMirror: Nullable<MirrorTexture>;
  13224. /**
  13225. * Gets the ground mirror render list to helps pushing the meshes
  13226. * you wish in the ground reflection.
  13227. */
  13228. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13229. private _groundMaterial;
  13230. /**
  13231. * Gets the ground material created by the helper.
  13232. */
  13233. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13234. /**
  13235. * Stores the creation options.
  13236. */
  13237. private readonly _scene;
  13238. private _options;
  13239. /**
  13240. * This observable will be notified with any error during the creation of the environment,
  13241. * mainly texture creation errors.
  13242. */
  13243. onErrorObservable: Observable<{
  13244. message?: string;
  13245. exception?: any;
  13246. }>;
  13247. /**
  13248. * constructor
  13249. * @param options
  13250. * @param scene The scene to add the material to
  13251. */
  13252. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13253. /**
  13254. * Updates the background according to the new options
  13255. * @param options
  13256. */
  13257. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13258. /**
  13259. * Sets the primary color of all the available elements.
  13260. * @param color the main color to affect to the ground and the background
  13261. */
  13262. setMainColor(color: Color3): void;
  13263. /**
  13264. * Setup the image processing according to the specified options.
  13265. */
  13266. private _setupImageProcessing;
  13267. /**
  13268. * Setup the environment texture according to the specified options.
  13269. */
  13270. private _setupEnvironmentTexture;
  13271. /**
  13272. * Setup the background according to the specified options.
  13273. */
  13274. private _setupBackground;
  13275. /**
  13276. * Get the scene sizes according to the setup.
  13277. */
  13278. private _getSceneSize;
  13279. /**
  13280. * Setup the ground according to the specified options.
  13281. */
  13282. private _setupGround;
  13283. /**
  13284. * Setup the ground material according to the specified options.
  13285. */
  13286. private _setupGroundMaterial;
  13287. /**
  13288. * Setup the ground diffuse texture according to the specified options.
  13289. */
  13290. private _setupGroundDiffuseTexture;
  13291. /**
  13292. * Setup the ground mirror texture according to the specified options.
  13293. */
  13294. private _setupGroundMirrorTexture;
  13295. /**
  13296. * Setup the ground to receive the mirror texture.
  13297. */
  13298. private _setupMirrorInGroundMaterial;
  13299. /**
  13300. * Setup the skybox according to the specified options.
  13301. */
  13302. private _setupSkybox;
  13303. /**
  13304. * Setup the skybox material according to the specified options.
  13305. */
  13306. private _setupSkyboxMaterial;
  13307. /**
  13308. * Setup the skybox reflection texture according to the specified options.
  13309. */
  13310. private _setupSkyboxReflectionTexture;
  13311. private _errorHandler;
  13312. /**
  13313. * Dispose all the elements created by the Helper.
  13314. */
  13315. dispose(): void;
  13316. }
  13317. }
  13318. declare module BABYLON {
  13319. /**
  13320. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13321. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13322. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13323. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13324. */
  13325. class PhotoDome extends TransformNode {
  13326. private _useDirectMapping;
  13327. /**
  13328. * The texture being displayed on the sphere
  13329. */
  13330. protected _photoTexture: Texture;
  13331. /**
  13332. * Gets or sets the texture being displayed on the sphere
  13333. */
  13334. photoTexture: Texture;
  13335. /**
  13336. * Observable raised when an error occured while loading the 360 image
  13337. */
  13338. onLoadErrorObservable: Observable<string>;
  13339. /**
  13340. * The skybox material
  13341. */
  13342. protected _material: BackgroundMaterial;
  13343. /**
  13344. * The surface used for the skybox
  13345. */
  13346. protected _mesh: Mesh;
  13347. /**
  13348. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13349. * Also see the options.resolution property.
  13350. */
  13351. fovMultiplier: number;
  13352. /**
  13353. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13354. * @param name Element's name, child elements will append suffixes for their own names.
  13355. * @param urlsOfPhoto defines the url of the photo to display
  13356. * @param options defines an object containing optional or exposed sub element properties
  13357. * @param onError defines a callback called when an error occured while loading the texture
  13358. */
  13359. constructor(name: string, urlOfPhoto: string, options: {
  13360. resolution?: number;
  13361. size?: number;
  13362. useDirectMapping?: boolean;
  13363. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13364. /**
  13365. * Releases resources associated with this node.
  13366. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13367. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13368. */
  13369. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13370. }
  13371. }
  13372. declare module BABYLON {
  13373. interface Scene {
  13374. /**
  13375. * Creates a default light for the scene.
  13376. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13377. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13378. */
  13379. createDefaultLight(replace?: boolean): void;
  13380. /**
  13381. * Creates a default camera for the scene.
  13382. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13383. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13384. * @param replace has default false, when true replaces the active camera in the scene
  13385. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13386. */
  13387. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13388. /**
  13389. * Creates a default camera and a default light.
  13390. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13391. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13392. * @param replace has the default false, when true replaces the active camera/light in the scene
  13393. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13394. */
  13395. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13396. /**
  13397. * Creates a new sky box
  13398. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13399. * @param environmentTexture defines the texture to use as environment texture
  13400. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13401. * @param scale defines the overall scale of the skybox
  13402. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13403. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13404. * @returns a new mesh holding the sky box
  13405. */
  13406. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13407. /**
  13408. * Creates a new environment
  13409. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13410. * @param options defines the options you can use to configure the environment
  13411. * @returns the new EnvironmentHelper
  13412. */
  13413. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13414. /**
  13415. * Creates a new VREXperienceHelper
  13416. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13417. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13418. * @returns a new VREXperienceHelper
  13419. */
  13420. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13421. }
  13422. }
  13423. declare module BABYLON {
  13424. /**
  13425. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13426. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13427. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13428. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13429. */
  13430. class VideoDome extends TransformNode {
  13431. private _useDirectMapping;
  13432. /**
  13433. * The video texture being displayed on the sphere
  13434. */
  13435. protected _videoTexture: VideoTexture;
  13436. /**
  13437. * Gets the video texture being displayed on the sphere
  13438. */
  13439. readonly videoTexture: VideoTexture;
  13440. /**
  13441. * The skybox material
  13442. */
  13443. protected _material: BackgroundMaterial;
  13444. /**
  13445. * The surface used for the skybox
  13446. */
  13447. protected _mesh: Mesh;
  13448. /**
  13449. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13450. * Also see the options.resolution property.
  13451. */
  13452. fovMultiplier: number;
  13453. /**
  13454. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13455. * @param name Element's name, child elements will append suffixes for their own names.
  13456. * @param urlsOrVideo defines the url(s) or the video element to use
  13457. * @param options An object containing optional or exposed sub element properties
  13458. */
  13459. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13460. resolution?: number;
  13461. clickToPlay?: boolean;
  13462. autoPlay?: boolean;
  13463. loop?: boolean;
  13464. size?: number;
  13465. poster?: string;
  13466. useDirectMapping?: boolean;
  13467. }, scene: Scene);
  13468. /**
  13469. * Releases resources associated with this node.
  13470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13472. */
  13473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13474. }
  13475. }
  13476. declare module BABYLON {
  13477. /**
  13478. * Effect layer options. This helps customizing the behaviour
  13479. * of the effect layer.
  13480. */
  13481. interface IEffectLayerOptions {
  13482. /**
  13483. * Multiplication factor apply to the canvas size to compute the render target size
  13484. * used to generated the objects (the smaller the faster).
  13485. */
  13486. mainTextureRatio: number;
  13487. /**
  13488. * Enforces a fixed size texture to ensure effect stability across devices.
  13489. */
  13490. mainTextureFixedSize?: number;
  13491. /**
  13492. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  13493. */
  13494. alphaBlendingMode: number;
  13495. /**
  13496. * The camera attached to the layer.
  13497. */
  13498. camera: Nullable<Camera>;
  13499. /**
  13500. * The rendering group to draw the layer in.
  13501. */
  13502. renderingGroupId: number;
  13503. }
  13504. /**
  13505. * The effect layer Helps adding post process effect blended with the main pass.
  13506. *
  13507. * This can be for instance use to generate glow or higlight effects on the scene.
  13508. *
  13509. * The effect layer class can not be used directly and is intented to inherited from to be
  13510. * customized per effects.
  13511. */
  13512. abstract class EffectLayer {
  13513. private _vertexBuffers;
  13514. private _indexBuffer;
  13515. private _cachedDefines;
  13516. private _effectLayerMapGenerationEffect;
  13517. private _effectLayerOptions;
  13518. private _mergeEffect;
  13519. protected _scene: Scene;
  13520. protected _engine: Engine;
  13521. protected _maxSize: number;
  13522. protected _mainTextureDesiredSize: ISize;
  13523. protected _mainTexture: RenderTargetTexture;
  13524. protected _shouldRender: boolean;
  13525. protected _postProcesses: PostProcess[];
  13526. protected _textures: BaseTexture[];
  13527. protected _emissiveTextureAndColor: {
  13528. texture: Nullable<BaseTexture>;
  13529. color: Color4;
  13530. };
  13531. /**
  13532. * The name of the layer
  13533. */
  13534. name: string;
  13535. /**
  13536. * The clear color of the texture used to generate the glow map.
  13537. */
  13538. neutralColor: Color4;
  13539. /**
  13540. * Specifies wether the highlight layer is enabled or not.
  13541. */
  13542. isEnabled: boolean;
  13543. /**
  13544. * Gets the camera attached to the layer.
  13545. */
  13546. readonly camera: Nullable<Camera>;
  13547. /**
  13548. * Gets the rendering group id the layer should render in.
  13549. */
  13550. readonly renderingGroupId: number;
  13551. /**
  13552. * An event triggered when the effect layer has been disposed.
  13553. */
  13554. onDisposeObservable: Observable<EffectLayer>;
  13555. /**
  13556. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  13557. */
  13558. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  13559. /**
  13560. * An event triggered when the generated texture is being merged in the scene.
  13561. */
  13562. onBeforeComposeObservable: Observable<EffectLayer>;
  13563. /**
  13564. * An event triggered when the generated texture has been merged in the scene.
  13565. */
  13566. onAfterComposeObservable: Observable<EffectLayer>;
  13567. /**
  13568. * An event triggered when the efffect layer changes its size.
  13569. */
  13570. onSizeChangedObservable: Observable<EffectLayer>;
  13571. /**
  13572. * Instantiates a new effect Layer and references it in the scene.
  13573. * @param name The name of the layer
  13574. * @param scene The scene to use the layer in
  13575. */
  13576. constructor(
  13577. /** The Friendly of the effect in the scene */
  13578. name: string, scene: Scene);
  13579. /**
  13580. * Get the effect name of the layer.
  13581. * @return The effect name
  13582. */
  13583. abstract getEffectName(): string;
  13584. /**
  13585. * Checks for the readiness of the element composing the layer.
  13586. * @param subMesh the mesh to check for
  13587. * @param useInstances specify wether or not to use instances to render the mesh
  13588. * @return true if ready otherwise, false
  13589. */
  13590. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13591. /**
  13592. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13593. * @returns true if the effect requires stencil during the main canvas render pass.
  13594. */
  13595. abstract needStencil(): boolean;
  13596. /**
  13597. * Create the merge effect. This is the shader use to blit the information back
  13598. * to the main canvas at the end of the scene rendering.
  13599. * @returns The effect containing the shader used to merge the effect on the main canvas
  13600. */
  13601. protected abstract _createMergeEffect(): Effect;
  13602. /**
  13603. * Creates the render target textures and post processes used in the effect layer.
  13604. */
  13605. protected abstract _createTextureAndPostProcesses(): void;
  13606. /**
  13607. * Implementation specific of rendering the generating effect on the main canvas.
  13608. * @param effect The effect used to render through
  13609. */
  13610. protected abstract _internalRender(effect: Effect): void;
  13611. /**
  13612. * Sets the required values for both the emissive texture and and the main color.
  13613. */
  13614. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13615. /**
  13616. * Free any resources and references associated to a mesh.
  13617. * Internal use
  13618. * @param mesh The mesh to free.
  13619. */
  13620. abstract _disposeMesh(mesh: Mesh): void;
  13621. /**
  13622. * Serializes this layer (Glow or Highlight for example)
  13623. * @returns a serialized layer object
  13624. */
  13625. abstract serialize?(): any;
  13626. /**
  13627. * Initializes the effect layer with the required options.
  13628. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  13629. */
  13630. protected _init(options: Partial<IEffectLayerOptions>): void;
  13631. /**
  13632. * Generates the index buffer of the full screen quad blending to the main canvas.
  13633. */
  13634. private _generateIndexBuffer;
  13635. /**
  13636. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  13637. */
  13638. private _genrateVertexBuffer;
  13639. /**
  13640. * Sets the main texture desired size which is the closest power of two
  13641. * of the engine canvas size.
  13642. */
  13643. private _setMainTextureSize;
  13644. /**
  13645. * Creates the main texture for the effect layer.
  13646. */
  13647. protected _createMainTexture(): void;
  13648. /**
  13649. * Checks for the readiness of the element composing the layer.
  13650. * @param subMesh the mesh to check for
  13651. * @param useInstances specify wether or not to use instances to render the mesh
  13652. * @param emissiveTexture the associated emissive texture used to generate the glow
  13653. * @return true if ready otherwise, false
  13654. */
  13655. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  13656. /**
  13657. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  13658. */
  13659. render(): void;
  13660. /**
  13661. * Determine if a given mesh will be used in the current effect.
  13662. * @param mesh mesh to test
  13663. * @returns true if the mesh will be used
  13664. */
  13665. hasMesh(mesh: AbstractMesh): boolean;
  13666. /**
  13667. * Returns true if the layer contains information to display, otherwise false.
  13668. * @returns true if the glow layer should be rendered
  13669. */
  13670. shouldRender(): boolean;
  13671. /**
  13672. * Returns true if the mesh should render, otherwise false.
  13673. * @param mesh The mesh to render
  13674. * @returns true if it should render otherwise false
  13675. */
  13676. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13677. /**
  13678. * Returns true if the mesh should render, otherwise false.
  13679. * @param mesh The mesh to render
  13680. * @returns true if it should render otherwise false
  13681. */
  13682. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  13683. /**
  13684. * Renders the submesh passed in parameter to the generation map.
  13685. */
  13686. protected _renderSubMesh(subMesh: SubMesh): void;
  13687. /**
  13688. * Rebuild the required buffers.
  13689. * @hidden Internal use only.
  13690. */
  13691. _rebuild(): void;
  13692. /**
  13693. * Dispose only the render target textures and post process.
  13694. */
  13695. private _disposeTextureAndPostProcesses;
  13696. /**
  13697. * Dispose the highlight layer and free resources.
  13698. */
  13699. dispose(): void;
  13700. /**
  13701. * Gets the class name of the effect layer
  13702. * @returns the string with the class name of the effect layer
  13703. */
  13704. getClassName(): string;
  13705. /**
  13706. * Creates an effect layer from parsed effect layer data
  13707. * @param parsedEffectLayer defines effect layer data
  13708. * @param scene defines the current scene
  13709. * @param rootUrl defines the root URL containing the effect layer information
  13710. * @returns a parsed effect Layer
  13711. */
  13712. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  13713. }
  13714. }
  13715. declare module BABYLON {
  13716. interface AbstractScene {
  13717. /**
  13718. * The list of effect layers (highlights/glow) added to the scene
  13719. * @see http://doc.babylonjs.com/how_to/highlight_layer
  13720. * @see http://doc.babylonjs.com/how_to/glow_layer
  13721. */
  13722. effectLayers: Array<EffectLayer>;
  13723. /**
  13724. * Removes the given effect layer from this scene.
  13725. * @param toRemove defines the effect layer to remove
  13726. * @returns the index of the removed effect layer
  13727. */
  13728. removeEffectLayer(toRemove: EffectLayer): number;
  13729. /**
  13730. * Adds the given effect layer to this scene
  13731. * @param newEffectLayer defines the effect layer to add
  13732. */
  13733. addEffectLayer(newEffectLayer: EffectLayer): void;
  13734. }
  13735. /**
  13736. * Defines the layer scene component responsible to manage any effect layers
  13737. * in a given scene.
  13738. */
  13739. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  13740. /**
  13741. * The component name helpfull to identify the component in the list of scene components.
  13742. */
  13743. readonly name: string;
  13744. /**
  13745. * The scene the component belongs to.
  13746. */
  13747. scene: Scene;
  13748. private _engine;
  13749. private _renderEffects;
  13750. private _needStencil;
  13751. private _previousStencilState;
  13752. /**
  13753. * Creates a new instance of the component for the given scene
  13754. * @param scene Defines the scene to register the component in
  13755. */
  13756. constructor(scene: Scene);
  13757. /**
  13758. * Registers the component in a given scene
  13759. */
  13760. register(): void;
  13761. /**
  13762. * Rebuilds the elements related to this component in case of
  13763. * context lost for instance.
  13764. */
  13765. rebuild(): void;
  13766. /**
  13767. * Serializes the component data to the specified json object
  13768. * @param serializationObject The object to serialize to
  13769. */
  13770. serialize(serializationObject: any): void;
  13771. /**
  13772. * Adds all the element from the container to the scene
  13773. * @param container the container holding the elements
  13774. */
  13775. addFromContainer(container: AbstractScene): void;
  13776. /**
  13777. * Removes all the elements in the container from the scene
  13778. * @param container contains the elements to remove
  13779. */
  13780. removeFromContainer(container: AbstractScene): void;
  13781. /**
  13782. * Disposes the component and the associated ressources.
  13783. */
  13784. dispose(): void;
  13785. private _isReadyForMesh;
  13786. private _renderMainTexture;
  13787. private _setStencil;
  13788. private _setStencilBack;
  13789. private _draw;
  13790. private _drawCamera;
  13791. private _drawRenderingGroup;
  13792. }
  13793. }
  13794. declare module BABYLON {
  13795. interface AbstractScene {
  13796. /**
  13797. * Return a the first highlight layer of the scene with a given name.
  13798. * @param name The name of the highlight layer to look for.
  13799. * @return The highlight layer if found otherwise null.
  13800. */
  13801. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  13802. }
  13803. /**
  13804. * Glow layer options. This helps customizing the behaviour
  13805. * of the glow layer.
  13806. */
  13807. interface IGlowLayerOptions {
  13808. /**
  13809. * Multiplication factor apply to the canvas size to compute the render target size
  13810. * used to generated the glowing objects (the smaller the faster).
  13811. */
  13812. mainTextureRatio: number;
  13813. /**
  13814. * Enforces a fixed size texture to ensure resize independant blur.
  13815. */
  13816. mainTextureFixedSize?: number;
  13817. /**
  13818. * How big is the kernel of the blur texture.
  13819. */
  13820. blurKernelSize: number;
  13821. /**
  13822. * The camera attached to the layer.
  13823. */
  13824. camera: Nullable<Camera>;
  13825. /**
  13826. * Enable MSAA by chosing the number of samples.
  13827. */
  13828. mainTextureSamples?: number;
  13829. /**
  13830. * The rendering group to draw the layer in.
  13831. */
  13832. renderingGroupId: number;
  13833. }
  13834. /**
  13835. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  13836. *
  13837. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  13838. * glowy meshes to your scene.
  13839. *
  13840. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  13841. */
  13842. class GlowLayer extends EffectLayer {
  13843. /**
  13844. * Effect Name of the layer.
  13845. */
  13846. static readonly EffectName: string;
  13847. /**
  13848. * The default blur kernel size used for the glow.
  13849. */
  13850. static DefaultBlurKernelSize: number;
  13851. /**
  13852. * The default texture size ratio used for the glow.
  13853. */
  13854. static DefaultTextureRatio: number;
  13855. /**
  13856. * Sets the kernel size of the blur.
  13857. */
  13858. /**
  13859. * Gets the kernel size of the blur.
  13860. */
  13861. blurKernelSize: number;
  13862. /**
  13863. * Sets the glow intensity.
  13864. */
  13865. /**
  13866. * Gets the glow intensity.
  13867. */
  13868. intensity: number;
  13869. private _options;
  13870. private _intensity;
  13871. private _horizontalBlurPostprocess1;
  13872. private _verticalBlurPostprocess1;
  13873. private _horizontalBlurPostprocess2;
  13874. private _verticalBlurPostprocess2;
  13875. private _blurTexture1;
  13876. private _blurTexture2;
  13877. private _postProcesses1;
  13878. private _postProcesses2;
  13879. private _includedOnlyMeshes;
  13880. private _excludedMeshes;
  13881. /**
  13882. * Callback used to let the user override the color selection on a per mesh basis
  13883. */
  13884. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  13885. /**
  13886. * Callback used to let the user override the texture selection on a per mesh basis
  13887. */
  13888. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  13889. /**
  13890. * Instantiates a new glow Layer and references it to the scene.
  13891. * @param name The name of the layer
  13892. * @param scene The scene to use the layer in
  13893. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  13894. */
  13895. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  13896. /**
  13897. * Get the effect name of the layer.
  13898. * @return The effect name
  13899. */
  13900. getEffectName(): string;
  13901. /**
  13902. * Create the merge effect. This is the shader use to blit the information back
  13903. * to the main canvas at the end of the scene rendering.
  13904. */
  13905. protected _createMergeEffect(): Effect;
  13906. /**
  13907. * Creates the render target textures and post processes used in the glow layer.
  13908. */
  13909. protected _createTextureAndPostProcesses(): void;
  13910. /**
  13911. * Checks for the readiness of the element composing the layer.
  13912. * @param subMesh the mesh to check for
  13913. * @param useInstances specify wether or not to use instances to render the mesh
  13914. * @param emissiveTexture the associated emissive texture used to generate the glow
  13915. * @return true if ready otherwise, false
  13916. */
  13917. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13918. /**
  13919. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13920. */
  13921. needStencil(): boolean;
  13922. /**
  13923. * Implementation specific of rendering the generating effect on the main canvas.
  13924. * @param effect The effect used to render through
  13925. */
  13926. protected _internalRender(effect: Effect): void;
  13927. /**
  13928. * Sets the required values for both the emissive texture and and the main color.
  13929. */
  13930. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13931. /**
  13932. * Returns true if the mesh should render, otherwise false.
  13933. * @param mesh The mesh to render
  13934. * @returns true if it should render otherwise false
  13935. */
  13936. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13937. /**
  13938. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  13939. * @param mesh The mesh to exclude from the glow layer
  13940. */
  13941. addExcludedMesh(mesh: Mesh): void;
  13942. /**
  13943. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  13944. * @param mesh The mesh to remove
  13945. */
  13946. removeExcludedMesh(mesh: Mesh): void;
  13947. /**
  13948. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  13949. * @param mesh The mesh to include in the glow layer
  13950. */
  13951. addIncludedOnlyMesh(mesh: Mesh): void;
  13952. /**
  13953. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  13954. * @param mesh The mesh to remove
  13955. */
  13956. removeIncludedOnlyMesh(mesh: Mesh): void;
  13957. /**
  13958. * Determine if a given mesh will be used in the glow layer
  13959. * @param mesh The mesh to test
  13960. * @returns true if the mesh will be highlighted by the current glow layer
  13961. */
  13962. hasMesh(mesh: AbstractMesh): boolean;
  13963. /**
  13964. * Free any resources and references associated to a mesh.
  13965. * Internal use
  13966. * @param mesh The mesh to free.
  13967. * @hidden
  13968. */
  13969. _disposeMesh(mesh: Mesh): void;
  13970. /**
  13971. * Gets the class name of the effect layer
  13972. * @returns the string with the class name of the effect layer
  13973. */
  13974. getClassName(): string;
  13975. /**
  13976. * Serializes this glow layer
  13977. * @returns a serialized glow layer object
  13978. */
  13979. serialize(): any;
  13980. /**
  13981. * Creates a Glow Layer from parsed glow layer data
  13982. * @param parsedGlowLayer defines glow layer data
  13983. * @param scene defines the current scene
  13984. * @param rootUrl defines the root URL containing the glow layer information
  13985. * @returns a parsed Glow Layer
  13986. */
  13987. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  13988. }
  13989. }
  13990. declare module BABYLON {
  13991. interface AbstractScene {
  13992. /**
  13993. * Return a the first highlight layer of the scene with a given name.
  13994. * @param name The name of the highlight layer to look for.
  13995. * @return The highlight layer if found otherwise null.
  13996. */
  13997. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  13998. }
  13999. /**
  14000. * Highlight layer options. This helps customizing the behaviour
  14001. * of the highlight layer.
  14002. */
  14003. interface IHighlightLayerOptions {
  14004. /**
  14005. * Multiplication factor apply to the canvas size to compute the render target size
  14006. * used to generated the glowing objects (the smaller the faster).
  14007. */
  14008. mainTextureRatio: number;
  14009. /**
  14010. * Enforces a fixed size texture to ensure resize independant blur.
  14011. */
  14012. mainTextureFixedSize?: number;
  14013. /**
  14014. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14015. * of the picture to blur (the smaller the faster).
  14016. */
  14017. blurTextureSizeRatio: number;
  14018. /**
  14019. * How big in texel of the blur texture is the vertical blur.
  14020. */
  14021. blurVerticalSize: number;
  14022. /**
  14023. * How big in texel of the blur texture is the horizontal blur.
  14024. */
  14025. blurHorizontalSize: number;
  14026. /**
  14027. * Alpha blending mode used to apply the blur. Default is combine.
  14028. */
  14029. alphaBlendingMode: number;
  14030. /**
  14031. * The camera attached to the layer.
  14032. */
  14033. camera: Nullable<Camera>;
  14034. /**
  14035. * Should we display highlight as a solid stroke?
  14036. */
  14037. isStroke?: boolean;
  14038. /**
  14039. * The rendering group to draw the layer in.
  14040. */
  14041. renderingGroupId: number;
  14042. }
  14043. /**
  14044. * The highlight layer Helps adding a glow effect around a mesh.
  14045. *
  14046. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14047. * glowy meshes to your scene.
  14048. *
  14049. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14050. */
  14051. class HighlightLayer extends EffectLayer {
  14052. name: string;
  14053. /**
  14054. * Effect Name of the highlight layer.
  14055. */
  14056. static readonly EffectName: string;
  14057. /**
  14058. * The neutral color used during the preparation of the glow effect.
  14059. * This is black by default as the blend operation is a blend operation.
  14060. */
  14061. static NeutralColor: Color4;
  14062. /**
  14063. * Stencil value used for glowing meshes.
  14064. */
  14065. static GlowingMeshStencilReference: number;
  14066. /**
  14067. * Stencil value used for the other meshes in the scene.
  14068. */
  14069. static NormalMeshStencilReference: number;
  14070. /**
  14071. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14072. */
  14073. innerGlow: boolean;
  14074. /**
  14075. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14076. */
  14077. outerGlow: boolean;
  14078. /**
  14079. * Specifies the horizontal size of the blur.
  14080. */
  14081. /**
  14082. * Gets the horizontal size of the blur.
  14083. */
  14084. blurHorizontalSize: number;
  14085. /**
  14086. * Specifies the vertical size of the blur.
  14087. */
  14088. /**
  14089. * Gets the vertical size of the blur.
  14090. */
  14091. blurVerticalSize: number;
  14092. /**
  14093. * An event triggered when the highlight layer is being blurred.
  14094. */
  14095. onBeforeBlurObservable: Observable<HighlightLayer>;
  14096. /**
  14097. * An event triggered when the highlight layer has been blurred.
  14098. */
  14099. onAfterBlurObservable: Observable<HighlightLayer>;
  14100. private _instanceGlowingMeshStencilReference;
  14101. private _options;
  14102. private _downSamplePostprocess;
  14103. private _horizontalBlurPostprocess;
  14104. private _verticalBlurPostprocess;
  14105. private _blurTexture;
  14106. private _meshes;
  14107. private _excludedMeshes;
  14108. /**
  14109. * Instantiates a new highlight Layer and references it to the scene..
  14110. * @param name The name of the layer
  14111. * @param scene The scene to use the layer in
  14112. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14113. */
  14114. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14115. /**
  14116. * Get the effect name of the layer.
  14117. * @return The effect name
  14118. */
  14119. getEffectName(): string;
  14120. /**
  14121. * Create the merge effect. This is the shader use to blit the information back
  14122. * to the main canvas at the end of the scene rendering.
  14123. */
  14124. protected _createMergeEffect(): Effect;
  14125. /**
  14126. * Creates the render target textures and post processes used in the highlight layer.
  14127. */
  14128. protected _createTextureAndPostProcesses(): void;
  14129. /**
  14130. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14131. */
  14132. needStencil(): boolean;
  14133. /**
  14134. * Checks for the readiness of the element composing the layer.
  14135. * @param subMesh the mesh to check for
  14136. * @param useInstances specify wether or not to use instances to render the mesh
  14137. * @param emissiveTexture the associated emissive texture used to generate the glow
  14138. * @return true if ready otherwise, false
  14139. */
  14140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14141. /**
  14142. * Implementation specific of rendering the generating effect on the main canvas.
  14143. * @param effect The effect used to render through
  14144. */
  14145. protected _internalRender(effect: Effect): void;
  14146. /**
  14147. * Returns true if the layer contains information to display, otherwise false.
  14148. */
  14149. shouldRender(): boolean;
  14150. /**
  14151. * Returns true if the mesh should render, otherwise false.
  14152. * @param mesh The mesh to render
  14153. * @returns true if it should render otherwise false
  14154. */
  14155. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14156. /**
  14157. * Sets the required values for both the emissive texture and and the main color.
  14158. */
  14159. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14160. /**
  14161. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14162. * @param mesh The mesh to exclude from the highlight layer
  14163. */
  14164. addExcludedMesh(mesh: Mesh): void;
  14165. /**
  14166. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14167. * @param mesh The mesh to highlight
  14168. */
  14169. removeExcludedMesh(mesh: Mesh): void;
  14170. /**
  14171. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14172. * @param mesh mesh to test
  14173. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14174. */
  14175. hasMesh(mesh: AbstractMesh): boolean;
  14176. /**
  14177. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14178. * @param mesh The mesh to highlight
  14179. * @param color The color of the highlight
  14180. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14181. */
  14182. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14183. /**
  14184. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14185. * @param mesh The mesh to highlight
  14186. */
  14187. removeMesh(mesh: Mesh): void;
  14188. /**
  14189. * Force the stencil to the normal expected value for none glowing parts
  14190. */
  14191. private _defaultStencilReference;
  14192. /**
  14193. * Free any resources and references associated to a mesh.
  14194. * Internal use
  14195. * @param mesh The mesh to free.
  14196. * @hidden
  14197. */
  14198. _disposeMesh(mesh: Mesh): void;
  14199. /**
  14200. * Dispose the highlight layer and free resources.
  14201. */
  14202. dispose(): void;
  14203. /**
  14204. * Gets the class name of the effect layer
  14205. * @returns the string with the class name of the effect layer
  14206. */
  14207. getClassName(): string;
  14208. /**
  14209. * Serializes this Highlight layer
  14210. * @returns a serialized Highlight layer object
  14211. */
  14212. serialize(): any;
  14213. /**
  14214. * Creates a Highlight layer from parsed Highlight layer data
  14215. * @param parsedHightlightLayer defines the Highlight layer data
  14216. * @param scene defines the current scene
  14217. * @param rootUrl defines the root URL containing the Highlight layer information
  14218. * @returns a parsed Highlight layer
  14219. */
  14220. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14221. }
  14222. }
  14223. declare module BABYLON {
  14224. /**
  14225. * This represents a full screen 2d layer.
  14226. * This can be usefull to display a picture in the background of your scene for instance.
  14227. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14228. */
  14229. class Layer {
  14230. /**
  14231. * Define the name of the layer.
  14232. */
  14233. name: string;
  14234. /**
  14235. * Define the texture the layer should display.
  14236. */
  14237. texture: Nullable<Texture>;
  14238. /**
  14239. * Is the layer in background or foreground.
  14240. */
  14241. isBackground: boolean;
  14242. /**
  14243. * Define the color of the layer (instead of texture).
  14244. */
  14245. color: Color4;
  14246. /**
  14247. * Define the scale of the layer in order to zoom in out of the texture.
  14248. */
  14249. scale: Vector2;
  14250. /**
  14251. * Define an offset for the layer in order to shift the texture.
  14252. */
  14253. offset: Vector2;
  14254. /**
  14255. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14256. */
  14257. alphaBlendingMode: number;
  14258. /**
  14259. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14260. * Alpha test will not mix with the background color in case of transparency.
  14261. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14262. */
  14263. alphaTest: boolean;
  14264. /**
  14265. * Define a mask to restrict the layer to only some of the scene cameras.
  14266. */
  14267. layerMask: number;
  14268. private _scene;
  14269. private _vertexBuffers;
  14270. private _indexBuffer;
  14271. private _effect;
  14272. private _alphaTestEffect;
  14273. /**
  14274. * An event triggered when the layer is disposed.
  14275. */
  14276. onDisposeObservable: Observable<Layer>;
  14277. private _onDisposeObserver;
  14278. /**
  14279. * Back compatibility with callback before the onDisposeObservable existed.
  14280. * The set callback will be triggered when the layer has been disposed.
  14281. */
  14282. onDispose: () => void;
  14283. /**
  14284. * An event triggered before rendering the scene
  14285. */
  14286. onBeforeRenderObservable: Observable<Layer>;
  14287. private _onBeforeRenderObserver;
  14288. /**
  14289. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14290. * The set callback will be triggered just before rendering the layer.
  14291. */
  14292. onBeforeRender: () => void;
  14293. /**
  14294. * An event triggered after rendering the scene
  14295. */
  14296. onAfterRenderObservable: Observable<Layer>;
  14297. private _onAfterRenderObserver;
  14298. /**
  14299. * Back compatibility with callback before the onAfterRenderObservable existed.
  14300. * The set callback will be triggered just after rendering the layer.
  14301. */
  14302. onAfterRender: () => void;
  14303. /**
  14304. * Instantiates a new layer.
  14305. * This represents a full screen 2d layer.
  14306. * This can be usefull to display a picture in the background of your scene for instance.
  14307. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14308. * @param name Define the name of the layer in the scene
  14309. * @param imgUrl Define the url of the texture to display in the layer
  14310. * @param scene Define the scene the layer belongs to
  14311. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14312. * @param color Defines a color for the layer
  14313. */
  14314. constructor(
  14315. /**
  14316. * Define the name of the layer.
  14317. */
  14318. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14319. private _createIndexBuffer;
  14320. /** @hidden */
  14321. _rebuild(): void;
  14322. /**
  14323. * Renders the layer in the scene.
  14324. */
  14325. render(): void;
  14326. /**
  14327. * Disposes and releases the associated ressources.
  14328. */
  14329. dispose(): void;
  14330. }
  14331. }
  14332. declare module BABYLON {
  14333. interface AbstractScene {
  14334. /**
  14335. * The list of layers (background and foreground) of the scene
  14336. */
  14337. layers: Array<Layer>;
  14338. }
  14339. /**
  14340. * Defines the layer scene component responsible to manage any layers
  14341. * in a given scene.
  14342. */
  14343. class LayerSceneComponent implements ISceneComponent {
  14344. /**
  14345. * The component name helpfull to identify the component in the list of scene components.
  14346. */
  14347. readonly name: string;
  14348. /**
  14349. * The scene the component belongs to.
  14350. */
  14351. scene: Scene;
  14352. private _engine;
  14353. /**
  14354. * Creates a new instance of the component for the given scene
  14355. * @param scene Defines the scene to register the component in
  14356. */
  14357. constructor(scene: Scene);
  14358. /**
  14359. * Registers the component in a given scene
  14360. */
  14361. register(): void;
  14362. /**
  14363. * Rebuilds the elements related to this component in case of
  14364. * context lost for instance.
  14365. */
  14366. rebuild(): void;
  14367. /**
  14368. * Disposes the component and the associated ressources.
  14369. */
  14370. dispose(): void;
  14371. private _draw;
  14372. private _drawBackground;
  14373. private _drawForeground;
  14374. }
  14375. }
  14376. declare module BABYLON {
  14377. /**
  14378. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14379. * It controls one of the indiviual texture used in the effect.
  14380. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14381. */
  14382. class LensFlare {
  14383. /**
  14384. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14385. */
  14386. size: number;
  14387. /**
  14388. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14389. */
  14390. position: number;
  14391. /**
  14392. * Define the lens color.
  14393. */
  14394. color: Color3;
  14395. /**
  14396. * Define the lens texture.
  14397. */
  14398. texture: Nullable<Texture>;
  14399. /**
  14400. * Define the alpha mode to render this particular lens.
  14401. */
  14402. alphaMode: number;
  14403. private _system;
  14404. /**
  14405. * Creates a new Lens Flare.
  14406. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14407. * It controls one of the indiviual texture used in the effect.
  14408. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14409. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14410. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14411. * @param color Define the lens color
  14412. * @param imgUrl Define the lens texture url
  14413. * @param system Define the `lensFlareSystem` this flare is part of
  14414. * @returns The newly created Lens Flare
  14415. */
  14416. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14417. /**
  14418. * Instantiates a new Lens Flare.
  14419. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14420. * It controls one of the indiviual texture used in the effect.
  14421. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14422. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14423. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14424. * @param color Define the lens color
  14425. * @param imgUrl Define the lens texture url
  14426. * @param system Define the `lensFlareSystem` this flare is part of
  14427. */
  14428. constructor(
  14429. /**
  14430. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14431. */
  14432. size: number,
  14433. /**
  14434. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14435. */
  14436. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14437. /**
  14438. * Dispose and release the lens flare with its associated resources.
  14439. */
  14440. dispose(): void;
  14441. }
  14442. }
  14443. declare module BABYLON {
  14444. /**
  14445. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14446. * It is usually composed of several `BABYLON.lensFlare`.
  14447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14448. */
  14449. class LensFlareSystem {
  14450. /**
  14451. * Define the name of the lens flare system
  14452. */
  14453. name: string;
  14454. /**
  14455. * List of lens flares used in this system.
  14456. */
  14457. lensFlares: LensFlare[];
  14458. /**
  14459. * Define a limit from the border the lens flare can be visible.
  14460. */
  14461. borderLimit: number;
  14462. /**
  14463. * Define a viewport border we do not want to see the lens flare in.
  14464. */
  14465. viewportBorder: number;
  14466. /**
  14467. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14468. */
  14469. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14470. /**
  14471. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14472. */
  14473. layerMask: number;
  14474. /**
  14475. * Define the id of the lens flare system in the scene.
  14476. * (equal to name by default)
  14477. */
  14478. id: string;
  14479. private _scene;
  14480. private _emitter;
  14481. private _vertexBuffers;
  14482. private _indexBuffer;
  14483. private _effect;
  14484. private _positionX;
  14485. private _positionY;
  14486. private _isEnabled;
  14487. /**
  14488. * Instantiates a lens flare system.
  14489. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14490. * It is usually composed of several `BABYLON.lensFlare`.
  14491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14492. * @param name Define the name of the lens flare system in the scene
  14493. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14494. * @param scene Define the scene the lens flare system belongs to
  14495. */
  14496. constructor(
  14497. /**
  14498. * Define the name of the lens flare system
  14499. */
  14500. name: string, emitter: any, scene: Scene);
  14501. /**
  14502. * Define if the lens flare system is enabled.
  14503. */
  14504. isEnabled: boolean;
  14505. /**
  14506. * Get the scene the effects belongs to.
  14507. * @returns the scene holding the lens flare system
  14508. */
  14509. getScene(): Scene;
  14510. /**
  14511. * Get the emitter of the lens flare system.
  14512. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14513. * @returns the emitter of the lens flare system
  14514. */
  14515. getEmitter(): any;
  14516. /**
  14517. * Set the emitter of the lens flare system.
  14518. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14519. * @param newEmitter Define the new emitter of the system
  14520. */
  14521. setEmitter(newEmitter: any): void;
  14522. /**
  14523. * Get the lens flare system emitter position.
  14524. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14525. * @returns the position
  14526. */
  14527. getEmitterPosition(): Vector3;
  14528. /**
  14529. * @hidden
  14530. */
  14531. computeEffectivePosition(globalViewport: Viewport): boolean;
  14532. /** @hidden */
  14533. _isVisible(): boolean;
  14534. /**
  14535. * @hidden
  14536. */
  14537. render(): boolean;
  14538. /**
  14539. * Dispose and release the lens flare with its associated resources.
  14540. */
  14541. dispose(): void;
  14542. /**
  14543. * Parse a lens flare system from a JSON repressentation
  14544. * @param parsedLensFlareSystem Define the JSON to parse
  14545. * @param scene Define the scene the parsed system should be instantiated in
  14546. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14547. * @returns the parsed system
  14548. */
  14549. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14550. /**
  14551. * Serialize the current Lens Flare System into a JSON representation.
  14552. * @returns the serialized JSON
  14553. */
  14554. serialize(): any;
  14555. }
  14556. }
  14557. declare module BABYLON {
  14558. interface AbstractScene {
  14559. /**
  14560. * The list of lens flare system added to the scene
  14561. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14562. */
  14563. lensFlareSystems: Array<LensFlareSystem>;
  14564. /**
  14565. * Removes the given lens flare system from this scene.
  14566. * @param toRemove The lens flare system to remove
  14567. * @returns The index of the removed lens flare system
  14568. */
  14569. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14570. /**
  14571. * Adds the given lens flare system to this scene
  14572. * @param newLensFlareSystem The lens flare system to add
  14573. */
  14574. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14575. /**
  14576. * Gets a lens flare system using its name
  14577. * @param name defines the name to look for
  14578. * @returns the lens flare system or null if not found
  14579. */
  14580. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14581. /**
  14582. * Gets a lens flare system using its id
  14583. * @param id defines the id to look for
  14584. * @returns the lens flare system or null if not found
  14585. */
  14586. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14587. }
  14588. /**
  14589. * Defines the lens flare scene component responsible to manage any lens flares
  14590. * in a given scene.
  14591. */
  14592. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14593. /**
  14594. * The component name helpfull to identify the component in the list of scene components.
  14595. */
  14596. readonly name: string;
  14597. /**
  14598. * The scene the component belongs to.
  14599. */
  14600. scene: Scene;
  14601. /**
  14602. * Creates a new instance of the component for the given scene
  14603. * @param scene Defines the scene to register the component in
  14604. */
  14605. constructor(scene: Scene);
  14606. /**
  14607. * Registers the component in a given scene
  14608. */
  14609. register(): void;
  14610. /**
  14611. * Rebuilds the elements related to this component in case of
  14612. * context lost for instance.
  14613. */
  14614. rebuild(): void;
  14615. /**
  14616. * Adds all the element from the container to the scene
  14617. * @param container the container holding the elements
  14618. */
  14619. addFromContainer(container: AbstractScene): void;
  14620. /**
  14621. * Removes all the elements in the container from the scene
  14622. * @param container contains the elements to remove
  14623. */
  14624. removeFromContainer(container: AbstractScene): void;
  14625. /**
  14626. * Serializes the component data to the specified json object
  14627. * @param serializationObject The object to serialize to
  14628. */
  14629. serialize(serializationObject: any): void;
  14630. /**
  14631. * Disposes the component and the associated ressources.
  14632. */
  14633. dispose(): void;
  14634. private _draw;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. /**
  14639. * A directional light is defined by a direction (what a surprise!).
  14640. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  14641. * 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.
  14642. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14643. */
  14644. class DirectionalLight extends ShadowLight {
  14645. private _shadowFrustumSize;
  14646. /**
  14647. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  14648. */
  14649. /**
  14650. * Specifies a fix frustum size for the shadow generation.
  14651. */
  14652. shadowFrustumSize: number;
  14653. private _shadowOrthoScale;
  14654. /**
  14655. * Gets the shadow projection scale against the optimal computed one.
  14656. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14657. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14658. */
  14659. /**
  14660. * Sets the shadow projection scale against the optimal computed one.
  14661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14663. */
  14664. shadowOrthoScale: number;
  14665. /**
  14666. * Automatically compute the projection matrix to best fit (including all the casters)
  14667. * on each frame.
  14668. */
  14669. autoUpdateExtends: boolean;
  14670. private _orthoLeft;
  14671. private _orthoRight;
  14672. private _orthoTop;
  14673. private _orthoBottom;
  14674. /**
  14675. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  14676. * The directional light is emitted from everywhere in the given direction.
  14677. * It can cast shadows.
  14678. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14679. * @param name The friendly name of the light
  14680. * @param direction The direction of the light
  14681. * @param scene The scene the light belongs to
  14682. */
  14683. constructor(name: string, direction: Vector3, scene: Scene);
  14684. /**
  14685. * Returns the string "DirectionalLight".
  14686. * @return The class name
  14687. */
  14688. getClassName(): string;
  14689. /**
  14690. * Returns the integer 1.
  14691. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14692. */
  14693. getTypeID(): number;
  14694. /**
  14695. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  14696. * Returns the DirectionalLight Shadow projection matrix.
  14697. */
  14698. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14699. /**
  14700. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  14701. * Returns the DirectionalLight Shadow projection matrix.
  14702. */
  14703. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  14704. /**
  14705. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  14706. * Returns the DirectionalLight Shadow projection matrix.
  14707. */
  14708. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14709. protected _buildUniformLayout(): void;
  14710. /**
  14711. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  14712. * @param effect The effect to update
  14713. * @param lightIndex The index of the light in the effect to update
  14714. * @returns The directional light
  14715. */
  14716. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  14717. /**
  14718. * Gets the minZ used for shadow according to both the scene and the light.
  14719. *
  14720. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14721. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14722. * @param activeCamera The camera we are returning the min for
  14723. * @returns the depth min z
  14724. */
  14725. getDepthMinZ(activeCamera: Camera): number;
  14726. /**
  14727. * Gets the maxZ used for shadow according to both the scene and the light.
  14728. *
  14729. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14730. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14731. * @param activeCamera The camera we are returning the max for
  14732. * @returns the depth max z
  14733. */
  14734. getDepthMaxZ(activeCamera: Camera): number;
  14735. /**
  14736. * Prepares the list of defines specific to the light type.
  14737. * @param defines the list of defines
  14738. * @param lightIndex defines the index of the light for the effect
  14739. */
  14740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14741. }
  14742. }
  14743. declare module BABYLON {
  14744. /**
  14745. * The HemisphericLight simulates the ambient environment light,
  14746. * so the passed direction is the light reflection direction, not the incoming direction.
  14747. */
  14748. class HemisphericLight extends Light {
  14749. /**
  14750. * The groundColor is the light in the opposite direction to the one specified during creation.
  14751. * 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.
  14752. */
  14753. groundColor: Color3;
  14754. /**
  14755. * The light reflection direction, not the incoming direction.
  14756. */
  14757. direction: Vector3;
  14758. /**
  14759. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14760. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14761. * The HemisphericLight can't cast shadows.
  14762. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14763. * @param name The friendly name of the light
  14764. * @param direction The direction of the light reflection
  14765. * @param scene The scene the light belongs to
  14766. */
  14767. constructor(name: string, direction: Vector3, scene: Scene);
  14768. protected _buildUniformLayout(): void;
  14769. /**
  14770. * Returns the string "HemisphericLight".
  14771. * @return The class name
  14772. */
  14773. getClassName(): string;
  14774. /**
  14775. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14776. * Returns the updated direction.
  14777. * @param target The target the direction should point to
  14778. * @return The computed direction
  14779. */
  14780. setDirectionToTarget(target: Vector3): Vector3;
  14781. /**
  14782. * Returns the shadow generator associated to the light.
  14783. * @returns Always null for hemispheric lights because it does not support shadows.
  14784. */
  14785. getShadowGenerator(): Nullable<IShadowGenerator>;
  14786. /**
  14787. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14788. * @param effect The effect to update
  14789. * @param lightIndex The index of the light in the effect to update
  14790. * @returns The hemispheric light
  14791. */
  14792. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14793. /**
  14794. * Computes the world matrix of the node
  14795. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14796. * @param useWasUpdatedFlag defines a reserved property
  14797. * @returns the world matrix
  14798. */
  14799. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  14800. /**
  14801. * Returns the integer 3.
  14802. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14803. */
  14804. getTypeID(): number;
  14805. /**
  14806. * Prepares the list of defines specific to the light type.
  14807. * @param defines the list of defines
  14808. * @param lightIndex defines the index of the light for the effect
  14809. */
  14810. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14811. }
  14812. }
  14813. declare module BABYLON {
  14814. /**
  14815. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  14816. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  14817. * 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.
  14818. */
  14819. abstract class Light extends Node {
  14820. /**
  14821. * Falloff Default: light is falling off following the material specification:
  14822. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  14823. */
  14824. static readonly FALLOFF_DEFAULT: number;
  14825. /**
  14826. * Falloff Physical: light is falling off following the inverse squared distance law.
  14827. */
  14828. static readonly FALLOFF_PHYSICAL: number;
  14829. /**
  14830. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  14831. * to enhance interoperability with other engines.
  14832. */
  14833. static readonly FALLOFF_GLTF: number;
  14834. /**
  14835. * Falloff Standard: light is falling off like in the standard material
  14836. * to enhance interoperability with other materials.
  14837. */
  14838. static readonly FALLOFF_STANDARD: number;
  14839. /**
  14840. * If every light affecting the material is in this lightmapMode,
  14841. * material.lightmapTexture adds or multiplies
  14842. * (depends on material.useLightmapAsShadowmap)
  14843. * after every other light calculations.
  14844. */
  14845. static readonly LIGHTMAP_DEFAULT: number;
  14846. /**
  14847. * material.lightmapTexture as only diffuse lighting from this light
  14848. * adds only specular lighting from this light
  14849. * adds dynamic shadows
  14850. */
  14851. static readonly LIGHTMAP_SPECULAR: number;
  14852. /**
  14853. * material.lightmapTexture as only lighting
  14854. * no light calculation from this light
  14855. * only adds dynamic shadows from this light
  14856. */
  14857. static readonly LIGHTMAP_SHADOWSONLY: number;
  14858. /**
  14859. * Each light type uses the default quantity according to its type:
  14860. * point/spot lights use luminous intensity
  14861. * directional lights use illuminance
  14862. */
  14863. static readonly INTENSITYMODE_AUTOMATIC: number;
  14864. /**
  14865. * lumen (lm)
  14866. */
  14867. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  14868. /**
  14869. * candela (lm/sr)
  14870. */
  14871. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  14872. /**
  14873. * lux (lm/m^2)
  14874. */
  14875. static readonly INTENSITYMODE_ILLUMINANCE: number;
  14876. /**
  14877. * nit (cd/m^2)
  14878. */
  14879. static readonly INTENSITYMODE_LUMINANCE: number;
  14880. /**
  14881. * Light type const id of the point light.
  14882. */
  14883. static readonly LIGHTTYPEID_POINTLIGHT: number;
  14884. /**
  14885. * Light type const id of the directional light.
  14886. */
  14887. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  14888. /**
  14889. * Light type const id of the spot light.
  14890. */
  14891. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  14892. /**
  14893. * Light type const id of the hemispheric light.
  14894. */
  14895. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  14896. /**
  14897. * Diffuse gives the basic color to an object.
  14898. */
  14899. diffuse: Color3;
  14900. /**
  14901. * Specular produces a highlight color on an object.
  14902. * Note: This is note affecting PBR materials.
  14903. */
  14904. specular: Color3;
  14905. /**
  14906. * Defines the falloff type for this light. This lets overrriding how punctual light are
  14907. * falling off base on range or angle.
  14908. * This can be set to any values in Light.FALLOFF_x.
  14909. *
  14910. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  14911. * other types of materials.
  14912. */
  14913. falloffType: number;
  14914. /**
  14915. * Strength of the light.
  14916. * Note: By default it is define in the framework own unit.
  14917. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  14918. */
  14919. intensity: number;
  14920. private _range;
  14921. protected _inverseSquaredRange: number;
  14922. /**
  14923. * Defines how far from the source the light is impacting in scene units.
  14924. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14925. */
  14926. /**
  14927. * Defines how far from the source the light is impacting in scene units.
  14928. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14929. */
  14930. range: number;
  14931. /**
  14932. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  14933. * of light.
  14934. */
  14935. private _photometricScale;
  14936. private _intensityMode;
  14937. /**
  14938. * Gets the photometric scale used to interpret the intensity.
  14939. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14940. */
  14941. /**
  14942. * Sets the photometric scale used to interpret the intensity.
  14943. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14944. */
  14945. intensityMode: number;
  14946. private _radius;
  14947. /**
  14948. * Gets the light radius used by PBR Materials to simulate soft area lights.
  14949. */
  14950. /**
  14951. * sets the light radius used by PBR Materials to simulate soft area lights.
  14952. */
  14953. radius: number;
  14954. private _renderPriority;
  14955. /**
  14956. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  14957. * exceeding the number allowed of the materials.
  14958. */
  14959. renderPriority: number;
  14960. private _shadowEnabled;
  14961. /**
  14962. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14963. * the current shadow generator.
  14964. */
  14965. /**
  14966. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14967. * the current shadow generator.
  14968. */
  14969. shadowEnabled: boolean;
  14970. private _includedOnlyMeshes;
  14971. /**
  14972. * Gets the only meshes impacted by this light.
  14973. */
  14974. /**
  14975. * Sets the only meshes impacted by this light.
  14976. */
  14977. includedOnlyMeshes: AbstractMesh[];
  14978. private _excludedMeshes;
  14979. /**
  14980. * Gets the meshes not impacted by this light.
  14981. */
  14982. /**
  14983. * Sets the meshes not impacted by this light.
  14984. */
  14985. excludedMeshes: AbstractMesh[];
  14986. private _excludeWithLayerMask;
  14987. /**
  14988. * Gets the layer id use to find what meshes are not impacted by the light.
  14989. * Inactive if 0
  14990. */
  14991. /**
  14992. * Sets the layer id use to find what meshes are not impacted by the light.
  14993. * Inactive if 0
  14994. */
  14995. excludeWithLayerMask: number;
  14996. private _includeOnlyWithLayerMask;
  14997. /**
  14998. * Gets the layer id use to find what meshes are impacted by the light.
  14999. * Inactive if 0
  15000. */
  15001. /**
  15002. * Sets the layer id use to find what meshes are impacted by the light.
  15003. * Inactive if 0
  15004. */
  15005. includeOnlyWithLayerMask: number;
  15006. private _lightmapMode;
  15007. /**
  15008. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15009. */
  15010. /**
  15011. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15012. */
  15013. lightmapMode: number;
  15014. /**
  15015. * Shadow generator associted to the light.
  15016. * @hidden Internal use only.
  15017. */
  15018. _shadowGenerator: Nullable<IShadowGenerator>;
  15019. /**
  15020. * @hidden Internal use only.
  15021. */
  15022. _excludedMeshesIds: string[];
  15023. /**
  15024. * @hidden Internal use only.
  15025. */
  15026. _includedOnlyMeshesIds: string[];
  15027. /**
  15028. * The current light unifom buffer.
  15029. * @hidden Internal use only.
  15030. */
  15031. _uniformBuffer: UniformBuffer;
  15032. /**
  15033. * Creates a Light object in the scene.
  15034. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15035. * @param name The firendly name of the light
  15036. * @param scene The scene the light belongs too
  15037. */
  15038. constructor(name: string, scene: Scene);
  15039. protected abstract _buildUniformLayout(): void;
  15040. /**
  15041. * Sets the passed Effect "effect" with the Light information.
  15042. * @param effect The effect to update
  15043. * @param lightIndex The index of the light in the effect to update
  15044. * @returns The light
  15045. */
  15046. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15047. /**
  15048. * Returns the string "Light".
  15049. * @returns the class name
  15050. */
  15051. getClassName(): string;
  15052. /**
  15053. * Converts the light information to a readable string for debug purpose.
  15054. * @param fullDetails Supports for multiple levels of logging within scene loading
  15055. * @returns the human readable light info
  15056. */
  15057. toString(fullDetails?: boolean): string;
  15058. /** @hidden */
  15059. protected _syncParentEnabledState(): void;
  15060. /**
  15061. * Set the enabled state of this node.
  15062. * @param value - the new enabled state
  15063. */
  15064. setEnabled(value: boolean): void;
  15065. /**
  15066. * Returns the Light associated shadow generator if any.
  15067. * @return the associated shadow generator.
  15068. */
  15069. getShadowGenerator(): Nullable<IShadowGenerator>;
  15070. /**
  15071. * Returns a Vector3, the absolute light position in the World.
  15072. * @returns the world space position of the light
  15073. */
  15074. getAbsolutePosition(): Vector3;
  15075. /**
  15076. * Specifies if the light will affect the passed mesh.
  15077. * @param mesh The mesh to test against the light
  15078. * @return true the mesh is affected otherwise, false.
  15079. */
  15080. canAffectMesh(mesh: AbstractMesh): boolean;
  15081. /**
  15082. * Sort function to order lights for rendering.
  15083. * @param a First Light object to compare to second.
  15084. * @param b Second Light object to compare first.
  15085. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15086. */
  15087. static CompareLightsPriority(a: Light, b: Light): number;
  15088. /**
  15089. * Releases resources associated with this node.
  15090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15092. */
  15093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15094. /**
  15095. * Returns the light type ID (integer).
  15096. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15097. */
  15098. getTypeID(): number;
  15099. /**
  15100. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15101. * @returns the scaled intensity in intensity mode unit
  15102. */
  15103. getScaledIntensity(): number;
  15104. /**
  15105. * Returns a new Light object, named "name", from the current one.
  15106. * @param name The name of the cloned light
  15107. * @returns the new created light
  15108. */
  15109. clone(name: string): Nullable<Light>;
  15110. /**
  15111. * Serializes the current light into a Serialization object.
  15112. * @returns the serialized object.
  15113. */
  15114. serialize(): any;
  15115. /**
  15116. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15117. * This new light is named "name" and added to the passed scene.
  15118. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15119. * @param name The friendly name of the light
  15120. * @param scene The scene the new light will belong to
  15121. * @returns the constructor function
  15122. */
  15123. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15124. /**
  15125. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15126. * @param parsedLight The JSON representation of the light
  15127. * @param scene The scene to create the parsed light in
  15128. * @returns the created light after parsing
  15129. */
  15130. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15131. private _hookArrayForExcluded;
  15132. private _hookArrayForIncludedOnly;
  15133. private _resyncMeshes;
  15134. /**
  15135. * Forces the meshes to update their light related information in their rendering used effects
  15136. * @hidden Internal Use Only
  15137. */
  15138. _markMeshesAsLightDirty(): void;
  15139. /**
  15140. * Recomputes the cached photometric scale if needed.
  15141. */
  15142. private _computePhotometricScale;
  15143. /**
  15144. * Returns the Photometric Scale according to the light type and intensity mode.
  15145. */
  15146. private _getPhotometricScale;
  15147. /**
  15148. * Reorder the light in the scene according to their defined priority.
  15149. * @hidden Internal Use Only
  15150. */
  15151. _reorderLightsInScene(): void;
  15152. /**
  15153. * Prepares the list of defines specific to the light type.
  15154. * @param defines the list of defines
  15155. * @param lightIndex defines the index of the light for the effect
  15156. */
  15157. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15158. }
  15159. }
  15160. declare module BABYLON {
  15161. /**
  15162. * A point light is a light defined by an unique point in world space.
  15163. * The light is emitted in every direction from this point.
  15164. * A good example of a point light is a standard light bulb.
  15165. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15166. */
  15167. class PointLight extends ShadowLight {
  15168. private _shadowAngle;
  15169. /**
  15170. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15171. * This specifies what angle the shadow will use to be created.
  15172. *
  15173. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15174. */
  15175. /**
  15176. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15177. * This specifies what angle the shadow will use to be created.
  15178. *
  15179. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15180. */
  15181. shadowAngle: number;
  15182. /**
  15183. * Gets the direction if it has been set.
  15184. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15185. */
  15186. /**
  15187. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15188. */
  15189. direction: Vector3;
  15190. /**
  15191. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15192. * A PointLight emits the light in every direction.
  15193. * It can cast shadows.
  15194. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15195. * ```javascript
  15196. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15197. * ```
  15198. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15199. * @param name The light friendly name
  15200. * @param position The position of the point light in the scene
  15201. * @param scene The scene the lights belongs to
  15202. */
  15203. constructor(name: string, position: Vector3, scene: Scene);
  15204. /**
  15205. * Returns the string "PointLight"
  15206. * @returns the class name
  15207. */
  15208. getClassName(): string;
  15209. /**
  15210. * Returns the integer 0.
  15211. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15212. */
  15213. getTypeID(): number;
  15214. /**
  15215. * Specifies wether or not the shadowmap should be a cube texture.
  15216. * @returns true if the shadowmap needs to be a cube texture.
  15217. */
  15218. needCube(): boolean;
  15219. /**
  15220. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15221. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15222. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15223. */
  15224. getShadowDirection(faceIndex?: number): Vector3;
  15225. /**
  15226. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15227. * - fov = PI / 2
  15228. * - aspect ratio : 1.0
  15229. * - z-near and far equal to the active camera minZ and maxZ.
  15230. * Returns the PointLight.
  15231. */
  15232. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15233. protected _buildUniformLayout(): void;
  15234. /**
  15235. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15236. * @param effect The effect to update
  15237. * @param lightIndex The index of the light in the effect to update
  15238. * @returns The point light
  15239. */
  15240. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15241. /**
  15242. * Prepares the list of defines specific to the light type.
  15243. * @param defines the list of defines
  15244. * @param lightIndex defines the index of the light for the effect
  15245. */
  15246. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15247. }
  15248. }
  15249. declare module BABYLON {
  15250. /**
  15251. * Interface describing all the common properties and methods a shadow light needs to implement.
  15252. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15253. * as well as binding the different shadow properties to the effects.
  15254. */
  15255. interface IShadowLight extends Light {
  15256. /**
  15257. * The light id in the scene (used in scene.findLighById for instance)
  15258. */
  15259. id: string;
  15260. /**
  15261. * The position the shdow will be casted from.
  15262. */
  15263. position: Vector3;
  15264. /**
  15265. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15266. */
  15267. direction: Vector3;
  15268. /**
  15269. * The transformed position. Position of the light in world space taking parenting in account.
  15270. */
  15271. transformedPosition: Vector3;
  15272. /**
  15273. * The transformed direction. Direction of the light in world space taking parenting in account.
  15274. */
  15275. transformedDirection: Vector3;
  15276. /**
  15277. * The friendly name of the light in the scene.
  15278. */
  15279. name: string;
  15280. /**
  15281. * Defines the shadow projection clipping minimum z value.
  15282. */
  15283. shadowMinZ: number;
  15284. /**
  15285. * Defines the shadow projection clipping maximum z value.
  15286. */
  15287. shadowMaxZ: number;
  15288. /**
  15289. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15290. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15291. */
  15292. computeTransformedInformation(): boolean;
  15293. /**
  15294. * Gets the scene the light belongs to.
  15295. * @returns The scene
  15296. */
  15297. getScene(): Scene;
  15298. /**
  15299. * Callback defining a custom Projection Matrix Builder.
  15300. * This can be used to override the default projection matrix computation.
  15301. */
  15302. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15303. /**
  15304. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15305. * @param matrix The materix to updated with the projection information
  15306. * @param viewMatrix The transform matrix of the light
  15307. * @param renderList The list of mesh to render in the map
  15308. * @returns The current light
  15309. */
  15310. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15311. /**
  15312. * Gets the current depth scale used in ESM.
  15313. * @returns The scale
  15314. */
  15315. getDepthScale(): number;
  15316. /**
  15317. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15318. * @returns true if a cube texture needs to be use
  15319. */
  15320. needCube(): boolean;
  15321. /**
  15322. * Detects if the projection matrix requires to be recomputed this frame.
  15323. * @returns true if it requires to be recomputed otherwise, false.
  15324. */
  15325. needProjectionMatrixCompute(): boolean;
  15326. /**
  15327. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15328. */
  15329. forceProjectionMatrixCompute(): void;
  15330. /**
  15331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15334. */
  15335. getShadowDirection(faceIndex?: number): Vector3;
  15336. /**
  15337. * Gets the minZ used for shadow according to both the scene and the light.
  15338. * @param activeCamera The camera we are returning the min for
  15339. * @returns the depth min z
  15340. */
  15341. getDepthMinZ(activeCamera: Camera): number;
  15342. /**
  15343. * Gets the maxZ used for shadow according to both the scene and the light.
  15344. * @param activeCamera The camera we are returning the max for
  15345. * @returns the depth max z
  15346. */
  15347. getDepthMaxZ(activeCamera: Camera): number;
  15348. }
  15349. /**
  15350. * Base implementation IShadowLight
  15351. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15352. */
  15353. abstract class ShadowLight extends Light implements IShadowLight {
  15354. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15355. protected _position: Vector3;
  15356. protected _setPosition(value: Vector3): void;
  15357. /**
  15358. * Sets the position the shadow will be casted from. Also use as the light position for both
  15359. * point and spot lights.
  15360. */
  15361. /**
  15362. * Sets the position the shadow will be casted from. Also use as the light position for both
  15363. * point and spot lights.
  15364. */
  15365. position: Vector3;
  15366. protected _direction: Vector3;
  15367. protected _setDirection(value: Vector3): void;
  15368. /**
  15369. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15370. * Also use as the light direction on spot and directional lights.
  15371. */
  15372. /**
  15373. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15374. * Also use as the light direction on spot and directional lights.
  15375. */
  15376. direction: Vector3;
  15377. private _shadowMinZ;
  15378. /**
  15379. * Gets the shadow projection clipping minimum z value.
  15380. */
  15381. /**
  15382. * Sets the shadow projection clipping minimum z value.
  15383. */
  15384. shadowMinZ: number;
  15385. private _shadowMaxZ;
  15386. /**
  15387. * Sets the shadow projection clipping maximum z value.
  15388. */
  15389. /**
  15390. * Gets the shadow projection clipping maximum z value.
  15391. */
  15392. shadowMaxZ: number;
  15393. /**
  15394. * Callback defining a custom Projection Matrix Builder.
  15395. * This can be used to override the default projection matrix computation.
  15396. */
  15397. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15398. /**
  15399. * The transformed position. Position of the light in world space taking parenting in account.
  15400. */
  15401. transformedPosition: Vector3;
  15402. /**
  15403. * The transformed direction. Direction of the light in world space taking parenting in account.
  15404. */
  15405. transformedDirection: Vector3;
  15406. private _needProjectionMatrixCompute;
  15407. /**
  15408. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15409. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15410. */
  15411. computeTransformedInformation(): boolean;
  15412. /**
  15413. * Return the depth scale used for the shadow map.
  15414. * @returns the depth scale.
  15415. */
  15416. getDepthScale(): number;
  15417. /**
  15418. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15419. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15420. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15421. */
  15422. getShadowDirection(faceIndex?: number): Vector3;
  15423. /**
  15424. * Returns the ShadowLight absolute position in the World.
  15425. * @returns the position vector in world space
  15426. */
  15427. getAbsolutePosition(): Vector3;
  15428. /**
  15429. * Sets the ShadowLight direction toward the passed target.
  15430. * @param target The point tot target in local space
  15431. * @returns the updated ShadowLight direction
  15432. */
  15433. setDirectionToTarget(target: Vector3): Vector3;
  15434. /**
  15435. * Returns the light rotation in euler definition.
  15436. * @returns the x y z rotation in local space.
  15437. */
  15438. getRotation(): Vector3;
  15439. /**
  15440. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15441. * @returns true if a cube texture needs to be use
  15442. */
  15443. needCube(): boolean;
  15444. /**
  15445. * Detects if the projection matrix requires to be recomputed this frame.
  15446. * @returns true if it requires to be recomputed otherwise, false.
  15447. */
  15448. needProjectionMatrixCompute(): boolean;
  15449. /**
  15450. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15451. */
  15452. forceProjectionMatrixCompute(): void;
  15453. /** @hidden */
  15454. _initCache(): void;
  15455. /** @hidden */
  15456. _isSynchronized(): boolean;
  15457. /**
  15458. * Computes the world matrix of the node
  15459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15460. * @returns the world matrix
  15461. */
  15462. computeWorldMatrix(force?: boolean): Matrix;
  15463. /**
  15464. * Gets the minZ used for shadow according to both the scene and the light.
  15465. * @param activeCamera The camera we are returning the min for
  15466. * @returns the depth min z
  15467. */
  15468. getDepthMinZ(activeCamera: Camera): number;
  15469. /**
  15470. * Gets the maxZ used for shadow according to both the scene and the light.
  15471. * @param activeCamera The camera we are returning the max for
  15472. * @returns the depth max z
  15473. */
  15474. getDepthMaxZ(activeCamera: Camera): number;
  15475. /**
  15476. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15477. * @param matrix The materix to updated with the projection information
  15478. * @param viewMatrix The transform matrix of the light
  15479. * @param renderList The list of mesh to render in the map
  15480. * @returns The current light
  15481. */
  15482. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15483. }
  15484. }
  15485. declare module BABYLON {
  15486. /**
  15487. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15488. * These values define a cone of light starting from the position, emitting toward the direction.
  15489. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15490. * and the exponent defines the speed of the decay of the light with distance (reach).
  15491. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15492. */
  15493. class SpotLight extends ShadowLight {
  15494. private _angle;
  15495. private _innerAngle;
  15496. private _cosHalfAngle;
  15497. private _lightAngleScale;
  15498. private _lightAngleOffset;
  15499. /**
  15500. * Gets the cone angle of the spot light in Radians.
  15501. */
  15502. /**
  15503. * Sets the cone angle of the spot light in Radians.
  15504. */
  15505. angle: number;
  15506. /**
  15507. * Only used in gltf falloff mode, this defines the angle where
  15508. * the directional falloff will start before cutting at angle which could be seen
  15509. * as outer angle.
  15510. */
  15511. /**
  15512. * Only used in gltf falloff mode, this defines the angle where
  15513. * the directional falloff will start before cutting at angle which could be seen
  15514. * as outer angle.
  15515. */
  15516. innerAngle: number;
  15517. private _shadowAngleScale;
  15518. /**
  15519. * Allows scaling the angle of the light for shadow generation only.
  15520. */
  15521. /**
  15522. * Allows scaling the angle of the light for shadow generation only.
  15523. */
  15524. shadowAngleScale: number;
  15525. /**
  15526. * The light decay speed with the distance from the emission spot.
  15527. */
  15528. exponent: number;
  15529. private _projectionTextureMatrix;
  15530. /**
  15531. * Allows reading the projecton texture
  15532. */
  15533. readonly projectionTextureMatrix: Matrix;
  15534. protected _projectionTextureLightNear: number;
  15535. /**
  15536. * Gets the near clip of the Spotlight for texture projection.
  15537. */
  15538. /**
  15539. * Sets the near clip of the Spotlight for texture projection.
  15540. */
  15541. projectionTextureLightNear: number;
  15542. protected _projectionTextureLightFar: number;
  15543. /**
  15544. * Gets the far clip of the Spotlight for texture projection.
  15545. */
  15546. /**
  15547. * Sets the far clip of the Spotlight for texture projection.
  15548. */
  15549. projectionTextureLightFar: number;
  15550. protected _projectionTextureUpDirection: Vector3;
  15551. /**
  15552. * Gets the Up vector of the Spotlight for texture projection.
  15553. */
  15554. /**
  15555. * Sets the Up vector of the Spotlight for texture projection.
  15556. */
  15557. projectionTextureUpDirection: Vector3;
  15558. private _projectionTexture;
  15559. /**
  15560. * Gets the projection texture of the light.
  15561. */
  15562. /**
  15563. * Sets the projection texture of the light.
  15564. */
  15565. projectionTexture: Nullable<BaseTexture>;
  15566. private _projectionTextureViewLightDirty;
  15567. private _projectionTextureProjectionLightDirty;
  15568. private _projectionTextureDirty;
  15569. private _projectionTextureViewTargetVector;
  15570. private _projectionTextureViewLightMatrix;
  15571. private _projectionTextureProjectionLightMatrix;
  15572. private _projectionTextureScalingMatrix;
  15573. /**
  15574. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15575. * It can cast shadows.
  15576. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15577. * @param name The light friendly name
  15578. * @param position The position of the spot light in the scene
  15579. * @param direction The direction of the light in the scene
  15580. * @param angle The cone angle of the light in Radians
  15581. * @param exponent The light decay speed with the distance from the emission spot
  15582. * @param scene The scene the lights belongs to
  15583. */
  15584. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15585. /**
  15586. * Returns the string "SpotLight".
  15587. * @returns the class name
  15588. */
  15589. getClassName(): string;
  15590. /**
  15591. * Returns the integer 2.
  15592. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15593. */
  15594. getTypeID(): number;
  15595. /**
  15596. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15597. */
  15598. protected _setDirection(value: Vector3): void;
  15599. /**
  15600. * Overrides the position setter to recompute the projection texture view light Matrix.
  15601. */
  15602. protected _setPosition(value: Vector3): void;
  15603. /**
  15604. * 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.
  15605. * Returns the SpotLight.
  15606. */
  15607. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15608. protected _computeProjectionTextureViewLightMatrix(): void;
  15609. protected _computeProjectionTextureProjectionLightMatrix(): void;
  15610. /**
  15611. * Main function for light texture projection matrix computing.
  15612. */
  15613. protected _computeProjectionTextureMatrix(): void;
  15614. protected _buildUniformLayout(): void;
  15615. private _computeAngleValues;
  15616. /**
  15617. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  15618. * @param effect The effect to update
  15619. * @param lightIndex The index of the light in the effect to update
  15620. * @returns The spot light
  15621. */
  15622. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  15623. /**
  15624. * Disposes the light and the associated resources.
  15625. */
  15626. dispose(): void;
  15627. /**
  15628. * Prepares the list of defines specific to the light type.
  15629. * @param defines the list of defines
  15630. * @param lightIndex defines the index of the light for the effect
  15631. */
  15632. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15633. }
  15634. }
  15635. declare module BABYLON {
  15636. interface ILoadingScreen {
  15637. displayLoadingUI: () => void;
  15638. hideLoadingUI: () => void;
  15639. loadingUIBackgroundColor: string;
  15640. loadingUIText: string;
  15641. }
  15642. class DefaultLoadingScreen implements ILoadingScreen {
  15643. private _renderingCanvas;
  15644. private _loadingText;
  15645. private _loadingDivBackgroundColor;
  15646. private _loadingDiv;
  15647. private _loadingTextDiv;
  15648. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  15649. displayLoadingUI(): void;
  15650. hideLoadingUI(): void;
  15651. loadingUIText: string;
  15652. loadingUIBackgroundColor: string;
  15653. private _resizeLoadingUI;
  15654. }
  15655. }
  15656. declare module BABYLON {
  15657. class SceneLoaderProgressEvent {
  15658. readonly lengthComputable: boolean;
  15659. readonly loaded: number;
  15660. readonly total: number;
  15661. constructor(lengthComputable: boolean, loaded: number, total: number);
  15662. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  15663. }
  15664. interface ISceneLoaderPluginExtensions {
  15665. [extension: string]: {
  15666. isBinary: boolean;
  15667. };
  15668. }
  15669. interface ISceneLoaderPluginFactory {
  15670. name: string;
  15671. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  15672. canDirectLoad?: (data: string) => boolean;
  15673. }
  15674. interface ISceneLoaderPlugin {
  15675. /**
  15676. * The friendly name of this plugin.
  15677. */
  15678. name: string;
  15679. /**
  15680. * The file extensions supported by this plugin.
  15681. */
  15682. extensions: string | ISceneLoaderPluginExtensions;
  15683. /**
  15684. * Import meshes into a scene.
  15685. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15686. * @param scene The scene to import into
  15687. * @param data The data to import
  15688. * @param rootUrl The root url for scene and resources
  15689. * @param meshes The meshes array to import into
  15690. * @param particleSystems The particle systems array to import into
  15691. * @param skeletons The skeletons array to import into
  15692. * @param onError The callback when import fails
  15693. * @returns True if successful or false otherwise
  15694. */
  15695. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  15696. /**
  15697. * Load into a scene.
  15698. * @param scene The scene to load into
  15699. * @param data The data to import
  15700. * @param rootUrl The root url for scene and resources
  15701. * @param onError The callback when import fails
  15702. * @returns true if successful or false otherwise
  15703. */
  15704. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  15705. /**
  15706. * The callback that returns true if the data can be directly loaded.
  15707. */
  15708. canDirectLoad?: (data: string) => boolean;
  15709. /**
  15710. * The callback that allows custom handling of the root url based on the response url.
  15711. */
  15712. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15713. /**
  15714. * Load into an asset container.
  15715. * @param scene The scene to load into
  15716. * @param data The data to import
  15717. * @param rootUrl The root url for scene and resources
  15718. * @param onError The callback when import fails
  15719. * @returns The loaded asset container
  15720. */
  15721. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  15722. }
  15723. interface ISceneLoaderPluginAsync {
  15724. /**
  15725. * The friendly name of this plugin.
  15726. */
  15727. name: string;
  15728. /**
  15729. * The file extensions supported by this plugin.
  15730. */
  15731. extensions: string | ISceneLoaderPluginExtensions;
  15732. /**
  15733. * Import meshes into a scene.
  15734. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15735. * @param scene The scene to import into
  15736. * @param data The data to import
  15737. * @param rootUrl The root url for scene and resources
  15738. * @param onProgress The callback when the load progresses
  15739. * @param fileName Defines the name of the file to load
  15740. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  15741. */
  15742. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  15743. meshes: AbstractMesh[];
  15744. particleSystems: IParticleSystem[];
  15745. skeletons: Skeleton[];
  15746. animationGroups: AnimationGroup[];
  15747. }>;
  15748. /**
  15749. * Load into a scene.
  15750. * @param scene The scene to load into
  15751. * @param data The data to import
  15752. * @param rootUrl The root url for scene and resources
  15753. * @param onProgress The callback when the load progresses
  15754. * @param fileName Defines the name of the file to load
  15755. * @returns Nothing
  15756. */
  15757. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  15758. /**
  15759. * The callback that returns true if the data can be directly loaded.
  15760. */
  15761. canDirectLoad?: (data: string) => boolean;
  15762. /**
  15763. * The callback that allows custom handling of the root url based on the response url.
  15764. */
  15765. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15766. /**
  15767. * Load into an asset container.
  15768. * @param scene The scene to load into
  15769. * @param data The data to import
  15770. * @param rootUrl The root url for scene and resources
  15771. * @param onProgress The callback when the load progresses
  15772. * @param fileName Defines the name of the file to load
  15773. * @returns The loaded asset container
  15774. */
  15775. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  15776. }
  15777. class SceneLoader {
  15778. private static _ForceFullSceneLoadingForIncremental;
  15779. private static _ShowLoadingScreen;
  15780. private static _CleanBoneMatrixWeights;
  15781. static readonly NO_LOGGING: number;
  15782. static readonly MINIMAL_LOGGING: number;
  15783. static readonly SUMMARY_LOGGING: number;
  15784. static readonly DETAILED_LOGGING: number;
  15785. private static _loggingLevel;
  15786. static ForceFullSceneLoadingForIncremental: boolean;
  15787. static ShowLoadingScreen: boolean;
  15788. static loggingLevel: number;
  15789. static CleanBoneMatrixWeights: boolean;
  15790. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  15791. private static _registeredPlugins;
  15792. private static _getDefaultPlugin;
  15793. private static _getPluginForExtension;
  15794. private static _getPluginForDirectLoad;
  15795. private static _getPluginForFilename;
  15796. private static _getDirectLoad;
  15797. private static _loadData;
  15798. private static _getFileInfo;
  15799. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  15800. static IsPluginForExtensionAvailable(extension: string): boolean;
  15801. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  15802. /**
  15803. * Import meshes into a scene
  15804. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15805. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15806. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15807. * @param scene the instance of BABYLON.Scene to append to
  15808. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  15809. * @param onProgress a callback with a progress event for each file being loaded
  15810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15811. * @param pluginExtension the extension used to determine the plugin
  15812. * @returns The loaded plugin
  15813. */
  15814. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, 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>;
  15815. /**
  15816. * Import meshes into a scene
  15817. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15818. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15819. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15820. * @param scene the instance of BABYLON.Scene to append to
  15821. * @param onProgress a callback with a progress event for each file being loaded
  15822. * @param pluginExtension the extension used to determine the plugin
  15823. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  15824. */
  15825. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  15826. meshes: AbstractMesh[];
  15827. particleSystems: IParticleSystem[];
  15828. skeletons: Skeleton[];
  15829. animationGroups: AnimationGroup[];
  15830. }>;
  15831. /**
  15832. * Load a scene
  15833. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15834. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15835. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15836. * @param onSuccess a callback with the scene when import succeeds
  15837. * @param onProgress a callback with a progress event for each file being loaded
  15838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15839. * @param pluginExtension the extension used to determine the plugin
  15840. * @returns The loaded plugin
  15841. */
  15842. static Load(rootUrl: string, sceneFilename: string, 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>;
  15843. /**
  15844. * Load a scene
  15845. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15846. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15847. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15848. * @param onProgress a callback with a progress event for each file being loaded
  15849. * @param pluginExtension the extension used to determine the plugin
  15850. * @returns The loaded scene
  15851. */
  15852. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15853. /**
  15854. * Append a scene
  15855. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15856. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15857. * @param scene is the instance of BABYLON.Scene to append to
  15858. * @param onSuccess a callback with the scene when import succeeds
  15859. * @param onProgress a callback with a progress event for each file being loaded
  15860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15861. * @param pluginExtension the extension used to determine the plugin
  15862. * @returns The loaded plugin
  15863. */
  15864. static Append(rootUrl: string, sceneFilename?: string, 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>;
  15865. /**
  15866. * Append a scene
  15867. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15868. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15869. * @param scene is the instance of BABYLON.Scene to append to
  15870. * @param onProgress a callback with a progress event for each file being loaded
  15871. * @param pluginExtension the extension used to determine the plugin
  15872. * @returns The given scene
  15873. */
  15874. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15875. /**
  15876. * Load a scene into an asset container
  15877. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15878. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15879. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  15880. * @param onSuccess a callback with the scene when import succeeds
  15881. * @param onProgress a callback with a progress event for each file being loaded
  15882. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15883. * @param pluginExtension the extension used to determine the plugin
  15884. * @returns The loaded plugin
  15885. */
  15886. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, 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>;
  15887. /**
  15888. * Load a scene into an asset container
  15889. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  15890. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  15891. * @param scene is the instance of BABYLON.Scene to append to
  15892. * @param onProgress a callback with a progress event for each file being loaded
  15893. * @param pluginExtension the extension used to determine the plugin
  15894. * @returns The loaded asset container
  15895. */
  15896. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  15897. }
  15898. }
  15899. declare module BABYLON {
  15900. /**
  15901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15903. * 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;
  15904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15905. */
  15906. class ColorCurves {
  15907. private _dirty;
  15908. private _tempColor;
  15909. private _globalCurve;
  15910. private _highlightsCurve;
  15911. private _midtonesCurve;
  15912. private _shadowsCurve;
  15913. private _positiveCurve;
  15914. private _negativeCurve;
  15915. private _globalHue;
  15916. private _globalDensity;
  15917. private _globalSaturation;
  15918. private _globalExposure;
  15919. /**
  15920. * Gets the global Hue value.
  15921. * 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).
  15922. */
  15923. /**
  15924. * Sets the global Hue value.
  15925. * 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).
  15926. */
  15927. globalHue: number;
  15928. /**
  15929. * Gets the global Density value.
  15930. * 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.
  15931. * Values less than zero provide a filter of opposite hue.
  15932. */
  15933. /**
  15934. * Sets the global Density value.
  15935. * 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.
  15936. * Values less than zero provide a filter of opposite hue.
  15937. */
  15938. globalDensity: number;
  15939. /**
  15940. * Gets the global Saturation value.
  15941. * 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.
  15942. */
  15943. /**
  15944. * Sets the global Saturation value.
  15945. * 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.
  15946. */
  15947. globalSaturation: number;
  15948. /**
  15949. * Gets the global Exposure value.
  15950. * 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.
  15951. */
  15952. /**
  15953. * Sets the global Exposure value.
  15954. * 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.
  15955. */
  15956. globalExposure: number;
  15957. private _highlightsHue;
  15958. private _highlightsDensity;
  15959. private _highlightsSaturation;
  15960. private _highlightsExposure;
  15961. /**
  15962. * Gets the highlights Hue value.
  15963. * 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).
  15964. */
  15965. /**
  15966. * Sets the highlights Hue value.
  15967. * 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).
  15968. */
  15969. highlightsHue: number;
  15970. /**
  15971. * Gets the highlights Density value.
  15972. * 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.
  15973. * Values less than zero provide a filter of opposite hue.
  15974. */
  15975. /**
  15976. * Sets the highlights Density value.
  15977. * 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.
  15978. * Values less than zero provide a filter of opposite hue.
  15979. */
  15980. highlightsDensity: number;
  15981. /**
  15982. * Gets the highlights Saturation value.
  15983. * 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.
  15984. */
  15985. /**
  15986. * Sets the highlights Saturation value.
  15987. * 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.
  15988. */
  15989. highlightsSaturation: number;
  15990. /**
  15991. * Gets the highlights Exposure value.
  15992. * 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.
  15993. */
  15994. /**
  15995. * Sets the highlights Exposure value.
  15996. * 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.
  15997. */
  15998. highlightsExposure: number;
  15999. private _midtonesHue;
  16000. private _midtonesDensity;
  16001. private _midtonesSaturation;
  16002. private _midtonesExposure;
  16003. /**
  16004. * Gets the midtones Hue value.
  16005. * 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).
  16006. */
  16007. /**
  16008. * Sets the midtones Hue value.
  16009. * 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).
  16010. */
  16011. midtonesHue: number;
  16012. /**
  16013. * Gets the midtones Density value.
  16014. * 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.
  16015. * Values less than zero provide a filter of opposite hue.
  16016. */
  16017. /**
  16018. * Sets the midtones Density value.
  16019. * 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.
  16020. * Values less than zero provide a filter of opposite hue.
  16021. */
  16022. midtonesDensity: number;
  16023. /**
  16024. * Gets the midtones Saturation value.
  16025. * 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.
  16026. */
  16027. /**
  16028. * Sets the midtones Saturation value.
  16029. * 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.
  16030. */
  16031. midtonesSaturation: number;
  16032. /**
  16033. * Gets the midtones Exposure value.
  16034. * 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.
  16035. */
  16036. /**
  16037. * Sets the midtones Exposure value.
  16038. * 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.
  16039. */
  16040. midtonesExposure: number;
  16041. private _shadowsHue;
  16042. private _shadowsDensity;
  16043. private _shadowsSaturation;
  16044. private _shadowsExposure;
  16045. /**
  16046. * Gets the shadows Hue value.
  16047. * 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).
  16048. */
  16049. /**
  16050. * Sets the shadows Hue value.
  16051. * 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).
  16052. */
  16053. shadowsHue: number;
  16054. /**
  16055. * Gets the shadows Density value.
  16056. * 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.
  16057. * Values less than zero provide a filter of opposite hue.
  16058. */
  16059. /**
  16060. * Sets the shadows Density value.
  16061. * 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.
  16062. * Values less than zero provide a filter of opposite hue.
  16063. */
  16064. shadowsDensity: number;
  16065. /**
  16066. * Gets the shadows Saturation value.
  16067. * 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.
  16068. */
  16069. /**
  16070. * Sets the shadows Saturation value.
  16071. * 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.
  16072. */
  16073. shadowsSaturation: number;
  16074. /**
  16075. * Gets the shadows Exposure value.
  16076. * 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.
  16077. */
  16078. /**
  16079. * Sets the shadows Exposure value.
  16080. * 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.
  16081. */
  16082. shadowsExposure: number;
  16083. getClassName(): string;
  16084. /**
  16085. * Binds the color curves to the shader.
  16086. * @param colorCurves The color curve to bind
  16087. * @param effect The effect to bind to
  16088. */
  16089. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16090. /**
  16091. * Prepare the list of uniforms associated with the ColorCurves effects.
  16092. * @param uniformsList The list of uniforms used in the effect
  16093. */
  16094. static PrepareUniforms(uniformsList: string[]): void;
  16095. /**
  16096. * Returns color grading data based on a hue, density, saturation and exposure value.
  16097. * @param filterHue The hue of the color filter.
  16098. * @param filterDensity The density of the color filter.
  16099. * @param saturation The saturation.
  16100. * @param exposure The exposure.
  16101. * @param result The result data container.
  16102. */
  16103. private getColorGradingDataToRef;
  16104. /**
  16105. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16106. * @param value The input slider value in range [-100,100].
  16107. * @returns Adjusted value.
  16108. */
  16109. private static applyColorGradingSliderNonlinear;
  16110. /**
  16111. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16112. * @param hue The hue (H) input.
  16113. * @param saturation The saturation (S) input.
  16114. * @param brightness The brightness (B) input.
  16115. * @result An RGBA color represented as Vector4.
  16116. */
  16117. private static fromHSBToRef;
  16118. /**
  16119. * Returns a value clamped between min and max
  16120. * @param value The value to clamp
  16121. * @param min The minimum of value
  16122. * @param max The maximum of value
  16123. * @returns The clamped value.
  16124. */
  16125. private static clamp;
  16126. /**
  16127. * Clones the current color curve instance.
  16128. * @return The cloned curves
  16129. */
  16130. clone(): ColorCurves;
  16131. /**
  16132. * Serializes the current color curve instance to a json representation.
  16133. * @return a JSON representation
  16134. */
  16135. serialize(): any;
  16136. /**
  16137. * Parses the color curve from a json representation.
  16138. * @param source the JSON source to parse
  16139. * @return The parsed curves
  16140. */
  16141. static Parse(source: any): ColorCurves;
  16142. }
  16143. }
  16144. declare module BABYLON {
  16145. /**
  16146. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16147. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16148. */
  16149. class EffectFallbacks {
  16150. private _defines;
  16151. private _currentRank;
  16152. private _maxRank;
  16153. private _mesh;
  16154. /**
  16155. * Removes the fallback from the bound mesh.
  16156. */
  16157. unBindMesh(): void;
  16158. /**
  16159. * Adds a fallback on the specified property.
  16160. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16161. * @param define The name of the define in the shader
  16162. */
  16163. addFallback(rank: number, define: string): void;
  16164. /**
  16165. * Sets the mesh to use CPU skinning when needing to fallback.
  16166. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16167. * @param mesh The mesh to use the fallbacks.
  16168. */
  16169. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16170. /**
  16171. * Checks to see if more fallbacks are still availible.
  16172. */
  16173. readonly isMoreFallbacks: boolean;
  16174. /**
  16175. * Removes the defines that shoould be removed when falling back.
  16176. * @param currentDefines defines the current define statements for the shader.
  16177. * @param effect defines the current effect we try to compile
  16178. * @returns The resulting defines with defines of the current rank removed.
  16179. */
  16180. reduce(currentDefines: string, effect: Effect): string;
  16181. }
  16182. /**
  16183. * Options to be used when creating an effect.
  16184. */
  16185. class EffectCreationOptions {
  16186. /**
  16187. * Atrributes that will be used in the shader.
  16188. */
  16189. attributes: string[];
  16190. /**
  16191. * Uniform varible names that will be set in the shader.
  16192. */
  16193. uniformsNames: string[];
  16194. /**
  16195. * Uniform buffer varible names that will be set in the shader.
  16196. */
  16197. uniformBuffersNames: string[];
  16198. /**
  16199. * Sampler texture variable names that will be set in the shader.
  16200. */
  16201. samplers: string[];
  16202. /**
  16203. * Define statements that will be set in the shader.
  16204. */
  16205. defines: any;
  16206. /**
  16207. * Possible fallbacks for this effect to improve performance when needed.
  16208. */
  16209. fallbacks: Nullable<EffectFallbacks>;
  16210. /**
  16211. * Callback that will be called when the shader is compiled.
  16212. */
  16213. onCompiled: Nullable<(effect: Effect) => void>;
  16214. /**
  16215. * Callback that will be called if an error occurs during shader compilation.
  16216. */
  16217. onError: Nullable<(effect: Effect, errors: string) => void>;
  16218. /**
  16219. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16220. */
  16221. indexParameters: any;
  16222. /**
  16223. * Max number of lights that can be used in the shader.
  16224. */
  16225. maxSimultaneousLights: number;
  16226. /**
  16227. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16228. */
  16229. transformFeedbackVaryings: Nullable<string[]>;
  16230. }
  16231. /**
  16232. * Effect containing vertex and fragment shader that can be executed on an object.
  16233. */
  16234. class Effect {
  16235. /**
  16236. * Name of the effect.
  16237. */
  16238. name: any;
  16239. /**
  16240. * String container all the define statements that should be set on the shader.
  16241. */
  16242. defines: string;
  16243. /**
  16244. * Callback that will be called when the shader is compiled.
  16245. */
  16246. onCompiled: Nullable<(effect: Effect) => void>;
  16247. /**
  16248. * Callback that will be called if an error occurs during shader compilation.
  16249. */
  16250. onError: Nullable<(effect: Effect, errors: string) => void>;
  16251. /**
  16252. * Callback that will be called when effect is bound.
  16253. */
  16254. onBind: Nullable<(effect: Effect) => void>;
  16255. /**
  16256. * Unique ID of the effect.
  16257. */
  16258. uniqueId: number;
  16259. /**
  16260. * Observable that will be called when the shader is compiled.
  16261. */
  16262. onCompileObservable: Observable<Effect>;
  16263. /**
  16264. * Observable that will be called if an error occurs during shader compilation.
  16265. */
  16266. onErrorObservable: Observable<Effect>;
  16267. /** @hidden */
  16268. _onBindObservable: Nullable<Observable<Effect>>;
  16269. /**
  16270. * Observable that will be called when effect is bound.
  16271. */
  16272. readonly onBindObservable: Observable<Effect>;
  16273. /** @hidden */
  16274. _bonesComputationForcedToCPU: boolean;
  16275. private static _uniqueIdSeed;
  16276. private _engine;
  16277. private _uniformBuffersNames;
  16278. private _uniformsNames;
  16279. private _samplers;
  16280. private _isReady;
  16281. private _compilationError;
  16282. private _attributesNames;
  16283. private _attributes;
  16284. private _uniforms;
  16285. /**
  16286. * Key for the effect.
  16287. * @hidden
  16288. */
  16289. _key: string;
  16290. private _indexParameters;
  16291. private _fallbacks;
  16292. private _vertexSourceCode;
  16293. private _fragmentSourceCode;
  16294. private _vertexSourceCodeOverride;
  16295. private _fragmentSourceCodeOverride;
  16296. private _transformFeedbackVaryings;
  16297. /**
  16298. * Compiled shader to webGL program.
  16299. * @hidden
  16300. */
  16301. _program: WebGLProgram;
  16302. private _valueCache;
  16303. private static _baseCache;
  16304. /**
  16305. * Instantiates an effect.
  16306. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16307. * @param baseName Name of the effect.
  16308. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16309. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16310. * @param samplers List of sampler variables that will be passed to the shader.
  16311. * @param engine Engine to be used to render the effect
  16312. * @param defines Define statements to be added to the shader.
  16313. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16314. * @param onCompiled Callback that will be called when the shader is compiled.
  16315. * @param onError Callback that will be called if an error occurs during shader compilation.
  16316. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16317. */
  16318. 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);
  16319. /**
  16320. * Unique key for this effect
  16321. */
  16322. readonly key: string;
  16323. /**
  16324. * If the effect has been compiled and prepared.
  16325. * @returns if the effect is compiled and prepared.
  16326. */
  16327. isReady(): boolean;
  16328. /**
  16329. * The engine the effect was initialized with.
  16330. * @returns the engine.
  16331. */
  16332. getEngine(): Engine;
  16333. /**
  16334. * The compiled webGL program for the effect
  16335. * @returns the webGL program.
  16336. */
  16337. getProgram(): WebGLProgram;
  16338. /**
  16339. * The set of names of attribute variables for the shader.
  16340. * @returns An array of attribute names.
  16341. */
  16342. getAttributesNames(): string[];
  16343. /**
  16344. * Returns the attribute at the given index.
  16345. * @param index The index of the attribute.
  16346. * @returns The location of the attribute.
  16347. */
  16348. getAttributeLocation(index: number): number;
  16349. /**
  16350. * Returns the attribute based on the name of the variable.
  16351. * @param name of the attribute to look up.
  16352. * @returns the attribute location.
  16353. */
  16354. getAttributeLocationByName(name: string): number;
  16355. /**
  16356. * The number of attributes.
  16357. * @returns the numnber of attributes.
  16358. */
  16359. getAttributesCount(): number;
  16360. /**
  16361. * Gets the index of a uniform variable.
  16362. * @param uniformName of the uniform to look up.
  16363. * @returns the index.
  16364. */
  16365. getUniformIndex(uniformName: string): number;
  16366. /**
  16367. * Returns the attribute based on the name of the variable.
  16368. * @param uniformName of the uniform to look up.
  16369. * @returns the location of the uniform.
  16370. */
  16371. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16372. /**
  16373. * Returns an array of sampler variable names
  16374. * @returns The array of sampler variable neames.
  16375. */
  16376. getSamplers(): string[];
  16377. /**
  16378. * The error from the last compilation.
  16379. * @returns the error string.
  16380. */
  16381. getCompilationError(): string;
  16382. /**
  16383. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16384. * @param func The callback to be used.
  16385. */
  16386. executeWhenCompiled(func: (effect: Effect) => void): void;
  16387. /** @hidden */
  16388. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  16389. /** @hidden */
  16390. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  16391. /** @hidden */
  16392. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  16393. private _processShaderConversion;
  16394. private _processIncludes;
  16395. private _processPrecision;
  16396. /**
  16397. * Recompiles the webGL program
  16398. * @param vertexSourceCode The source code for the vertex shader.
  16399. * @param fragmentSourceCode The source code for the fragment shader.
  16400. * @param onCompiled Callback called when completed.
  16401. * @param onError Callback called on error.
  16402. * @hidden
  16403. */
  16404. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  16405. /**
  16406. * Gets the uniform locations of the the specified variable names
  16407. * @param names THe names of the variables to lookup.
  16408. * @returns Array of locations in the same order as variable names.
  16409. */
  16410. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16411. /**
  16412. * Prepares the effect
  16413. * @hidden
  16414. */
  16415. _prepareEffect(): void;
  16416. /**
  16417. * Checks if the effect is supported. (Must be called after compilation)
  16418. */
  16419. readonly isSupported: boolean;
  16420. /**
  16421. * Binds a texture to the engine to be used as output of the shader.
  16422. * @param channel Name of the output variable.
  16423. * @param texture Texture to bind.
  16424. * @hidden
  16425. */
  16426. _bindTexture(channel: string, texture: InternalTexture): void;
  16427. /**
  16428. * Sets a texture on the engine to be used in the shader.
  16429. * @param channel Name of the sampler variable.
  16430. * @param texture Texture to set.
  16431. */
  16432. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16433. /**
  16434. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16435. * @param channel Name of the sampler variable.
  16436. * @param texture Texture to set.
  16437. */
  16438. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16439. /**
  16440. * Sets an array of textures on the engine to be used in the shader.
  16441. * @param channel Name of the variable.
  16442. * @param textures Textures to set.
  16443. */
  16444. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16445. /**
  16446. * 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)
  16447. * @param channel Name of the sampler variable.
  16448. * @param postProcess Post process to get the input texture from.
  16449. */
  16450. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16451. /**
  16452. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16453. * 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)
  16454. * @param channel Name of the sampler variable.
  16455. * @param postProcess Post process to get the output texture from.
  16456. */
  16457. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16458. /** @hidden */
  16459. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  16460. /** @hidden */
  16461. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  16462. /** @hidden */
  16463. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  16464. /** @hidden */
  16465. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  16466. /**
  16467. * Binds a buffer to a uniform.
  16468. * @param buffer Buffer to bind.
  16469. * @param name Name of the uniform variable to bind to.
  16470. */
  16471. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16472. /**
  16473. * Binds block to a uniform.
  16474. * @param blockName Name of the block to bind.
  16475. * @param index Index to bind.
  16476. */
  16477. bindUniformBlock(blockName: string, index: number): void;
  16478. /**
  16479. * Sets an interger value on a uniform variable.
  16480. * @param uniformName Name of the variable.
  16481. * @param value Value to be set.
  16482. * @returns this effect.
  16483. */
  16484. setInt(uniformName: string, value: number): Effect;
  16485. /**
  16486. * Sets an int array on a uniform variable.
  16487. * @param uniformName Name of the variable.
  16488. * @param array array to be set.
  16489. * @returns this effect.
  16490. */
  16491. setIntArray(uniformName: string, array: Int32Array): Effect;
  16492. /**
  16493. * 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)
  16494. * @param uniformName Name of the variable.
  16495. * @param array array to be set.
  16496. * @returns this effect.
  16497. */
  16498. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16499. /**
  16500. * 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)
  16501. * @param uniformName Name of the variable.
  16502. * @param array array to be set.
  16503. * @returns this effect.
  16504. */
  16505. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16506. /**
  16507. * 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)
  16508. * @param uniformName Name of the variable.
  16509. * @param array array to be set.
  16510. * @returns this effect.
  16511. */
  16512. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16513. /**
  16514. * Sets an float array on a uniform variable.
  16515. * @param uniformName Name of the variable.
  16516. * @param array array to be set.
  16517. * @returns this effect.
  16518. */
  16519. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16520. /**
  16521. * 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)
  16522. * @param uniformName Name of the variable.
  16523. * @param array array to be set.
  16524. * @returns this effect.
  16525. */
  16526. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16527. /**
  16528. * 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)
  16529. * @param uniformName Name of the variable.
  16530. * @param array array to be set.
  16531. * @returns this effect.
  16532. */
  16533. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16534. /**
  16535. * 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)
  16536. * @param uniformName Name of the variable.
  16537. * @param array array to be set.
  16538. * @returns this effect.
  16539. */
  16540. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16541. /**
  16542. * Sets an array on a uniform variable.
  16543. * @param uniformName Name of the variable.
  16544. * @param array array to be set.
  16545. * @returns this effect.
  16546. */
  16547. setArray(uniformName: string, array: number[]): Effect;
  16548. /**
  16549. * 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)
  16550. * @param uniformName Name of the variable.
  16551. * @param array array to be set.
  16552. * @returns this effect.
  16553. */
  16554. setArray2(uniformName: string, array: number[]): Effect;
  16555. /**
  16556. * 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)
  16557. * @param uniformName Name of the variable.
  16558. * @param array array to be set.
  16559. * @returns this effect.
  16560. */
  16561. setArray3(uniformName: string, array: number[]): Effect;
  16562. /**
  16563. * 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)
  16564. * @param uniformName Name of the variable.
  16565. * @param array array to be set.
  16566. * @returns this effect.
  16567. */
  16568. setArray4(uniformName: string, array: number[]): Effect;
  16569. /**
  16570. * Sets matrices on a uniform variable.
  16571. * @param uniformName Name of the variable.
  16572. * @param matrices matrices to be set.
  16573. * @returns this effect.
  16574. */
  16575. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16576. /**
  16577. * Sets matrix on a uniform variable.
  16578. * @param uniformName Name of the variable.
  16579. * @param matrix matrix to be set.
  16580. * @returns this effect.
  16581. */
  16582. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16583. /**
  16584. * 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)
  16585. * @param uniformName Name of the variable.
  16586. * @param matrix matrix to be set.
  16587. * @returns this effect.
  16588. */
  16589. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16590. /**
  16591. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16592. * @param uniformName Name of the variable.
  16593. * @param matrix matrix to be set.
  16594. * @returns this effect.
  16595. */
  16596. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16597. /**
  16598. * Sets a float on a uniform variable.
  16599. * @param uniformName Name of the variable.
  16600. * @param value value to be set.
  16601. * @returns this effect.
  16602. */
  16603. setFloat(uniformName: string, value: number): Effect;
  16604. /**
  16605. * Sets a boolean on a uniform variable.
  16606. * @param uniformName Name of the variable.
  16607. * @param bool value to be set.
  16608. * @returns this effect.
  16609. */
  16610. setBool(uniformName: string, bool: boolean): Effect;
  16611. /**
  16612. * Sets a Vector2 on a uniform variable.
  16613. * @param uniformName Name of the variable.
  16614. * @param vector2 vector2 to be set.
  16615. * @returns this effect.
  16616. */
  16617. setVector2(uniformName: string, vector2: Vector2): Effect;
  16618. /**
  16619. * Sets a float2 on a uniform variable.
  16620. * @param uniformName Name of the variable.
  16621. * @param x First float in float2.
  16622. * @param y Second float in float2.
  16623. * @returns this effect.
  16624. */
  16625. setFloat2(uniformName: string, x: number, y: number): Effect;
  16626. /**
  16627. * Sets a Vector3 on a uniform variable.
  16628. * @param uniformName Name of the variable.
  16629. * @param vector3 Value to be set.
  16630. * @returns this effect.
  16631. */
  16632. setVector3(uniformName: string, vector3: Vector3): Effect;
  16633. /**
  16634. * Sets a float3 on a uniform variable.
  16635. * @param uniformName Name of the variable.
  16636. * @param x First float in float3.
  16637. * @param y Second float in float3.
  16638. * @param z Third float in float3.
  16639. * @returns this effect.
  16640. */
  16641. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16642. /**
  16643. * Sets a Vector4 on a uniform variable.
  16644. * @param uniformName Name of the variable.
  16645. * @param vector4 Value to be set.
  16646. * @returns this effect.
  16647. */
  16648. setVector4(uniformName: string, vector4: Vector4): Effect;
  16649. /**
  16650. * Sets a float4 on a uniform variable.
  16651. * @param uniformName Name of the variable.
  16652. * @param x First float in float4.
  16653. * @param y Second float in float4.
  16654. * @param z Third float in float4.
  16655. * @param w Fourth float in float4.
  16656. * @returns this effect.
  16657. */
  16658. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16659. /**
  16660. * Sets a Color3 on a uniform variable.
  16661. * @param uniformName Name of the variable.
  16662. * @param color3 Value to be set.
  16663. * @returns this effect.
  16664. */
  16665. setColor3(uniformName: string, color3: Color3): Effect;
  16666. /**
  16667. * Sets a Color4 on a uniform variable.
  16668. * @param uniformName Name of the variable.
  16669. * @param color3 Value to be set.
  16670. * @param alpha Alpha value to be set.
  16671. * @returns this effect.
  16672. */
  16673. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16674. /**
  16675. * Sets a Color4 on a uniform variable
  16676. * @param uniformName defines the name of the variable
  16677. * @param color4 defines the value to be set
  16678. * @returns this effect.
  16679. */
  16680. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16681. /**
  16682. * This function will add a new shader to the shader store
  16683. * @param name the name of the shader
  16684. * @param pixelShader optional pixel shader content
  16685. * @param vertexShader optional vertex shader content
  16686. */
  16687. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  16688. /**
  16689. * Store of each shader (The can be looked up using effect.key)
  16690. */
  16691. static ShadersStore: {
  16692. [key: string]: string;
  16693. };
  16694. /**
  16695. * Store of each included file for a shader (The can be looked up using effect.key)
  16696. */
  16697. static IncludesShadersStore: {
  16698. [key: string]: string;
  16699. };
  16700. /**
  16701. * Resets the cache of effects.
  16702. */
  16703. static ResetCache(): void;
  16704. }
  16705. }
  16706. declare module BABYLON {
  16707. class FresnelParameters {
  16708. private _isEnabled;
  16709. isEnabled: boolean;
  16710. leftColor: Color3;
  16711. rightColor: Color3;
  16712. bias: number;
  16713. power: number;
  16714. clone(): FresnelParameters;
  16715. serialize(): any;
  16716. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16717. }
  16718. }
  16719. declare module BABYLON {
  16720. /**
  16721. * Interface to follow in your material defines to integrate easily the
  16722. * Image proccessing functions.
  16723. * @hidden
  16724. */
  16725. interface IImageProcessingConfigurationDefines {
  16726. IMAGEPROCESSING: boolean;
  16727. VIGNETTE: boolean;
  16728. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16729. VIGNETTEBLENDMODEOPAQUE: boolean;
  16730. TONEMAPPING: boolean;
  16731. TONEMAPPING_ACES: boolean;
  16732. CONTRAST: boolean;
  16733. EXPOSURE: boolean;
  16734. COLORCURVES: boolean;
  16735. COLORGRADING: boolean;
  16736. COLORGRADING3D: boolean;
  16737. SAMPLER3DGREENDEPTH: boolean;
  16738. SAMPLER3DBGRMAP: boolean;
  16739. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16740. }
  16741. /**
  16742. * @hidden
  16743. */
  16744. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  16745. IMAGEPROCESSING: boolean;
  16746. VIGNETTE: boolean;
  16747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16748. VIGNETTEBLENDMODEOPAQUE: boolean;
  16749. TONEMAPPING: boolean;
  16750. TONEMAPPING_ACES: boolean;
  16751. CONTRAST: boolean;
  16752. COLORCURVES: boolean;
  16753. COLORGRADING: boolean;
  16754. COLORGRADING3D: boolean;
  16755. SAMPLER3DGREENDEPTH: boolean;
  16756. SAMPLER3DBGRMAP: boolean;
  16757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16758. EXPOSURE: boolean;
  16759. constructor();
  16760. }
  16761. /**
  16762. * This groups together the common properties used for image processing either in direct forward pass
  16763. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16764. * or not.
  16765. */
  16766. class ImageProcessingConfiguration {
  16767. /**
  16768. * Default tone mapping applied in BabylonJS.
  16769. */
  16770. static readonly TONEMAPPING_STANDARD: number;
  16771. /**
  16772. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  16773. * to other engines rendering to increase portability.
  16774. */
  16775. static readonly TONEMAPPING_ACES: number;
  16776. /**
  16777. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16778. */
  16779. colorCurves: Nullable<ColorCurves>;
  16780. private _colorCurvesEnabled;
  16781. /**
  16782. * Gets wether the color curves effect is enabled.
  16783. */
  16784. /**
  16785. * Sets wether the color curves effect is enabled.
  16786. */
  16787. colorCurvesEnabled: boolean;
  16788. /**
  16789. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16790. */
  16791. colorGradingTexture: Nullable<BaseTexture>;
  16792. private _colorGradingEnabled;
  16793. /**
  16794. * Gets wether the color grading effect is enabled.
  16795. */
  16796. /**
  16797. * Sets wether the color grading effect is enabled.
  16798. */
  16799. colorGradingEnabled: boolean;
  16800. private _colorGradingWithGreenDepth;
  16801. /**
  16802. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16803. */
  16804. /**
  16805. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16806. */
  16807. colorGradingWithGreenDepth: boolean;
  16808. private _colorGradingBGR;
  16809. /**
  16810. * Gets wether the color grading texture contains BGR values.
  16811. */
  16812. /**
  16813. * Sets wether the color grading texture contains BGR values.
  16814. */
  16815. colorGradingBGR: boolean;
  16816. /** @hidden */
  16817. _exposure: number;
  16818. /**
  16819. * Gets the Exposure used in the effect.
  16820. */
  16821. /**
  16822. * Sets the Exposure used in the effect.
  16823. */
  16824. exposure: number;
  16825. private _toneMappingEnabled;
  16826. /**
  16827. * Gets wether the tone mapping effect is enabled.
  16828. */
  16829. /**
  16830. * Sets wether the tone mapping effect is enabled.
  16831. */
  16832. toneMappingEnabled: boolean;
  16833. private _toneMappingType;
  16834. /**
  16835. * Gets the type of tone mapping effect.
  16836. */
  16837. /**
  16838. * Sets the type of tone mapping effect used in BabylonJS.
  16839. */
  16840. toneMappingType: number;
  16841. protected _contrast: number;
  16842. /**
  16843. * Gets the contrast used in the effect.
  16844. */
  16845. /**
  16846. * Sets the contrast used in the effect.
  16847. */
  16848. contrast: number;
  16849. /**
  16850. * Vignette stretch size.
  16851. */
  16852. vignetteStretch: number;
  16853. /**
  16854. * Vignette centre X Offset.
  16855. */
  16856. vignetteCentreX: number;
  16857. /**
  16858. * Vignette centre Y Offset.
  16859. */
  16860. vignetteCentreY: number;
  16861. /**
  16862. * Vignette weight or intensity of the vignette effect.
  16863. */
  16864. vignetteWeight: number;
  16865. /**
  16866. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16867. * if vignetteEnabled is set to true.
  16868. */
  16869. vignetteColor: Color4;
  16870. /**
  16871. * Camera field of view used by the Vignette effect.
  16872. */
  16873. vignetteCameraFov: number;
  16874. private _vignetteBlendMode;
  16875. /**
  16876. * Gets the vignette blend mode allowing different kind of effect.
  16877. */
  16878. /**
  16879. * Sets the vignette blend mode allowing different kind of effect.
  16880. */
  16881. vignetteBlendMode: number;
  16882. private _vignetteEnabled;
  16883. /**
  16884. * Gets wether the vignette effect is enabled.
  16885. */
  16886. /**
  16887. * Sets wether the vignette effect is enabled.
  16888. */
  16889. vignetteEnabled: boolean;
  16890. private _applyByPostProcess;
  16891. /**
  16892. * Gets wether the image processing is applied through a post process or not.
  16893. */
  16894. /**
  16895. * Sets wether the image processing is applied through a post process or not.
  16896. */
  16897. applyByPostProcess: boolean;
  16898. private _isEnabled;
  16899. /**
  16900. * Gets wether the image processing is enabled or not.
  16901. */
  16902. /**
  16903. * Sets wether the image processing is enabled or not.
  16904. */
  16905. isEnabled: boolean;
  16906. /**
  16907. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16908. */
  16909. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16910. /**
  16911. * Method called each time the image processing information changes requires to recompile the effect.
  16912. */
  16913. protected _updateParameters(): void;
  16914. getClassName(): string;
  16915. /**
  16916. * Prepare the list of uniforms associated with the Image Processing effects.
  16917. * @param uniformsList The list of uniforms used in the effect
  16918. * @param defines the list of defines currently in use
  16919. */
  16920. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16921. /**
  16922. * Prepare the list of samplers associated with the Image Processing effects.
  16923. * @param uniformsList The list of uniforms used in the effect
  16924. * @param defines the list of defines currently in use
  16925. */
  16926. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16927. /**
  16928. * Prepare the list of defines associated to the shader.
  16929. * @param defines the list of defines to complete
  16930. */
  16931. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16932. /**
  16933. * Returns true if all the image processing information are ready.
  16934. */
  16935. isReady(): boolean;
  16936. /**
  16937. * Binds the image processing to the shader.
  16938. * @param effect The effect to bind to
  16939. */
  16940. bind(effect: Effect, aspectRatio?: number): void;
  16941. /**
  16942. * Clones the current image processing instance.
  16943. * @return The cloned image processing
  16944. */
  16945. clone(): ImageProcessingConfiguration;
  16946. /**
  16947. * Serializes the current image processing instance to a json representation.
  16948. * @return a JSON representation
  16949. */
  16950. serialize(): any;
  16951. /**
  16952. * Parses the image processing from a json representation.
  16953. * @param source the JSON source to parse
  16954. * @return The parsed image processing
  16955. */
  16956. static Parse(source: any): ImageProcessingConfiguration;
  16957. private static _VIGNETTEMODE_MULTIPLY;
  16958. private static _VIGNETTEMODE_OPAQUE;
  16959. /**
  16960. * Used to apply the vignette as a mix with the pixel color.
  16961. */
  16962. static readonly VIGNETTEMODE_MULTIPLY: number;
  16963. /**
  16964. * Used to apply the vignette as a replacement of the pixel color.
  16965. */
  16966. static readonly VIGNETTEMODE_OPAQUE: number;
  16967. }
  16968. }
  16969. declare module BABYLON {
  16970. /**
  16971. * Manages the defines for the Material
  16972. */
  16973. class MaterialDefines {
  16974. private _keys;
  16975. private _isDirty;
  16976. /** @hidden */
  16977. _renderId: number;
  16978. /** @hidden */
  16979. _areLightsDirty: boolean;
  16980. /** @hidden */
  16981. _areAttributesDirty: boolean;
  16982. /** @hidden */
  16983. _areTexturesDirty: boolean;
  16984. /** @hidden */
  16985. _areFresnelDirty: boolean;
  16986. /** @hidden */
  16987. _areMiscDirty: boolean;
  16988. /** @hidden */
  16989. _areImageProcessingDirty: boolean;
  16990. /** @hidden */
  16991. _normals: boolean;
  16992. /** @hidden */
  16993. _uvs: boolean;
  16994. /** @hidden */
  16995. _needNormals: boolean;
  16996. /** @hidden */
  16997. _needUVs: boolean;
  16998. /**
  16999. * Specifies if the material needs to be re-calculated
  17000. */
  17001. readonly isDirty: boolean;
  17002. /**
  17003. * Marks the material to indicate that it has been re-calculated
  17004. */
  17005. markAsProcessed(): void;
  17006. /**
  17007. * Marks the material to indicate that it needs to be re-calculated
  17008. */
  17009. markAsUnprocessed(): void;
  17010. /**
  17011. * Marks the material to indicate all of its defines need to be re-calculated
  17012. */
  17013. markAllAsDirty(): void;
  17014. /**
  17015. * Marks the material to indicate that image processing needs to be re-calculated
  17016. */
  17017. markAsImageProcessingDirty(): void;
  17018. /**
  17019. * Marks the material to indicate the lights need to be re-calculated
  17020. */
  17021. markAsLightDirty(): void;
  17022. /**
  17023. * Marks the attribute state as changed
  17024. */
  17025. markAsAttributesDirty(): void;
  17026. /**
  17027. * Marks the texture state as changed
  17028. */
  17029. markAsTexturesDirty(): void;
  17030. /**
  17031. * Marks the fresnel state as changed
  17032. */
  17033. markAsFresnelDirty(): void;
  17034. /**
  17035. * Marks the misc state as changed
  17036. */
  17037. markAsMiscDirty(): void;
  17038. /**
  17039. * Rebuilds the material defines
  17040. */
  17041. rebuild(): void;
  17042. /**
  17043. * Specifies if two material defines are equal
  17044. * @param other - A material define instance to compare to
  17045. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17046. */
  17047. isEqual(other: MaterialDefines): boolean;
  17048. /**
  17049. * Clones this instance's defines to another instance
  17050. * @param other - material defines to clone values to
  17051. */
  17052. cloneTo(other: MaterialDefines): void;
  17053. /**
  17054. * Resets the material define values
  17055. */
  17056. reset(): void;
  17057. /**
  17058. * Converts the material define values to a string
  17059. * @returns - String of material define information
  17060. */
  17061. toString(): string;
  17062. }
  17063. /**
  17064. * Base class for the main features of a material in Babylon.js
  17065. */
  17066. class Material implements IAnimatable {
  17067. private static _TriangleFillMode;
  17068. private static _WireFrameFillMode;
  17069. private static _PointFillMode;
  17070. private static _PointListDrawMode;
  17071. private static _LineListDrawMode;
  17072. private static _LineLoopDrawMode;
  17073. private static _LineStripDrawMode;
  17074. private static _TriangleStripDrawMode;
  17075. private static _TriangleFanDrawMode;
  17076. /**
  17077. * Returns the triangle fill mode
  17078. */
  17079. static readonly TriangleFillMode: number;
  17080. /**
  17081. * Returns the wireframe mode
  17082. */
  17083. static readonly WireFrameFillMode: number;
  17084. /**
  17085. * Returns the point fill mode
  17086. */
  17087. static readonly PointFillMode: number;
  17088. /**
  17089. * Returns the point list draw mode
  17090. */
  17091. static readonly PointListDrawMode: number;
  17092. /**
  17093. * Returns the line list draw mode
  17094. */
  17095. static readonly LineListDrawMode: number;
  17096. /**
  17097. * Returns the line loop draw mode
  17098. */
  17099. static readonly LineLoopDrawMode: number;
  17100. /**
  17101. * Returns the line strip draw mode
  17102. */
  17103. static readonly LineStripDrawMode: number;
  17104. /**
  17105. * Returns the triangle strip draw mode
  17106. */
  17107. static readonly TriangleStripDrawMode: number;
  17108. /**
  17109. * Returns the triangle fan draw mode
  17110. */
  17111. static readonly TriangleFanDrawMode: number;
  17112. /**
  17113. * Stores the clock-wise side orientation
  17114. */
  17115. private static _ClockWiseSideOrientation;
  17116. /**
  17117. * Stores the counter clock-wise side orientation
  17118. */
  17119. private static _CounterClockWiseSideOrientation;
  17120. /**
  17121. * Returns the clock-wise side orientation
  17122. */
  17123. static readonly ClockWiseSideOrientation: number;
  17124. /**
  17125. * Returns the counter clock-wise side orientation
  17126. */
  17127. static readonly CounterClockWiseSideOrientation: number;
  17128. /**
  17129. * The dirty texture flag value
  17130. */
  17131. static readonly TextureDirtyFlag: number;
  17132. /**
  17133. * The dirty light flag value
  17134. */
  17135. static readonly LightDirtyFlag: number;
  17136. /**
  17137. * The dirty fresnel flag value
  17138. */
  17139. static readonly FresnelDirtyFlag: number;
  17140. /**
  17141. * The dirty attribute flag value
  17142. */
  17143. static readonly AttributesDirtyFlag: number;
  17144. /**
  17145. * The dirty misc flag value
  17146. */
  17147. static readonly MiscDirtyFlag: number;
  17148. /**
  17149. * The all dirty flag value
  17150. */
  17151. static readonly AllDirtyFlag: number;
  17152. /**
  17153. * The ID of the material
  17154. */
  17155. id: string;
  17156. /**
  17157. * Gets or sets the unique id of the material
  17158. */
  17159. uniqueId: number;
  17160. /**
  17161. * The name of the material
  17162. */
  17163. name: string;
  17164. /**
  17165. * Specifies if the ready state should be checked on each call
  17166. */
  17167. checkReadyOnEveryCall: boolean;
  17168. /**
  17169. * Specifies if the ready state should be checked once
  17170. */
  17171. checkReadyOnlyOnce: boolean;
  17172. /**
  17173. * The state of the material
  17174. */
  17175. state: string;
  17176. /**
  17177. * The alpha value of the material
  17178. */
  17179. protected _alpha: number;
  17180. /**
  17181. * Sets the alpha value of the material
  17182. */
  17183. /**
  17184. * Gets the alpha value of the material
  17185. */
  17186. alpha: number;
  17187. /**
  17188. * Specifies if back face culling is enabled
  17189. */
  17190. protected _backFaceCulling: boolean;
  17191. /**
  17192. * Sets the back-face culling state
  17193. */
  17194. /**
  17195. * Gets the back-face culling state
  17196. */
  17197. backFaceCulling: boolean;
  17198. /**
  17199. * Stores the value for side orientation
  17200. */
  17201. sideOrientation: number;
  17202. /**
  17203. * Callback triggered when the material is compiled
  17204. */
  17205. onCompiled: (effect: Effect) => void;
  17206. /**
  17207. * Callback triggered when an error occurs
  17208. */
  17209. onError: (effect: Effect, errors: string) => void;
  17210. /**
  17211. * Callback triggered to get the render target textures
  17212. */
  17213. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17214. /**
  17215. * Gets a boolean indicating that current material needs to register RTT
  17216. */
  17217. readonly hasRenderTargetTextures: boolean;
  17218. /**
  17219. * Specifies if the material should be serialized
  17220. */
  17221. doNotSerialize: boolean;
  17222. /**
  17223. * Specifies if the effect should be stored on sub meshes
  17224. */
  17225. storeEffectOnSubMeshes: boolean;
  17226. /**
  17227. * Stores the animations for the material
  17228. */
  17229. animations: Array<Animation>;
  17230. /**
  17231. * An event triggered when the material is disposed
  17232. */
  17233. onDisposeObservable: Observable<Material>;
  17234. /**
  17235. * An observer which watches for dispose events
  17236. */
  17237. private _onDisposeObserver;
  17238. private _onUnBindObservable;
  17239. /**
  17240. * Called during a dispose event
  17241. */
  17242. onDispose: () => void;
  17243. private _onBindObservable;
  17244. /**
  17245. * An event triggered when the material is bound
  17246. */
  17247. readonly onBindObservable: Observable<AbstractMesh>;
  17248. /**
  17249. * An observer which watches for bind events
  17250. */
  17251. private _onBindObserver;
  17252. /**
  17253. * Called during a bind event
  17254. */
  17255. onBind: (Mesh: AbstractMesh) => void;
  17256. /**
  17257. * An event triggered when the material is unbound
  17258. */
  17259. readonly onUnBindObservable: Observable<Material>;
  17260. /**
  17261. * Stores the value of the alpha mode
  17262. */
  17263. private _alphaMode;
  17264. /**
  17265. * Sets the value of the alpha mode.
  17266. *
  17267. * | Value | Type | Description |
  17268. * | --- | --- | --- |
  17269. * | 0 | ALPHA_DISABLE | |
  17270. * | 1 | ALPHA_ADD | |
  17271. * | 2 | ALPHA_COMBINE | |
  17272. * | 3 | ALPHA_SUBTRACT | |
  17273. * | 4 | ALPHA_MULTIPLY | |
  17274. * | 5 | ALPHA_MAXIMIZED | |
  17275. * | 6 | ALPHA_ONEONE | |
  17276. * | 7 | ALPHA_PREMULTIPLIED | |
  17277. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17278. * | 9 | ALPHA_INTERPOLATE | |
  17279. * | 10 | ALPHA_SCREENMODE | |
  17280. *
  17281. */
  17282. /**
  17283. * Gets the value of the alpha mode
  17284. */
  17285. alphaMode: number;
  17286. /**
  17287. * Stores the state of the need depth pre-pass value
  17288. */
  17289. private _needDepthPrePass;
  17290. /**
  17291. * Sets the need depth pre-pass value
  17292. */
  17293. /**
  17294. * Gets the depth pre-pass value
  17295. */
  17296. needDepthPrePass: boolean;
  17297. /**
  17298. * Specifies if depth writing should be disabled
  17299. */
  17300. disableDepthWrite: boolean;
  17301. /**
  17302. * Specifies if depth writing should be forced
  17303. */
  17304. forceDepthWrite: boolean;
  17305. /**
  17306. * Specifies if there should be a separate pass for culling
  17307. */
  17308. separateCullingPass: boolean;
  17309. /**
  17310. * Stores the state specifing if fog should be enabled
  17311. */
  17312. private _fogEnabled;
  17313. /**
  17314. * Sets the state for enabling fog
  17315. */
  17316. /**
  17317. * Gets the value of the fog enabled state
  17318. */
  17319. fogEnabled: boolean;
  17320. /**
  17321. * Stores the size of points
  17322. */
  17323. pointSize: number;
  17324. /**
  17325. * Stores the z offset value
  17326. */
  17327. zOffset: number;
  17328. /**
  17329. * Gets a value specifying if wireframe mode is enabled
  17330. */
  17331. /**
  17332. * Sets the state of wireframe mode
  17333. */
  17334. wireframe: boolean;
  17335. /**
  17336. * Gets the value specifying if point clouds are enabled
  17337. */
  17338. /**
  17339. * Sets the state of point cloud mode
  17340. */
  17341. pointsCloud: boolean;
  17342. /**
  17343. * Gets the material fill mode
  17344. */
  17345. /**
  17346. * Sets the material fill mode
  17347. */
  17348. fillMode: number;
  17349. /**
  17350. * @hidden
  17351. * Stores the effects for the material
  17352. */
  17353. _effect: Nullable<Effect>;
  17354. /**
  17355. * @hidden
  17356. * Specifies if the material was previously ready
  17357. */
  17358. _wasPreviouslyReady: boolean;
  17359. /**
  17360. * Specifies if uniform buffers should be used
  17361. */
  17362. private _useUBO;
  17363. /**
  17364. * Stores a reference to the scene
  17365. */
  17366. private _scene;
  17367. /**
  17368. * Stores the fill mode state
  17369. */
  17370. private _fillMode;
  17371. /**
  17372. * Specifies if the depth write state should be cached
  17373. */
  17374. private _cachedDepthWriteState;
  17375. /**
  17376. * Stores the uniform buffer
  17377. */
  17378. protected _uniformBuffer: UniformBuffer;
  17379. /**
  17380. * Creates a material instance
  17381. * @param name defines the name of the material
  17382. * @param scene defines the scene to reference
  17383. * @param doNotAdd specifies if the material should be added to the scene
  17384. */
  17385. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17386. /**
  17387. * Returns a string representation of the current material
  17388. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17389. * @returns a string with material information
  17390. */
  17391. toString(fullDetails?: boolean): string;
  17392. /**
  17393. * Gets the class name of the material
  17394. * @returns a string with the class name of the material
  17395. */
  17396. getClassName(): string;
  17397. /**
  17398. * Specifies if updates for the material been locked
  17399. */
  17400. readonly isFrozen: boolean;
  17401. /**
  17402. * Locks updates for the material
  17403. */
  17404. freeze(): void;
  17405. /**
  17406. * Unlocks updates for the material
  17407. */
  17408. unfreeze(): void;
  17409. /**
  17410. * Specifies if the material is ready to be used
  17411. * @param mesh defines the mesh to check
  17412. * @param useInstances specifies if instances should be used
  17413. * @returns a boolean indicating if the material is ready to be used
  17414. */
  17415. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17416. /**
  17417. * Specifies that the submesh is ready to be used
  17418. * @param mesh defines the mesh to check
  17419. * @param subMesh defines which submesh to check
  17420. * @param useInstances specifies that instances should be used
  17421. * @returns a boolean indicating that the submesh is ready or not
  17422. */
  17423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17424. /**
  17425. * Returns the material effect
  17426. * @returns the effect associated with the material
  17427. */
  17428. getEffect(): Nullable<Effect>;
  17429. /**
  17430. * Returns the current scene
  17431. * @returns a Scene
  17432. */
  17433. getScene(): Scene;
  17434. /**
  17435. * Specifies if the material will require alpha blending
  17436. * @returns a boolean specifying if alpha blending is needed
  17437. */
  17438. needAlphaBlending(): boolean;
  17439. /**
  17440. * Specifies if the mesh will require alpha blending
  17441. * @param mesh defines the mesh to check
  17442. * @returns a boolean specifying if alpha blending is needed for the mesh
  17443. */
  17444. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17445. /**
  17446. * Specifies if this material should be rendered in alpha test mode
  17447. * @returns a boolean specifying if an alpha test is needed.
  17448. */
  17449. needAlphaTesting(): boolean;
  17450. /**
  17451. * Gets the texture used for the alpha test
  17452. * @returns the texture to use for alpha testing
  17453. */
  17454. getAlphaTestTexture(): Nullable<BaseTexture>;
  17455. /**
  17456. * Marks the material to indicate that it needs to be re-calculated
  17457. */
  17458. markDirty(): void;
  17459. /** @hidden */
  17460. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17461. /**
  17462. * Binds the material to the mesh
  17463. * @param world defines the world transformation matrix
  17464. * @param mesh defines the mesh to bind the material to
  17465. */
  17466. bind(world: Matrix, mesh?: Mesh): void;
  17467. /**
  17468. * Binds the submesh to the material
  17469. * @param world defines the world transformation matrix
  17470. * @param mesh defines the mesh containing the submesh
  17471. * @param subMesh defines the submesh to bind the material to
  17472. */
  17473. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17474. /**
  17475. * Binds the world matrix to the material
  17476. * @param world defines the world transformation matrix
  17477. */
  17478. bindOnlyWorldMatrix(world: Matrix): void;
  17479. /**
  17480. * Binds the scene's uniform buffer to the effect.
  17481. * @param effect defines the effect to bind to the scene uniform buffer
  17482. * @param sceneUbo defines the uniform buffer storing scene data
  17483. */
  17484. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17485. /**
  17486. * Binds the view matrix to the effect
  17487. * @param effect defines the effect to bind the view matrix to
  17488. */
  17489. bindView(effect: Effect): void;
  17490. /**
  17491. * Binds the view projection matrix to the effect
  17492. * @param effect defines the effect to bind the view projection matrix to
  17493. */
  17494. bindViewProjection(effect: Effect): void;
  17495. /**
  17496. * Specifies if material alpha testing should be turned on for the mesh
  17497. * @param mesh defines the mesh to check
  17498. */
  17499. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17500. /**
  17501. * Processes to execute after binding the material to a mesh
  17502. * @param mesh defines the rendered mesh
  17503. */
  17504. protected _afterBind(mesh?: Mesh): void;
  17505. /**
  17506. * Unbinds the material from the mesh
  17507. */
  17508. unbind(): void;
  17509. /**
  17510. * Gets the active textures from the material
  17511. * @returns an array of textures
  17512. */
  17513. getActiveTextures(): BaseTexture[];
  17514. /**
  17515. * Specifies if the material uses a texture
  17516. * @param texture defines the texture to check against the material
  17517. * @returns a boolean specifying if the material uses the texture
  17518. */
  17519. hasTexture(texture: BaseTexture): boolean;
  17520. /**
  17521. * Makes a duplicate of the material, and gives it a new name
  17522. * @param name defines the new name for the duplicated material
  17523. * @returns the cloned material
  17524. */
  17525. clone(name: string): Nullable<Material>;
  17526. /**
  17527. * Gets the meshes bound to the material
  17528. * @returns an array of meshes bound to the material
  17529. */
  17530. getBindedMeshes(): AbstractMesh[];
  17531. /**
  17532. * Force shader compilation
  17533. * @param mesh defines the mesh associated with this material
  17534. * @param onCompiled defines a function to execute once the material is compiled
  17535. * @param options defines the options to configure the compilation
  17536. */
  17537. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17538. clipPlane: boolean;
  17539. }>): void;
  17540. /**
  17541. * Force shader compilation
  17542. * @param mesh defines the mesh that will use this material
  17543. * @param options defines additional options for compiling the shaders
  17544. * @returns a promise that resolves when the compilation completes
  17545. */
  17546. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17547. clipPlane: boolean;
  17548. }>): Promise<void>;
  17549. /**
  17550. * Marks a define in the material to indicate that it needs to be re-computed
  17551. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17552. */
  17553. markAsDirty(flag: number): void;
  17554. /**
  17555. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17556. * @param func defines a function which checks material defines against the submeshes
  17557. */
  17558. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17559. /**
  17560. * Indicates that image processing needs to be re-calculated for all submeshes
  17561. */
  17562. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17563. /**
  17564. * Indicates that textures need to be re-calculated for all submeshes
  17565. */
  17566. protected _markAllSubMeshesAsTexturesDirty(): void;
  17567. /**
  17568. * Indicates that fresnel needs to be re-calculated for all submeshes
  17569. */
  17570. protected _markAllSubMeshesAsFresnelDirty(): void;
  17571. /**
  17572. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17573. */
  17574. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17575. /**
  17576. * Indicates that lights need to be re-calculated for all submeshes
  17577. */
  17578. protected _markAllSubMeshesAsLightsDirty(): void;
  17579. /**
  17580. * Indicates that attributes need to be re-calculated for all submeshes
  17581. */
  17582. protected _markAllSubMeshesAsAttributesDirty(): void;
  17583. /**
  17584. * Indicates that misc needs to be re-calculated for all submeshes
  17585. */
  17586. protected _markAllSubMeshesAsMiscDirty(): void;
  17587. /**
  17588. * Indicates that textures and misc need to be re-calculated for all submeshes
  17589. */
  17590. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17591. /**
  17592. * Disposes the material
  17593. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17594. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17595. */
  17596. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17597. /**
  17598. * Serializes this material
  17599. * @returns the serialized material object
  17600. */
  17601. serialize(): any;
  17602. /**
  17603. * Creates a MultiMaterial from parsed MultiMaterial data.
  17604. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17605. * @param scene defines the hosting scene
  17606. * @returns a new MultiMaterial
  17607. */
  17608. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17609. /**
  17610. * Creates a material from parsed material data
  17611. * @param parsedMaterial defines parsed material data
  17612. * @param scene defines the hosting scene
  17613. * @param rootUrl defines the root URL to use to load textures
  17614. * @returns a new material
  17615. */
  17616. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17617. }
  17618. }
  17619. declare module BABYLON {
  17620. /**
  17621. * "Static Class" containing the most commonly used helper while dealing with material for
  17622. * rendering purpose.
  17623. *
  17624. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17625. *
  17626. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17627. */
  17628. class MaterialHelper {
  17629. /**
  17630. * Bind the current view position to an effect.
  17631. * @param effect The effect to be bound
  17632. * @param scene The scene the eyes position is used from
  17633. */
  17634. static BindEyePosition(effect: Effect, scene: Scene): void;
  17635. /**
  17636. * Helps preparing the defines values about the UVs in used in the effect.
  17637. * UVs are shared as much as we can accross chanels in the shaders.
  17638. * @param texture The texture we are preparing the UVs for
  17639. * @param defines The defines to update
  17640. * @param key The chanel key "diffuse", "specular"... used in the shader
  17641. */
  17642. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17643. /**
  17644. * Binds a texture matrix value to its corrsponding uniform
  17645. * @param texture The texture to bind the matrix for
  17646. * @param uniformBuffer The uniform buffer receivin the data
  17647. * @param key The chanel key "diffuse", "specular"... used in the shader
  17648. */
  17649. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17650. /**
  17651. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17652. * @param mesh defines the current mesh
  17653. * @param scene defines the current scene
  17654. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17655. * @param pointsCloud defines if point cloud rendering has to be turned on
  17656. * @param fogEnabled defines if fog has to be turned on
  17657. * @param alphaTest defines if alpha testing has to be turned on
  17658. * @param defines defines the current list of defines
  17659. */
  17660. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17661. /**
  17662. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17663. * @param scene defines the current scene
  17664. * @param engine defines the current engine
  17665. * @param defines specifies the list of active defines
  17666. * @param useInstances defines if instances have to be turned on
  17667. * @param useClipPlane defines if clip plane have to be turned on
  17668. */
  17669. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17670. /**
  17671. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17672. * @param mesh The mesh containing the geometry data we will draw
  17673. * @param defines The defines to update
  17674. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17675. * @param useBones Precise whether bones should be used or not (override mesh info)
  17676. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17677. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17678. * @returns false if defines are considered not dirty and have not been checked
  17679. */
  17680. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17681. /**
  17682. * Prepares the defines related to the light information passed in parameter
  17683. * @param scene The scene we are intending to draw
  17684. * @param mesh The mesh the effect is compiling for
  17685. * @param defines The defines to update
  17686. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17687. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17688. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17689. * @returns true if normals will be required for the rest of the effect
  17690. */
  17691. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17692. /**
  17693. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17694. * that won t be acctive due to defines being turned off.
  17695. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17696. * @param samplersList The samplers list
  17697. * @param defines The defines helping in the list generation
  17698. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17699. */
  17700. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17701. /**
  17702. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17703. * @param defines The defines to update while falling back
  17704. * @param fallbacks The authorized effect fallbacks
  17705. * @param maxSimultaneousLights The maximum number of lights allowed
  17706. * @param rank the current rank of the Effect
  17707. * @returns The newly affected rank
  17708. */
  17709. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17710. /**
  17711. * Prepares the list of attributes required for morph targets according to the effect defines.
  17712. * @param attribs The current list of supported attribs
  17713. * @param mesh The mesh to prepare the morph targets attributes for
  17714. * @param defines The current Defines of the effect
  17715. */
  17716. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17717. /**
  17718. * Prepares the list of attributes required for bones according to the effect defines.
  17719. * @param attribs The current list of supported attribs
  17720. * @param mesh The mesh to prepare the bones attributes for
  17721. * @param defines The current Defines of the effect
  17722. * @param fallbacks The current efffect fallback strategy
  17723. */
  17724. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17725. /**
  17726. * Prepares the list of attributes required for instances according to the effect defines.
  17727. * @param attribs The current list of supported attribs
  17728. * @param defines The current Defines of the effect
  17729. */
  17730. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17731. /**
  17732. * Binds the light shadow information to the effect for the given mesh.
  17733. * @param light The light containing the generator
  17734. * @param scene The scene the lights belongs to
  17735. * @param mesh The mesh we are binding the information to render
  17736. * @param lightIndex The light index in the effect used to render the mesh
  17737. * @param effect The effect we are binding the data to
  17738. */
  17739. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17740. /**
  17741. * Binds the light information to the effect.
  17742. * @param light The light containing the generator
  17743. * @param effect The effect we are binding the data to
  17744. * @param lightIndex The light index in the effect used to render
  17745. */
  17746. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17747. /**
  17748. * Binds the lights information from the scene to the effect for the given mesh.
  17749. * @param scene The scene the lights belongs to
  17750. * @param mesh The mesh we are binding the information to render
  17751. * @param effect The effect we are binding the data to
  17752. * @param defines The generated defines for the effect
  17753. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17754. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17755. */
  17756. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17757. private static _tempFogColor;
  17758. /**
  17759. * Binds the fog information from the scene to the effect for the given mesh.
  17760. * @param scene The scene the lights belongs to
  17761. * @param mesh The mesh we are binding the information to render
  17762. * @param effect The effect we are binding the data to
  17763. * @param linearSpace Defines if the fog effect is applied in linear space
  17764. */
  17765. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  17766. /**
  17767. * Binds the bones information from the mesh to the effect.
  17768. * @param mesh The mesh we are binding the information to render
  17769. * @param effect The effect we are binding the data to
  17770. */
  17771. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17772. /**
  17773. * Binds the morph targets information from the mesh to the effect.
  17774. * @param abstractMesh The mesh we are binding the information to render
  17775. * @param effect The effect we are binding the data to
  17776. */
  17777. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17778. /**
  17779. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17780. * @param defines The generated defines used in the effect
  17781. * @param effect The effect we are binding the data to
  17782. * @param scene The scene we are willing to render with logarithmic scale for
  17783. */
  17784. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17785. /**
  17786. * Binds the clip plane information from the scene to the effect.
  17787. * @param scene The scene the clip plane information are extracted from
  17788. * @param effect The effect we are binding the data to
  17789. */
  17790. static BindClipPlane(effect: Effect, scene: Scene): void;
  17791. }
  17792. }
  17793. declare module BABYLON {
  17794. class MultiMaterial extends Material {
  17795. private _subMaterials;
  17796. subMaterials: Nullable<Material>[];
  17797. constructor(name: string, scene: Scene);
  17798. private _hookArray;
  17799. getSubMaterial(index: number): Nullable<Material>;
  17800. getActiveTextures(): BaseTexture[];
  17801. getClassName(): string;
  17802. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17803. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17804. serialize(): any;
  17805. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17806. }
  17807. }
  17808. declare module BABYLON {
  17809. class PushMaterial extends Material {
  17810. protected _activeEffect: Effect;
  17811. protected _normalMatrix: Matrix;
  17812. constructor(name: string, scene: Scene);
  17813. getEffect(): Effect;
  17814. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17815. /**
  17816. * Binds the given world matrix to the active effect
  17817. *
  17818. * @param world the matrix to bind
  17819. */
  17820. bindOnlyWorldMatrix(world: Matrix): void;
  17821. /**
  17822. * Binds the given normal matrix to the active effect
  17823. *
  17824. * @param normalMatrix the matrix to bind
  17825. */
  17826. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17827. bind(world: Matrix, mesh?: Mesh): void;
  17828. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17829. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17830. }
  17831. }
  17832. declare module BABYLON {
  17833. class ShaderMaterial extends Material {
  17834. private _shaderPath;
  17835. private _options;
  17836. private _textures;
  17837. private _textureArrays;
  17838. private _floats;
  17839. private _ints;
  17840. private _floatsArrays;
  17841. private _colors3;
  17842. private _colors3Arrays;
  17843. private _colors4;
  17844. private _vectors2;
  17845. private _vectors3;
  17846. private _vectors4;
  17847. private _matrices;
  17848. private _matrices3x3;
  17849. private _matrices2x2;
  17850. private _vectors2Arrays;
  17851. private _vectors3Arrays;
  17852. private _cachedWorldViewMatrix;
  17853. private _renderId;
  17854. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17855. getClassName(): string;
  17856. needAlphaBlending(): boolean;
  17857. needAlphaTesting(): boolean;
  17858. private _checkUniform;
  17859. setTexture(name: string, texture: Texture): ShaderMaterial;
  17860. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17861. setFloat(name: string, value: number): ShaderMaterial;
  17862. setInt(name: string, value: number): ShaderMaterial;
  17863. setFloats(name: string, value: number[]): ShaderMaterial;
  17864. setColor3(name: string, value: Color3): ShaderMaterial;
  17865. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17866. setColor4(name: string, value: Color4): ShaderMaterial;
  17867. setVector2(name: string, value: Vector2): ShaderMaterial;
  17868. setVector3(name: string, value: Vector3): ShaderMaterial;
  17869. setVector4(name: string, value: Vector4): ShaderMaterial;
  17870. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17871. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17872. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17873. setArray2(name: string, value: number[]): ShaderMaterial;
  17874. setArray3(name: string, value: number[]): ShaderMaterial;
  17875. private _checkCache;
  17876. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17877. bindOnlyWorldMatrix(world: Matrix): void;
  17878. bind(world: Matrix, mesh?: Mesh): void;
  17879. getActiveTextures(): BaseTexture[];
  17880. hasTexture(texture: BaseTexture): boolean;
  17881. clone(name: string): ShaderMaterial;
  17882. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17883. serialize(): any;
  17884. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17885. }
  17886. }
  17887. declare module BABYLON {
  17888. /** @hidden */
  17889. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17890. MAINUV1: boolean;
  17891. MAINUV2: boolean;
  17892. DIFFUSE: boolean;
  17893. DIFFUSEDIRECTUV: number;
  17894. AMBIENT: boolean;
  17895. AMBIENTDIRECTUV: number;
  17896. OPACITY: boolean;
  17897. OPACITYDIRECTUV: number;
  17898. OPACITYRGB: boolean;
  17899. REFLECTION: boolean;
  17900. EMISSIVE: boolean;
  17901. EMISSIVEDIRECTUV: number;
  17902. SPECULAR: boolean;
  17903. SPECULARDIRECTUV: number;
  17904. BUMP: boolean;
  17905. BUMPDIRECTUV: number;
  17906. PARALLAX: boolean;
  17907. PARALLAXOCCLUSION: boolean;
  17908. SPECULAROVERALPHA: boolean;
  17909. CLIPPLANE: boolean;
  17910. CLIPPLANE2: boolean;
  17911. CLIPPLANE3: boolean;
  17912. CLIPPLANE4: boolean;
  17913. ALPHATEST: boolean;
  17914. DEPTHPREPASS: boolean;
  17915. ALPHAFROMDIFFUSE: boolean;
  17916. POINTSIZE: boolean;
  17917. FOG: boolean;
  17918. SPECULARTERM: boolean;
  17919. DIFFUSEFRESNEL: boolean;
  17920. OPACITYFRESNEL: boolean;
  17921. REFLECTIONFRESNEL: boolean;
  17922. REFRACTIONFRESNEL: boolean;
  17923. EMISSIVEFRESNEL: boolean;
  17924. FRESNEL: boolean;
  17925. NORMAL: boolean;
  17926. UV1: boolean;
  17927. UV2: boolean;
  17928. VERTEXCOLOR: boolean;
  17929. VERTEXALPHA: boolean;
  17930. NUM_BONE_INFLUENCERS: number;
  17931. BonesPerMesh: number;
  17932. INSTANCES: boolean;
  17933. GLOSSINESS: boolean;
  17934. ROUGHNESS: boolean;
  17935. EMISSIVEASILLUMINATION: boolean;
  17936. LINKEMISSIVEWITHDIFFUSE: boolean;
  17937. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17938. LIGHTMAP: boolean;
  17939. LIGHTMAPDIRECTUV: number;
  17940. OBJECTSPACE_NORMALMAP: boolean;
  17941. USELIGHTMAPASSHADOWMAP: boolean;
  17942. REFLECTIONMAP_3D: boolean;
  17943. REFLECTIONMAP_SPHERICAL: boolean;
  17944. REFLECTIONMAP_PLANAR: boolean;
  17945. REFLECTIONMAP_CUBIC: boolean;
  17946. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17947. REFLECTIONMAP_PROJECTION: boolean;
  17948. REFLECTIONMAP_SKYBOX: boolean;
  17949. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  17950. REFLECTIONMAP_EXPLICIT: boolean;
  17951. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17952. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17953. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17954. INVERTCUBICMAP: boolean;
  17955. LOGARITHMICDEPTH: boolean;
  17956. REFRACTION: boolean;
  17957. REFRACTIONMAP_3D: boolean;
  17958. REFLECTIONOVERALPHA: boolean;
  17959. TWOSIDEDLIGHTING: boolean;
  17960. SHADOWFLOAT: boolean;
  17961. MORPHTARGETS: boolean;
  17962. MORPHTARGETS_NORMAL: boolean;
  17963. MORPHTARGETS_TANGENT: boolean;
  17964. NUM_MORPH_INFLUENCERS: number;
  17965. NONUNIFORMSCALING: boolean;
  17966. PREMULTIPLYALPHA: boolean;
  17967. IMAGEPROCESSING: boolean;
  17968. VIGNETTE: boolean;
  17969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17970. VIGNETTEBLENDMODEOPAQUE: boolean;
  17971. TONEMAPPING: boolean;
  17972. TONEMAPPING_ACES: boolean;
  17973. CONTRAST: boolean;
  17974. COLORCURVES: boolean;
  17975. COLORGRADING: boolean;
  17976. COLORGRADING3D: boolean;
  17977. SAMPLER3DGREENDEPTH: boolean;
  17978. SAMPLER3DBGRMAP: boolean;
  17979. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17980. /**
  17981. * If the reflection texture on this material is in linear color space
  17982. * @hidden
  17983. */
  17984. IS_REFLECTION_LINEAR: boolean;
  17985. /**
  17986. * If the refraction texture on this material is in linear color space
  17987. * @hidden
  17988. */
  17989. IS_REFRACTION_LINEAR: boolean;
  17990. EXPOSURE: boolean;
  17991. constructor();
  17992. setReflectionMode(modeToEnable: string): void;
  17993. }
  17994. class StandardMaterial extends PushMaterial {
  17995. private _diffuseTexture;
  17996. diffuseTexture: Nullable<BaseTexture>;
  17997. private _ambientTexture;
  17998. ambientTexture: Nullable<BaseTexture>;
  17999. private _opacityTexture;
  18000. opacityTexture: Nullable<BaseTexture>;
  18001. private _reflectionTexture;
  18002. reflectionTexture: Nullable<BaseTexture>;
  18003. private _emissiveTexture;
  18004. emissiveTexture: Nullable<BaseTexture>;
  18005. private _specularTexture;
  18006. specularTexture: Nullable<BaseTexture>;
  18007. private _bumpTexture;
  18008. bumpTexture: Nullable<BaseTexture>;
  18009. private _lightmapTexture;
  18010. lightmapTexture: Nullable<BaseTexture>;
  18011. private _refractionTexture;
  18012. refractionTexture: Nullable<BaseTexture>;
  18013. ambientColor: Color3;
  18014. diffuseColor: Color3;
  18015. specularColor: Color3;
  18016. emissiveColor: Color3;
  18017. specularPower: number;
  18018. private _useAlphaFromDiffuseTexture;
  18019. useAlphaFromDiffuseTexture: boolean;
  18020. private _useEmissiveAsIllumination;
  18021. useEmissiveAsIllumination: boolean;
  18022. private _linkEmissiveWithDiffuse;
  18023. linkEmissiveWithDiffuse: boolean;
  18024. private _useSpecularOverAlpha;
  18025. useSpecularOverAlpha: boolean;
  18026. private _useReflectionOverAlpha;
  18027. useReflectionOverAlpha: boolean;
  18028. private _disableLighting;
  18029. disableLighting: boolean;
  18030. private _useObjectSpaceNormalMap;
  18031. /**
  18032. * Allows using an object space normal map (instead of tangent space).
  18033. */
  18034. useObjectSpaceNormalMap: boolean;
  18035. private _useParallax;
  18036. useParallax: boolean;
  18037. private _useParallaxOcclusion;
  18038. useParallaxOcclusion: boolean;
  18039. parallaxScaleBias: number;
  18040. private _roughness;
  18041. roughness: number;
  18042. indexOfRefraction: number;
  18043. invertRefractionY: boolean;
  18044. /**
  18045. * Defines the alpha limits in alpha test mode
  18046. */
  18047. alphaCutOff: number;
  18048. private _useLightmapAsShadowmap;
  18049. useLightmapAsShadowmap: boolean;
  18050. private _diffuseFresnelParameters;
  18051. diffuseFresnelParameters: FresnelParameters;
  18052. private _opacityFresnelParameters;
  18053. opacityFresnelParameters: FresnelParameters;
  18054. private _reflectionFresnelParameters;
  18055. reflectionFresnelParameters: FresnelParameters;
  18056. private _refractionFresnelParameters;
  18057. refractionFresnelParameters: FresnelParameters;
  18058. private _emissiveFresnelParameters;
  18059. emissiveFresnelParameters: FresnelParameters;
  18060. private _useReflectionFresnelFromSpecular;
  18061. useReflectionFresnelFromSpecular: boolean;
  18062. private _useGlossinessFromSpecularMapAlpha;
  18063. useGlossinessFromSpecularMapAlpha: boolean;
  18064. private _maxSimultaneousLights;
  18065. maxSimultaneousLights: number;
  18066. /**
  18067. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18068. */
  18069. private _invertNormalMapX;
  18070. invertNormalMapX: boolean;
  18071. /**
  18072. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18073. */
  18074. private _invertNormalMapY;
  18075. invertNormalMapY: boolean;
  18076. /**
  18077. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18078. */
  18079. private _twoSidedLighting;
  18080. twoSidedLighting: boolean;
  18081. /**
  18082. * Default configuration related to image processing available in the standard Material.
  18083. */
  18084. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18085. /**
  18086. * Gets the image processing configuration used either in this material.
  18087. */
  18088. /**
  18089. * Sets the Default image processing configuration used either in the this material.
  18090. *
  18091. * If sets to null, the scene one is in use.
  18092. */
  18093. imageProcessingConfiguration: ImageProcessingConfiguration;
  18094. /**
  18095. * Keep track of the image processing observer to allow dispose and replace.
  18096. */
  18097. private _imageProcessingObserver;
  18098. /**
  18099. * Attaches a new image processing configuration to the Standard Material.
  18100. * @param configuration
  18101. */
  18102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18103. /**
  18104. * Gets wether the color curves effect is enabled.
  18105. */
  18106. /**
  18107. * Sets wether the color curves effect is enabled.
  18108. */
  18109. cameraColorCurvesEnabled: boolean;
  18110. /**
  18111. * Gets wether the color grading effect is enabled.
  18112. */
  18113. /**
  18114. * Gets wether the color grading effect is enabled.
  18115. */
  18116. cameraColorGradingEnabled: boolean;
  18117. /**
  18118. * Gets wether tonemapping is enabled or not.
  18119. */
  18120. /**
  18121. * Sets wether tonemapping is enabled or not
  18122. */
  18123. cameraToneMappingEnabled: boolean;
  18124. /**
  18125. * The camera exposure used on this material.
  18126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18127. * This corresponds to a photographic exposure.
  18128. */
  18129. /**
  18130. * The camera exposure used on this material.
  18131. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18132. * This corresponds to a photographic exposure.
  18133. */
  18134. cameraExposure: number;
  18135. /**
  18136. * Gets The camera contrast used on this material.
  18137. */
  18138. /**
  18139. * Sets The camera contrast used on this material.
  18140. */
  18141. cameraContrast: number;
  18142. /**
  18143. * Gets the Color Grading 2D Lookup Texture.
  18144. */
  18145. /**
  18146. * Sets the Color Grading 2D Lookup Texture.
  18147. */
  18148. cameraColorGradingTexture: Nullable<BaseTexture>;
  18149. /**
  18150. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18151. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18152. * 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;
  18153. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18154. */
  18155. /**
  18156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18158. * 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;
  18159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18160. */
  18161. cameraColorCurves: Nullable<ColorCurves>;
  18162. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  18163. protected _renderTargets: SmartArray<RenderTargetTexture>;
  18164. protected _worldViewProjectionMatrix: Matrix;
  18165. protected _globalAmbientColor: Color3;
  18166. protected _useLogarithmicDepth: boolean;
  18167. constructor(name: string, scene: Scene);
  18168. /**
  18169. * Gets a boolean indicating that current material needs to register RTT
  18170. */
  18171. readonly hasRenderTargetTextures: boolean;
  18172. getClassName(): string;
  18173. useLogarithmicDepth: boolean;
  18174. needAlphaBlending(): boolean;
  18175. needAlphaTesting(): boolean;
  18176. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  18177. getAlphaTestTexture(): Nullable<BaseTexture>;
  18178. /**
  18179. * Child classes can use it to update shaders
  18180. */
  18181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18182. buildUniformLayout(): void;
  18183. unbind(): void;
  18184. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18185. getAnimatables(): IAnimatable[];
  18186. getActiveTextures(): BaseTexture[];
  18187. hasTexture(texture: BaseTexture): boolean;
  18188. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18189. clone(name: string): StandardMaterial;
  18190. serialize(): any;
  18191. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  18192. static _DiffuseTextureEnabled: boolean;
  18193. static DiffuseTextureEnabled: boolean;
  18194. static _AmbientTextureEnabled: boolean;
  18195. static AmbientTextureEnabled: boolean;
  18196. static _OpacityTextureEnabled: boolean;
  18197. static OpacityTextureEnabled: boolean;
  18198. static _ReflectionTextureEnabled: boolean;
  18199. static ReflectionTextureEnabled: boolean;
  18200. static _EmissiveTextureEnabled: boolean;
  18201. static EmissiveTextureEnabled: boolean;
  18202. static _SpecularTextureEnabled: boolean;
  18203. static SpecularTextureEnabled: boolean;
  18204. static _BumpTextureEnabled: boolean;
  18205. static BumpTextureEnabled: boolean;
  18206. static _LightmapTextureEnabled: boolean;
  18207. static LightmapTextureEnabled: boolean;
  18208. static _RefractionTextureEnabled: boolean;
  18209. static RefractionTextureEnabled: boolean;
  18210. static _ColorGradingTextureEnabled: boolean;
  18211. static ColorGradingTextureEnabled: boolean;
  18212. static _FresnelEnabled: boolean;
  18213. static FresnelEnabled: boolean;
  18214. }
  18215. }
  18216. declare module BABYLON {
  18217. class UniformBuffer {
  18218. private _engine;
  18219. private _buffer;
  18220. private _data;
  18221. private _bufferData;
  18222. private _dynamic?;
  18223. private _uniformLocations;
  18224. private _uniformSizes;
  18225. private _uniformLocationPointer;
  18226. private _needSync;
  18227. private _noUBO;
  18228. private _currentEffect;
  18229. private static _MAX_UNIFORM_SIZE;
  18230. private static _tempBuffer;
  18231. /**
  18232. * Wrapper for updateUniform.
  18233. * @method updateMatrix3x3
  18234. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18235. * @param {Float32Array} matrix
  18236. */
  18237. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  18238. /**
  18239. * Wrapper for updateUniform.
  18240. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18241. * @param {Float32Array} matrix
  18242. */
  18243. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  18244. /**
  18245. * Wrapper for updateUniform.
  18246. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18247. * @param {number} x
  18248. */
  18249. updateFloat: (name: string, x: number) => void;
  18250. /**
  18251. * Wrapper for updateUniform.
  18252. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18253. * @param {number} x
  18254. * @param {number} y
  18255. * @param {string} [suffix] Suffix to add to the uniform name.
  18256. */
  18257. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  18258. /**
  18259. * Wrapper for updateUniform.
  18260. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18261. * @param {number} x
  18262. * @param {number} y
  18263. * @param {number} z
  18264. * @param {string} [suffix] Suffix to add to the uniform name.
  18265. */
  18266. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  18267. /**
  18268. * Wrapper for updateUniform.
  18269. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18270. * @param {number} x
  18271. * @param {number} y
  18272. * @param {number} z
  18273. * @param {number} w
  18274. * @param {string} [suffix] Suffix to add to the uniform name.
  18275. */
  18276. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  18277. /**
  18278. * Wrapper for updateUniform.
  18279. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18280. * @param {Matrix} A 4x4 matrix.
  18281. */
  18282. updateMatrix: (name: string, mat: Matrix) => void;
  18283. /**
  18284. * Wrapper for updateUniform.
  18285. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18286. * @param {Vector3} vector
  18287. */
  18288. updateVector3: (name: string, vector: Vector3) => void;
  18289. /**
  18290. * Wrapper for updateUniform.
  18291. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18292. * @param {Vector4} vector
  18293. */
  18294. updateVector4: (name: string, vector: Vector4) => void;
  18295. /**
  18296. * Wrapper for updateUniform.
  18297. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18298. * @param {Color3} color
  18299. * @param {string} [suffix] Suffix to add to the uniform name.
  18300. */
  18301. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  18302. /**
  18303. * Wrapper for updateUniform.
  18304. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18305. * @param {Color3} color
  18306. * @param {number} alpha
  18307. * @param {string} [suffix] Suffix to add to the uniform name.
  18308. */
  18309. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  18310. /**
  18311. * Uniform buffer objects.
  18312. *
  18313. * Handles blocks of uniform on the GPU.
  18314. *
  18315. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18316. *
  18317. * For more information, please refer to :
  18318. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18319. */
  18320. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  18321. /**
  18322. * Indicates if the buffer is using the WebGL2 UBO implementation,
  18323. * or just falling back on setUniformXXX calls.
  18324. */
  18325. readonly useUbo: boolean;
  18326. /**
  18327. * Indicates if the WebGL underlying uniform buffer is in sync
  18328. * with the javascript cache data.
  18329. */
  18330. readonly isSync: boolean;
  18331. /**
  18332. * Indicates if the WebGL underlying uniform buffer is dynamic.
  18333. * Also, a dynamic UniformBuffer will disable cache verification and always
  18334. * update the underlying WebGL uniform buffer to the GPU.
  18335. */
  18336. isDynamic(): boolean;
  18337. /**
  18338. * The data cache on JS side.
  18339. */
  18340. getData(): Float32Array;
  18341. /**
  18342. * The underlying WebGL Uniform buffer.
  18343. */
  18344. getBuffer(): Nullable<WebGLBuffer>;
  18345. /**
  18346. * std140 layout specifies how to align data within an UBO structure.
  18347. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  18348. * for specs.
  18349. */
  18350. private _fillAlignment;
  18351. /**
  18352. * Adds an uniform in the buffer.
  18353. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  18354. * for the layout to be correct !
  18355. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18356. * @param {number|number[]} size Data size, or data directly.
  18357. */
  18358. addUniform(name: string, size: number | number[]): void;
  18359. /**
  18360. * Wrapper for addUniform.
  18361. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18362. * @param {Matrix} mat A 4x4 matrix.
  18363. */
  18364. addMatrix(name: string, mat: Matrix): void;
  18365. /**
  18366. * Wrapper for addUniform.
  18367. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18368. * @param {number} x
  18369. * @param {number} y
  18370. */
  18371. addFloat2(name: string, x: number, y: number): void;
  18372. /**
  18373. * Wrapper for addUniform.
  18374. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18375. * @param {number} x
  18376. * @param {number} y
  18377. * @param {number} z
  18378. */
  18379. addFloat3(name: string, x: number, y: number, z: number): void;
  18380. /**
  18381. * Wrapper for addUniform.
  18382. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18383. * @param {Color3} color
  18384. */
  18385. addColor3(name: string, color: Color3): void;
  18386. /**
  18387. * Wrapper for addUniform.
  18388. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18389. * @param {Color3} color
  18390. * @param {number} alpha
  18391. */
  18392. addColor4(name: string, color: Color3, alpha: number): void;
  18393. /**
  18394. * Wrapper for addUniform.
  18395. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18396. * @param {Vector3} vector
  18397. */
  18398. addVector3(name: string, vector: Vector3): void;
  18399. /**
  18400. * Wrapper for addUniform.
  18401. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18402. */
  18403. addMatrix3x3(name: string): void;
  18404. /**
  18405. * Wrapper for addUniform.
  18406. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18407. */
  18408. addMatrix2x2(name: string): void;
  18409. /**
  18410. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  18411. */
  18412. create(): void;
  18413. /** @hidden */
  18414. _rebuild(): void;
  18415. /**
  18416. * Updates the WebGL Uniform Buffer on the GPU.
  18417. * If the `dynamic` flag is set to true, no cache comparison is done.
  18418. * Otherwise, the buffer will be updated only if the cache differs.
  18419. */
  18420. update(): void;
  18421. /**
  18422. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  18423. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18424. * @param {number[]|Float32Array} data Flattened data
  18425. * @param {number} size Size of the data.
  18426. */
  18427. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  18428. private _updateMatrix3x3ForUniform;
  18429. private _updateMatrix3x3ForEffect;
  18430. private _updateMatrix2x2ForEffect;
  18431. private _updateMatrix2x2ForUniform;
  18432. private _updateFloatForEffect;
  18433. private _updateFloatForUniform;
  18434. private _updateFloat2ForEffect;
  18435. private _updateFloat2ForUniform;
  18436. private _updateFloat3ForEffect;
  18437. private _updateFloat3ForUniform;
  18438. private _updateFloat4ForEffect;
  18439. private _updateFloat4ForUniform;
  18440. private _updateMatrixForEffect;
  18441. private _updateMatrixForUniform;
  18442. private _updateVector3ForEffect;
  18443. private _updateVector3ForUniform;
  18444. private _updateVector4ForEffect;
  18445. private _updateVector4ForUniform;
  18446. private _updateColor3ForEffect;
  18447. private _updateColor3ForUniform;
  18448. private _updateColor4ForEffect;
  18449. private _updateColor4ForUniform;
  18450. /**
  18451. * Sets a sampler uniform on the effect.
  18452. * @param {string} name Name of the sampler.
  18453. * @param {Texture} texture
  18454. */
  18455. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  18456. /**
  18457. * Directly updates the value of the uniform in the cache AND on the GPU.
  18458. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18459. * @param {number[]|Float32Array} data Flattened data
  18460. */
  18461. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  18462. /**
  18463. * Binds this uniform buffer to an effect.
  18464. * @param {Effect} effect
  18465. * @param {string} name Name of the uniform block in the shader.
  18466. */
  18467. bindToEffect(effect: Effect, name: string): void;
  18468. /**
  18469. * Disposes the uniform buffer.
  18470. */
  18471. dispose(): void;
  18472. }
  18473. }
  18474. declare module BABYLON {
  18475. class Scalar {
  18476. /**
  18477. * Two pi constants convenient for computation.
  18478. */
  18479. static TwoPi: number;
  18480. /**
  18481. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  18482. */
  18483. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  18484. /**
  18485. * Returns a string : the upper case translation of the number i to hexadecimal.
  18486. */
  18487. static ToHex(i: number): string;
  18488. /**
  18489. * Returns -1 if value is negative and +1 is value is positive.
  18490. * Returns the value itself if it's equal to zero.
  18491. */
  18492. static Sign(value: number): number;
  18493. /**
  18494. * Returns the value itself if it's between min and max.
  18495. * Returns min if the value is lower than min.
  18496. * Returns max if the value is greater than max.
  18497. */
  18498. static Clamp(value: number, min?: number, max?: number): number;
  18499. /**
  18500. * Returns the log2 of value.
  18501. */
  18502. static Log2(value: number): number;
  18503. /**
  18504. * Loops the value, so that it is never larger than length and never smaller than 0.
  18505. *
  18506. * This is similar to the modulo operator but it works with floating point numbers.
  18507. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  18508. * With t = 5 and length = 2.5, the result would be 0.0.
  18509. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  18510. */
  18511. static Repeat(value: number, length: number): number;
  18512. /**
  18513. * Normalize the value between 0.0 and 1.0 using min and max values
  18514. */
  18515. static Normalize(value: number, min: number, max: number): number;
  18516. /**
  18517. * Denormalize the value from 0.0 and 1.0 using min and max values
  18518. */
  18519. static Denormalize(normalized: number, min: number, max: number): number;
  18520. /**
  18521. * Calculates the shortest difference between two given angles given in degrees.
  18522. */
  18523. static DeltaAngle(current: number, target: number): number;
  18524. /**
  18525. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  18526. *
  18527. * The returned value will move back and forth between 0 and length
  18528. */
  18529. static PingPong(tx: number, length: number): number;
  18530. /**
  18531. * Interpolates between min and max with smoothing at the limits.
  18532. *
  18533. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  18534. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  18535. */
  18536. static SmoothStep(from: number, to: number, tx: number): number;
  18537. /**
  18538. * Moves a value current towards target.
  18539. *
  18540. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  18541. * Negative values of maxDelta pushes the value away from target.
  18542. */
  18543. static MoveTowards(current: number, target: number, maxDelta: number): number;
  18544. /**
  18545. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  18546. *
  18547. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  18548. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  18549. */
  18550. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  18551. /**
  18552. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  18553. */
  18554. static Lerp(start: number, end: number, amount: number): number;
  18555. /**
  18556. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  18557. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  18558. */
  18559. static LerpAngle(start: number, end: number, amount: number): number;
  18560. /**
  18561. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  18562. */
  18563. static InverseLerp(a: number, b: number, value: number): number;
  18564. /**
  18565. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  18566. */
  18567. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  18568. /**
  18569. * Returns a random float number between and min and max values
  18570. */
  18571. static RandomRange(min: number, max: number): number;
  18572. /**
  18573. * This function returns percentage of a number in a given range.
  18574. *
  18575. * RangeToPercent(40,20,60) will return 0.5 (50%)
  18576. * RangeToPercent(34,0,100) will return 0.34 (34%)
  18577. */
  18578. static RangeToPercent(number: number, min: number, max: number): number;
  18579. /**
  18580. * This function returns number that corresponds to the percentage in a given range.
  18581. *
  18582. * PercentToRange(0.34,0,100) will return 34.
  18583. */
  18584. static PercentToRange(percent: number, min: number, max: number): number;
  18585. /**
  18586. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  18587. * @param angle The angle to normalize in radian.
  18588. * @return The converted angle.
  18589. */
  18590. static NormalizeRadians(angle: number): number;
  18591. }
  18592. }
  18593. declare module BABYLON {
  18594. /**
  18595. * Constant used to convert a value to gamma space
  18596. * @ignorenaming
  18597. */
  18598. const ToGammaSpace: number;
  18599. /**
  18600. * Constant used to convert a value to linear space
  18601. * @ignorenaming
  18602. */
  18603. const ToLinearSpace = 2.2;
  18604. /**
  18605. * Constant used to define the minimal number value in Babylon.js
  18606. * @ignorenaming
  18607. */
  18608. const Epsilon = 0.001;
  18609. /**
  18610. * Class used to hold a RBG color
  18611. */
  18612. class Color3 {
  18613. /**
  18614. * Defines the red component (between 0 and 1, default is 0)
  18615. */
  18616. r: number;
  18617. /**
  18618. * Defines the green component (between 0 and 1, default is 0)
  18619. */
  18620. g: number;
  18621. /**
  18622. * Defines the blue component (between 0 and 1, default is 0)
  18623. */
  18624. b: number;
  18625. /**
  18626. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  18627. * @param r defines the red component (between 0 and 1, default is 0)
  18628. * @param g defines the green component (between 0 and 1, default is 0)
  18629. * @param b defines the blue component (between 0 and 1, default is 0)
  18630. */
  18631. constructor(
  18632. /**
  18633. * Defines the red component (between 0 and 1, default is 0)
  18634. */
  18635. r?: number,
  18636. /**
  18637. * Defines the green component (between 0 and 1, default is 0)
  18638. */
  18639. g?: number,
  18640. /**
  18641. * Defines the blue component (between 0 and 1, default is 0)
  18642. */
  18643. b?: number);
  18644. /**
  18645. * Creates a string with the Color3 current values
  18646. * @returns the string representation of the Color3 object
  18647. */
  18648. toString(): string;
  18649. /**
  18650. * Returns the string "Color3"
  18651. * @returns "Color3"
  18652. */
  18653. getClassName(): string;
  18654. /**
  18655. * Compute the Color3 hash code
  18656. * @returns an unique number that can be used to hash Color3 objects
  18657. */
  18658. getHashCode(): number;
  18659. /**
  18660. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  18661. * @param array defines the array where to store the r,g,b components
  18662. * @param index defines an optional index in the target array to define where to start storing values
  18663. * @returns the current Color3 object
  18664. */
  18665. toArray(array: FloatArray, index?: number): Color3;
  18666. /**
  18667. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  18668. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  18669. * @returns a new {BABYLON.Color4} object
  18670. */
  18671. toColor4(alpha?: number): Color4;
  18672. /**
  18673. * Returns a new array populated with 3 numeric elements : red, green and blue values
  18674. * @returns the new array
  18675. */
  18676. asArray(): number[];
  18677. /**
  18678. * Returns the luminance value
  18679. * @returns a float value
  18680. */
  18681. toLuminance(): number;
  18682. /**
  18683. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  18684. * @param otherColor defines the second operand
  18685. * @returns the new Color3 object
  18686. */
  18687. multiply(otherColor: Color3): Color3;
  18688. /**
  18689. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  18690. * @param otherColor defines the second operand
  18691. * @param result defines the Color3 object where to store the result
  18692. * @returns the current Color3
  18693. */
  18694. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  18695. /**
  18696. * Determines equality between Color3 objects
  18697. * @param otherColor defines the second operand
  18698. * @returns true if the rgb values are equal to the given ones
  18699. */
  18700. equals(otherColor: Color3): boolean;
  18701. /**
  18702. * Determines equality between the current Color3 object and a set of r,b,g values
  18703. * @param r defines the red component to check
  18704. * @param g defines the green component to check
  18705. * @param b defines the blue component to check
  18706. * @returns true if the rgb values are equal to the given ones
  18707. */
  18708. equalsFloats(r: number, g: number, b: number): boolean;
  18709. /**
  18710. * Multiplies in place each rgb value by scale
  18711. * @param scale defines the scaling factor
  18712. * @returns the updated Color3
  18713. */
  18714. scale(scale: number): Color3;
  18715. /**
  18716. * Multiplies the rgb values by scale and stores the result into "result"
  18717. * @param scale defines the scaling factor
  18718. * @param result defines the Color3 object where to store the result
  18719. * @returns the unmodified current Color3
  18720. */
  18721. scaleToRef(scale: number, result: Color3): Color3;
  18722. /**
  18723. * Scale the current Color3 values by a factor and add the result to a given Color3
  18724. * @param scale defines the scale factor
  18725. * @param result defines color to store the result into
  18726. * @returns the unmodified current Color3
  18727. */
  18728. scaleAndAddToRef(scale: number, result: Color3): Color3;
  18729. /**
  18730. * Clamps the rgb values by the min and max values and stores the result into "result"
  18731. * @param min defines minimum clamping value (default is 0)
  18732. * @param max defines maximum clamping value (default is 1)
  18733. * @param result defines color to store the result into
  18734. * @returns the original Color3
  18735. */
  18736. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  18737. /**
  18738. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  18739. * @param otherColor defines the second operand
  18740. * @returns the new Color3
  18741. */
  18742. add(otherColor: Color3): Color3;
  18743. /**
  18744. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  18745. * @param otherColor defines the second operand
  18746. * @param result defines Color3 object to store the result into
  18747. * @returns the unmodified current Color3
  18748. */
  18749. addToRef(otherColor: Color3, result: Color3): Color3;
  18750. /**
  18751. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  18752. * @param otherColor defines the second operand
  18753. * @returns the new Color3
  18754. */
  18755. subtract(otherColor: Color3): Color3;
  18756. /**
  18757. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  18758. * @param otherColor defines the second operand
  18759. * @param result defines Color3 object to store the result into
  18760. * @returns the unmodified current Color3
  18761. */
  18762. subtractToRef(otherColor: Color3, result: Color3): Color3;
  18763. /**
  18764. * Copy the current object
  18765. * @returns a new Color3 copied the current one
  18766. */
  18767. clone(): Color3;
  18768. /**
  18769. * Copies the rgb values from the source in the current Color3
  18770. * @param source defines the source Color3 object
  18771. * @returns the updated Color3 object
  18772. */
  18773. copyFrom(source: Color3): Color3;
  18774. /**
  18775. * Updates the Color3 rgb values from the given floats
  18776. * @param r defines the red component to read from
  18777. * @param g defines the green component to read from
  18778. * @param b defines the blue component to read from
  18779. * @returns the current Color3 object
  18780. */
  18781. copyFromFloats(r: number, g: number, b: number): Color3;
  18782. /**
  18783. * Updates the Color3 rgb values from the given floats
  18784. * @param r defines the red component to read from
  18785. * @param g defines the green component to read from
  18786. * @param b defines the blue component to read from
  18787. * @returns the current Color3 object
  18788. */
  18789. set(r: number, g: number, b: number): Color3;
  18790. /**
  18791. * Compute the Color3 hexadecimal code as a string
  18792. * @returns a string containing the hexadecimal representation of the Color3 object
  18793. */
  18794. toHexString(): string;
  18795. /**
  18796. * Computes a new Color3 converted from the current one to linear space
  18797. * @returns a new Color3 object
  18798. */
  18799. toLinearSpace(): Color3;
  18800. /**
  18801. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  18802. * @param convertedColor defines the Color3 object where to store the linear space version
  18803. * @returns the unmodified Color3
  18804. */
  18805. toLinearSpaceToRef(convertedColor: Color3): Color3;
  18806. /**
  18807. * Computes a new Color3 converted from the current one to gamma space
  18808. * @returns a new Color3 object
  18809. */
  18810. toGammaSpace(): Color3;
  18811. /**
  18812. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  18813. * @param convertedColor defines the Color3 object where to store the gamma space version
  18814. * @returns the unmodified Color3
  18815. */
  18816. toGammaSpaceToRef(convertedColor: Color3): Color3;
  18817. /**
  18818. * Creates a new Color3 from the string containing valid hexadecimal values
  18819. * @param hex defines a string containing valid hexadecimal values
  18820. * @returns a new Color3 object
  18821. */
  18822. static FromHexString(hex: string): Color3;
  18823. /**
  18824. * Creates a new Vector3 from the starting index of the given array
  18825. * @param array defines the source array
  18826. * @param offset defines an offset in the source array
  18827. * @returns a new Color3 object
  18828. */
  18829. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  18830. /**
  18831. * Creates a new Color3 from integer values (< 256)
  18832. * @param r defines the red component to read from (value between 0 and 255)
  18833. * @param g defines the green component to read from (value between 0 and 255)
  18834. * @param b defines the blue component to read from (value between 0 and 255)
  18835. * @returns a new Color3 object
  18836. */
  18837. static FromInts(r: number, g: number, b: number): Color3;
  18838. /**
  18839. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  18840. * @param start defines the start Color3 value
  18841. * @param end defines the end Color3 value
  18842. * @param amount defines the gradient value between start and end
  18843. * @returns a new Color3 object
  18844. */
  18845. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  18846. /**
  18847. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  18848. * @param left defines the start value
  18849. * @param right defines the end value
  18850. * @param amount defines the gradient factor
  18851. * @param result defines the Color3 object where to store the result
  18852. */
  18853. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  18854. /**
  18855. * Returns a Color3 value containing a red color
  18856. * @returns a new Color3 object
  18857. */
  18858. static Red(): Color3;
  18859. /**
  18860. * Returns a Color3 value containing a green color
  18861. * @returns a new Color3 object
  18862. */
  18863. static Green(): Color3;
  18864. /**
  18865. * Returns a Color3 value containing a blue color
  18866. * @returns a new Color3 object
  18867. */
  18868. static Blue(): Color3;
  18869. /**
  18870. * Returns a Color3 value containing a black color
  18871. * @returns a new Color3 object
  18872. */
  18873. static Black(): Color3;
  18874. /**
  18875. * Returns a Color3 value containing a white color
  18876. * @returns a new Color3 object
  18877. */
  18878. static White(): Color3;
  18879. /**
  18880. * Returns a Color3 value containing a purple color
  18881. * @returns a new Color3 object
  18882. */
  18883. static Purple(): Color3;
  18884. /**
  18885. * Returns a Color3 value containing a magenta color
  18886. * @returns a new Color3 object
  18887. */
  18888. static Magenta(): Color3;
  18889. /**
  18890. * Returns a Color3 value containing a yellow color
  18891. * @returns a new Color3 object
  18892. */
  18893. static Yellow(): Color3;
  18894. /**
  18895. * Returns a Color3 value containing a gray color
  18896. * @returns a new Color3 object
  18897. */
  18898. static Gray(): Color3;
  18899. /**
  18900. * Returns a Color3 value containing a teal color
  18901. * @returns a new Color3 object
  18902. */
  18903. static Teal(): Color3;
  18904. /**
  18905. * Returns a Color3 value containing a random color
  18906. * @returns a new Color3 object
  18907. */
  18908. static Random(): Color3;
  18909. }
  18910. /**
  18911. * Class used to hold a RBGA color
  18912. */
  18913. class Color4 {
  18914. /**
  18915. * Defines the red component (between 0 and 1, default is 0)
  18916. */
  18917. r: number;
  18918. /**
  18919. * Defines the green component (between 0 and 1, default is 0)
  18920. */
  18921. g: number;
  18922. /**
  18923. * Defines the blue component (between 0 and 1, default is 0)
  18924. */
  18925. b: number;
  18926. /**
  18927. * Defines the alpha component (between 0 and 1, default is 1)
  18928. */
  18929. a: number;
  18930. /**
  18931. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  18932. * @param r defines the red component (between 0 and 1, default is 0)
  18933. * @param g defines the green component (between 0 and 1, default is 0)
  18934. * @param b defines the blue component (between 0 and 1, default is 0)
  18935. * @param a defines the alpha component (between 0 and 1, default is 1)
  18936. */
  18937. constructor(
  18938. /**
  18939. * Defines the red component (between 0 and 1, default is 0)
  18940. */
  18941. r?: number,
  18942. /**
  18943. * Defines the green component (between 0 and 1, default is 0)
  18944. */
  18945. g?: number,
  18946. /**
  18947. * Defines the blue component (between 0 and 1, default is 0)
  18948. */
  18949. b?: number,
  18950. /**
  18951. * Defines the alpha component (between 0 and 1, default is 1)
  18952. */
  18953. a?: number);
  18954. /**
  18955. * Adds in place the given Color4 values to the current Color4 object
  18956. * @param right defines the second operand
  18957. * @returns the current updated Color4 object
  18958. */
  18959. addInPlace(right: Color4): Color4;
  18960. /**
  18961. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  18962. * @returns the new array
  18963. */
  18964. asArray(): number[];
  18965. /**
  18966. * Stores from the starting index in the given array the Color4 successive values
  18967. * @param array defines the array where to store the r,g,b components
  18968. * @param index defines an optional index in the target array to define where to start storing values
  18969. * @returns the current Color4 object
  18970. */
  18971. toArray(array: number[], index?: number): Color4;
  18972. /**
  18973. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  18974. * @param right defines the second operand
  18975. * @returns a new Color4 object
  18976. */
  18977. add(right: Color4): Color4;
  18978. /**
  18979. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  18980. * @param right defines the second operand
  18981. * @returns a new Color4 object
  18982. */
  18983. subtract(right: Color4): Color4;
  18984. /**
  18985. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  18986. * @param right defines the second operand
  18987. * @param result defines the Color4 object where to store the result
  18988. * @returns the current Color4 object
  18989. */
  18990. subtractToRef(right: Color4, result: Color4): Color4;
  18991. /**
  18992. * Creates a new Color4 with the current Color4 values multiplied by scale
  18993. * @param scale defines the scaling factor to apply
  18994. * @returns a new Color4 object
  18995. */
  18996. scale(scale: number): Color4;
  18997. /**
  18998. * Multiplies the current Color4 values by scale and stores the result in "result"
  18999. * @param scale defines the scaling factor to apply
  19000. * @param result defines the Color4 object where to store the result
  19001. * @returns the current unmodified Color4
  19002. */
  19003. scaleToRef(scale: number, result: Color4): Color4;
  19004. /**
  19005. * Scale the current Color4 values by a factor and add the result to a given Color4
  19006. * @param scale defines the scale factor
  19007. * @param result defines the Color4 object where to store the result
  19008. * @returns the unmodified current Color4
  19009. */
  19010. scaleAndAddToRef(scale: number, result: Color4): Color4;
  19011. /**
  19012. * Clamps the rgb values by the min and max values and stores the result into "result"
  19013. * @param min defines minimum clamping value (default is 0)
  19014. * @param max defines maximum clamping value (default is 1)
  19015. * @param result defines color to store the result into.
  19016. * @returns the cuurent Color4
  19017. */
  19018. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  19019. /**
  19020. * Multipy an Color4 value by another and return a new Color4 object
  19021. * @param color defines the Color4 value to multiply by
  19022. * @returns a new Color4 object
  19023. */
  19024. multiply(color: Color4): Color4;
  19025. /**
  19026. * Multipy a Color4 value by another and push the result in a reference value
  19027. * @param color defines the Color4 value to multiply by
  19028. * @param result defines the Color4 to fill the result in
  19029. * @returns the result Color4
  19030. */
  19031. multiplyToRef(color: Color4, result: Color4): Color4;
  19032. /**
  19033. * Creates a string with the Color4 current values
  19034. * @returns the string representation of the Color4 object
  19035. */
  19036. toString(): string;
  19037. /**
  19038. * Returns the string "Color4"
  19039. * @returns "Color4"
  19040. */
  19041. getClassName(): string;
  19042. /**
  19043. * Compute the Color4 hash code
  19044. * @returns an unique number that can be used to hash Color4 objects
  19045. */
  19046. getHashCode(): number;
  19047. /**
  19048. * Creates a new Color4 copied from the current one
  19049. * @returns a new Color4 object
  19050. */
  19051. clone(): Color4;
  19052. /**
  19053. * Copies the given Color4 values into the current one
  19054. * @param source defines the source Color4 object
  19055. * @returns the current updated Color4 object
  19056. */
  19057. copyFrom(source: Color4): Color4;
  19058. /**
  19059. * Copies the given float values into the current one
  19060. * @param r defines the red component to read from
  19061. * @param g defines the green component to read from
  19062. * @param b defines the blue component to read from
  19063. * @param a defines the alpha component to read from
  19064. * @returns the current updated Color4 object
  19065. */
  19066. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  19067. /**
  19068. * Copies the given float values into the current one
  19069. * @param r defines the red component to read from
  19070. * @param g defines the green component to read from
  19071. * @param b defines the blue component to read from
  19072. * @param a defines the alpha component to read from
  19073. * @returns the current updated Color4 object
  19074. */
  19075. set(r: number, g: number, b: number, a: number): Color4;
  19076. /**
  19077. * Compute the Color4 hexadecimal code as a string
  19078. * @returns a string containing the hexadecimal representation of the Color4 object
  19079. */
  19080. toHexString(): string;
  19081. /**
  19082. * Computes a new Color4 converted from the current one to linear space
  19083. * @returns a new Color4 object
  19084. */
  19085. toLinearSpace(): Color4;
  19086. /**
  19087. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  19088. * @param convertedColor defines the Color4 object where to store the linear space version
  19089. * @returns the unmodified Color4
  19090. */
  19091. toLinearSpaceToRef(convertedColor: Color4): Color4;
  19092. /**
  19093. * Computes a new Color4 converted from the current one to gamma space
  19094. * @returns a new Color4 object
  19095. */
  19096. toGammaSpace(): Color4;
  19097. /**
  19098. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  19099. * @param convertedColor defines the Color4 object where to store the gamma space version
  19100. * @returns the unmodified Color4
  19101. */
  19102. toGammaSpaceToRef(convertedColor: Color4): Color4;
  19103. /**
  19104. * Creates a new Color4 from the string containing valid hexadecimal values
  19105. * @param hex defines a string containing valid hexadecimal values
  19106. * @returns a new Color4 object
  19107. */
  19108. static FromHexString(hex: string): Color4;
  19109. /**
  19110. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  19111. * @param left defines the start value
  19112. * @param right defines the end value
  19113. * @param amount defines the gradient factor
  19114. * @returns a new Color4 object
  19115. */
  19116. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  19117. /**
  19118. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  19119. * @param left defines the start value
  19120. * @param right defines the end value
  19121. * @param amount defines the gradient factor
  19122. * @param result defines the Color4 object where to store data
  19123. */
  19124. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  19125. /**
  19126. * Creates a new Color4 from a Color3 and an alpha value
  19127. * @param color3 defines the source Color3 to read from
  19128. * @param alpha defines the alpha component (1.0 by default)
  19129. * @returns a new Color4 object
  19130. */
  19131. static FromColor3(color3: Color3, alpha?: number): Color4;
  19132. /**
  19133. * Creates a new Color4 from the starting index element of the given array
  19134. * @param array defines the source array to read from
  19135. * @param offset defines the offset in the source array
  19136. * @returns a new Color4 object
  19137. */
  19138. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  19139. /**
  19140. * Creates a new Color3 from integer values (< 256)
  19141. * @param r defines the red component to read from (value between 0 and 255)
  19142. * @param g defines the green component to read from (value between 0 and 255)
  19143. * @param b defines the blue component to read from (value between 0 and 255)
  19144. * @param a defines the alpha component to read from (value between 0 and 255)
  19145. * @returns a new Color3 object
  19146. */
  19147. static FromInts(r: number, g: number, b: number, a: number): Color4;
  19148. /**
  19149. * Check the content of a given array and convert it to an array containing RGBA data
  19150. * If the original array was already containing count * 4 values then it is returned directly
  19151. * @param colors defines the array to check
  19152. * @param count defines the number of RGBA data to expect
  19153. * @returns an array containing count * 4 values (RGBA)
  19154. */
  19155. static CheckColors4(colors: number[], count: number): number[];
  19156. }
  19157. /**
  19158. * Class representing a vector containing 2 coordinates
  19159. */
  19160. class Vector2 {
  19161. /** defines the first coordinate */
  19162. x: number;
  19163. /** defines the second coordinate */
  19164. y: number;
  19165. /**
  19166. * Creates a new Vector2 from the given x and y coordinates
  19167. * @param x defines the first coordinate
  19168. * @param y defines the second coordinate
  19169. */
  19170. constructor(
  19171. /** defines the first coordinate */
  19172. x?: number,
  19173. /** defines the second coordinate */
  19174. y?: number);
  19175. /**
  19176. * Gets a string with the Vector2 coordinates
  19177. * @returns a string with the Vector2 coordinates
  19178. */
  19179. toString(): string;
  19180. /**
  19181. * Gets class name
  19182. * @returns the string "Vector2"
  19183. */
  19184. getClassName(): string;
  19185. /**
  19186. * Gets current vector hash code
  19187. * @returns the Vector2 hash code as a number
  19188. */
  19189. getHashCode(): number;
  19190. /**
  19191. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  19192. * @param array defines the source array
  19193. * @param index defines the offset in source array
  19194. * @returns the current Vector2
  19195. */
  19196. toArray(array: FloatArray, index?: number): Vector2;
  19197. /**
  19198. * Copy the current vector to an array
  19199. * @returns a new array with 2 elements: the Vector2 coordinates.
  19200. */
  19201. asArray(): number[];
  19202. /**
  19203. * Sets the Vector2 coordinates with the given Vector2 coordinates
  19204. * @param source defines the source Vector2
  19205. * @returns the current updated Vector2
  19206. */
  19207. copyFrom(source: Vector2): Vector2;
  19208. /**
  19209. * Sets the Vector2 coordinates with the given floats
  19210. * @param x defines the first coordinate
  19211. * @param y defines the second coordinate
  19212. * @returns the current updated Vector2
  19213. */
  19214. copyFromFloats(x: number, y: number): Vector2;
  19215. /**
  19216. * Sets the Vector2 coordinates with the given floats
  19217. * @param x defines the first coordinate
  19218. * @param y defines the second coordinate
  19219. * @returns the current updated Vector2
  19220. */
  19221. set(x: number, y: number): Vector2;
  19222. /**
  19223. * Add another vector with the current one
  19224. * @param otherVector defines the other vector
  19225. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  19226. */
  19227. add(otherVector: Vector2): Vector2;
  19228. /**
  19229. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  19230. * @param otherVector defines the other vector
  19231. * @param result defines the target vector
  19232. * @returns the unmodified current Vector2
  19233. */
  19234. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  19235. /**
  19236. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  19237. * @param otherVector defines the other vector
  19238. * @returns the current updated Vector2
  19239. */
  19240. addInPlace(otherVector: Vector2): Vector2;
  19241. /**
  19242. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  19243. * @param otherVector defines the other vector
  19244. * @returns a new Vector2
  19245. */
  19246. addVector3(otherVector: Vector3): Vector2;
  19247. /**
  19248. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  19249. * @param otherVector defines the other vector
  19250. * @returns a new Vector2
  19251. */
  19252. subtract(otherVector: Vector2): Vector2;
  19253. /**
  19254. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  19255. * @param otherVector defines the other vector
  19256. * @param result defines the target vector
  19257. * @returns the unmodified current Vector2
  19258. */
  19259. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  19260. /**
  19261. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  19262. * @param otherVector defines the other vector
  19263. * @returns the current updated Vector2
  19264. */
  19265. subtractInPlace(otherVector: Vector2): Vector2;
  19266. /**
  19267. * Multiplies in place the current Vector2 coordinates by the given ones
  19268. * @param otherVector defines the other vector
  19269. * @returns the current updated Vector2
  19270. */
  19271. multiplyInPlace(otherVector: Vector2): Vector2;
  19272. /**
  19273. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  19274. * @param otherVector defines the other vector
  19275. * @returns a new Vector2
  19276. */
  19277. multiply(otherVector: Vector2): Vector2;
  19278. /**
  19279. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  19280. * @param otherVector defines the other vector
  19281. * @param result defines the target vector
  19282. * @returns the unmodified current Vector2
  19283. */
  19284. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  19285. /**
  19286. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  19287. * @param x defines the first coordinate
  19288. * @param y defines the second coordinate
  19289. * @returns a new Vector2
  19290. */
  19291. multiplyByFloats(x: number, y: number): Vector2;
  19292. /**
  19293. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  19294. * @param otherVector defines the other vector
  19295. * @returns a new Vector2
  19296. */
  19297. divide(otherVector: Vector2): Vector2;
  19298. /**
  19299. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  19300. * @param otherVector defines the other vector
  19301. * @param result defines the target vector
  19302. * @returns the unmodified current Vector2
  19303. */
  19304. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  19305. /**
  19306. * Divides the current Vector2 coordinates by the given ones
  19307. * @param otherVector defines the other vector
  19308. * @returns the current updated Vector2
  19309. */
  19310. divideInPlace(otherVector: Vector2): Vector2;
  19311. /**
  19312. * Gets a new Vector2 with current Vector2 negated coordinates
  19313. * @returns a new Vector2
  19314. */
  19315. negate(): Vector2;
  19316. /**
  19317. * Multiply the Vector2 coordinates by scale
  19318. * @param scale defines the scaling factor
  19319. * @returns the current updated Vector2
  19320. */
  19321. scaleInPlace(scale: number): Vector2;
  19322. /**
  19323. * Returns a new Vector2 scaled by "scale" from the current Vector2
  19324. * @param scale defines the scaling factor
  19325. * @returns a new Vector2
  19326. */
  19327. scale(scale: number): Vector2;
  19328. /**
  19329. * Scale the current Vector2 values by a factor to a given Vector2
  19330. * @param scale defines the scale factor
  19331. * @param result defines the Vector2 object where to store the result
  19332. * @returns the unmodified current Vector2
  19333. */
  19334. scaleToRef(scale: number, result: Vector2): Vector2;
  19335. /**
  19336. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  19337. * @param scale defines the scale factor
  19338. * @param result defines the Vector2 object where to store the result
  19339. * @returns the unmodified current Vector2
  19340. */
  19341. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  19342. /**
  19343. * Gets a boolean if two vectors are equals
  19344. * @param otherVector defines the other vector
  19345. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  19346. */
  19347. equals(otherVector: Vector2): boolean;
  19348. /**
  19349. * Gets a boolean if two vectors are equals (using an epsilon value)
  19350. * @param otherVector defines the other vector
  19351. * @param epsilon defines the minimal distance to consider equality
  19352. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  19353. */
  19354. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  19355. /**
  19356. * Gets a new Vector2 from current Vector2 floored values
  19357. * @returns a new Vector2
  19358. */
  19359. floor(): Vector2;
  19360. /**
  19361. * Gets a new Vector2 from current Vector2 floored values
  19362. * @returns a new Vector2
  19363. */
  19364. fract(): Vector2;
  19365. /**
  19366. * Gets the length of the vector
  19367. * @returns the vector length (float)
  19368. */
  19369. length(): number;
  19370. /**
  19371. * Gets the vector squared length
  19372. * @returns the vector squared length (float)
  19373. */
  19374. lengthSquared(): number;
  19375. /**
  19376. * Normalize the vector
  19377. * @returns the current updated Vector2
  19378. */
  19379. normalize(): Vector2;
  19380. /**
  19381. * Gets a new Vector2 copied from the Vector2
  19382. * @returns a new Vector2
  19383. */
  19384. clone(): Vector2;
  19385. /**
  19386. * Gets a new Vector2(0, 0)
  19387. * @returns a new Vector2
  19388. */
  19389. static Zero(): Vector2;
  19390. /**
  19391. * Gets a new Vector2(1, 1)
  19392. * @returns a new Vector2
  19393. */
  19394. static One(): Vector2;
  19395. /**
  19396. * Gets a new Vector2 set from the given index element of the given array
  19397. * @param array defines the data source
  19398. * @param offset defines the offset in the data source
  19399. * @returns a new Vector2
  19400. */
  19401. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  19402. /**
  19403. * Sets "result" from the given index element of the given array
  19404. * @param array defines the data source
  19405. * @param offset defines the offset in the data source
  19406. * @param result defines the target vector
  19407. */
  19408. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  19409. /**
  19410. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  19411. * @param value1 defines 1st point of control
  19412. * @param value2 defines 2nd point of control
  19413. * @param value3 defines 3rd point of control
  19414. * @param value4 defines 4th point of control
  19415. * @param amount defines the interpolation factor
  19416. * @returns a new Vector2
  19417. */
  19418. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  19419. /**
  19420. * 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".
  19421. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  19422. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  19423. * @param value defines the value to clamp
  19424. * @param min defines the lower limit
  19425. * @param max defines the upper limit
  19426. * @returns a new Vector2
  19427. */
  19428. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  19429. /**
  19430. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  19431. * @param value1 defines the 1st control point
  19432. * @param tangent1 defines the outgoing tangent
  19433. * @param value2 defines the 2nd control point
  19434. * @param tangent2 defines the incoming tangent
  19435. * @param amount defines the interpolation factor
  19436. * @returns a new Vector2
  19437. */
  19438. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  19439. /**
  19440. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  19441. * @param start defines the start vector
  19442. * @param end defines the end vector
  19443. * @param amount defines the interpolation factor
  19444. * @returns a new Vector2
  19445. */
  19446. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  19447. /**
  19448. * Gets the dot product of the vector "left" and the vector "right"
  19449. * @param left defines first vector
  19450. * @param right defines second vector
  19451. * @returns the dot product (float)
  19452. */
  19453. static Dot(left: Vector2, right: Vector2): number;
  19454. /**
  19455. * Returns a new Vector2 equal to the normalized given vector
  19456. * @param vector defines the vector to normalize
  19457. * @returns a new Vector2
  19458. */
  19459. static Normalize(vector: Vector2): Vector2;
  19460. /**
  19461. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  19462. * @param left defines 1st vector
  19463. * @param right defines 2nd vector
  19464. * @returns a new Vector2
  19465. */
  19466. static Minimize(left: Vector2, right: Vector2): Vector2;
  19467. /**
  19468. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  19469. * @param left defines 1st vector
  19470. * @param right defines 2nd vector
  19471. * @returns a new Vector2
  19472. */
  19473. static Maximize(left: Vector2, right: Vector2): Vector2;
  19474. /**
  19475. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  19476. * @param vector defines the vector to transform
  19477. * @param transformation defines the matrix to apply
  19478. * @returns a new Vector2
  19479. */
  19480. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  19481. /**
  19482. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  19483. * @param vector defines the vector to transform
  19484. * @param transformation defines the matrix to apply
  19485. * @param result defines the target vector
  19486. */
  19487. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  19488. /**
  19489. * Determines if a given vector is included in a triangle
  19490. * @param p defines the vector to test
  19491. * @param p0 defines 1st triangle point
  19492. * @param p1 defines 2nd triangle point
  19493. * @param p2 defines 3rd triangle point
  19494. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  19495. */
  19496. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  19497. /**
  19498. * Gets the distance between the vectors "value1" and "value2"
  19499. * @param value1 defines first vector
  19500. * @param value2 defines second vector
  19501. * @returns the distance between vectors
  19502. */
  19503. static Distance(value1: Vector2, value2: Vector2): number;
  19504. /**
  19505. * Returns the squared distance between the vectors "value1" and "value2"
  19506. * @param value1 defines first vector
  19507. * @param value2 defines second vector
  19508. * @returns the squared distance between vectors
  19509. */
  19510. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  19511. /**
  19512. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  19513. * @param value1 defines first vector
  19514. * @param value2 defines second vector
  19515. * @returns a new Vector2
  19516. */
  19517. static Center(value1: Vector2, value2: Vector2): Vector2;
  19518. /**
  19519. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  19520. * @param p defines the middle point
  19521. * @param segA defines one point of the segment
  19522. * @param segB defines the other point of the segment
  19523. * @returns the shortest distance
  19524. */
  19525. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  19526. }
  19527. /**
  19528. * Classed used to store (x,y,z) vector representation
  19529. * A Vector3 is the main object used in 3D geometry
  19530. * It can represent etiher the coordinates of a point the space, either a direction
  19531. * Reminder: Babylon.js uses a left handed forward facing system
  19532. */
  19533. class Vector3 {
  19534. /**
  19535. * Defines the first coordinates (on X axis)
  19536. */
  19537. x: number;
  19538. /**
  19539. * Defines the second coordinates (on Y axis)
  19540. */
  19541. y: number;
  19542. /**
  19543. * Defines the third coordinates (on Z axis)
  19544. */
  19545. z: number;
  19546. /**
  19547. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  19548. * @param x defines the first coordinates (on X axis)
  19549. * @param y defines the second coordinates (on Y axis)
  19550. * @param z defines the third coordinates (on Z axis)
  19551. */
  19552. constructor(
  19553. /**
  19554. * Defines the first coordinates (on X axis)
  19555. */
  19556. x?: number,
  19557. /**
  19558. * Defines the second coordinates (on Y axis)
  19559. */
  19560. y?: number,
  19561. /**
  19562. * Defines the third coordinates (on Z axis)
  19563. */
  19564. z?: number);
  19565. /**
  19566. * Creates a string representation of the Vector3
  19567. * @returns a string with the Vector3 coordinates.
  19568. */
  19569. toString(): string;
  19570. /**
  19571. * Gets the class name
  19572. * @returns the string "Vector3"
  19573. */
  19574. getClassName(): string;
  19575. /**
  19576. * Creates the Vector3 hash code
  19577. * @returns a number which tends to be unique between Vector3 instances
  19578. */
  19579. getHashCode(): number;
  19580. /**
  19581. * Creates an array containing three elements : the coordinates of the Vector3
  19582. * @returns a new array of numbers
  19583. */
  19584. asArray(): number[];
  19585. /**
  19586. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  19587. * @param array defines the destination array
  19588. * @param index defines the offset in the destination array
  19589. * @returns the current Vector3
  19590. */
  19591. toArray(array: FloatArray, index?: number): Vector3;
  19592. /**
  19593. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  19594. * @returns a new Quaternion object, computed from the Vector3 coordinates
  19595. */
  19596. toQuaternion(): Quaternion;
  19597. /**
  19598. * Adds the given vector to the current Vector3
  19599. * @param otherVector defines the second operand
  19600. * @returns the current updated Vector3
  19601. */
  19602. addInPlace(otherVector: Vector3): Vector3;
  19603. /**
  19604. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  19605. * @param otherVector defines the second operand
  19606. * @returns the resulting Vector3
  19607. */
  19608. add(otherVector: Vector3): Vector3;
  19609. /**
  19610. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  19611. * @param otherVector defines the second operand
  19612. * @param result defines the Vector3 object where to store the result
  19613. * @returns the current Vector3
  19614. */
  19615. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  19616. /**
  19617. * Subtract the given vector from the current Vector3
  19618. * @param otherVector defines the second operand
  19619. * @returns the current updated Vector3
  19620. */
  19621. subtractInPlace(otherVector: Vector3): Vector3;
  19622. /**
  19623. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  19624. * @param otherVector defines the second operand
  19625. * @returns the resulting Vector3
  19626. */
  19627. subtract(otherVector: Vector3): Vector3;
  19628. /**
  19629. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  19630. * @param otherVector defines the second operand
  19631. * @param result defines the Vector3 object where to store the result
  19632. * @returns the current Vector3
  19633. */
  19634. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  19635. /**
  19636. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  19637. * @param x defines the x coordinate of the operand
  19638. * @param y defines the y coordinate of the operand
  19639. * @param z defines the z coordinate of the operand
  19640. * @returns the resulting Vector3
  19641. */
  19642. subtractFromFloats(x: number, y: number, z: number): Vector3;
  19643. /**
  19644. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  19645. * @param x defines the x coordinate of the operand
  19646. * @param y defines the y coordinate of the operand
  19647. * @param z defines the z coordinate of the operand
  19648. * @param result defines the Vector3 object where to store the result
  19649. * @returns the current Vector3
  19650. */
  19651. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  19652. /**
  19653. * Gets a new Vector3 set with the current Vector3 negated coordinates
  19654. * @returns a new Vector3
  19655. */
  19656. negate(): Vector3;
  19657. /**
  19658. * Multiplies the Vector3 coordinates by the float "scale"
  19659. * @param scale defines the multiplier factor
  19660. * @returns the current updated Vector3
  19661. */
  19662. scaleInPlace(scale: number): Vector3;
  19663. /**
  19664. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  19665. * @param scale defines the multiplier factor
  19666. * @returns a new Vector3
  19667. */
  19668. scale(scale: number): Vector3;
  19669. /**
  19670. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  19671. * @param scale defines the multiplier factor
  19672. * @param result defines the Vector3 object where to store the result
  19673. * @returns the current Vector3
  19674. */
  19675. scaleToRef(scale: number, result: Vector3): Vector3;
  19676. /**
  19677. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  19678. * @param scale defines the scale factor
  19679. * @param result defines the Vector3 object where to store the result
  19680. * @returns the unmodified current Vector3
  19681. */
  19682. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  19683. /**
  19684. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  19685. * @param otherVector defines the second operand
  19686. * @returns true if both vectors are equals
  19687. */
  19688. equals(otherVector: Vector3): boolean;
  19689. /**
  19690. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  19691. * @param otherVector defines the second operand
  19692. * @param epsilon defines the minimal distance to define values as equals
  19693. * @returns true if both vectors are distant less than epsilon
  19694. */
  19695. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  19696. /**
  19697. * Returns true if the current Vector3 coordinates equals the given floats
  19698. * @param x defines the x coordinate of the operand
  19699. * @param y defines the y coordinate of the operand
  19700. * @param z defines the z coordinate of the operand
  19701. * @returns true if both vectors are equals
  19702. */
  19703. equalsToFloats(x: number, y: number, z: number): boolean;
  19704. /**
  19705. * Multiplies the current Vector3 coordinates by the given ones
  19706. * @param otherVector defines the second operand
  19707. * @returns the current updated Vector3
  19708. */
  19709. multiplyInPlace(otherVector: Vector3): Vector3;
  19710. /**
  19711. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  19712. * @param otherVector defines the second operand
  19713. * @returns the new Vector3
  19714. */
  19715. multiply(otherVector: Vector3): Vector3;
  19716. /**
  19717. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  19718. * @param otherVector defines the second operand
  19719. * @param result defines the Vector3 object where to store the result
  19720. * @returns the current Vector3
  19721. */
  19722. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  19723. /**
  19724. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  19725. * @param x defines the x coordinate of the operand
  19726. * @param y defines the y coordinate of the operand
  19727. * @param z defines the z coordinate of the operand
  19728. * @returns the new Vector3
  19729. */
  19730. multiplyByFloats(x: number, y: number, z: number): Vector3;
  19731. /**
  19732. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  19733. * @param otherVector defines the second operand
  19734. * @returns the new Vector3
  19735. */
  19736. divide(otherVector: Vector3): Vector3;
  19737. /**
  19738. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  19739. * @param otherVector defines the second operand
  19740. * @param result defines the Vector3 object where to store the result
  19741. * @returns the current Vector3
  19742. */
  19743. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  19744. /**
  19745. * Divides the current Vector3 coordinates by the given ones.
  19746. * @param otherVector defines the second operand
  19747. * @returns the current updated Vector3
  19748. */
  19749. divideInPlace(otherVector: Vector3): Vector3;
  19750. /**
  19751. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  19752. * @param other defines the second operand
  19753. * @returns the current updated Vector3
  19754. */
  19755. minimizeInPlace(other: Vector3): Vector3;
  19756. /**
  19757. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  19758. * @param other defines the second operand
  19759. * @returns the current updated Vector3
  19760. */
  19761. maximizeInPlace(other: Vector3): Vector3;
  19762. /**
  19763. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  19764. */
  19765. readonly isNonUniform: boolean;
  19766. /**
  19767. * Gets a new Vector3 from current Vector3 floored values
  19768. * @returns a new Vector3
  19769. */
  19770. floor(): Vector3;
  19771. /**
  19772. * Gets a new Vector3 from current Vector3 floored values
  19773. * @returns a new Vector3
  19774. */
  19775. fract(): Vector3;
  19776. /**
  19777. * Gets the length of the Vector3
  19778. * @returns the length of the Vecto3
  19779. */
  19780. length(): number;
  19781. /**
  19782. * Gets the squared length of the Vector3
  19783. * @returns squared length of the Vector3
  19784. */
  19785. lengthSquared(): number;
  19786. /**
  19787. * Normalize the current Vector3.
  19788. * Please note that this is an in place operation.
  19789. * @returns the current updated Vector3
  19790. */
  19791. normalize(): Vector3;
  19792. /**
  19793. * Normalize the current Vector3 to a new vector
  19794. * @returns the new Vector3
  19795. */
  19796. normalizeToNew(): Vector3;
  19797. /**
  19798. * Normalize the current Vector3 to the reference
  19799. * @param reference define the Vector3 to update
  19800. * @returns the updated Vector3
  19801. */
  19802. normalizeToRef(reference: Vector3): Vector3;
  19803. /**
  19804. * Creates a new Vector3 copied from the current Vector3
  19805. * @returns the new Vector3
  19806. */
  19807. clone(): Vector3;
  19808. /**
  19809. * Copies the given vector coordinates to the current Vector3 ones
  19810. * @param source defines the source Vector3
  19811. * @returns the current updated Vector3
  19812. */
  19813. copyFrom(source: Vector3): Vector3;
  19814. /**
  19815. * Copies the given floats to the current Vector3 coordinates
  19816. * @param x defines the x coordinate of the operand
  19817. * @param y defines the y coordinate of the operand
  19818. * @param z defines the z coordinate of the operand
  19819. * @returns the current updated Vector3
  19820. */
  19821. copyFromFloats(x: number, y: number, z: number): Vector3;
  19822. /**
  19823. * Copies the given floats to the current Vector3 coordinates
  19824. * @param x defines the x coordinate of the operand
  19825. * @param y defines the y coordinate of the operand
  19826. * @param z defines the z coordinate of the operand
  19827. * @returns the current updated Vector3
  19828. */
  19829. set(x: number, y: number, z: number): Vector3;
  19830. /**
  19831. * Get the clip factor between two vectors
  19832. * @param vector0 defines the first operand
  19833. * @param vector1 defines the second operand
  19834. * @param axis defines the axis to use
  19835. * @param size defines the size along the axis
  19836. * @returns the clip factor
  19837. */
  19838. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  19839. /**
  19840. * Get angle between two vectors
  19841. * @param vector0 angle between vector0 and vector1
  19842. * @param vector1 angle between vector0 and vector1
  19843. * @param normal direction of the normal
  19844. * @return the angle between vector0 and vector1
  19845. */
  19846. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  19847. /**
  19848. * Returns a new Vector3 set from the index "offset" of the given array
  19849. * @param array defines the source array
  19850. * @param offset defines the offset in the source array
  19851. * @returns the new Vector3
  19852. */
  19853. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  19854. /**
  19855. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  19856. * This function is deprecated. Use FromArray instead
  19857. * @param array defines the source array
  19858. * @param offset defines the offset in the source array
  19859. * @returns the new Vector3
  19860. */
  19861. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  19862. /**
  19863. * Sets the given vector "result" with the element values from the index "offset" of the given array
  19864. * @param array defines the source array
  19865. * @param offset defines the offset in the source array
  19866. * @param result defines the Vector3 where to store the result
  19867. */
  19868. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  19869. /**
  19870. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  19871. * This function is deprecated. Use FromArrayToRef instead.
  19872. * @param array defines the source array
  19873. * @param offset defines the offset in the source array
  19874. * @param result defines the Vector3 where to store the result
  19875. */
  19876. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  19877. /**
  19878. * Sets the given vector "result" with the given floats.
  19879. * @param x defines the x coordinate of the source
  19880. * @param y defines the y coordinate of the source
  19881. * @param z defines the z coordinate of the source
  19882. * @param result defines the Vector3 where to store the result
  19883. */
  19884. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  19885. /**
  19886. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  19887. * @returns a new empty Vector3
  19888. */
  19889. static Zero(): Vector3;
  19890. /**
  19891. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  19892. * @returns a new unit Vector3
  19893. */
  19894. static One(): Vector3;
  19895. /**
  19896. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  19897. * @returns a new up Vector3
  19898. */
  19899. static Up(): Vector3;
  19900. /**
  19901. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  19902. * @returns a new down Vector3
  19903. */
  19904. static Down(): Vector3;
  19905. /**
  19906. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  19907. * @returns a new forward Vector3
  19908. */
  19909. static Forward(): Vector3;
  19910. /**
  19911. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  19912. * @returns a new forward Vector3
  19913. */
  19914. static Backward(): Vector3;
  19915. /**
  19916. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  19917. * @returns a new right Vector3
  19918. */
  19919. static Right(): Vector3;
  19920. /**
  19921. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  19922. * @returns a new left Vector3
  19923. */
  19924. static Left(): Vector3;
  19925. /**
  19926. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  19927. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  19928. * @param vector defines the Vector3 to transform
  19929. * @param transformation defines the transformation matrix
  19930. * @returns the transformed Vector3
  19931. */
  19932. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  19933. /**
  19934. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  19935. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  19936. * @param vector defines the Vector3 to transform
  19937. * @param transformation defines the transformation matrix
  19938. * @param result defines the Vector3 where to store the result
  19939. */
  19940. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  19941. /**
  19942. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  19943. * This method computes tranformed coordinates only, not transformed direction vectors
  19944. * @param x define the x coordinate of the source vector
  19945. * @param y define the y coordinate of the source vector
  19946. * @param z define the z coordinate of the source vector
  19947. * @param transformation defines the transformation matrix
  19948. * @param result defines the Vector3 where to store the result
  19949. */
  19950. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  19951. /**
  19952. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  19953. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  19954. * @param vector defines the Vector3 to transform
  19955. * @param transformation defines the transformation matrix
  19956. * @returns the new Vector3
  19957. */
  19958. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  19959. /**
  19960. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  19961. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  19962. * @param vector defines the Vector3 to transform
  19963. * @param transformation defines the transformation matrix
  19964. * @param result defines the Vector3 where to store the result
  19965. */
  19966. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  19967. /**
  19968. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  19969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  19970. * @param x define the x coordinate of the source vector
  19971. * @param y define the y coordinate of the source vector
  19972. * @param z define the z coordinate of the source vector
  19973. * @param transformation defines the transformation matrix
  19974. * @param result defines the Vector3 where to store the result
  19975. */
  19976. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  19977. /**
  19978. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  19979. * @param value1 defines the first control point
  19980. * @param value2 defines the second control point
  19981. * @param value3 defines the third control point
  19982. * @param value4 defines the fourth control point
  19983. * @param amount defines the amount on the spline to use
  19984. * @returns the new Vector3
  19985. */
  19986. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  19987. /**
  19988. * 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"
  19989. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  19990. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  19991. * @param value defines the current value
  19992. * @param min defines the lower range value
  19993. * @param max defines the upper range value
  19994. * @returns the new Vector3
  19995. */
  19996. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  19997. /**
  19998. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  19999. * @param value1 defines the first control point
  20000. * @param tangent1 defines the first tangent vector
  20001. * @param value2 defines the second control point
  20002. * @param tangent2 defines the second tangent vector
  20003. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  20004. * @returns the new Vector3
  20005. */
  20006. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  20007. /**
  20008. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  20009. * @param start defines the start value
  20010. * @param end defines the end value
  20011. * @param amount max defines amount between both (between 0 and 1)
  20012. * @returns the new Vector3
  20013. */
  20014. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  20015. /**
  20016. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  20017. * @param start defines the start value
  20018. * @param end defines the end value
  20019. * @param amount max defines amount between both (between 0 and 1)
  20020. * @param result defines the Vector3 where to store the result
  20021. */
  20022. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  20023. /**
  20024. * Returns the dot product (float) between the vectors "left" and "right"
  20025. * @param left defines the left operand
  20026. * @param right defines the right operand
  20027. * @returns the dot product
  20028. */
  20029. static Dot(left: Vector3, right: Vector3): number;
  20030. /**
  20031. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  20032. * The cross product is then orthogonal to both "left" and "right"
  20033. * @param left defines the left operand
  20034. * @param right defines the right operand
  20035. * @returns the cross product
  20036. */
  20037. static Cross(left: Vector3, right: Vector3): Vector3;
  20038. /**
  20039. * Sets the given vector "result" with the cross product of "left" and "right"
  20040. * The cross product is then orthogonal to both "left" and "right"
  20041. * @param left defines the left operand
  20042. * @param right defines the right operand
  20043. * @param result defines the Vector3 where to store the result
  20044. */
  20045. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  20046. /**
  20047. * Returns a new Vector3 as the normalization of the given vector
  20048. * @param vector defines the Vector3 to normalize
  20049. * @returns the new Vector3
  20050. */
  20051. static Normalize(vector: Vector3): Vector3;
  20052. /**
  20053. * Sets the given vector "result" with the normalization of the given first vector
  20054. * @param vector defines the Vector3 to normalize
  20055. * @param result defines the Vector3 where to store the result
  20056. */
  20057. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  20058. private static _viewportMatrixCache;
  20059. /**
  20060. * Project a Vector3 onto screen space
  20061. * @param vector defines the Vector3 to project
  20062. * @param world defines the world matrix to use
  20063. * @param transform defines the transform (view x projection) matrix to use
  20064. * @param viewport defines the screen viewport to use
  20065. * @returns the new Vector3
  20066. */
  20067. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  20068. /**
  20069. * Unproject from screen space to object space
  20070. * @param source defines the screen space Vector3 to use
  20071. * @param viewportWidth defines the current width of the viewport
  20072. * @param viewportHeight defines the current height of the viewport
  20073. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20074. * @param transform defines the transform (view x projection) matrix to use
  20075. * @returns the new Vector3
  20076. */
  20077. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  20078. /**
  20079. * Unproject from screen space to object space
  20080. * @param source defines the screen space Vector3 to use
  20081. * @param viewportWidth defines the current width of the viewport
  20082. * @param viewportHeight defines the current height of the viewport
  20083. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20084. * @param view defines the view matrix to use
  20085. * @param projection defines the projection matrix to use
  20086. * @returns the new Vector3
  20087. */
  20088. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  20089. /**
  20090. * Unproject from screen space to object space
  20091. * @param source defines the screen space Vector3 to use
  20092. * @param viewportWidth defines the current width of the viewport
  20093. * @param viewportHeight defines the current height of the viewport
  20094. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20095. * @param view defines the view matrix to use
  20096. * @param projection defines the projection matrix to use
  20097. * @param result defines the Vector3 where to store the result
  20098. */
  20099. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  20100. /**
  20101. * Unproject from screen space to object space
  20102. * @param sourceX defines the screen space x coordinate to use
  20103. * @param sourceY defines the screen space y coordinate to use
  20104. * @param sourceZ defines the screen space z coordinate to use
  20105. * @param viewportWidth defines the current width of the viewport
  20106. * @param viewportHeight defines the current height of the viewport
  20107. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20108. * @param view defines the view matrix to use
  20109. * @param projection defines the projection matrix to use
  20110. * @param result defines the Vector3 where to store the result
  20111. */
  20112. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  20113. /**
  20114. * Gets the minimal coordinate values between two Vector3
  20115. * @param left defines the first operand
  20116. * @param right defines the second operand
  20117. * @returns the new Vector3
  20118. */
  20119. static Minimize(left: Vector3, right: Vector3): Vector3;
  20120. /**
  20121. * Gets the maximal coordinate values between two Vector3
  20122. * @param left defines the first operand
  20123. * @param right defines the second operand
  20124. * @returns the new Vector3
  20125. */
  20126. static Maximize(left: Vector3, right: Vector3): Vector3;
  20127. /**
  20128. * Returns the distance between the vectors "value1" and "value2"
  20129. * @param value1 defines the first operand
  20130. * @param value2 defines the second operand
  20131. * @returns the distance
  20132. */
  20133. static Distance(value1: Vector3, value2: Vector3): number;
  20134. /**
  20135. * Returns the squared distance between the vectors "value1" and "value2"
  20136. * @param value1 defines the first operand
  20137. * @param value2 defines the second operand
  20138. * @returns the squared distance
  20139. */
  20140. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  20141. /**
  20142. * Returns a new Vector3 located at the center between "value1" and "value2"
  20143. * @param value1 defines the first operand
  20144. * @param value2 defines the second operand
  20145. * @returns the new Vector3
  20146. */
  20147. static Center(value1: Vector3, value2: Vector3): Vector3;
  20148. /**
  20149. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  20150. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  20151. * to something in order to rotate it from its local system to the given target system
  20152. * Note: axis1, axis2 and axis3 are normalized during this operation
  20153. * @param axis1 defines the first axis
  20154. * @param axis2 defines the second axis
  20155. * @param axis3 defines the third axis
  20156. * @returns a new Vector3
  20157. */
  20158. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  20159. /**
  20160. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  20161. * @param axis1 defines the first axis
  20162. * @param axis2 defines the second axis
  20163. * @param axis3 defines the third axis
  20164. * @param ref defines the Vector3 where to store the result
  20165. */
  20166. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  20167. }
  20168. class Vector4 {
  20169. x: number;
  20170. y: number;
  20171. z: number;
  20172. w: number;
  20173. /**
  20174. * Creates a Vector4 object from the given floats.
  20175. */
  20176. constructor(x: number, y: number, z: number, w: number);
  20177. /**
  20178. * Returns the string with the Vector4 coordinates.
  20179. */
  20180. toString(): string;
  20181. /**
  20182. * Returns the string "Vector4".
  20183. */
  20184. getClassName(): string;
  20185. /**
  20186. * Returns the Vector4 hash code.
  20187. */
  20188. getHashCode(): number;
  20189. /**
  20190. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  20191. */
  20192. asArray(): number[];
  20193. /**
  20194. * Populates the given array from the given index with the Vector4 coordinates.
  20195. * Returns the Vector4.
  20196. */
  20197. toArray(array: FloatArray, index?: number): Vector4;
  20198. /**
  20199. * Adds the given vector to the current Vector4.
  20200. * Returns the updated Vector4.
  20201. */
  20202. addInPlace(otherVector: Vector4): Vector4;
  20203. /**
  20204. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  20205. */
  20206. add(otherVector: Vector4): Vector4;
  20207. /**
  20208. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  20209. * Returns the current Vector4.
  20210. */
  20211. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  20212. /**
  20213. * Subtract in place the given vector from the current Vector4.
  20214. * Returns the updated Vector4.
  20215. */
  20216. subtractInPlace(otherVector: Vector4): Vector4;
  20217. /**
  20218. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  20219. */
  20220. subtract(otherVector: Vector4): Vector4;
  20221. /**
  20222. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  20223. * Returns the current Vector4.
  20224. */
  20225. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  20226. /**
  20227. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20228. */
  20229. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  20230. /**
  20231. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20232. * Returns the current Vector4.
  20233. */
  20234. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  20235. /**
  20236. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  20237. */
  20238. negate(): Vector4;
  20239. /**
  20240. * Multiplies the current Vector4 coordinates by scale (float).
  20241. * Returns the updated Vector4.
  20242. */
  20243. scaleInPlace(scale: number): Vector4;
  20244. /**
  20245. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  20246. */
  20247. scale(scale: number): Vector4;
  20248. /**
  20249. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  20250. * Returns the current Vector4.
  20251. */
  20252. scaleToRef(scale: number, result: Vector4): Vector4;
  20253. /**
  20254. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  20255. * @param scale defines the scale factor
  20256. * @param result defines the Vector4 object where to store the result
  20257. * @returns the unmodified current Vector4
  20258. */
  20259. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  20260. /**
  20261. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  20262. */
  20263. equals(otherVector: Vector4): boolean;
  20264. /**
  20265. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  20266. */
  20267. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  20268. /**
  20269. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  20270. */
  20271. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  20272. /**
  20273. * Multiplies in place the current Vector4 by the given one.
  20274. * Returns the updated Vector4.
  20275. */
  20276. multiplyInPlace(otherVector: Vector4): Vector4;
  20277. /**
  20278. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  20279. */
  20280. multiply(otherVector: Vector4): Vector4;
  20281. /**
  20282. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  20283. * Returns the current Vector4.
  20284. */
  20285. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  20286. /**
  20287. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  20288. */
  20289. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  20290. /**
  20291. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  20292. */
  20293. divide(otherVector: Vector4): Vector4;
  20294. /**
  20295. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  20296. * Returns the current Vector4.
  20297. */
  20298. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  20299. /**
  20300. * Divides the current Vector3 coordinates by the given ones.
  20301. * @returns the updated Vector3.
  20302. */
  20303. divideInPlace(otherVector: Vector4): Vector4;
  20304. /**
  20305. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  20306. * @param other defines the second operand
  20307. * @returns the current updated Vector4
  20308. */
  20309. minimizeInPlace(other: Vector4): Vector4;
  20310. /**
  20311. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  20312. * @param other defines the second operand
  20313. * @returns the current updated Vector4
  20314. */
  20315. maximizeInPlace(other: Vector4): Vector4;
  20316. /**
  20317. * Gets a new Vector4 from current Vector4 floored values
  20318. * @returns a new Vector4
  20319. */
  20320. floor(): Vector4;
  20321. /**
  20322. * Gets a new Vector4 from current Vector3 floored values
  20323. * @returns a new Vector4
  20324. */
  20325. fract(): Vector4;
  20326. /**
  20327. * Returns the Vector4 length (float).
  20328. */
  20329. length(): number;
  20330. /**
  20331. * Returns the Vector4 squared length (float).
  20332. */
  20333. lengthSquared(): number;
  20334. /**
  20335. * Normalizes in place the Vector4.
  20336. * Returns the updated Vector4.
  20337. */
  20338. normalize(): Vector4;
  20339. /**
  20340. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  20341. */
  20342. toVector3(): Vector3;
  20343. /**
  20344. * Returns a new Vector4 copied from the current one.
  20345. */
  20346. clone(): Vector4;
  20347. /**
  20348. * Updates the current Vector4 with the given one coordinates.
  20349. * Returns the updated Vector4.
  20350. */
  20351. copyFrom(source: Vector4): Vector4;
  20352. /**
  20353. * Updates the current Vector4 coordinates with the given floats.
  20354. * Returns the updated Vector4.
  20355. */
  20356. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  20357. /**
  20358. * Updates the current Vector4 coordinates with the given floats.
  20359. * Returns the updated Vector4.
  20360. */
  20361. set(x: number, y: number, z: number, w: number): Vector4;
  20362. /**
  20363. * Returns a new Vector4 set from the starting index of the given array.
  20364. */
  20365. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  20366. /**
  20367. * Updates the given vector "result" from the starting index of the given array.
  20368. */
  20369. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  20370. /**
  20371. * Updates the given vector "result" from the starting index of the given Float32Array.
  20372. */
  20373. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  20374. /**
  20375. * Updates the given vector "result" coordinates from the given floats.
  20376. */
  20377. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  20378. /**
  20379. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  20380. */
  20381. static Zero(): Vector4;
  20382. /**
  20383. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  20384. */
  20385. static One(): Vector4;
  20386. /**
  20387. * Returns a new normalized Vector4 from the given one.
  20388. */
  20389. static Normalize(vector: Vector4): Vector4;
  20390. /**
  20391. * Updates the given vector "result" from the normalization of the given one.
  20392. */
  20393. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  20394. static Minimize(left: Vector4, right: Vector4): Vector4;
  20395. static Maximize(left: Vector4, right: Vector4): Vector4;
  20396. /**
  20397. * Returns the distance (float) between the vectors "value1" and "value2".
  20398. */
  20399. static Distance(value1: Vector4, value2: Vector4): number;
  20400. /**
  20401. * Returns the squared distance (float) between the vectors "value1" and "value2".
  20402. */
  20403. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  20404. /**
  20405. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  20406. */
  20407. static Center(value1: Vector4, value2: Vector4): Vector4;
  20408. /**
  20409. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  20410. * This methods computes transformed normalized direction vectors only.
  20411. */
  20412. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  20413. /**
  20414. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  20415. * This methods computes transformed normalized direction vectors only.
  20416. */
  20417. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  20418. /**
  20419. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  20420. * This methods computes transformed normalized direction vectors only.
  20421. */
  20422. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  20423. }
  20424. interface ISize {
  20425. width: number;
  20426. height: number;
  20427. }
  20428. class Size implements ISize {
  20429. width: number;
  20430. height: number;
  20431. /**
  20432. * Creates a Size object from the given width and height (floats).
  20433. */
  20434. constructor(width: number, height: number);
  20435. toString(): string;
  20436. /**
  20437. * Returns the string "Size"
  20438. */
  20439. getClassName(): string;
  20440. /**
  20441. * Returns the Size hash code.
  20442. */
  20443. getHashCode(): number;
  20444. /**
  20445. * Updates the current size from the given one.
  20446. * Returns the updated Size.
  20447. */
  20448. copyFrom(src: Size): void;
  20449. /**
  20450. * Updates in place the current Size from the given floats.
  20451. * Returns the updated Size.
  20452. */
  20453. copyFromFloats(width: number, height: number): Size;
  20454. /**
  20455. * Updates in place the current Size from the given floats.
  20456. * Returns the updated Size.
  20457. */
  20458. set(width: number, height: number): Size;
  20459. /**
  20460. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  20461. */
  20462. multiplyByFloats(w: number, h: number): Size;
  20463. /**
  20464. * Returns a new Size copied from the given one.
  20465. */
  20466. clone(): Size;
  20467. /**
  20468. * Boolean : True if the current Size and the given one width and height are strictly equal.
  20469. */
  20470. equals(other: Size): boolean;
  20471. /**
  20472. * Returns the surface of the Size : width * height (float).
  20473. */
  20474. readonly surface: number;
  20475. /**
  20476. * Returns a new Size set to (0.0, 0.0)
  20477. */
  20478. static Zero(): Size;
  20479. /**
  20480. * Returns a new Size set as the addition result of the current Size and the given one.
  20481. */
  20482. add(otherSize: Size): Size;
  20483. /**
  20484. * Returns a new Size set as the subtraction result of the given one from the current Size.
  20485. */
  20486. subtract(otherSize: Size): Size;
  20487. /**
  20488. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  20489. */
  20490. static Lerp(start: Size, end: Size, amount: number): Size;
  20491. }
  20492. /**
  20493. * Class used to store quaternion data
  20494. * @see https://en.wikipedia.org/wiki/Quaternion
  20495. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  20496. */
  20497. class Quaternion {
  20498. /** defines the first component (0 by default) */
  20499. x: number;
  20500. /** defines the second component (0 by default) */
  20501. y: number;
  20502. /** defines the third component (0 by default) */
  20503. z: number;
  20504. /** defines the fourth component (1.0 by default) */
  20505. w: number;
  20506. /**
  20507. * Creates a new Quaternion from the given floats
  20508. * @param x defines the first component (0 by default)
  20509. * @param y defines the second component (0 by default)
  20510. * @param z defines the third component (0 by default)
  20511. * @param w defines the fourth component (1.0 by default)
  20512. */
  20513. constructor(
  20514. /** defines the first component (0 by default) */
  20515. x?: number,
  20516. /** defines the second component (0 by default) */
  20517. y?: number,
  20518. /** defines the third component (0 by default) */
  20519. z?: number,
  20520. /** defines the fourth component (1.0 by default) */
  20521. w?: number);
  20522. /**
  20523. * Gets a string representation for the current quaternion
  20524. * @returns a string with the Quaternion coordinates
  20525. */
  20526. toString(): string;
  20527. /**
  20528. * Gets the class name of the quaternion
  20529. * @returns the string "Quaternion"
  20530. */
  20531. getClassName(): string;
  20532. /**
  20533. * Gets a hash code for this quaternion
  20534. * @returns the quaternion hash code
  20535. */
  20536. getHashCode(): number;
  20537. /**
  20538. * Copy the quaternion to an array
  20539. * @returns a new array populated with 4 elements from the quaternion coordinates
  20540. */
  20541. asArray(): number[];
  20542. /**
  20543. * Check if two quaternions are equals
  20544. * @param otherQuaternion defines the second operand
  20545. * @return true if the current quaternion and the given one coordinates are strictly equals
  20546. */
  20547. equals(otherQuaternion: Quaternion): boolean;
  20548. /**
  20549. * Clone the current quaternion
  20550. * @returns a new quaternion copied from the current one
  20551. */
  20552. clone(): Quaternion;
  20553. /**
  20554. * Copy a quaternion to the current one
  20555. * @param other defines the other quaternion
  20556. * @returns the updated current quaternion
  20557. */
  20558. copyFrom(other: Quaternion): Quaternion;
  20559. /**
  20560. * Updates the current quaternion with the given float coordinates
  20561. * @param x defines the x coordinate
  20562. * @param y defines the y coordinate
  20563. * @param z defines the z coordinate
  20564. * @param w defines the w coordinate
  20565. * @returns the updated current quaternion
  20566. */
  20567. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  20568. /**
  20569. * Updates the current quaternion from the given float coordinates
  20570. * @param x defines the x coordinate
  20571. * @param y defines the y coordinate
  20572. * @param z defines the z coordinate
  20573. * @param w defines the w coordinate
  20574. * @returns the updated current quaternion
  20575. */
  20576. set(x: number, y: number, z: number, w: number): Quaternion;
  20577. /**
  20578. * Adds two quaternions
  20579. * @param other defines the second operand
  20580. * @returns a new quaternion as the addition result of the given one and the current quaternion
  20581. */
  20582. add(other: Quaternion): Quaternion;
  20583. /**
  20584. * Add a quaternion to the current one
  20585. * @param other defines the quaternion to add
  20586. * @returns the current quaternion
  20587. */
  20588. addInPlace(other: Quaternion): Quaternion;
  20589. /**
  20590. * Subtract two quaternions
  20591. * @param other defines the second operand
  20592. * @returns a new quaternion as the subtraction result of the given one from the current one
  20593. */
  20594. subtract(other: Quaternion): Quaternion;
  20595. /**
  20596. * Multiplies the current quaternion by a scale factor
  20597. * @param value defines the scale factor
  20598. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  20599. */
  20600. scale(value: number): Quaternion;
  20601. /**
  20602. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  20603. * @param scale defines the scale factor
  20604. * @param result defines the Quaternion object where to store the result
  20605. * @returns the unmodified current quaternion
  20606. */
  20607. scaleToRef(scale: number, result: Quaternion): Quaternion;
  20608. /**
  20609. * Multiplies in place the current quaternion by a scale factor
  20610. * @param value defines the scale factor
  20611. * @returns the current modified quaternion
  20612. */
  20613. scaleInPlace(value: number): Quaternion;
  20614. /**
  20615. * Scale the current quaternion values by a factor and add the result to a given quaternion
  20616. * @param scale defines the scale factor
  20617. * @param result defines the Quaternion object where to store the result
  20618. * @returns the unmodified current quaternion
  20619. */
  20620. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  20621. /**
  20622. * Multiplies two quaternions
  20623. * @param q1 defines the second operand
  20624. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  20625. */
  20626. multiply(q1: Quaternion): Quaternion;
  20627. /**
  20628. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  20629. * @param q1 defines the second operand
  20630. * @param result defines the target quaternion
  20631. * @returns the current quaternion
  20632. */
  20633. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  20634. /**
  20635. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  20636. * @param q1 defines the second operand
  20637. * @returns the currentupdated quaternion
  20638. */
  20639. multiplyInPlace(q1: Quaternion): Quaternion;
  20640. /**
  20641. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  20642. * @param ref defines the target quaternion
  20643. * @returns the current quaternion
  20644. */
  20645. conjugateToRef(ref: Quaternion): Quaternion;
  20646. /**
  20647. * Conjugates in place (1-q) the current quaternion
  20648. * @returns the current updated quaternion
  20649. */
  20650. conjugateInPlace(): Quaternion;
  20651. /**
  20652. * Conjugates in place (1-q) the current quaternion
  20653. * @returns a new quaternion
  20654. */
  20655. conjugate(): Quaternion;
  20656. /**
  20657. * Gets length of current quaternion
  20658. * @returns the quaternion length (float)
  20659. */
  20660. length(): number;
  20661. /**
  20662. * Normalize in place the current quaternion
  20663. * @returns the current updated quaternion
  20664. */
  20665. normalize(): Quaternion;
  20666. /**
  20667. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  20668. * @param order is a reserved parameter and is ignore for now
  20669. * @returns a new Vector3 containing the Euler angles
  20670. */
  20671. toEulerAngles(order?: string): Vector3;
  20672. /**
  20673. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  20674. * @param result defines the vector which will be filled with the Euler angles
  20675. * @param order is a reserved parameter and is ignore for now
  20676. * @returns the current unchanged quaternion
  20677. */
  20678. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  20679. /**
  20680. * Updates the given rotation matrix with the current quaternion values
  20681. * @param result defines the target matrix
  20682. * @returns the current unchanged quaternion
  20683. */
  20684. toRotationMatrix(result: Matrix): Quaternion;
  20685. /**
  20686. * Updates the current quaternion from the given rotation matrix values
  20687. * @param matrix defines the source matrix
  20688. * @returns the current updated quaternion
  20689. */
  20690. fromRotationMatrix(matrix: Matrix): Quaternion;
  20691. /**
  20692. * Creates a new quaternion from a rotation matrix
  20693. * @param matrix defines the source matrix
  20694. * @returns a new quaternion created from the given rotation matrix values
  20695. */
  20696. static FromRotationMatrix(matrix: Matrix): Quaternion;
  20697. /**
  20698. * Updates the given quaternion with the given rotation matrix values
  20699. * @param matrix defines the source matrix
  20700. * @param result defines the target quaternion
  20701. */
  20702. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  20703. /**
  20704. * Returns the dot product (float) between the quaternions "left" and "right"
  20705. * @param left defines the left operand
  20706. * @param right defines the right operand
  20707. * @returns the dot product
  20708. */
  20709. static Dot(left: Quaternion, right: Quaternion): number;
  20710. /**
  20711. * Checks if the two quaternions are close to each other
  20712. * @param quat0 defines the first quaternion to check
  20713. * @param quat1 defines the second quaternion to check
  20714. * @returns true if the two quaternions are close to each other
  20715. */
  20716. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  20717. /**
  20718. * Creates an empty quaternion
  20719. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  20720. */
  20721. static Zero(): Quaternion;
  20722. /**
  20723. * Inverse a given quaternion
  20724. * @param q defines the source quaternion
  20725. * @returns a new quaternion as the inverted current quaternion
  20726. */
  20727. static Inverse(q: Quaternion): Quaternion;
  20728. /**
  20729. * Creates an identity quaternion
  20730. * @returns the identity quaternion
  20731. */
  20732. static Identity(): Quaternion;
  20733. /**
  20734. * Gets a boolean indicating if the given quaternion is identity
  20735. * @param quaternion defines the quaternion to check
  20736. * @returns true if the quaternion is identity
  20737. */
  20738. static IsIdentity(quaternion: Quaternion): boolean;
  20739. /**
  20740. * Creates a quaternion from a rotation around an axis
  20741. * @param axis defines the axis to use
  20742. * @param angle defines the angle to use
  20743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  20744. */
  20745. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  20746. /**
  20747. * Creates a rotation around an axis and stores it into the given quaternion
  20748. * @param axis defines the axis to use
  20749. * @param angle defines the angle to use
  20750. * @param result defines the target quaternion
  20751. * @returns the target quaternion
  20752. */
  20753. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  20754. /**
  20755. * Creates a new quaternion from data stored into an array
  20756. * @param array defines the data source
  20757. * @param offset defines the offset in the source array where the data starts
  20758. * @returns a new quaternion
  20759. */
  20760. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  20761. /**
  20762. * Creates a new quaternion from the given Euler float angles (y, x, z)
  20763. * @param yaw defines the rotation around Y axis
  20764. * @param pitch defines the rotation around X axis
  20765. * @param roll defines the rotation around Z axis
  20766. * @returns the new quaternion
  20767. */
  20768. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  20769. /**
  20770. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  20771. * @param yaw defines the rotation around Y axis
  20772. * @param pitch defines the rotation around X axis
  20773. * @param roll defines the rotation around Z axis
  20774. * @param result defines the target quaternion
  20775. */
  20776. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  20777. /**
  20778. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  20779. * @param alpha defines the rotation around first axis
  20780. * @param beta defines the rotation around second axis
  20781. * @param gamma defines the rotation around third axis
  20782. * @returns the new quaternion
  20783. */
  20784. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  20785. /**
  20786. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  20787. * @param alpha defines the rotation around first axis
  20788. * @param beta defines the rotation around second axis
  20789. * @param gamma defines the rotation around third axis
  20790. * @param result defines the target quaternion
  20791. */
  20792. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  20793. /**
  20794. * 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)
  20795. * @param axis1 defines the first axis
  20796. * @param axis2 defines the second axis
  20797. * @param axis3 defines the third axis
  20798. * @returns the new quaternion
  20799. */
  20800. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  20801. /**
  20802. * 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
  20803. * @param axis1 defines the first axis
  20804. * @param axis2 defines the second axis
  20805. * @param axis3 defines the third axis
  20806. * @param ref defines the target quaternion
  20807. */
  20808. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  20809. /**
  20810. * Interpolates between two quaternions
  20811. * @param left defines first quaternion
  20812. * @param right defines second quaternion
  20813. * @param amount defines the gradient to use
  20814. * @returns the new interpolated quaternion
  20815. */
  20816. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  20817. /**
  20818. * Interpolates between two quaternions and stores it into a target quaternion
  20819. * @param left defines first quaternion
  20820. * @param right defines second quaternion
  20821. * @param amount defines the gradient to use
  20822. * @param result defines the target quaternion
  20823. */
  20824. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  20825. /**
  20826. * Interpolate between two quaternions using Hermite interpolation
  20827. * @param value1 defines first quaternion
  20828. * @param tangent1 defines the incoming tangent
  20829. * @param value2 defines second quaternion
  20830. * @param tangent2 defines the outgoing tangent
  20831. * @param amount defines the target quaternion
  20832. * @returns the new interpolated quaternion
  20833. */
  20834. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  20835. }
  20836. /**
  20837. * Class used to store matrix data (4x4)
  20838. */
  20839. class Matrix {
  20840. private static _tempQuaternion;
  20841. private static _xAxis;
  20842. private static _yAxis;
  20843. private static _zAxis;
  20844. private static _updateFlagSeed;
  20845. private static _identityReadOnly;
  20846. private _isIdentity;
  20847. private _isIdentityDirty;
  20848. /**
  20849. * Gets the update flag of the matrix which is an unique number for the matrix.
  20850. * It will be incremented every time the matrix data change.
  20851. * You can use it to speed the comparison between two versions of the same matrix.
  20852. */
  20853. updateFlag: number;
  20854. /**
  20855. * Gets or sets the internal data of the matrix
  20856. */
  20857. m: Float32Array;
  20858. /** @hidden */
  20859. _markAsUpdated(): void;
  20860. /**
  20861. * Creates an empty matrix (filled with zeros)
  20862. */
  20863. constructor();
  20864. /**
  20865. * Check if the current matrix is indentity
  20866. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  20867. * @returns true is the matrix is the identity matrix
  20868. */
  20869. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  20870. /**
  20871. * Gets the determinant of the matrix
  20872. * @returns the matrix determinant
  20873. */
  20874. determinant(): number;
  20875. /**
  20876. * Returns the matrix as a Float32Array
  20877. * @returns the matrix underlying array
  20878. */
  20879. toArray(): Float32Array;
  20880. /**
  20881. * Returns the matrix as a Float32Array
  20882. * @returns the matrix underlying array.
  20883. */
  20884. asArray(): Float32Array;
  20885. /**
  20886. * Inverts the current matrix in place
  20887. * @returns the current inverted matrix
  20888. */
  20889. invert(): Matrix;
  20890. /**
  20891. * Sets all the matrix elements to zero
  20892. * @returns the current matrix
  20893. */
  20894. reset(): Matrix;
  20895. /**
  20896. * Adds the current matrix with a second one
  20897. * @param other defines the matrix to add
  20898. * @returns a new matrix as the addition of the current matrix and the given one
  20899. */
  20900. add(other: Matrix): Matrix;
  20901. /**
  20902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  20903. * @param other defines the matrix to add
  20904. * @param result defines the target matrix
  20905. * @returns the current matrix
  20906. */
  20907. addToRef(other: Matrix, result: Matrix): Matrix;
  20908. /**
  20909. * Adds in place the given matrix to the current matrix
  20910. * @param other defines the second operand
  20911. * @returns the current updated matrix
  20912. */
  20913. addToSelf(other: Matrix): Matrix;
  20914. /**
  20915. * Sets the given matrix to the current inverted Matrix
  20916. * @param other defines the target matrix
  20917. * @returns the unmodified current matrix
  20918. */
  20919. invertToRef(other: Matrix): Matrix;
  20920. /**
  20921. * Inserts the translation vector (using 3 floats) in the current matrix
  20922. * @param x defines the 1st component of the translation
  20923. * @param y defines the 2nd component of the translation
  20924. * @param z defines the 3rd component of the translation
  20925. * @returns the current updated matrix
  20926. */
  20927. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  20928. /**
  20929. * Inserts the translation vector in the current matrix
  20930. * @param vector3 defines the translation to insert
  20931. * @returns the current updated matrix
  20932. */
  20933. setTranslation(vector3: Vector3): Matrix;
  20934. /**
  20935. * Gets the translation value of the current matrix
  20936. * @returns a new Vector3 as the extracted translation from the matrix
  20937. */
  20938. getTranslation(): Vector3;
  20939. /**
  20940. * Fill a Vector3 with the extracted translation from the matrix
  20941. * @param result defines the Vector3 where to store the translation
  20942. * @returns the current matrix
  20943. */
  20944. getTranslationToRef(result: Vector3): Matrix;
  20945. /**
  20946. * Remove rotation and scaling part from the matrix
  20947. * @returns the updated matrix
  20948. */
  20949. removeRotationAndScaling(): Matrix;
  20950. /**
  20951. * Multiply two matrices
  20952. * @param other defines the second operand
  20953. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  20954. */
  20955. multiply(other: Matrix): Matrix;
  20956. /**
  20957. * Copy the current matrix from the given one
  20958. * @param other defines the source matrix
  20959. * @returns the current updated matrix
  20960. */
  20961. copyFrom(other: Matrix): Matrix;
  20962. /**
  20963. * Populates the given array from the starting index with the current matrix values
  20964. * @param array defines the target array
  20965. * @param offset defines the offset in the target array where to start storing values
  20966. * @returns the current matrix
  20967. */
  20968. copyToArray(array: Float32Array, offset?: number): Matrix;
  20969. /**
  20970. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  20971. * @param other defines the second operand
  20972. * @param result defines the matrix where to store the multiplication
  20973. * @returns the current matrix
  20974. */
  20975. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  20976. /**
  20977. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  20978. * @param other defines the second operand
  20979. * @param result defines the array where to store the multiplication
  20980. * @param offset defines the offset in the target array where to start storing values
  20981. * @returns the current matrix
  20982. */
  20983. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  20984. /**
  20985. * Check equality between this matrix and a second one
  20986. * @param value defines the second matrix to compare
  20987. * @returns true is the current matrix and the given one values are strictly equal
  20988. */
  20989. equals(value: Matrix): boolean;
  20990. /**
  20991. * Clone the current matrix
  20992. * @returns a new matrix from the current matrix
  20993. */
  20994. clone(): Matrix;
  20995. /**
  20996. * Returns the name of the current matrix class
  20997. * @returns the string "Matrix"
  20998. */
  20999. getClassName(): string;
  21000. /**
  21001. * Gets the hash code of the current matrix
  21002. * @returns the hash code
  21003. */
  21004. getHashCode(): number;
  21005. /**
  21006. * Decomposes the current Matrix into a translation, rotation and scaling components
  21007. * @param scale defines the scale vector3 given as a reference to update
  21008. * @param rotation defines the rotation quaternion given as a reference to update
  21009. * @param translation defines the translation vector3 given as a reference to update
  21010. * @returns true if operation was successful
  21011. */
  21012. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  21013. /**
  21014. * Gets specific row of the matrix
  21015. * @param index defines the number of the row to get
  21016. * @returns the index-th row of the current matrix as a new Vector4
  21017. */
  21018. getRow(index: number): Nullable<Vector4>;
  21019. /**
  21020. * Sets the index-th row of the current matrix to the vector4 values
  21021. * @param index defines the number of the row to set
  21022. * @param row defines the target vector4
  21023. * @returns the updated current matrix
  21024. */
  21025. setRow(index: number, row: Vector4): Matrix;
  21026. /**
  21027. * Compute the transpose of the matrix
  21028. * @returns the new transposed matrix
  21029. */
  21030. transpose(): Matrix;
  21031. /**
  21032. * Compute the transpose of the matrix and store it in a given matrix
  21033. * @param result defines the target matrix
  21034. * @returns the current matrix
  21035. */
  21036. transposeToRef(result: Matrix): Matrix;
  21037. /**
  21038. * Sets the index-th row of the current matrix with the given 4 x float values
  21039. * @param index defines the row index
  21040. * @param x defines the x component to set
  21041. * @param y defines the y component to set
  21042. * @param z defines the z component to set
  21043. * @param w defines the w component to set
  21044. * @returns the updated current matrix
  21045. */
  21046. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  21047. /**
  21048. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  21049. * @param scale defines the scale factor
  21050. * @returns a new matrix
  21051. */
  21052. scale(scale: number): Matrix;
  21053. /**
  21054. * Scale the current matrix values by a factor to a given result matrix
  21055. * @param scale defines the scale factor
  21056. * @param result defines the matrix to store the result
  21057. * @returns the current matrix
  21058. */
  21059. scaleToRef(scale: number, result: Matrix): Matrix;
  21060. /**
  21061. * Scale the current matrix values by a factor and add the result to a given matrix
  21062. * @param scale defines the scale factor
  21063. * @param result defines the Matrix to store the result
  21064. * @returns the current matrix
  21065. */
  21066. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  21067. /**
  21068. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  21069. * @param ref matrix to store the result
  21070. */
  21071. toNormalMatrix(ref: Matrix): void;
  21072. /**
  21073. * Gets only rotation part of the current matrix
  21074. * @returns a new matrix sets to the extracted rotation matrix from the current one
  21075. */
  21076. getRotationMatrix(): Matrix;
  21077. /**
  21078. * Extracts the rotation matrix from the current one and sets it as the given "result"
  21079. * @param result defines the target matrix to store data to
  21080. * @returns the current matrix
  21081. */
  21082. getRotationMatrixToRef(result: Matrix): Matrix;
  21083. /**
  21084. * Creates a matrix from an array
  21085. * @param array defines the source array
  21086. * @param offset defines an offset in the source array
  21087. * @returns a new Matrix set from the starting index of the given array
  21088. */
  21089. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  21090. /**
  21091. * Copy the content of an array into a given matrix
  21092. * @param array defines the source array
  21093. * @param offset defines an offset in the source array
  21094. * @param result defines the target matrix
  21095. */
  21096. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  21097. /**
  21098. * Stores an array into a matrix after having multiplied each component by a given factor
  21099. * @param array defines the source array
  21100. * @param offset defines the offset in the source array
  21101. * @param scale defines the scaling factor
  21102. * @param result defines the target matrix
  21103. */
  21104. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  21105. /**
  21106. * Stores a list of values (16) inside a given matrix
  21107. * @param initialM11 defines 1st value of 1st row
  21108. * @param initialM12 defines 2nd value of 1st row
  21109. * @param initialM13 defines 3rd value of 1st row
  21110. * @param initialM14 defines 4th value of 1st row
  21111. * @param initialM21 defines 1st value of 2nd row
  21112. * @param initialM22 defines 2nd value of 2nd row
  21113. * @param initialM23 defines 3rd value of 2nd row
  21114. * @param initialM24 defines 4th value of 2nd row
  21115. * @param initialM31 defines 1st value of 3rd row
  21116. * @param initialM32 defines 2nd value of 3rd row
  21117. * @param initialM33 defines 3rd value of 3rd row
  21118. * @param initialM34 defines 4th value of 3rd row
  21119. * @param initialM41 defines 1st value of 4th row
  21120. * @param initialM42 defines 2nd value of 4th row
  21121. * @param initialM43 defines 3rd value of 4th row
  21122. * @param initialM44 defines 4th value of 4th row
  21123. * @param result defines the target matrix
  21124. */
  21125. 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;
  21126. /**
  21127. * Gets an identity matrix that must not be updated
  21128. */
  21129. static readonly IdentityReadOnly: Matrix;
  21130. /**
  21131. * Creates new matrix from a list of values (16)
  21132. * @param initialM11 defines 1st value of 1st row
  21133. * @param initialM12 defines 2nd value of 1st row
  21134. * @param initialM13 defines 3rd value of 1st row
  21135. * @param initialM14 defines 4th value of 1st row
  21136. * @param initialM21 defines 1st value of 2nd row
  21137. * @param initialM22 defines 2nd value of 2nd row
  21138. * @param initialM23 defines 3rd value of 2nd row
  21139. * @param initialM24 defines 4th value of 2nd row
  21140. * @param initialM31 defines 1st value of 3rd row
  21141. * @param initialM32 defines 2nd value of 3rd row
  21142. * @param initialM33 defines 3rd value of 3rd row
  21143. * @param initialM34 defines 4th value of 3rd row
  21144. * @param initialM41 defines 1st value of 4th row
  21145. * @param initialM42 defines 2nd value of 4th row
  21146. * @param initialM43 defines 3rd value of 4th row
  21147. * @param initialM44 defines 4th value of 4th row
  21148. * @returns the new matrix
  21149. */
  21150. 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;
  21151. /**
  21152. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  21153. * @param scale defines the scale vector3
  21154. * @param rotation defines the rotation quaternion
  21155. * @param translation defines the translation vector3
  21156. * @returns a new matrix
  21157. */
  21158. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  21159. /**
  21160. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  21161. * @param scale defines the scale vector3
  21162. * @param rotation defines the rotation quaternion
  21163. * @param translation defines the translation vector3
  21164. * @param result defines the target matrix
  21165. */
  21166. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  21167. /**
  21168. * Creates a new identity matrix
  21169. * @returns a new identity matrix
  21170. */
  21171. static Identity(): Matrix;
  21172. /**
  21173. * Creates a new identity matrix and stores the result in a given matrix
  21174. * @param result defines the target matrix
  21175. */
  21176. static IdentityToRef(result: Matrix): void;
  21177. /**
  21178. * Creates a new zero matrix
  21179. * @returns a new zero matrix
  21180. */
  21181. static Zero(): Matrix;
  21182. /**
  21183. * Creates a new rotation matrix for "angle" radians around the X axis
  21184. * @param angle defines the angle (in radians) to use
  21185. * @return the new matrix
  21186. */
  21187. static RotationX(angle: number): Matrix;
  21188. /**
  21189. * Creates a new matrix as the invert of a given matrix
  21190. * @param source defines the source matrix
  21191. * @returns the new matrix
  21192. */
  21193. static Invert(source: Matrix): Matrix;
  21194. /**
  21195. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  21196. * @param angle defines the angle (in radians) to use
  21197. * @param result defines the target matrix
  21198. */
  21199. static RotationXToRef(angle: number, result: Matrix): void;
  21200. /**
  21201. * Creates a new rotation matrix for "angle" radians around the Y axis
  21202. * @param angle defines the angle (in radians) to use
  21203. * @return the new matrix
  21204. */
  21205. static RotationY(angle: number): Matrix;
  21206. /**
  21207. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  21208. * @param angle defines the angle (in radians) to use
  21209. * @param result defines the target matrix
  21210. */
  21211. static RotationYToRef(angle: number, result: Matrix): void;
  21212. /**
  21213. * Creates a new rotation matrix for "angle" radians around the Z axis
  21214. * @param angle defines the angle (in radians) to use
  21215. * @return the new matrix
  21216. */
  21217. static RotationZ(angle: number): Matrix;
  21218. /**
  21219. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  21220. * @param angle defines the angle (in radians) to use
  21221. * @param result defines the target matrix
  21222. */
  21223. static RotationZToRef(angle: number, result: Matrix): void;
  21224. /**
  21225. * Creates a new rotation matrix for "angle" radians around the given axis
  21226. * @param axis defines the axis to use
  21227. * @param angle defines the angle (in radians) to use
  21228. * @return the new matrix
  21229. */
  21230. static RotationAxis(axis: Vector3, angle: number): Matrix;
  21231. /**
  21232. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  21233. * @param axis defines the axis to use
  21234. * @param angle defines the angle (in radians) to use
  21235. * @param result defines the target matrix
  21236. */
  21237. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  21238. /**
  21239. * Creates a rotation matrix
  21240. * @param yaw defines the yaw angle in radians (Y axis)
  21241. * @param pitch defines the pitch angle in radians (X axis)
  21242. * @param roll defines the roll angle in radians (X axis)
  21243. * @returns the new rotation matrix
  21244. */
  21245. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  21246. /**
  21247. * Creates a rotation matrix and stores it in a given matrix
  21248. * @param yaw defines the yaw angle in radians (Y axis)
  21249. * @param pitch defines the pitch angle in radians (X axis)
  21250. * @param roll defines the roll angle in radians (X axis)
  21251. * @param result defines the target matrix
  21252. */
  21253. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  21254. /**
  21255. * Creates a scaling matrix
  21256. * @param x defines the scale factor on X axis
  21257. * @param y defines the scale factor on Y axis
  21258. * @param z defines the scale factor on Z axis
  21259. * @returns the new matrix
  21260. */
  21261. static Scaling(x: number, y: number, z: number): Matrix;
  21262. /**
  21263. * Creates a scaling matrix and stores it in a given matrix
  21264. * @param x defines the scale factor on X axis
  21265. * @param y defines the scale factor on Y axis
  21266. * @param z defines the scale factor on Z axis
  21267. * @param result defines the target matrix
  21268. */
  21269. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  21270. /**
  21271. * Creates a translation matrix
  21272. * @param x defines the translation on X axis
  21273. * @param y defines the translation on Y axis
  21274. * @param z defines the translationon Z axis
  21275. * @returns the new matrix
  21276. */
  21277. static Translation(x: number, y: number, z: number): Matrix;
  21278. /**
  21279. * Creates a translation matrix and stores it in a given matrix
  21280. * @param x defines the translation on X axis
  21281. * @param y defines the translation on Y axis
  21282. * @param z defines the translationon Z axis
  21283. * @param result defines the target matrix
  21284. */
  21285. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  21286. /**
  21287. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  21288. * @param startValue defines the start value
  21289. * @param endValue defines the end value
  21290. * @param gradient defines the gradient factor
  21291. * @returns the new matrix
  21292. */
  21293. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  21294. /**
  21295. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  21296. * @param startValue defines the start value
  21297. * @param endValue defines the end value
  21298. * @param gradient defines the gradient factor
  21299. * @param result defines the Matrix object where to store data
  21300. */
  21301. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  21302. /**
  21303. * Builds a new matrix whose values are computed by:
  21304. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  21305. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  21306. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  21307. * @param startValue defines the first matrix
  21308. * @param endValue defines the second matrix
  21309. * @param gradient defines the gradient between the two matrices
  21310. * @returns the new matrix
  21311. */
  21312. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  21313. /**
  21314. * Update a matrix to values which are computed by:
  21315. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  21316. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  21317. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  21318. * @param startValue defines the first matrix
  21319. * @param endValue defines the second matrix
  21320. * @param gradient defines the gradient between the two matrices
  21321. * @param result defines the target matrix
  21322. */
  21323. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  21324. /**
  21325. * 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"
  21326. * This function works in left handed mode
  21327. * @param eye defines the final position of the entity
  21328. * @param target defines where the entity should look at
  21329. * @param up defines the up vector for the entity
  21330. * @returns the new matrix
  21331. */
  21332. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  21333. /**
  21334. * 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".
  21335. * This function works in left handed mode
  21336. * @param eye defines the final position of the entity
  21337. * @param target defines where the entity should look at
  21338. * @param up defines the up vector for the entity
  21339. * @param result defines the target matrix
  21340. */
  21341. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  21342. /**
  21343. * 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"
  21344. * This function works in right handed mode
  21345. * @param eye defines the final position of the entity
  21346. * @param target defines where the entity should look at
  21347. * @param up defines the up vector for the entity
  21348. * @returns the new matrix
  21349. */
  21350. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  21351. /**
  21352. * 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".
  21353. * This function works in right handed mode
  21354. * @param eye defines the final position of the entity
  21355. * @param target defines where the entity should look at
  21356. * @param up defines the up vector for the entity
  21357. * @param result defines the target matrix
  21358. */
  21359. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  21360. /**
  21361. * Create a left-handed orthographic projection matrix
  21362. * @param width defines the viewport width
  21363. * @param height defines the viewport height
  21364. * @param znear defines the near clip plane
  21365. * @param zfar defines the far clip plane
  21366. * @returns a new matrix as a left-handed orthographic projection matrix
  21367. */
  21368. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  21369. /**
  21370. * Store a left-handed orthographic projection to a given matrix
  21371. * @param width defines the viewport width
  21372. * @param height defines the viewport height
  21373. * @param znear defines the near clip plane
  21374. * @param zfar defines the far clip plane
  21375. * @param result defines the target matrix
  21376. */
  21377. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  21378. /**
  21379. * Create a left-handed orthographic projection matrix
  21380. * @param left defines the viewport left coordinate
  21381. * @param right defines the viewport right coordinate
  21382. * @param bottom defines the viewport bottom coordinate
  21383. * @param top defines the viewport top coordinate
  21384. * @param znear defines the near clip plane
  21385. * @param zfar defines the far clip plane
  21386. * @returns a new matrix as a left-handed orthographic projection matrix
  21387. */
  21388. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  21389. /**
  21390. * Stores a left-handed orthographic projection into a given matrix
  21391. * @param left defines the viewport left coordinate
  21392. * @param right defines the viewport right coordinate
  21393. * @param bottom defines the viewport bottom coordinate
  21394. * @param top defines the viewport top coordinate
  21395. * @param znear defines the near clip plane
  21396. * @param zfar defines the far clip plane
  21397. * @param result defines the target matrix
  21398. */
  21399. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  21400. /**
  21401. * Creates a right-handed orthographic projection matrix
  21402. * @param left defines the viewport left coordinate
  21403. * @param right defines the viewport right coordinate
  21404. * @param bottom defines the viewport bottom coordinate
  21405. * @param top defines the viewport top coordinate
  21406. * @param znear defines the near clip plane
  21407. * @param zfar defines the far clip plane
  21408. * @returns a new matrix as a right-handed orthographic projection matrix
  21409. */
  21410. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  21411. /**
  21412. * Stores a right-handed orthographic projection into a given matrix
  21413. * @param left defines the viewport left coordinate
  21414. * @param right defines the viewport right coordinate
  21415. * @param bottom defines the viewport bottom coordinate
  21416. * @param top defines the viewport top coordinate
  21417. * @param znear defines the near clip plane
  21418. * @param zfar defines the far clip plane
  21419. * @param result defines the target matrix
  21420. */
  21421. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  21422. /**
  21423. * Creates a left-handed perspective projection matrix
  21424. * @param width defines the viewport width
  21425. * @param height defines the viewport height
  21426. * @param znear defines the near clip plane
  21427. * @param zfar defines the far clip plane
  21428. * @returns a new matrix as a left-handed perspective projection matrix
  21429. */
  21430. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  21431. /**
  21432. * Creates a left-handed perspective projection matrix
  21433. * @param fov defines the horizontal field of view
  21434. * @param aspect defines the aspect ratio
  21435. * @param znear defines the near clip plane
  21436. * @param zfar defines the far clip plane
  21437. * @returns a new matrix as a left-handed perspective projection matrix
  21438. */
  21439. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  21440. /**
  21441. * Stores a left-handed perspective projection into a given matrix
  21442. * @param fov defines the horizontal field of view
  21443. * @param aspect defines the aspect ratio
  21444. * @param znear defines the near clip plane
  21445. * @param zfar defines the far clip plane
  21446. * @param result defines the target matrix
  21447. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  21448. */
  21449. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  21450. /**
  21451. * Creates a right-handed perspective projection matrix
  21452. * @param fov defines the horizontal field of view
  21453. * @param aspect defines the aspect ratio
  21454. * @param znear defines the near clip plane
  21455. * @param zfar defines the far clip plane
  21456. * @returns a new matrix as a right-handed perspective projection matrix
  21457. */
  21458. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  21459. /**
  21460. * Stores a right-handed perspective projection into a given matrix
  21461. * @param fov defines the horizontal field of view
  21462. * @param aspect defines the aspect ratio
  21463. * @param znear defines the near clip plane
  21464. * @param zfar defines the far clip plane
  21465. * @param result defines the target matrix
  21466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  21467. */
  21468. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  21469. /**
  21470. * Stores a perspective projection for WebVR info a given matrix
  21471. * @param fov defines the field of view
  21472. * @param znear defines the near clip plane
  21473. * @param zfar defines the far clip plane
  21474. * @param result defines the target matrix
  21475. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  21476. */
  21477. static PerspectiveFovWebVRToRef(fov: {
  21478. upDegrees: number;
  21479. downDegrees: number;
  21480. leftDegrees: number;
  21481. rightDegrees: number;
  21482. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  21483. /**
  21484. * Computes a complete transformation matrix
  21485. * @param viewport defines the viewport to use
  21486. * @param world defines the world matrix
  21487. * @param view defines the view matrix
  21488. * @param projection defines the projection matrix
  21489. * @param zmin defines the near clip plane
  21490. * @param zmax defines the far clip plane
  21491. * @returns the transformation matrix
  21492. */
  21493. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  21494. /**
  21495. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  21496. * @param matrix defines the matrix to use
  21497. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  21498. */
  21499. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  21500. /**
  21501. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  21502. * @param matrix defines the matrix to use
  21503. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  21504. */
  21505. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  21506. /**
  21507. * Compute the transpose of a given matrix
  21508. * @param matrix defines the matrix to transpose
  21509. * @returns the new matrix
  21510. */
  21511. static Transpose(matrix: Matrix): Matrix;
  21512. /**
  21513. * Compute the transpose of a matrix and store it in a target matrix
  21514. * @param matrix defines the matrix to transpose
  21515. * @param result defines the target matrix
  21516. */
  21517. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  21518. /**
  21519. * Computes a reflection matrix from a plane
  21520. * @param plane defines the reflection plane
  21521. * @returns a new matrix
  21522. */
  21523. static Reflection(plane: Plane): Matrix;
  21524. /**
  21525. * Computes a reflection matrix from a plane
  21526. * @param plane defines the reflection plane
  21527. * @param result defines the target matrix
  21528. */
  21529. static ReflectionToRef(plane: Plane, result: Matrix): void;
  21530. /**
  21531. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  21532. * @param xaxis defines the value of the 1st axis
  21533. * @param yaxis defines the value of the 2nd axis
  21534. * @param zaxis defines the value of the 3rd axis
  21535. * @param result defines the target matrix
  21536. */
  21537. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  21538. /**
  21539. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  21540. * @param quat defines the quaternion to use
  21541. * @param result defines the target matrix
  21542. */
  21543. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  21544. }
  21545. class Plane {
  21546. normal: Vector3;
  21547. d: number;
  21548. /**
  21549. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  21550. */
  21551. constructor(a: number, b: number, c: number, d: number);
  21552. /**
  21553. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  21554. */
  21555. asArray(): number[];
  21556. /**
  21557. * Returns a new plane copied from the current Plane.
  21558. */
  21559. clone(): Plane;
  21560. /**
  21561. * Returns the string "Plane".
  21562. */
  21563. getClassName(): string;
  21564. /**
  21565. * Returns the Plane hash code.
  21566. */
  21567. getHashCode(): number;
  21568. /**
  21569. * Normalize the current Plane in place.
  21570. * Returns the updated Plane.
  21571. */
  21572. normalize(): Plane;
  21573. /**
  21574. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  21575. */
  21576. transform(transformation: Matrix): Plane;
  21577. /**
  21578. * Returns the dot product (float) of the point coordinates and the plane normal.
  21579. */
  21580. dotCoordinate(point: Vector3): number;
  21581. /**
  21582. * Updates the current Plane from the plane defined by the three given points.
  21583. * Returns the updated Plane.
  21584. */
  21585. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  21586. /**
  21587. * Boolean : True is the vector "direction" is the same side than the plane normal.
  21588. */
  21589. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  21590. /**
  21591. * Returns the signed distance (float) from the given point to the Plane.
  21592. */
  21593. signedDistanceTo(point: Vector3): number;
  21594. /**
  21595. * Returns a new Plane from the given array.
  21596. */
  21597. static FromArray(array: ArrayLike<number>): Plane;
  21598. /**
  21599. * Returns a new Plane defined by the three given points.
  21600. */
  21601. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  21602. /**
  21603. * Returns a new Plane the normal vector to this plane at the given origin point.
  21604. * Note : the vector "normal" is updated because normalized.
  21605. */
  21606. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  21607. /**
  21608. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  21609. */
  21610. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  21611. }
  21612. /**
  21613. * Class used to represent a viewport on screen
  21614. */
  21615. class Viewport {
  21616. /** viewport left coordinate */
  21617. x: number;
  21618. /** viewport top coordinate */
  21619. y: number;
  21620. /**viewport width */
  21621. width: number;
  21622. /** viewport height */
  21623. height: number;
  21624. /**
  21625. * Creates a Viewport object located at (x, y) and sized (width, height)
  21626. * @param x defines viewport left coordinate
  21627. * @param y defines viewport top coordinate
  21628. * @param width defines the viewport width
  21629. * @param height defines the viewport height
  21630. */
  21631. constructor(
  21632. /** viewport left coordinate */
  21633. x: number,
  21634. /** viewport top coordinate */
  21635. y: number,
  21636. /**viewport width */
  21637. width: number,
  21638. /** viewport height */
  21639. height: number);
  21640. /**
  21641. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  21642. * @param renderWidthOrEngine defines either an engine or the rendering width
  21643. * @param renderHeight defines the rendering height
  21644. * @returns a new Viewport
  21645. */
  21646. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  21647. /**
  21648. * Returns a new Viewport copied from the current one
  21649. * @returns a new Viewport
  21650. */
  21651. clone(): Viewport;
  21652. }
  21653. class Frustum {
  21654. /**
  21655. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  21656. */
  21657. static GetPlanes(transform: Matrix): Plane[];
  21658. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21659. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21660. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21661. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21662. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21663. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21664. /**
  21665. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  21666. */
  21667. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  21668. }
  21669. /** Defines supported spaces */
  21670. enum Space {
  21671. /** Local (object) space */
  21672. LOCAL = 0,
  21673. /** World space */
  21674. WORLD = 1,
  21675. /** Bone space */
  21676. BONE = 2
  21677. }
  21678. /** Defines the 3 main axes */
  21679. class Axis {
  21680. /** X axis */
  21681. static X: Vector3;
  21682. /** Y axis */
  21683. static Y: Vector3;
  21684. /** Z axis */
  21685. static Z: Vector3;
  21686. }
  21687. /** Class used to represent a Bezier curve */
  21688. class BezierCurve {
  21689. /**
  21690. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  21691. * @param t defines the time
  21692. * @param x1 defines the left coordinate on X axis
  21693. * @param y1 defines the left coordinate on Y axis
  21694. * @param x2 defines the right coordinate on X axis
  21695. * @param y2 defines the right coordinate on Y axis
  21696. * @returns the interpolated value
  21697. */
  21698. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  21699. }
  21700. /**
  21701. * Defines potential orientation for back face culling
  21702. */
  21703. enum Orientation {
  21704. /**
  21705. * Clockwise
  21706. */
  21707. CW = 0,
  21708. /** Counter clockwise */
  21709. CCW = 1
  21710. }
  21711. /**
  21712. * Defines angle representation
  21713. */
  21714. class Angle {
  21715. private _radians;
  21716. /**
  21717. * Creates an Angle object of "radians" radians (float).
  21718. */
  21719. constructor(radians: number);
  21720. /**
  21721. * Get value in degrees
  21722. * @returns the Angle value in degrees (float)
  21723. */
  21724. degrees(): number;
  21725. /**
  21726. * Get value in radians
  21727. * @returns the Angle value in radians (float)
  21728. */
  21729. radians(): number;
  21730. /**
  21731. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  21732. * @param a defines first vector
  21733. * @param b defines second vector
  21734. * @returns a new Angle
  21735. */
  21736. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  21737. /**
  21738. * Gets a new Angle object from the given float in radians
  21739. * @param radians defines the angle value in radians
  21740. * @returns a new Angle
  21741. */
  21742. static FromRadians(radians: number): Angle;
  21743. /**
  21744. * Gets a new Angle object from the given float in degrees
  21745. * @param degrees defines the angle value in degrees
  21746. * @returns a new Angle
  21747. */
  21748. static FromDegrees(degrees: number): Angle;
  21749. }
  21750. /**
  21751. * This represents an arc in a 2d space.
  21752. */
  21753. class Arc2 {
  21754. /** Defines the start point of the arc */
  21755. startPoint: Vector2;
  21756. /** Defines the mid point of the arc */
  21757. midPoint: Vector2;
  21758. /** Defines the end point of the arc */
  21759. endPoint: Vector2;
  21760. /**
  21761. * Defines the center point of the arc.
  21762. */
  21763. centerPoint: Vector2;
  21764. /**
  21765. * Defines the radius of the arc.
  21766. */
  21767. radius: number;
  21768. /**
  21769. * Defines the angle of the arc (from mid point to end point).
  21770. */
  21771. angle: Angle;
  21772. /**
  21773. * Defines the start angle of the arc (from start point to middle point).
  21774. */
  21775. startAngle: Angle;
  21776. /**
  21777. * Defines the orientation of the arc (clock wise/counter clock wise).
  21778. */
  21779. orientation: Orientation;
  21780. /**
  21781. * Creates an Arc object from the three given points : start, middle and end.
  21782. * @param startPoint Defines the start point of the arc
  21783. * @param midPoint Defines the midlle point of the arc
  21784. * @param endPoint Defines the end point of the arc
  21785. */
  21786. constructor(
  21787. /** Defines the start point of the arc */
  21788. startPoint: Vector2,
  21789. /** Defines the mid point of the arc */
  21790. midPoint: Vector2,
  21791. /** Defines the end point of the arc */
  21792. endPoint: Vector2);
  21793. }
  21794. class Path2 {
  21795. private _points;
  21796. private _length;
  21797. closed: boolean;
  21798. /**
  21799. * Creates a Path2 object from the starting 2D coordinates x and y.
  21800. */
  21801. constructor(x: number, y: number);
  21802. /**
  21803. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  21804. * Returns the updated Path2.
  21805. */
  21806. addLineTo(x: number, y: number): Path2;
  21807. /**
  21808. * 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.
  21809. * Returns the updated Path2.
  21810. */
  21811. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  21812. /**
  21813. * Closes the Path2.
  21814. * Returns the Path2.
  21815. */
  21816. close(): Path2;
  21817. /**
  21818. * Returns the Path2 total length (float).
  21819. */
  21820. length(): number;
  21821. /**
  21822. * Returns the Path2 internal array of points.
  21823. */
  21824. getPoints(): Vector2[];
  21825. /**
  21826. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  21827. */
  21828. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  21829. /**
  21830. * Returns a new Path2 starting at the coordinates (x, y).
  21831. */
  21832. static StartingAt(x: number, y: number): Path2;
  21833. }
  21834. class Path3D {
  21835. path: Vector3[];
  21836. private _curve;
  21837. private _distances;
  21838. private _tangents;
  21839. private _normals;
  21840. private _binormals;
  21841. private _raw;
  21842. /**
  21843. * new Path3D(path, normal, raw)
  21844. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  21845. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  21846. * path : an array of Vector3, the curve axis of the Path3D
  21847. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  21848. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  21849. */
  21850. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  21851. /**
  21852. * Returns the Path3D array of successive Vector3 designing its curve.
  21853. */
  21854. getCurve(): Vector3[];
  21855. /**
  21856. * Returns an array populated with tangent vectors on each Path3D curve point.
  21857. */
  21858. getTangents(): Vector3[];
  21859. /**
  21860. * Returns an array populated with normal vectors on each Path3D curve point.
  21861. */
  21862. getNormals(): Vector3[];
  21863. /**
  21864. * Returns an array populated with binormal vectors on each Path3D curve point.
  21865. */
  21866. getBinormals(): Vector3[];
  21867. /**
  21868. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  21869. */
  21870. getDistances(): number[];
  21871. /**
  21872. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  21873. * Returns the same object updated.
  21874. */
  21875. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  21876. private _compute;
  21877. private _getFirstNonNullVector;
  21878. private _getLastNonNullVector;
  21879. private _normalVector;
  21880. }
  21881. class Curve3 {
  21882. private _points;
  21883. private _length;
  21884. /**
  21885. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  21886. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  21887. * @param v1 (Vector3) the control point
  21888. * @param v2 (Vector3) the end point of the Quadratic Bezier
  21889. * @param nbPoints (integer) the wanted number of points in the curve
  21890. */
  21891. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  21892. /**
  21893. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  21894. * @param v0 (Vector3) the origin point of the Cubic Bezier
  21895. * @param v1 (Vector3) the first control point
  21896. * @param v2 (Vector3) the second control point
  21897. * @param v3 (Vector3) the end point of the Cubic Bezier
  21898. * @param nbPoints (integer) the wanted number of points in the curve
  21899. */
  21900. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  21901. /**
  21902. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  21903. * @param p1 (Vector3) the origin point of the Hermite Spline
  21904. * @param t1 (Vector3) the tangent vector at the origin point
  21905. * @param p2 (Vector3) the end point of the Hermite Spline
  21906. * @param t2 (Vector3) the tangent vector at the end point
  21907. * @param nbPoints (integer) the wanted number of points in the curve
  21908. */
  21909. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  21910. /**
  21911. * Returns a Curve3 object along a CatmullRom Spline curve :
  21912. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  21913. * @param nbPoints (integer) the wanted number of points between each curve control points
  21914. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  21915. */
  21916. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  21917. /**
  21918. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  21919. * A Curve3 is designed from a series of successive Vector3.
  21920. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  21921. */
  21922. constructor(points: Vector3[]);
  21923. /**
  21924. * Returns the Curve3 stored array of successive Vector3
  21925. */
  21926. getPoints(): Vector3[];
  21927. /**
  21928. * Returns the computed length (float) of the curve.
  21929. */
  21930. length(): number;
  21931. /**
  21932. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  21933. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  21934. * curveA and curveB keep unchanged.
  21935. */
  21936. continue(curve: Curve3): Curve3;
  21937. private _computeLength;
  21938. }
  21939. class PositionNormalVertex {
  21940. position: Vector3;
  21941. normal: Vector3;
  21942. constructor(position?: Vector3, normal?: Vector3);
  21943. clone(): PositionNormalVertex;
  21944. }
  21945. class PositionNormalTextureVertex {
  21946. position: Vector3;
  21947. normal: Vector3;
  21948. uv: Vector2;
  21949. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  21950. clone(): PositionNormalTextureVertex;
  21951. }
  21952. class Tmp {
  21953. static Color3: Color3[];
  21954. static Color4: Color4[];
  21955. static Vector2: Vector2[];
  21956. static Vector3: Vector3[];
  21957. static Vector4: Vector4[];
  21958. static Quaternion: Quaternion[];
  21959. static Matrix: Matrix[];
  21960. }
  21961. }
  21962. declare module BABYLON {
  21963. /**
  21964. * Class representing spherical polynomial coefficients to the 3rd degree
  21965. */
  21966. class SphericalPolynomial {
  21967. /**
  21968. * The x coefficients of the spherical polynomial
  21969. */
  21970. x: Vector3;
  21971. /**
  21972. * The y coefficients of the spherical polynomial
  21973. */
  21974. y: Vector3;
  21975. /**
  21976. * The z coefficients of the spherical polynomial
  21977. */
  21978. z: Vector3;
  21979. /**
  21980. * The xx coefficients of the spherical polynomial
  21981. */
  21982. xx: Vector3;
  21983. /**
  21984. * The yy coefficients of the spherical polynomial
  21985. */
  21986. yy: Vector3;
  21987. /**
  21988. * The zz coefficients of the spherical polynomial
  21989. */
  21990. zz: Vector3;
  21991. /**
  21992. * The xy coefficients of the spherical polynomial
  21993. */
  21994. xy: Vector3;
  21995. /**
  21996. * The yz coefficients of the spherical polynomial
  21997. */
  21998. yz: Vector3;
  21999. /**
  22000. * The zx coefficients of the spherical polynomial
  22001. */
  22002. zx: Vector3;
  22003. /**
  22004. * Adds an ambient color to the spherical polynomial
  22005. * @param color the color to add
  22006. */
  22007. addAmbient(color: Color3): void;
  22008. /**
  22009. * Scales the spherical polynomial by the given amount
  22010. * @param scale the amount to scale
  22011. */
  22012. scale(scale: number): void;
  22013. /**
  22014. * Gets the spherical polynomial from harmonics
  22015. * @param harmonics the spherical harmonics
  22016. * @returns the spherical polynomial
  22017. */
  22018. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  22019. /**
  22020. * Constructs a spherical polynomial from an array.
  22021. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  22022. * @returns the spherical polynomial
  22023. */
  22024. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  22025. }
  22026. /**
  22027. * Class representing spherical harmonics coefficients to the 3rd degree
  22028. */
  22029. class SphericalHarmonics {
  22030. /**
  22031. * The l0,0 coefficients of the spherical harmonics
  22032. */
  22033. l00: Vector3;
  22034. /**
  22035. * The l1,-1 coefficients of the spherical harmonics
  22036. */
  22037. l1_1: Vector3;
  22038. /**
  22039. * The l1,0 coefficients of the spherical harmonics
  22040. */
  22041. l10: Vector3;
  22042. /**
  22043. * The l1,1 coefficients of the spherical harmonics
  22044. */
  22045. l11: Vector3;
  22046. /**
  22047. * The l2,-2 coefficients of the spherical harmonics
  22048. */
  22049. l2_2: Vector3;
  22050. /**
  22051. * The l2,-1 coefficients of the spherical harmonics
  22052. */
  22053. l2_1: Vector3;
  22054. /**
  22055. * The l2,0 coefficients of the spherical harmonics
  22056. */
  22057. l20: Vector3;
  22058. /**
  22059. * The l2,1 coefficients of the spherical harmonics
  22060. */
  22061. l21: Vector3;
  22062. /**
  22063. * The l2,2 coefficients of the spherical harmonics
  22064. */
  22065. lL22: Vector3;
  22066. /**
  22067. * Adds a light to the spherical harmonics
  22068. * @param direction the direction of the light
  22069. * @param color the color of the light
  22070. * @param deltaSolidAngle the delta solid angle of the light
  22071. */
  22072. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  22073. /**
  22074. * Scales the spherical harmonics by the given amount
  22075. * @param scale the amount to scale
  22076. */
  22077. scale(scale: number): void;
  22078. /**
  22079. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  22080. *
  22081. * ```
  22082. * E_lm = A_l * L_lm
  22083. * ```
  22084. *
  22085. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  22086. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  22087. * the scaling factors are given in equation 9.
  22088. */
  22089. convertIncidentRadianceToIrradiance(): void;
  22090. /**
  22091. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  22092. *
  22093. * ```
  22094. * L = (1/pi) * E * rho
  22095. * ```
  22096. *
  22097. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  22098. */
  22099. convertIrradianceToLambertianRadiance(): void;
  22100. /**
  22101. * Gets the spherical harmonics from polynomial
  22102. * @param polynomial the spherical polynomial
  22103. * @returns the spherical harmonics
  22104. */
  22105. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  22106. /**
  22107. * Constructs a spherical harmonics from an array.
  22108. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  22109. * @returns the spherical harmonics
  22110. */
  22111. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  22112. }
  22113. }
  22114. declare module BABYLON {
  22115. /**
  22116. * Class used to store all common mesh properties
  22117. */
  22118. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22119. /** No occlusion */
  22120. static OCCLUSION_TYPE_NONE: number;
  22121. /** Occlusion set to optimisitic */
  22122. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22123. /** Occlusion set to strict */
  22124. static OCCLUSION_TYPE_STRICT: number;
  22125. /** Use an accurante occlusion algorithm */
  22126. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22127. /** Use a conservative occlusion algorithm */
  22128. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22129. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  22130. static readonly CULLINGSTRATEGY_STANDARD: number;
  22131. /** Culling strategy with bounding sphere only and then frustum culling */
  22132. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22133. /**
  22134. * No billboard
  22135. */
  22136. static readonly BILLBOARDMODE_NONE: number;
  22137. /** Billboard on X axis */
  22138. static readonly BILLBOARDMODE_X: number;
  22139. /** Billboard on Y axis */
  22140. static readonly BILLBOARDMODE_Y: number;
  22141. /** Billboard on Z axis */
  22142. static readonly BILLBOARDMODE_Z: number;
  22143. /** Billboard on all axes */
  22144. static readonly BILLBOARDMODE_ALL: number;
  22145. private _facetPositions;
  22146. private _facetNormals;
  22147. private _facetPartitioning;
  22148. private _facetNb;
  22149. private _partitioningSubdivisions;
  22150. private _partitioningBBoxRatio;
  22151. private _facetDataEnabled;
  22152. private _facetParameters;
  22153. private _bbSize;
  22154. private _subDiv;
  22155. private _facetDepthSort;
  22156. private _facetDepthSortEnabled;
  22157. private _depthSortedIndices;
  22158. private _depthSortedFacets;
  22159. private _facetDepthSortFunction;
  22160. private _facetDepthSortFrom;
  22161. private _facetDepthSortOrigin;
  22162. private _invertedMatrix;
  22163. /** Gets ot sets the culling strategy to use to find visible meshes */
  22164. cullingStrategy: number;
  22165. /**
  22166. * Gets the number of facets in the mesh
  22167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22168. */
  22169. readonly facetNb: number;
  22170. /**
  22171. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22173. */
  22174. partitioningSubdivisions: number;
  22175. /**
  22176. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22177. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22179. */
  22180. partitioningBBoxRatio: number;
  22181. /**
  22182. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22183. * Works only for updatable meshes.
  22184. * Doesn't work with multi-materials
  22185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22186. */
  22187. mustDepthSortFacets: boolean;
  22188. /**
  22189. * The location (Vector3) where the facet depth sort must be computed from.
  22190. * By default, the active camera position.
  22191. * Used only when facet depth sort is enabled
  22192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22193. */
  22194. facetDepthSortFrom: Vector3;
  22195. /**
  22196. * gets a boolean indicating if facetData is enabled
  22197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22198. */
  22199. readonly isFacetDataEnabled: boolean;
  22200. /** @hidden */
  22201. _updateNonUniformScalingState(value: boolean): boolean;
  22202. /**
  22203. * An event triggered when this mesh collides with another one
  22204. */
  22205. onCollideObservable: Observable<AbstractMesh>;
  22206. private _onCollideObserver;
  22207. /** Set a function to call when this mesh collides with another one */
  22208. onCollide: () => void;
  22209. /**
  22210. * An event triggered when the collision's position changes
  22211. */
  22212. onCollisionPositionChangeObservable: Observable<Vector3>;
  22213. private _onCollisionPositionChangeObserver;
  22214. /** Set a function to call when the collision's position changes */
  22215. onCollisionPositionChange: () => void;
  22216. /**
  22217. * An event triggered when material is changed
  22218. */
  22219. onMaterialChangedObservable: Observable<AbstractMesh>;
  22220. /**
  22221. * Gets or sets the orientation for POV movement & rotation
  22222. */
  22223. definedFacingForward: boolean;
  22224. /**
  22225. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  22226. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  22227. * * 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.
  22228. * @see http://doc.babylonjs.com/features/occlusionquery
  22229. */
  22230. occlusionQueryAlgorithmType: number;
  22231. /**
  22232. * 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:
  22233. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  22234. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  22235. * * 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.
  22236. * @see http://doc.babylonjs.com/features/occlusionquery
  22237. */
  22238. occlusionType: number;
  22239. /**
  22240. * 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.
  22241. * The default value is -1 which means don't break the query and wait till the result
  22242. * @see http://doc.babylonjs.com/features/occlusionquery
  22243. */
  22244. occlusionRetryCount: number;
  22245. /** @hidden */
  22246. _occlusionInternalRetryCounter: number;
  22247. /** @hidden */
  22248. _isOccluded: boolean;
  22249. /**
  22250. * 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
  22251. * @see http://doc.babylonjs.com/features/occlusionquery
  22252. */
  22253. isOccluded: boolean;
  22254. /** @hidden */
  22255. _isOcclusionQueryInProgress: boolean;
  22256. /**
  22257. * Flag to check the progress status of the query
  22258. * @see http://doc.babylonjs.com/features/occlusionquery
  22259. */
  22260. readonly isOcclusionQueryInProgress: boolean;
  22261. /** @hidden */
  22262. _occlusionQuery: Nullable<WebGLQuery>;
  22263. private _visibility;
  22264. /**
  22265. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22266. */
  22267. /**
  22268. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22269. */
  22270. visibility: number;
  22271. /** Gets or sets the alpha index used to sort transparent meshes
  22272. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22273. */
  22274. alphaIndex: number;
  22275. /**
  22276. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22277. */
  22278. isVisible: boolean;
  22279. /**
  22280. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22281. */
  22282. isPickable: boolean;
  22283. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22284. showSubMeshesBoundingBox: boolean;
  22285. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22286. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22287. */
  22288. isBlocker: boolean;
  22289. /**
  22290. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22291. */
  22292. enablePointerMoveEvents: boolean;
  22293. /**
  22294. * Specifies the rendering group id for this mesh (0 by default)
  22295. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22296. */
  22297. renderingGroupId: number;
  22298. private _material;
  22299. /** Gets or sets current material */
  22300. material: Nullable<Material>;
  22301. private _receiveShadows;
  22302. /**
  22303. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22304. * @see http://doc.babylonjs.com/babylon101/shadows
  22305. */
  22306. receiveShadows: boolean;
  22307. /** Defines color to use when rendering outline */
  22308. outlineColor: Color3;
  22309. /** Define width to use when rendering outline */
  22310. outlineWidth: number;
  22311. /** Defines color to use when rendering overlay */
  22312. overlayColor: Color3;
  22313. /** Defines alpha to use when rendering overlay */
  22314. overlayAlpha: number;
  22315. private _hasVertexAlpha;
  22316. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22317. hasVertexAlpha: boolean;
  22318. private _useVertexColors;
  22319. /** 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) */
  22320. useVertexColors: boolean;
  22321. private _computeBonesUsingShaders;
  22322. /**
  22323. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22324. */
  22325. computeBonesUsingShaders: boolean;
  22326. private _numBoneInfluencers;
  22327. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22328. numBoneInfluencers: number;
  22329. private _applyFog;
  22330. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22331. applyFog: boolean;
  22332. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22333. useOctreeForRenderingSelection: boolean;
  22334. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22335. useOctreeForPicking: boolean;
  22336. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22337. useOctreeForCollisions: boolean;
  22338. private _layerMask;
  22339. /**
  22340. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22341. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22342. */
  22343. layerMask: number;
  22344. /**
  22345. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22346. */
  22347. alwaysSelectAsActiveMesh: boolean;
  22348. /**
  22349. * Gets or sets the current action manager
  22350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22351. */
  22352. actionManager: Nullable<ActionManager>;
  22353. private _checkCollisions;
  22354. private _collisionMask;
  22355. private _collisionGroup;
  22356. /**
  22357. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22359. */
  22360. ellipsoid: Vector3;
  22361. /**
  22362. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22364. */
  22365. ellipsoidOffset: Vector3;
  22366. private _collider;
  22367. private _oldPositionForCollisions;
  22368. private _diffPositionForCollisions;
  22369. /**
  22370. * Gets or sets a collision mask used to mask collisions (default is -1).
  22371. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22372. */
  22373. collisionMask: number;
  22374. /**
  22375. * Gets or sets the current collision group mask (-1 by default).
  22376. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22377. */
  22378. collisionGroup: number;
  22379. /**
  22380. * Defines edge width used when edgesRenderer is enabled
  22381. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22382. */
  22383. edgesWidth: number;
  22384. /**
  22385. * Defines edge color used when edgesRenderer is enabled
  22386. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22387. */
  22388. edgesColor: Color4;
  22389. /** @hidden */
  22390. _edgesRenderer: Nullable<IEdgesRenderer>;
  22391. private _collisionsTransformMatrix;
  22392. private _collisionsScalingMatrix;
  22393. /** @hidden */
  22394. _masterMesh: Nullable<AbstractMesh>;
  22395. /** @hidden */
  22396. _boundingInfo: Nullable<BoundingInfo>;
  22397. /** @hidden */
  22398. _renderId: number;
  22399. /**
  22400. * Gets or sets the list of subMeshes
  22401. * @see http://doc.babylonjs.com/how_to/multi_materials
  22402. */
  22403. subMeshes: SubMesh[];
  22404. /** @hidden */
  22405. _intersectionsInProgress: AbstractMesh[];
  22406. /** @hidden */
  22407. _unIndexed: boolean;
  22408. /** @hidden */
  22409. _lightSources: Light[];
  22410. /** @hidden */
  22411. readonly _positions: Nullable<Vector3[]>;
  22412. /** @hidden */
  22413. _waitingActions: any;
  22414. /** @hidden */
  22415. _waitingFreezeWorldMatrix: Nullable<boolean>;
  22416. private _skeleton;
  22417. /** @hidden */
  22418. _bonesTransformMatrices: Nullable<Float32Array>;
  22419. /**
  22420. * Gets or sets a skeleton to apply skining transformations
  22421. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22422. */
  22423. skeleton: Nullable<Skeleton>;
  22424. /**
  22425. * An event triggered when the mesh is rebuilt.
  22426. */
  22427. onRebuildObservable: Observable<AbstractMesh>;
  22428. /**
  22429. * Creates a new AbstractMesh
  22430. * @param name defines the name of the mesh
  22431. * @param scene defines the hosting scene
  22432. */
  22433. constructor(name: string, scene?: Nullable<Scene>);
  22434. /**
  22435. * Returns the string "AbstractMesh"
  22436. * @returns "AbstractMesh"
  22437. */
  22438. getClassName(): string;
  22439. /**
  22440. * Gets a string representation of the current mesh
  22441. * @param fullDetails defines a boolean indicating if full details must be included
  22442. * @returns a string representation of the current mesh
  22443. */
  22444. toString(fullDetails?: boolean): string;
  22445. /** @hidden */
  22446. _rebuild(): void;
  22447. /** @hidden */
  22448. _resyncLightSources(): void;
  22449. /** @hidden */
  22450. _resyncLighSource(light: Light): void;
  22451. /** @hidden */
  22452. _unBindEffect(): void;
  22453. /** @hidden */
  22454. _removeLightSource(light: Light): void;
  22455. private _markSubMeshesAsDirty;
  22456. /** @hidden */
  22457. _markSubMeshesAsLightDirty(): void;
  22458. /** @hidden */
  22459. _markSubMeshesAsAttributesDirty(): void;
  22460. /** @hidden */
  22461. _markSubMeshesAsMiscDirty(): void;
  22462. /**
  22463. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22464. */
  22465. scaling: Vector3;
  22466. /**
  22467. * Returns true if the mesh is blocked. Implemented by child classes
  22468. */
  22469. readonly isBlocked: boolean;
  22470. /**
  22471. * Returns the mesh itself by default. Implemented by child classes
  22472. * @param camera defines the camera to use to pick the right LOD level
  22473. * @returns the currentAbstractMesh
  22474. */
  22475. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22476. /**
  22477. * Returns 0 by default. Implemented by child classes
  22478. * @returns an integer
  22479. */
  22480. getTotalVertices(): number;
  22481. /**
  22482. * Returns null by default. Implemented by child classes
  22483. * @returns null
  22484. */
  22485. getIndices(): Nullable<IndicesArray>;
  22486. /**
  22487. * Returns the array of the requested vertex data kind. Implemented by child classes
  22488. * @param kind defines the vertex data kind to use
  22489. * @returns null
  22490. */
  22491. getVerticesData(kind: string): Nullable<FloatArray>;
  22492. /**
  22493. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22494. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22495. * Note that a new underlying VertexBuffer object is created each call.
  22496. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22497. * @param kind defines vertex data kind:
  22498. * * BABYLON.VertexBuffer.PositionKind
  22499. * * BABYLON.VertexBuffer.UVKind
  22500. * * BABYLON.VertexBuffer.UV2Kind
  22501. * * BABYLON.VertexBuffer.UV3Kind
  22502. * * BABYLON.VertexBuffer.UV4Kind
  22503. * * BABYLON.VertexBuffer.UV5Kind
  22504. * * BABYLON.VertexBuffer.UV6Kind
  22505. * * BABYLON.VertexBuffer.ColorKind
  22506. * * BABYLON.VertexBuffer.MatricesIndicesKind
  22507. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22508. * * BABYLON.VertexBuffer.MatricesWeightsKind
  22509. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22510. * @param data defines the data source
  22511. * @param updatable defines if the data must be flagged as updatable (or static)
  22512. * @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
  22513. * @returns the current mesh
  22514. */
  22515. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22516. /**
  22517. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22518. * If the mesh has no geometry, it is simply returned as it is.
  22519. * @param kind defines vertex data kind:
  22520. * * BABYLON.VertexBuffer.PositionKind
  22521. * * BABYLON.VertexBuffer.UVKind
  22522. * * BABYLON.VertexBuffer.UV2Kind
  22523. * * BABYLON.VertexBuffer.UV3Kind
  22524. * * BABYLON.VertexBuffer.UV4Kind
  22525. * * BABYLON.VertexBuffer.UV5Kind
  22526. * * BABYLON.VertexBuffer.UV6Kind
  22527. * * BABYLON.VertexBuffer.ColorKind
  22528. * * BABYLON.VertexBuffer.MatricesIndicesKind
  22529. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22530. * * BABYLON.VertexBuffer.MatricesWeightsKind
  22531. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22532. * @param data defines the data source
  22533. * @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
  22534. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22535. * @returns the current mesh
  22536. */
  22537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22538. /**
  22539. * Sets the mesh indices,
  22540. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22541. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22542. * @param totalVertices Defines the total number of vertices
  22543. * @returns the current mesh
  22544. */
  22545. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22546. /**
  22547. * Gets a boolean indicating if specific vertex data is present
  22548. * @param kind defines the vertex data kind to use
  22549. * @returns true is data kind is present
  22550. */
  22551. isVerticesDataPresent(kind: string): boolean;
  22552. /**
  22553. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22554. * @returns a BoundingInfo
  22555. */
  22556. getBoundingInfo(): BoundingInfo;
  22557. /**
  22558. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22559. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22560. * @returns the current mesh
  22561. */
  22562. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22563. /**
  22564. * Overwrite the current bounding info
  22565. * @param boundingInfo defines the new bounding info
  22566. * @returns the current mesh
  22567. */
  22568. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22569. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22570. readonly useBones: boolean;
  22571. /** @hidden */
  22572. _preActivate(): void;
  22573. /** @hidden */
  22574. _preActivateForIntermediateRendering(renderId: number): void;
  22575. /** @hidden */
  22576. _activate(renderId: number): void;
  22577. /**
  22578. * Gets the current world matrix
  22579. * @returns a Matrix
  22580. */
  22581. getWorldMatrix(): Matrix;
  22582. /** @hidden */
  22583. _getWorldMatrixDeterminant(): number;
  22584. /**
  22585. * Perform relative position change from the point of view of behind the front of the mesh.
  22586. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22587. * Supports definition of mesh facing forward or backward
  22588. * @param amountRight defines the distance on the right axis
  22589. * @param amountUp defines the distance on the up axis
  22590. * @param amountForward defines the distance on the forward axis
  22591. * @returns the current mesh
  22592. */
  22593. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22594. /**
  22595. * Calculate relative position change from the point of view of behind the front of the mesh.
  22596. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22597. * Supports definition of mesh facing forward or backward
  22598. * @param amountRight defines the distance on the right axis
  22599. * @param amountUp defines the distance on the up axis
  22600. * @param amountForward defines the distance on the forward axis
  22601. * @returns the new displacement vector
  22602. */
  22603. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22604. /**
  22605. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22606. * Supports definition of mesh facing forward or backward
  22607. * @param flipBack defines the flip
  22608. * @param twirlClockwise defines the twirl
  22609. * @param tiltRight defines the tilt
  22610. * @returns the current mesh
  22611. */
  22612. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22613. /**
  22614. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22615. * Supports definition of mesh facing forward or backward.
  22616. * @param flipBack defines the flip
  22617. * @param twirlClockwise defines the twirl
  22618. * @param tiltRight defines the tilt
  22619. * @returns the new rotation vector
  22620. */
  22621. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22622. /**
  22623. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22624. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22625. * @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
  22626. * @returns the new bounding vectors
  22627. */
  22628. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22629. min: Vector3;
  22630. max: Vector3;
  22631. };
  22632. /** @hidden */
  22633. _updateBoundingInfo(): AbstractMesh;
  22634. /** @hidden */
  22635. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  22636. /** @hidden */
  22637. protected _afterComputeWorldMatrix(): void;
  22638. /**
  22639. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22640. * A mesh is in the frustum if its bounding box intersects the frustum
  22641. * @param frustumPlanes defines the frustum to test
  22642. * @returns true if the mesh is in the frustum planes
  22643. */
  22644. isInFrustum(frustumPlanes: Plane[]): boolean;
  22645. /**
  22646. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22647. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  22648. * @param frustumPlanes defines the frustum to test
  22649. * @returns true if the mesh is completely in the frustum planes
  22650. */
  22651. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22652. /**
  22653. * True if the mesh intersects another mesh or a SolidParticle object
  22654. * @param mesh defines a target mesh or SolidParticle to test
  22655. * @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)
  22656. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  22657. * @returns true if there is an intersection
  22658. */
  22659. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  22660. /**
  22661. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  22662. * @param point defines the point to test
  22663. * @returns true if there is an intersection
  22664. */
  22665. intersectsPoint(point: Vector3): boolean;
  22666. /**
  22667. * Gets the position of the current mesh in camera space
  22668. * @param camera defines the camera to use
  22669. * @returns a position
  22670. */
  22671. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  22672. /**
  22673. * Returns the distance from the mesh to the active camera
  22674. * @param camera defines the camera to use
  22675. * @returns the distance
  22676. */
  22677. getDistanceToCamera(camera?: Nullable<Camera>): number;
  22678. /**
  22679. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  22680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22681. */
  22682. checkCollisions: boolean;
  22683. /**
  22684. * Gets Collider object used to compute collisions (not physics)
  22685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22686. */
  22687. readonly collider: Collider;
  22688. /**
  22689. * Move the mesh using collision engine
  22690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22691. * @param displacement defines the requested displacement vector
  22692. * @returns the current mesh
  22693. */
  22694. moveWithCollisions(displacement: Vector3): AbstractMesh;
  22695. private _onCollisionPositionChange;
  22696. /** @hidden */
  22697. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  22698. /** @hidden */
  22699. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  22700. /** @hidden */
  22701. _checkCollision(collider: Collider): AbstractMesh;
  22702. /** @hidden */
  22703. _generatePointsArray(): boolean;
  22704. /**
  22705. * Checks if the passed Ray intersects with the mesh
  22706. * @param ray defines the ray to use
  22707. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  22708. * @returns the picking info
  22709. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  22710. */
  22711. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  22712. /**
  22713. * Clones the current mesh
  22714. * @param name defines the mesh name
  22715. * @param newParent defines the new mesh parent
  22716. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  22717. * @returns the new mesh
  22718. */
  22719. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  22720. /**
  22721. * Disposes all the submeshes of the current meshnp
  22722. * @returns the current mesh
  22723. */
  22724. releaseSubMeshes(): AbstractMesh;
  22725. /**
  22726. * Releases resources associated with this abstract mesh.
  22727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22729. */
  22730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22731. /**
  22732. * Adds the passed mesh as a child to the current mesh
  22733. * @param mesh defines the child mesh
  22734. * @returns the current mesh
  22735. */
  22736. addChild(mesh: AbstractMesh): AbstractMesh;
  22737. /**
  22738. * Removes the passed mesh from the current mesh children list
  22739. * @param mesh defines the child mesh
  22740. * @returns the current mesh
  22741. */
  22742. removeChild(mesh: AbstractMesh): AbstractMesh;
  22743. /** @hidden */
  22744. private _initFacetData;
  22745. /**
  22746. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  22747. * This method can be called within the render loop.
  22748. * 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
  22749. * @returns the current mesh
  22750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22751. */
  22752. updateFacetData(): AbstractMesh;
  22753. /**
  22754. * Returns the facetLocalNormals array.
  22755. * The normals are expressed in the mesh local spac
  22756. * @returns an array of Vector3
  22757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22758. */
  22759. getFacetLocalNormals(): Vector3[];
  22760. /**
  22761. * Returns the facetLocalPositions array.
  22762. * The facet positions are expressed in the mesh local space
  22763. * @returns an array of Vector3
  22764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22765. */
  22766. getFacetLocalPositions(): Vector3[];
  22767. /**
  22768. * Returns the facetLocalPartioning array
  22769. * @returns an array of array of numbers
  22770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22771. */
  22772. getFacetLocalPartitioning(): number[][];
  22773. /**
  22774. * Returns the i-th facet position in the world system.
  22775. * This method allocates a new Vector3 per call
  22776. * @param i defines the facet index
  22777. * @returns a new Vector3
  22778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22779. */
  22780. getFacetPosition(i: number): Vector3;
  22781. /**
  22782. * Sets the reference Vector3 with the i-th facet position in the world system
  22783. * @param i defines the facet index
  22784. * @param ref defines the target vector
  22785. * @returns the current mesh
  22786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22787. */
  22788. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  22789. /**
  22790. * Returns the i-th facet normal in the world system.
  22791. * This method allocates a new Vector3 per call
  22792. * @param i defines the facet index
  22793. * @returns a new Vector3
  22794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22795. */
  22796. getFacetNormal(i: number): Vector3;
  22797. /**
  22798. * Sets the reference Vector3 with the i-th facet normal in the world system
  22799. * @param i defines the facet index
  22800. * @param ref defines the target vector
  22801. * @returns the current mesh
  22802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22803. */
  22804. getFacetNormalToRef(i: number, ref: Vector3): this;
  22805. /**
  22806. * 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)
  22807. * @param x defines x coordinate
  22808. * @param y defines y coordinate
  22809. * @param z defines z coordinate
  22810. * @returns the array of facet indexes
  22811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22812. */
  22813. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  22814. /**
  22815. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  22816. * @param projected sets as the (x,y,z) world projection on the facet
  22817. * @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
  22818. * @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
  22819. * @param x defines x coordinate
  22820. * @param y defines y coordinate
  22821. * @param z defines z coordinate
  22822. * @returns the face index if found (or null instead)
  22823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22824. */
  22825. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22826. /**
  22827. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  22828. * @param projected sets as the (x,y,z) local projection on the facet
  22829. * @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
  22830. * @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
  22831. * @param x defines x coordinate
  22832. * @param y defines y coordinate
  22833. * @param z defines z coordinate
  22834. * @returns the face index if found (or null instead)
  22835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22836. */
  22837. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22838. /**
  22839. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  22840. * @returns the parameters
  22841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22842. */
  22843. getFacetDataParameters(): any;
  22844. /**
  22845. * Disables the feature FacetData and frees the related memory
  22846. * @returns the current mesh
  22847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22848. */
  22849. disableFacetData(): AbstractMesh;
  22850. /**
  22851. * Updates the AbstractMesh indices array
  22852. * @param indices defines the data source
  22853. * @returns the current mesh
  22854. */
  22855. updateIndices(indices: IndicesArray): AbstractMesh;
  22856. /**
  22857. * Creates new normals data for the mesh
  22858. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  22859. * @returns the current mesh
  22860. */
  22861. createNormals(updatable: boolean): AbstractMesh;
  22862. /**
  22863. * Align the mesh with a normal
  22864. * @param normal defines the normal to use
  22865. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  22866. * @returns the current mesh
  22867. */
  22868. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  22869. /** @hidden */
  22870. _checkOcclusionQuery(): void;
  22871. }
  22872. }
  22873. declare module BABYLON {
  22874. class Buffer {
  22875. private _engine;
  22876. private _buffer;
  22877. /** @hidden */
  22878. _data: Nullable<DataArray>;
  22879. private _updatable;
  22880. private _instanced;
  22881. /**
  22882. * Gets the byte stride.
  22883. */
  22884. readonly byteStride: number;
  22885. /**
  22886. * Constructor
  22887. * @param engine the engine
  22888. * @param data the data to use for this buffer
  22889. * @param updatable whether the data is updatable
  22890. * @param stride the stride (optional)
  22891. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22892. * @param instanced whether the buffer is instanced (optional)
  22893. * @param useBytes set to true if the stride in in bytes (optional)
  22894. */
  22895. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  22896. /**
  22897. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  22898. * @param kind defines the vertex buffer kind (position, normal, etc.)
  22899. * @param offset defines offset in the buffer (0 by default)
  22900. * @param size defines the size in floats of attributes (position is 3 for instance)
  22901. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  22902. * @param instanced defines if the vertex buffer contains indexed data
  22903. * @param useBytes defines if the offset and stride are in bytes
  22904. * @returns the new vertex buffer
  22905. */
  22906. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  22907. isUpdatable(): boolean;
  22908. getData(): Nullable<DataArray>;
  22909. getBuffer(): Nullable<WebGLBuffer>;
  22910. /**
  22911. * Gets the stride in float32 units (i.e. byte stride / 4).
  22912. * May not be an integer if the byte stride is not divisible by 4.
  22913. * DEPRECATED. Use byteStride instead.
  22914. * @returns the stride in float32 units
  22915. */
  22916. getStrideSize(): number;
  22917. create(data?: Nullable<DataArray>): void;
  22918. /** @hidden */
  22919. _rebuild(): void;
  22920. update(data: DataArray): void;
  22921. /**
  22922. * Updates the data directly.
  22923. * @param data the new data
  22924. * @param offset the new offset
  22925. * @param vertexCount the vertex count (optional)
  22926. * @param useBytes set to true if the offset is in bytes
  22927. */
  22928. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  22929. dispose(): void;
  22930. }
  22931. }
  22932. declare module BABYLON {
  22933. class CSG {
  22934. private polygons;
  22935. matrix: Matrix;
  22936. position: Vector3;
  22937. rotation: Vector3;
  22938. rotationQuaternion: Nullable<Quaternion>;
  22939. scaling: Vector3;
  22940. static FromMesh(mesh: Mesh): CSG;
  22941. private static FromPolygons;
  22942. clone(): CSG;
  22943. union(csg: CSG): CSG;
  22944. unionInPlace(csg: CSG): void;
  22945. subtract(csg: CSG): CSG;
  22946. subtractInPlace(csg: CSG): void;
  22947. intersect(csg: CSG): CSG;
  22948. intersectInPlace(csg: CSG): void;
  22949. inverse(): CSG;
  22950. inverseInPlace(): void;
  22951. copyTransformAttributes(csg: CSG): CSG;
  22952. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  22953. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  22954. }
  22955. }
  22956. declare module BABYLON {
  22957. /**
  22958. * Class used to store geometry data (vertex buffers + index buffer)
  22959. */
  22960. class Geometry implements IGetSetVerticesData {
  22961. /**
  22962. * Gets or sets the unique ID of the geometry
  22963. */
  22964. id: string;
  22965. /**
  22966. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22967. */
  22968. delayLoadState: number;
  22969. /**
  22970. * Gets the file containing the data to load when running in delay load state
  22971. */
  22972. delayLoadingFile: Nullable<string>;
  22973. /**
  22974. * Callback called when the geometry is updated
  22975. */
  22976. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22977. private _scene;
  22978. private _engine;
  22979. private _meshes;
  22980. private _totalVertices;
  22981. /** @hidden */
  22982. _indices: IndicesArray;
  22983. /** @hidden */
  22984. _vertexBuffers: {
  22985. [key: string]: VertexBuffer;
  22986. };
  22987. private _isDisposed;
  22988. private _extend;
  22989. private _boundingBias;
  22990. /** @hidden */
  22991. _delayInfo: Array<string>;
  22992. private _indexBuffer;
  22993. private _indexBufferIsUpdatable;
  22994. /** @hidden */
  22995. _boundingInfo: Nullable<BoundingInfo>;
  22996. /** @hidden */
  22997. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22998. /** @hidden */
  22999. _softwareSkinningFrameId: number;
  23000. private _vertexArrayObjects;
  23001. private _updatable;
  23002. /** @hidden */
  23003. _positions: Nullable<Vector3[]>;
  23004. /**
  23005. * 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
  23006. */
  23007. /**
  23008. * 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
  23009. */
  23010. boundingBias: Vector2;
  23011. /**
  23012. * Static function used to attach a new empty geometry to a mesh
  23013. * @param mesh defines the mesh to attach the geometry to
  23014. * @returns the new {BABYLON.Geometry}
  23015. */
  23016. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23017. /**
  23018. * Creates a new geometry
  23019. * @param id defines the unique ID
  23020. * @param scene defines the hosting scene
  23021. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  23022. * @param updatable defines if geometry must be updatable (false by default)
  23023. * @param mesh defines the mesh that will be associated with the geometry
  23024. */
  23025. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23026. /**
  23027. * Gets the current extend of the geometry
  23028. */
  23029. readonly extend: {
  23030. minimum: Vector3;
  23031. maximum: Vector3;
  23032. };
  23033. /**
  23034. * Gets the hosting scene
  23035. * @returns the hosting {BABYLON.Scene}
  23036. */
  23037. getScene(): Scene;
  23038. /**
  23039. * Gets the hosting engine
  23040. * @returns the hosting {BABYLON.Engine}
  23041. */
  23042. getEngine(): Engine;
  23043. /**
  23044. * Defines if the geometry is ready to use
  23045. * @returns true if the geometry is ready to be used
  23046. */
  23047. isReady(): boolean;
  23048. /**
  23049. * Gets a value indicating that the geometry should not be serialized
  23050. */
  23051. readonly doNotSerialize: boolean;
  23052. /** @hidden */
  23053. _rebuild(): void;
  23054. /**
  23055. * Affects all geometry data in one call
  23056. * @param vertexData defines the geometry data
  23057. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23058. */
  23059. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23060. /**
  23061. * Set specific vertex data
  23062. * @param kind defines the data kind (Position, normal, etc...)
  23063. * @param data defines the vertex data to use
  23064. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23065. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23066. */
  23067. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23068. /**
  23069. * Removes a specific vertex data
  23070. * @param kind defines the data kind (Position, normal, etc...)
  23071. */
  23072. removeVerticesData(kind: string): void;
  23073. /**
  23074. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23075. * @param buffer defines the vertex buffer to use
  23076. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23077. */
  23078. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23079. /**
  23080. * Update a specific vertex buffer
  23081. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23082. * It will do nothing if the buffer is not updatable
  23083. * @param kind defines the data kind (Position, normal, etc...)
  23084. * @param data defines the data to use
  23085. * @param offset defines the offset in the target buffer where to store the data
  23086. * @param useBytes set to true if the offset is in bytes
  23087. */
  23088. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23089. /**
  23090. * Update a specific vertex buffer
  23091. * This function will create a new buffer if the current one is not updatable
  23092. * @param kind defines the data kind (Position, normal, etc...)
  23093. * @param data defines the data to use
  23094. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23095. */
  23096. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23097. private _updateBoundingInfo;
  23098. /** @hidden */
  23099. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23100. /**
  23101. * Gets total number of vertices
  23102. * @returns the total number of vertices
  23103. */
  23104. getTotalVertices(): number;
  23105. /**
  23106. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23107. * @param kind defines the data kind (Position, normal, etc...)
  23108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23110. * @returns a float array containing vertex data
  23111. */
  23112. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23113. /**
  23114. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23115. * @param kind defines the data kind (Position, normal, etc...)
  23116. * @returns true if the vertex buffer with the specified kind is updatable
  23117. */
  23118. isVertexBufferUpdatable(kind: string): boolean;
  23119. /**
  23120. * Gets a specific vertex buffer
  23121. * @param kind defines the data kind (Position, normal, etc...)
  23122. * @returns a {BABYLON.VertexBuffer}
  23123. */
  23124. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23125. /**
  23126. * Returns all vertex buffers
  23127. * @return an object holding all vertex buffers indexed by kind
  23128. */
  23129. getVertexBuffers(): Nullable<{
  23130. [key: string]: VertexBuffer;
  23131. }>;
  23132. /**
  23133. * Gets a boolean indicating if specific vertex buffer is present
  23134. * @param kind defines the data kind (Position, normal, etc...)
  23135. * @returns true if data is present
  23136. */
  23137. isVerticesDataPresent(kind: string): boolean;
  23138. /**
  23139. * Gets a list of all attached data kinds (Position, normal, etc...)
  23140. * @returns a list of string containing all kinds
  23141. */
  23142. getVerticesDataKinds(): string[];
  23143. /**
  23144. * Update index buffer
  23145. * @param indices defines the indices to store in the index buffer
  23146. * @param offset defines the offset in the target buffer where to store the data
  23147. */
  23148. updateIndices(indices: IndicesArray, offset?: number): void;
  23149. /**
  23150. * Creates a new index buffer
  23151. * @param indices defines the indices to store in the index buffer
  23152. * @param totalVertices defines the total number of vertices (could be null)
  23153. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23154. */
  23155. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23156. /**
  23157. * Return the total number of indices
  23158. * @returns the total number of indices
  23159. */
  23160. getTotalIndices(): number;
  23161. /**
  23162. * Gets the index buffer array
  23163. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23165. * @returns the index buffer array
  23166. */
  23167. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23168. /**
  23169. * Gets the index buffer
  23170. * @return the index buffer
  23171. */
  23172. getIndexBuffer(): Nullable<WebGLBuffer>;
  23173. /** @hidden */
  23174. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23175. /**
  23176. * Release the associated resources for a specific mesh
  23177. * @param mesh defines the source mesh
  23178. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23179. */
  23180. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23181. /**
  23182. * Apply current geometry to a given mesh
  23183. * @param mesh defines the mesh to apply geometry to
  23184. */
  23185. applyToMesh(mesh: Mesh): void;
  23186. private _updateExtend;
  23187. private _applyToMesh;
  23188. private notifyUpdate;
  23189. /**
  23190. * Load the geometry if it was flagged as delay loaded
  23191. * @param scene defines the hosting scene
  23192. * @param onLoaded defines a callback called when the geometry is loaded
  23193. */
  23194. load(scene: Scene, onLoaded?: () => void): void;
  23195. private _queueLoad;
  23196. /**
  23197. * Invert the geometry to move from a right handed system to a left handed one.
  23198. */
  23199. toLeftHanded(): void;
  23200. /** @hidden */
  23201. _resetPointsArrayCache(): void;
  23202. /** @hidden */
  23203. _generatePointsArray(): boolean;
  23204. /**
  23205. * Gets a value indicating if the geometry is disposed
  23206. * @returns true if the geometry was disposed
  23207. */
  23208. isDisposed(): boolean;
  23209. private _disposeVertexArrayObjects;
  23210. /**
  23211. * Free all associated resources
  23212. */
  23213. dispose(): void;
  23214. /**
  23215. * Clone the current geometry into a new geometry
  23216. * @param id defines the unique ID of the new geometry
  23217. * @returns a new geometry object
  23218. */
  23219. copy(id: string): Geometry;
  23220. /**
  23221. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23222. * @return a JSON representation of the current geometry data (without the vertices data)
  23223. */
  23224. serialize(): any;
  23225. private toNumberArray;
  23226. /**
  23227. * Serialize all vertices data into a JSON oject
  23228. * @returns a JSON representation of the current geometry data
  23229. */
  23230. serializeVerticeData(): any;
  23231. /**
  23232. * Extracts a clone of a mesh geometry
  23233. * @param mesh defines the source mesh
  23234. * @param id defines the unique ID of the new geometry object
  23235. * @returns the new geometry object
  23236. */
  23237. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23238. /**
  23239. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23240. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23241. * Be aware Math.random() could cause collisions, but:
  23242. * "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"
  23243. * @returns a string containing a new GUID
  23244. */
  23245. static RandomId(): string;
  23246. /** @hidden */
  23247. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23248. private static _CleanMatricesWeights;
  23249. /**
  23250. * Create a new geometry from persisted data (Using .babylon file format)
  23251. * @param parsedVertexData defines the persisted data
  23252. * @param scene defines the hosting scene
  23253. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23254. * @returns the new geometry object
  23255. */
  23256. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23257. }
  23258. /**
  23259. * Abstract class used to provide common services for all typed geometries
  23260. * @hidden
  23261. */
  23262. class _PrimitiveGeometry extends Geometry {
  23263. private _canBeRegenerated;
  23264. private _beingRegenerated;
  23265. /**
  23266. * Creates a new typed geometry
  23267. * @param id defines the unique ID of the geometry
  23268. * @param scene defines the hosting scene
  23269. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23270. * @param mesh defines the hosting mesh (can be null)
  23271. */
  23272. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23273. /**
  23274. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  23275. * @returns true if the geometry can be regenerated
  23276. */
  23277. canBeRegenerated(): boolean;
  23278. /**
  23279. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  23280. */
  23281. regenerate(): void;
  23282. /**
  23283. * Clone the geometry
  23284. * @param id defines the unique ID of the new geometry
  23285. * @returns the new geometry
  23286. */
  23287. asNewGeometry(id: string): Geometry;
  23288. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23289. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  23290. /** @hidden */
  23291. _regenerateVertexData(): VertexData;
  23292. copy(id: string): Geometry;
  23293. serialize(): any;
  23294. }
  23295. /**
  23296. * Creates a ribbon geometry
  23297. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  23298. */
  23299. class RibbonGeometry extends _PrimitiveGeometry {
  23300. /**
  23301. * Defines the array of paths to use
  23302. */
  23303. pathArray: Vector3[][];
  23304. /**
  23305. * Defines if the last and first points of each path in your pathArray must be joined
  23306. */
  23307. closeArray: boolean;
  23308. /**
  23309. * Defines if the last and first points of each path in your pathArray must be joined
  23310. */
  23311. closePath: boolean;
  23312. /**
  23313. * Defines the offset between points
  23314. */
  23315. offset: number;
  23316. /**
  23317. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23318. */
  23319. side: number;
  23320. /**
  23321. * Creates a ribbon geometry
  23322. * @param id defines the unique ID of the geometry
  23323. * @param scene defines the hosting scene
  23324. * @param pathArray defines the array of paths to use
  23325. * @param closeArray defines if the last path and the first path must be joined
  23326. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  23327. * @param offset defines the offset between points
  23328. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23329. * @param mesh defines the hosting mesh (can be null)
  23330. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23331. */
  23332. constructor(id: string, scene: Scene,
  23333. /**
  23334. * Defines the array of paths to use
  23335. */
  23336. pathArray: Vector3[][],
  23337. /**
  23338. * Defines if the last and first points of each path in your pathArray must be joined
  23339. */
  23340. closeArray: boolean,
  23341. /**
  23342. * Defines if the last and first points of each path in your pathArray must be joined
  23343. */
  23344. closePath: boolean,
  23345. /**
  23346. * Defines the offset between points
  23347. */
  23348. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  23349. /**
  23350. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23351. */
  23352. side?: number);
  23353. /** @hidden */
  23354. _regenerateVertexData(): VertexData;
  23355. copy(id: string): Geometry;
  23356. }
  23357. /**
  23358. * Creates a box geometry
  23359. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  23360. */
  23361. class BoxGeometry extends _PrimitiveGeometry {
  23362. /**
  23363. * Defines the zise of the box (width, height and depth are the same)
  23364. */
  23365. size: number;
  23366. /**
  23367. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23368. */
  23369. side: number;
  23370. /**
  23371. * Creates a box geometry
  23372. * @param id defines the unique ID of the geometry
  23373. * @param scene defines the hosting scene
  23374. * @param size defines the zise of the box (width, height and depth are the same)
  23375. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23376. * @param mesh defines the hosting mesh (can be null)
  23377. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23378. */
  23379. constructor(id: string, scene: Scene,
  23380. /**
  23381. * Defines the zise of the box (width, height and depth are the same)
  23382. */
  23383. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23384. /**
  23385. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23386. */
  23387. side?: number);
  23388. /** @hidden */
  23389. _regenerateVertexData(): VertexData;
  23390. copy(id: string): Geometry;
  23391. serialize(): any;
  23392. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  23393. }
  23394. /**
  23395. * Creates a sphere geometry
  23396. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  23397. */
  23398. class SphereGeometry extends _PrimitiveGeometry {
  23399. /**
  23400. * Defines the number of segments to use to create the sphere
  23401. */
  23402. segments: number;
  23403. /**
  23404. * Defines the diameter of the sphere
  23405. */
  23406. diameter: number;
  23407. /**
  23408. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23409. */
  23410. side: number;
  23411. /**
  23412. * Create a new sphere geometry
  23413. * @param id defines the unique ID of the geometry
  23414. * @param scene defines the hosting scene
  23415. * @param segments defines the number of segments to use to create the sphere
  23416. * @param diameter defines the diameter of the sphere
  23417. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23418. * @param mesh defines the hosting mesh (can be null)
  23419. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23420. */
  23421. constructor(id: string, scene: Scene,
  23422. /**
  23423. * Defines the number of segments to use to create the sphere
  23424. */
  23425. segments: number,
  23426. /**
  23427. * Defines the diameter of the sphere
  23428. */
  23429. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23430. /**
  23431. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23432. */
  23433. side?: number);
  23434. /** @hidden */
  23435. _regenerateVertexData(): VertexData;
  23436. copy(id: string): Geometry;
  23437. serialize(): any;
  23438. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  23439. }
  23440. /**
  23441. * Creates a disc geometry
  23442. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23443. */
  23444. class DiscGeometry extends _PrimitiveGeometry {
  23445. /**
  23446. * Defines the radius of the disc
  23447. */
  23448. radius: number;
  23449. /**
  23450. * Defines the tesselation factor to apply to the disc
  23451. */
  23452. tessellation: number;
  23453. /**
  23454. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23455. */
  23456. side: number;
  23457. /**
  23458. * Creates a new disc geometry
  23459. * @param id defines the unique ID of the geometry
  23460. * @param scene defines the hosting scene
  23461. * @param radius defines the radius of the disc
  23462. * @param tessellation defines the tesselation factor to apply to the disc
  23463. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23464. * @param mesh defines the hosting mesh (can be null)
  23465. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23466. */
  23467. constructor(id: string, scene: Scene,
  23468. /**
  23469. * Defines the radius of the disc
  23470. */
  23471. radius: number,
  23472. /**
  23473. * Defines the tesselation factor to apply to the disc
  23474. */
  23475. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23476. /**
  23477. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23478. */
  23479. side?: number);
  23480. /** @hidden */
  23481. _regenerateVertexData(): VertexData;
  23482. copy(id: string): Geometry;
  23483. }
  23484. /**
  23485. * Creates a new cylinder geometry
  23486. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23487. */
  23488. class CylinderGeometry extends _PrimitiveGeometry {
  23489. /**
  23490. * Defines the height of the cylinder
  23491. */
  23492. height: number;
  23493. /**
  23494. * Defines the diameter of the cylinder's top cap
  23495. */
  23496. diameterTop: number;
  23497. /**
  23498. * Defines the diameter of the cylinder's bottom cap
  23499. */
  23500. diameterBottom: number;
  23501. /**
  23502. * Defines the tessellation factor to apply to the cylinder
  23503. */
  23504. tessellation: number;
  23505. /**
  23506. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  23507. */
  23508. subdivisions: number;
  23509. /**
  23510. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23511. */
  23512. side: number;
  23513. /**
  23514. * Creates a new cylinder geometry
  23515. * @param id defines the unique ID of the geometry
  23516. * @param scene defines the hosting scene
  23517. * @param height defines the height of the cylinder
  23518. * @param diameterTop defines the diameter of the cylinder's top cap
  23519. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  23520. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  23521. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  23522. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23523. * @param mesh defines the hosting mesh (can be null)
  23524. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23525. */
  23526. constructor(id: string, scene: Scene,
  23527. /**
  23528. * Defines the height of the cylinder
  23529. */
  23530. height: number,
  23531. /**
  23532. * Defines the diameter of the cylinder's top cap
  23533. */
  23534. diameterTop: number,
  23535. /**
  23536. * Defines the diameter of the cylinder's bottom cap
  23537. */
  23538. diameterBottom: number,
  23539. /**
  23540. * Defines the tessellation factor to apply to the cylinder
  23541. */
  23542. tessellation: number,
  23543. /**
  23544. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  23545. */
  23546. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23547. /**
  23548. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23549. */
  23550. side?: number);
  23551. /** @hidden */
  23552. _regenerateVertexData(): VertexData;
  23553. copy(id: string): Geometry;
  23554. serialize(): any;
  23555. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  23556. }
  23557. /**
  23558. * Creates a new torus geometry
  23559. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  23560. */
  23561. class TorusGeometry extends _PrimitiveGeometry {
  23562. /**
  23563. * Defines the diameter of the torus
  23564. */
  23565. diameter: number;
  23566. /**
  23567. * Defines the thickness of the torus (ie. internal diameter)
  23568. */
  23569. thickness: number;
  23570. /**
  23571. * Defines the tesselation factor to apply to the torus
  23572. */
  23573. tessellation: number;
  23574. /**
  23575. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23576. */
  23577. side: number;
  23578. /**
  23579. * Creates a new torus geometry
  23580. * @param id defines the unique ID of the geometry
  23581. * @param scene defines the hosting scene
  23582. * @param diameter defines the diameter of the torus
  23583. * @param thickness defines the thickness of the torus (ie. internal diameter)
  23584. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  23585. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23586. * @param mesh defines the hosting mesh (can be null)
  23587. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23588. */
  23589. constructor(id: string, scene: Scene,
  23590. /**
  23591. * Defines the diameter of the torus
  23592. */
  23593. diameter: number,
  23594. /**
  23595. * Defines the thickness of the torus (ie. internal diameter)
  23596. */
  23597. thickness: number,
  23598. /**
  23599. * Defines the tesselation factor to apply to the torus
  23600. */
  23601. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23602. /**
  23603. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23604. */
  23605. side?: number);
  23606. /** @hidden */
  23607. _regenerateVertexData(): VertexData;
  23608. copy(id: string): Geometry;
  23609. serialize(): any;
  23610. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  23611. }
  23612. /**
  23613. * Creates a new ground geometry
  23614. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  23615. */
  23616. class GroundGeometry extends _PrimitiveGeometry {
  23617. /**
  23618. * Defines the width of the ground
  23619. */
  23620. width: number;
  23621. /**
  23622. * Defines the height of the ground
  23623. */
  23624. height: number;
  23625. /**
  23626. * Defines the subdivisions to apply to the ground
  23627. */
  23628. subdivisions: number;
  23629. /**
  23630. * Creates a new ground geometry
  23631. * @param id defines the unique ID of the geometry
  23632. * @param scene defines the hosting scene
  23633. * @param width defines the width of the ground
  23634. * @param height defines the height of the ground
  23635. * @param subdivisions defines the subdivisions to apply to the ground
  23636. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23637. * @param mesh defines the hosting mesh (can be null)
  23638. */
  23639. constructor(id: string, scene: Scene,
  23640. /**
  23641. * Defines the width of the ground
  23642. */
  23643. width: number,
  23644. /**
  23645. * Defines the height of the ground
  23646. */
  23647. height: number,
  23648. /**
  23649. * Defines the subdivisions to apply to the ground
  23650. */
  23651. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23652. /** @hidden */
  23653. _regenerateVertexData(): VertexData;
  23654. copy(id: string): Geometry;
  23655. serialize(): any;
  23656. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  23657. }
  23658. /**
  23659. * Creates a tiled ground geometry
  23660. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  23661. */
  23662. class TiledGroundGeometry extends _PrimitiveGeometry {
  23663. /**
  23664. * Defines the minimum value on X axis
  23665. */
  23666. xmin: number;
  23667. /**
  23668. * Defines the minimum value on Z axis
  23669. */
  23670. zmin: number;
  23671. /**
  23672. * Defines the maximum value on X axis
  23673. */
  23674. xmax: number;
  23675. /**
  23676. * Defines the maximum value on Z axis
  23677. */
  23678. zmax: number;
  23679. /**
  23680. * Defines the subdivisions to apply to the ground
  23681. */
  23682. subdivisions: {
  23683. w: number;
  23684. h: number;
  23685. };
  23686. /**
  23687. * Defines the precision to use when computing the tiles
  23688. */
  23689. precision: {
  23690. w: number;
  23691. h: number;
  23692. };
  23693. /**
  23694. * Creates a tiled ground geometry
  23695. * @param id defines the unique ID of the geometry
  23696. * @param scene defines the hosting scene
  23697. * @param xmin defines the minimum value on X axis
  23698. * @param zmin defines the minimum value on Z axis
  23699. * @param xmax defines the maximum value on X axis
  23700. * @param zmax defines the maximum value on Z axis
  23701. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  23702. * @param precision defines the precision to use when computing the tiles
  23703. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23704. * @param mesh defines the hosting mesh (can be null)
  23705. */
  23706. constructor(id: string, scene: Scene,
  23707. /**
  23708. * Defines the minimum value on X axis
  23709. */
  23710. xmin: number,
  23711. /**
  23712. * Defines the minimum value on Z axis
  23713. */
  23714. zmin: number,
  23715. /**
  23716. * Defines the maximum value on X axis
  23717. */
  23718. xmax: number,
  23719. /**
  23720. * Defines the maximum value on Z axis
  23721. */
  23722. zmax: number,
  23723. /**
  23724. * Defines the subdivisions to apply to the ground
  23725. */
  23726. subdivisions: {
  23727. w: number;
  23728. h: number;
  23729. },
  23730. /**
  23731. * Defines the precision to use when computing the tiles
  23732. */
  23733. precision: {
  23734. w: number;
  23735. h: number;
  23736. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23737. /** @hidden */
  23738. _regenerateVertexData(): VertexData;
  23739. copy(id: string): Geometry;
  23740. }
  23741. /**
  23742. * Creates a plane geometry
  23743. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  23744. */
  23745. class PlaneGeometry extends _PrimitiveGeometry {
  23746. /**
  23747. * Defines the size of the plane (width === height)
  23748. */
  23749. size: number;
  23750. /**
  23751. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23752. */
  23753. side: number;
  23754. /**
  23755. * Creates a plane geometry
  23756. * @param id defines the unique ID of the geometry
  23757. * @param scene defines the hosting scene
  23758. * @param size defines the size of the plane (width === height)
  23759. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23760. * @param mesh defines the hosting mesh (can be null)
  23761. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23762. */
  23763. constructor(id: string, scene: Scene,
  23764. /**
  23765. * Defines the size of the plane (width === height)
  23766. */
  23767. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23768. /**
  23769. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23770. */
  23771. side?: number);
  23772. /** @hidden */
  23773. _regenerateVertexData(): VertexData;
  23774. copy(id: string): Geometry;
  23775. serialize(): any;
  23776. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  23777. }
  23778. /**
  23779. * Creates a torus knot geometry
  23780. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23781. */
  23782. class TorusKnotGeometry extends _PrimitiveGeometry {
  23783. /**
  23784. * Defines the radius of the torus knot
  23785. */
  23786. radius: number;
  23787. /**
  23788. * Defines the thickness of the torus knot tube
  23789. */
  23790. tube: number;
  23791. /**
  23792. * Defines the number of radial segments
  23793. */
  23794. radialSegments: number;
  23795. /**
  23796. * Defines the number of tubular segments
  23797. */
  23798. tubularSegments: number;
  23799. /**
  23800. * Defines the first number of windings
  23801. */
  23802. p: number;
  23803. /**
  23804. * Defines the second number of windings
  23805. */
  23806. q: number;
  23807. /**
  23808. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23809. */
  23810. side: number;
  23811. /**
  23812. * Creates a torus knot geometry
  23813. * @param id defines the unique ID of the geometry
  23814. * @param scene defines the hosting scene
  23815. * @param radius defines the radius of the torus knot
  23816. * @param tube defines the thickness of the torus knot tube
  23817. * @param radialSegments defines the number of radial segments
  23818. * @param tubularSegments defines the number of tubular segments
  23819. * @param p defines the first number of windings
  23820. * @param q defines the second number of windings
  23821. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23822. * @param mesh defines the hosting mesh (can be null)
  23823. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23824. */
  23825. constructor(id: string, scene: Scene,
  23826. /**
  23827. * Defines the radius of the torus knot
  23828. */
  23829. radius: number,
  23830. /**
  23831. * Defines the thickness of the torus knot tube
  23832. */
  23833. tube: number,
  23834. /**
  23835. * Defines the number of radial segments
  23836. */
  23837. radialSegments: number,
  23838. /**
  23839. * Defines the number of tubular segments
  23840. */
  23841. tubularSegments: number,
  23842. /**
  23843. * Defines the first number of windings
  23844. */
  23845. p: number,
  23846. /**
  23847. * Defines the second number of windings
  23848. */
  23849. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23850. /**
  23851. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23852. */
  23853. side?: number);
  23854. /** @hidden */
  23855. _regenerateVertexData(): VertexData;
  23856. copy(id: string): Geometry;
  23857. serialize(): any;
  23858. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  23859. }
  23860. }
  23861. declare module BABYLON {
  23862. class GroundMesh extends Mesh {
  23863. generateOctree: boolean;
  23864. private _heightQuads;
  23865. /** @hidden */
  23866. _subdivisionsX: number;
  23867. /** @hidden */
  23868. _subdivisionsY: number;
  23869. /** @hidden */
  23870. _width: number;
  23871. /** @hidden */
  23872. _height: number;
  23873. /** @hidden */
  23874. _minX: number;
  23875. /** @hidden */
  23876. _maxX: number;
  23877. /** @hidden */
  23878. _minZ: number;
  23879. /** @hidden */
  23880. _maxZ: number;
  23881. constructor(name: string, scene: Scene);
  23882. getClassName(): string;
  23883. readonly subdivisions: number;
  23884. readonly subdivisionsX: number;
  23885. readonly subdivisionsY: number;
  23886. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23887. /**
  23888. * Returns a height (y) value in the Worl system :
  23889. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23890. * Returns the ground y position if (x, z) are outside the ground surface.
  23891. */
  23892. getHeightAtCoordinates(x: number, z: number): number;
  23893. /**
  23894. * Returns a normalized vector (Vector3) orthogonal to the ground
  23895. * at the ground coordinates (x, z) expressed in the World system.
  23896. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23897. */
  23898. getNormalAtCoordinates(x: number, z: number): Vector3;
  23899. /**
  23900. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23901. * at the ground coordinates (x, z) expressed in the World system.
  23902. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23903. * Returns the GroundMesh.
  23904. */
  23905. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23906. /**
  23907. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23908. * if the ground has been updated.
  23909. * This can be used in the render loop.
  23910. * Returns the GroundMesh.
  23911. */
  23912. updateCoordinateHeights(): GroundMesh;
  23913. private _getFacetAt;
  23914. private _initHeightQuads;
  23915. private _computeHeightQuads;
  23916. serialize(serializationObject: any): void;
  23917. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23918. }
  23919. }
  23920. declare module BABYLON {
  23921. /**
  23922. * Creates an instance based on a source mesh.
  23923. */
  23924. class InstancedMesh extends AbstractMesh {
  23925. private _sourceMesh;
  23926. private _currentLOD;
  23927. constructor(name: string, source: Mesh);
  23928. /**
  23929. * Returns the string "InstancedMesh".
  23930. */
  23931. getClassName(): string;
  23932. readonly receiveShadows: boolean;
  23933. readonly material: Nullable<Material>;
  23934. readonly visibility: number;
  23935. readonly skeleton: Nullable<Skeleton>;
  23936. renderingGroupId: number;
  23937. /**
  23938. * Returns the total number of vertices (integer).
  23939. */
  23940. getTotalVertices(): number;
  23941. readonly sourceMesh: Mesh;
  23942. /**
  23943. * Is this node ready to be used/rendered
  23944. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23945. * @return {boolean} is it ready
  23946. */
  23947. isReady(completeCheck?: boolean): boolean;
  23948. /**
  23949. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  23950. */
  23951. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  23952. /**
  23953. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23954. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23955. * The `data` are either a numeric array either a Float32Array.
  23956. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  23957. * 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).
  23958. * Note that a new underlying VertexBuffer object is created each call.
  23959. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23960. *
  23961. * Possible `kind` values :
  23962. * - BABYLON.VertexBuffer.PositionKind
  23963. * - BABYLON.VertexBuffer.UVKind
  23964. * - BABYLON.VertexBuffer.UV2Kind
  23965. * - BABYLON.VertexBuffer.UV3Kind
  23966. * - BABYLON.VertexBuffer.UV4Kind
  23967. * - BABYLON.VertexBuffer.UV5Kind
  23968. * - BABYLON.VertexBuffer.UV6Kind
  23969. * - BABYLON.VertexBuffer.ColorKind
  23970. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23971. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23972. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23973. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23974. *
  23975. * Returns the Mesh.
  23976. */
  23977. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23978. /**
  23979. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23980. * If the mesh has no geometry, it is simply returned as it is.
  23981. * The `data` are either a numeric array either a Float32Array.
  23982. * No new underlying VertexBuffer object is created.
  23983. * 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.
  23984. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  23985. *
  23986. * Possible `kind` values :
  23987. * - BABYLON.VertexBuffer.PositionKind
  23988. * - BABYLON.VertexBuffer.UVKind
  23989. * - BABYLON.VertexBuffer.UV2Kind
  23990. * - BABYLON.VertexBuffer.UV3Kind
  23991. * - BABYLON.VertexBuffer.UV4Kind
  23992. * - BABYLON.VertexBuffer.UV5Kind
  23993. * - BABYLON.VertexBuffer.UV6Kind
  23994. * - BABYLON.VertexBuffer.ColorKind
  23995. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23996. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23997. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23998. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23999. *
  24000. * Returns the Mesh.
  24001. */
  24002. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24003. /**
  24004. * Sets the mesh indices.
  24005. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  24006. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24007. * This method creates a new index buffer each call.
  24008. * Returns the Mesh.
  24009. */
  24010. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  24011. /**
  24012. * Boolean : True if the mesh owns the requested kind of data.
  24013. */
  24014. isVerticesDataPresent(kind: string): boolean;
  24015. /**
  24016. * Returns an array of indices (IndicesArray).
  24017. */
  24018. getIndices(): Nullable<IndicesArray>;
  24019. readonly _positions: Nullable<Vector3[]>;
  24020. /**
  24021. * Sets a new updated BoundingInfo to the mesh.
  24022. * Returns the mesh.
  24023. */
  24024. refreshBoundingInfo(): InstancedMesh;
  24025. /** @hidden */
  24026. _preActivate(): InstancedMesh;
  24027. /** @hidden */
  24028. _activate(renderId: number): InstancedMesh;
  24029. /**
  24030. * Returns the current associated LOD AbstractMesh.
  24031. */
  24032. getLOD(camera: Camera): AbstractMesh;
  24033. /** @hidden */
  24034. _syncSubMeshes(): InstancedMesh;
  24035. /** @hidden */
  24036. _generatePointsArray(): boolean;
  24037. /**
  24038. * Creates a new InstancedMesh from the current mesh.
  24039. * - name (string) : the cloned mesh name
  24040. * - newParent (optional Node) : the optional Node to parent the clone to.
  24041. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  24042. *
  24043. * Returns the clone.
  24044. */
  24045. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  24046. /**
  24047. * Disposes the InstancedMesh.
  24048. * Returns nothing.
  24049. */
  24050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24051. }
  24052. }
  24053. declare module BABYLON {
  24054. class LinesMesh extends Mesh {
  24055. useVertexColor?: boolean | undefined;
  24056. useVertexAlpha?: boolean | undefined;
  24057. color: Color3;
  24058. alpha: number;
  24059. /**
  24060. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  24061. * This margin is expressed in world space coordinates, so its value may vary.
  24062. * Default value is 0.1
  24063. * @returns the intersection Threshold value.
  24064. */
  24065. /**
  24066. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  24067. * This margin is expressed in world space coordinates, so its value may vary.
  24068. * @param value the new threshold to apply
  24069. */
  24070. intersectionThreshold: number;
  24071. private _intersectionThreshold;
  24072. private _colorShader;
  24073. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  24074. /**
  24075. * Returns the string "LineMesh"
  24076. */
  24077. getClassName(): string;
  24078. /**
  24079. * @hidden
  24080. */
  24081. /**
  24082. * @hidden
  24083. */
  24084. material: Material;
  24085. /**
  24086. * @hidden
  24087. */
  24088. readonly checkCollisions: boolean;
  24089. createInstance(name: string): InstancedMesh;
  24090. /** @hidden */
  24091. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  24092. /** @hidden */
  24093. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  24094. dispose(doNotRecurse?: boolean): void;
  24095. /**
  24096. * Returns a new LineMesh object cloned from the current one.
  24097. */
  24098. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * @hidden
  24104. **/
  24105. class _InstancesBatch {
  24106. mustReturn: boolean;
  24107. visibleInstances: Nullable<InstancedMesh[]>[];
  24108. renderSelf: boolean[];
  24109. }
  24110. /**
  24111. * Class used to represent renderable models
  24112. */
  24113. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24114. /**
  24115. * Mesh side orientation : usually the external or front surface
  24116. */
  24117. static readonly FRONTSIDE: number;
  24118. /**
  24119. * Mesh side orientation : usually the internal or back surface
  24120. */
  24121. static readonly BACKSIDE: number;
  24122. /**
  24123. * Mesh side orientation : both internal and external or front and back surfaces
  24124. */
  24125. static readonly DOUBLESIDE: number;
  24126. /**
  24127. * Mesh side orientation : by default, `FRONTSIDE`
  24128. */
  24129. static readonly DEFAULTSIDE: number;
  24130. /**
  24131. * Mesh cap setting : no cap
  24132. */
  24133. static readonly NO_CAP: number;
  24134. /**
  24135. * Mesh cap setting : one cap at the beginning of the mesh
  24136. */
  24137. static readonly CAP_START: number;
  24138. /**
  24139. * Mesh cap setting : one cap at the end of the mesh
  24140. */
  24141. static readonly CAP_END: number;
  24142. /**
  24143. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24144. */
  24145. static readonly CAP_ALL: number;
  24146. private _onBeforeRenderObservable;
  24147. private _onAfterRenderObservable;
  24148. private _onBeforeDrawObservable;
  24149. /**
  24150. * An event triggered before rendering the mesh
  24151. */
  24152. readonly onBeforeRenderObservable: Observable<Mesh>;
  24153. /**
  24154. * An event triggered after rendering the mesh
  24155. */
  24156. readonly onAfterRenderObservable: Observable<Mesh>;
  24157. /**
  24158. * An event triggered before drawing the mesh
  24159. */
  24160. readonly onBeforeDrawObservable: Observable<Mesh>;
  24161. private _onBeforeDrawObserver;
  24162. /**
  24163. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24164. */
  24165. onBeforeDraw: () => void;
  24166. /**
  24167. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24168. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24169. */
  24170. delayLoadState: number;
  24171. /**
  24172. * Gets the list of instances created from this mesh
  24173. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24174. */
  24175. instances: InstancedMesh[];
  24176. /**
  24177. * Gets the file containing delay loading data for this mesh
  24178. */
  24179. delayLoadingFile: string;
  24180. /** @hidden */
  24181. _binaryInfo: any;
  24182. private _LODLevels;
  24183. /**
  24184. * User defined function used to change how LOD level selection is done
  24185. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24186. */
  24187. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24188. private _morphTargetManager;
  24189. /**
  24190. * Gets or sets the morph target manager
  24191. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24192. */
  24193. morphTargetManager: Nullable<MorphTargetManager>;
  24194. /** @hidden */
  24195. _geometry: Nullable<Geometry>;
  24196. /** @hidden */
  24197. _delayInfo: Array<string>;
  24198. /** @hidden */
  24199. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24200. /** @hidden */
  24201. _visibleInstances: any;
  24202. private _renderIdForInstances;
  24203. private _batchCache;
  24204. private _instancesBufferSize;
  24205. private _instancesBuffer;
  24206. private _instancesData;
  24207. private _overridenInstanceCount;
  24208. private _effectiveMaterial;
  24209. /** @hidden */
  24210. _shouldGenerateFlatShading: boolean;
  24211. private _preActivateId;
  24212. /** @hidden */
  24213. _originalBuilderSideOrientation: number;
  24214. /**
  24215. * Use this property to change the original side orientation defined at construction time
  24216. */
  24217. overrideMaterialSideOrientation: Nullable<number>;
  24218. private _areNormalsFrozen;
  24219. private _sourcePositions;
  24220. private _sourceNormals;
  24221. private _source;
  24222. /**
  24223. * Gets the source mesh (the one used to clone this one from)
  24224. */
  24225. readonly source: Nullable<Mesh>;
  24226. /**
  24227. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24228. */
  24229. isUnIndexed: boolean;
  24230. /**
  24231. * @constructor
  24232. * @param name The value used by scene.getMeshByName() to do a lookup.
  24233. * @param scene The scene to add this mesh to.
  24234. * @param parent The parent of this mesh, if it has one
  24235. * @param source An optional Mesh from which geometry is shared, cloned.
  24236. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24237. * When false, achieved by calling a clone(), also passing False.
  24238. * This will make creation of children, recursive.
  24239. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24240. */
  24241. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24242. /**
  24243. * Gets the class name
  24244. * @returns the string "Mesh".
  24245. */
  24246. getClassName(): string;
  24247. /**
  24248. * Returns a description of this mesh
  24249. * @param fullDetails define if full details about this mesh must be used
  24250. * @returns a descriptive string representing this mesh
  24251. */
  24252. toString(fullDetails?: boolean): string;
  24253. /** @hidden */
  24254. _unBindEffect(): void;
  24255. /**
  24256. * Gets a boolean indicating if this mesh has LOD
  24257. */
  24258. readonly hasLODLevels: boolean;
  24259. /**
  24260. * Gets the list of MeshLODLevel associated with the current mesh
  24261. * @returns an array of MeshLODLevel
  24262. */
  24263. getLODLevels(): MeshLODLevel[];
  24264. private _sortLODLevels;
  24265. /**
  24266. * Add a mesh as LOD level triggered at the given distance.
  24267. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24268. * @param distance The distance from the center of the object to show this level
  24269. * @param mesh The mesh to be added as LOD level (can be null)
  24270. * @return This mesh (for chaining)
  24271. */
  24272. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24273. /**
  24274. * Returns the LOD level mesh at the passed distance or null if not found.
  24275. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24276. * @param distance The distance from the center of the object to show this level
  24277. * @returns a Mesh or `null`
  24278. */
  24279. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24280. /**
  24281. * Remove a mesh from the LOD array
  24282. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24283. * @param mesh defines the mesh to be removed
  24284. * @return This mesh (for chaining)
  24285. */
  24286. removeLODLevel(mesh: Mesh): Mesh;
  24287. /**
  24288. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24289. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24290. * @param camera defines the camera to use to compute distance
  24291. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24292. * @return This mesh (for chaining)
  24293. */
  24294. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24295. /**
  24296. * Gets the mesh internal Geometry object
  24297. */
  24298. readonly geometry: Nullable<Geometry>;
  24299. /**
  24300. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24301. * @returns the total number of vertices
  24302. */
  24303. getTotalVertices(): number;
  24304. /**
  24305. * Returns the content of an associated vertex buffer
  24306. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24307. * - BABYLON.VertexBuffer.PositionKind
  24308. * - BABYLON.VertexBuffer.UVKind
  24309. * - BABYLON.VertexBuffer.UV2Kind
  24310. * - BABYLON.VertexBuffer.UV3Kind
  24311. * - BABYLON.VertexBuffer.UV4Kind
  24312. * - BABYLON.VertexBuffer.UV5Kind
  24313. * - BABYLON.VertexBuffer.UV6Kind
  24314. * - BABYLON.VertexBuffer.ColorKind
  24315. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24316. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24317. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24318. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24319. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24320. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24321. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24322. */
  24323. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24324. /**
  24325. * Returns the mesh VertexBuffer object from the requested `kind`
  24326. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24327. * - BABYLON.VertexBuffer.PositionKind
  24328. * - BABYLON.VertexBuffer.UVKind
  24329. * - BABYLON.VertexBuffer.UV2Kind
  24330. * - BABYLON.VertexBuffer.UV3Kind
  24331. * - BABYLON.VertexBuffer.UV4Kind
  24332. * - BABYLON.VertexBuffer.UV5Kind
  24333. * - BABYLON.VertexBuffer.UV6Kind
  24334. * - BABYLON.VertexBuffer.ColorKind
  24335. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24336. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24337. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24338. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24339. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24340. */
  24341. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24342. /**
  24343. * Tests if a specific vertex buffer is associated with this mesh
  24344. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24345. * - BABYLON.VertexBuffer.PositionKind
  24346. * - BABYLON.VertexBuffer.UVKind
  24347. * - BABYLON.VertexBuffer.UV2Kind
  24348. * - BABYLON.VertexBuffer.UV3Kind
  24349. * - BABYLON.VertexBuffer.UV4Kind
  24350. * - BABYLON.VertexBuffer.UV5Kind
  24351. * - BABYLON.VertexBuffer.UV6Kind
  24352. * - BABYLON.VertexBuffer.ColorKind
  24353. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24354. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24355. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24356. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24357. * @returns a boolean
  24358. */
  24359. isVerticesDataPresent(kind: string): boolean;
  24360. /**
  24361. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24362. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24363. * - BABYLON.VertexBuffer.PositionKind
  24364. * - BABYLON.VertexBuffer.UVKind
  24365. * - BABYLON.VertexBuffer.UV2Kind
  24366. * - BABYLON.VertexBuffer.UV3Kind
  24367. * - BABYLON.VertexBuffer.UV4Kind
  24368. * - BABYLON.VertexBuffer.UV5Kind
  24369. * - BABYLON.VertexBuffer.UV6Kind
  24370. * - BABYLON.VertexBuffer.ColorKind
  24371. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24372. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24373. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24374. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24375. * @returns a boolean
  24376. */
  24377. isVertexBufferUpdatable(kind: string): boolean;
  24378. /**
  24379. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24380. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24381. * - BABYLON.VertexBuffer.PositionKind
  24382. * - BABYLON.VertexBuffer.UVKind
  24383. * - BABYLON.VertexBuffer.UV2Kind
  24384. * - BABYLON.VertexBuffer.UV3Kind
  24385. * - BABYLON.VertexBuffer.UV4Kind
  24386. * - BABYLON.VertexBuffer.UV5Kind
  24387. * - BABYLON.VertexBuffer.UV6Kind
  24388. * - BABYLON.VertexBuffer.ColorKind
  24389. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24390. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24391. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24392. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24393. * @returns an array of strings
  24394. */
  24395. getVerticesDataKinds(): string[];
  24396. /**
  24397. * Returns a positive integer : the total number of indices in this mesh geometry.
  24398. * @returns the numner of indices or zero if the mesh has no geometry.
  24399. */
  24400. getTotalIndices(): number;
  24401. /**
  24402. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24403. * @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.
  24404. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24405. * @returns the indices array or an empty array if the mesh has no geometry
  24406. */
  24407. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24408. readonly isBlocked: boolean;
  24409. /**
  24410. * Determine if the current mesh is ready to be rendered
  24411. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24412. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24413. * @returns true if all associated assets are ready (material, textures, shaders)
  24414. */
  24415. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24416. /**
  24417. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24418. */
  24419. readonly areNormalsFrozen: boolean;
  24420. /**
  24421. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24422. * @returns the current mesh
  24423. */
  24424. freezeNormals(): Mesh;
  24425. /**
  24426. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24427. * @returns the current mesh
  24428. */
  24429. unfreezeNormals(): Mesh;
  24430. /**
  24431. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24432. */
  24433. overridenInstanceCount: number;
  24434. /** @hidden */
  24435. _preActivate(): Mesh;
  24436. /** @hidden */
  24437. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24438. /** @hidden */
  24439. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24440. /**
  24441. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24442. * This means the mesh underlying bounding box and sphere are recomputed.
  24443. * @returns the current mesh
  24444. */
  24445. refreshBoundingInfo(): Mesh;
  24446. /** @hidden */
  24447. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  24448. private _getPositionData;
  24449. /** @hidden */
  24450. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24451. /**
  24452. * This function will subdivide the mesh into multiple submeshes
  24453. * @param count defines the expected number of submeshes
  24454. */
  24455. subdivide(count: number): void;
  24456. /**
  24457. * Copy a FloatArray into a specific associated vertex buffer
  24458. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24459. * - BABYLON.VertexBuffer.PositionKind
  24460. * - BABYLON.VertexBuffer.UVKind
  24461. * - BABYLON.VertexBuffer.UV2Kind
  24462. * - BABYLON.VertexBuffer.UV3Kind
  24463. * - BABYLON.VertexBuffer.UV4Kind
  24464. * - BABYLON.VertexBuffer.UV5Kind
  24465. * - BABYLON.VertexBuffer.UV6Kind
  24466. * - BABYLON.VertexBuffer.ColorKind
  24467. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24468. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24469. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24470. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24471. * @param data defines the data source
  24472. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24473. * @param stride defines the data stride size (can be null)
  24474. * @returns the current mesh
  24475. */
  24476. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24477. /**
  24478. * Flags an associated vertex buffer as updatable
  24479. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24480. * - BABYLON.VertexBuffer.PositionKind
  24481. * - BABYLON.VertexBuffer.UVKind
  24482. * - BABYLON.VertexBuffer.UV2Kind
  24483. * - BABYLON.VertexBuffer.UV3Kind
  24484. * - BABYLON.VertexBuffer.UV4Kind
  24485. * - BABYLON.VertexBuffer.UV5Kind
  24486. * - BABYLON.VertexBuffer.UV6Kind
  24487. * - BABYLON.VertexBuffer.ColorKind
  24488. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24489. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24490. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24491. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24492. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24493. */
  24494. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24495. /**
  24496. * Sets the mesh global Vertex Buffer
  24497. * @param buffer defines the buffer to use
  24498. * @returns the current mesh
  24499. */
  24500. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24501. /**
  24502. * Update a specific associated vertex buffer
  24503. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24504. * - BABYLON.VertexBuffer.PositionKind
  24505. * - BABYLON.VertexBuffer.UVKind
  24506. * - BABYLON.VertexBuffer.UV2Kind
  24507. * - BABYLON.VertexBuffer.UV3Kind
  24508. * - BABYLON.VertexBuffer.UV4Kind
  24509. * - BABYLON.VertexBuffer.UV5Kind
  24510. * - BABYLON.VertexBuffer.UV6Kind
  24511. * - BABYLON.VertexBuffer.ColorKind
  24512. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24513. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24514. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24515. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24516. * @param data defines the data source
  24517. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24518. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24519. * @returns the current mesh
  24520. */
  24521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24522. /**
  24523. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24524. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24525. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24526. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24527. * @returns the current mesh
  24528. */
  24529. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24530. /**
  24531. * Creates a un-shared specific occurence of the geometry for the mesh.
  24532. * @returns the current mesh
  24533. */
  24534. makeGeometryUnique(): Mesh;
  24535. /**
  24536. * Set the index buffer of this mesh
  24537. * @param indices defines the source data
  24538. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24539. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24540. * @returns the current mesh
  24541. */
  24542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24543. /**
  24544. * Update the current index buffer
  24545. * @param indices defines the source data
  24546. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24547. * @returns the current mesh
  24548. */
  24549. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  24550. /**
  24551. * Invert the geometry to move from a right handed system to a left handed one.
  24552. * @returns the current mesh
  24553. */
  24554. toLeftHanded(): Mesh;
  24555. /** @hidden */
  24556. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24557. /** @hidden */
  24558. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  24559. /**
  24560. * Registers for this mesh a javascript function called just before the rendering process
  24561. * @param func defines the function to call before rendering this mesh
  24562. * @returns the current mesh
  24563. */
  24564. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24565. /**
  24566. * Disposes a previously registered javascript function called before the rendering
  24567. * @param func defines the function to remove
  24568. * @returns the current mesh
  24569. */
  24570. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24571. /**
  24572. * Registers for this mesh a javascript function called just after the rendering is complete
  24573. * @param func defines the function to call after rendering this mesh
  24574. * @returns the current mesh
  24575. */
  24576. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24577. /**
  24578. * Disposes a previously registered javascript function called after the rendering.
  24579. * @param func defines the function to remove
  24580. * @returns the current mesh
  24581. */
  24582. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24583. /** @hidden */
  24584. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24585. /** @hidden */
  24586. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24587. /** @hidden */
  24588. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24589. /**
  24590. * 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
  24591. * @param subMesh defines the subMesh to render
  24592. * @param enableAlphaMode defines if alpha mode can be changed
  24593. * @returns the current mesh
  24594. */
  24595. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24596. private _onBeforeDraw;
  24597. /**
  24598. * Normalize matrix weights so that all vertices have a total weight set to 1
  24599. */
  24600. cleanMatrixWeights(): void;
  24601. /** @hidden */
  24602. _checkDelayState(): Mesh;
  24603. private _queueLoad;
  24604. /**
  24605. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24606. * A mesh is in the frustum if its bounding box intersects the frustum
  24607. * @param frustumPlanes defines the frustum to test
  24608. * @returns true if the mesh is in the frustum planes
  24609. */
  24610. isInFrustum(frustumPlanes: Plane[]): boolean;
  24611. /**
  24612. * Sets the mesh material by the material or multiMaterial `id` property
  24613. * @param id is a string identifying the material or the multiMaterial
  24614. * @returns the current mesh
  24615. */
  24616. setMaterialByID(id: string): Mesh;
  24617. /**
  24618. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24619. * @returns an array of IAnimatable
  24620. */
  24621. getAnimatables(): IAnimatable[];
  24622. /**
  24623. * Modifies the mesh geometry according to the passed transformation matrix.
  24624. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24625. * The mesh normals are modified using the same transformation.
  24626. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24627. * @param transform defines the transform matrix to use
  24628. * @see http://doc.babylonjs.com/resources/baking_transformations
  24629. * @returns the current mesh
  24630. */
  24631. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24632. /**
  24633. * Modifies the mesh geometry according to its own current World Matrix.
  24634. * The mesh World Matrix is then reset.
  24635. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24636. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24637. * @see http://doc.babylonjs.com/resources/baking_transformations
  24638. * @returns the current mesh
  24639. */
  24640. bakeCurrentTransformIntoVertices(): Mesh;
  24641. /** @hidden */
  24642. readonly _positions: Nullable<Vector3[]>;
  24643. /** @hidden */
  24644. _resetPointsArrayCache(): Mesh;
  24645. /** @hidden */
  24646. _generatePointsArray(): boolean;
  24647. /**
  24648. * Returns a new Mesh object generated from the current mesh properties.
  24649. * This method must not get confused with createInstance()
  24650. * @param name is a string, the name given to the new mesh
  24651. * @param newParent can be any Node object (default `null`)
  24652. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24653. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24654. * @returns a new mesh
  24655. */
  24656. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24657. /**
  24658. * Releases resources associated with this mesh.
  24659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24661. */
  24662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24663. /**
  24664. * Modifies the mesh geometry according to a displacement map.
  24665. * 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.
  24666. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24667. * @param url is a string, the URL from the image file is to be downloaded.
  24668. * @param minHeight is the lower limit of the displacement.
  24669. * @param maxHeight is the upper limit of the displacement.
  24670. * @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.
  24671. * @param uvOffset is an optional vector2 used to offset UV.
  24672. * @param uvScale is an optional vector2 used to scale UV.
  24673. * @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.
  24674. * @returns the Mesh.
  24675. */
  24676. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24677. /**
  24678. * Modifies the mesh geometry according to a displacementMap buffer.
  24679. * 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.
  24680. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24681. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24682. * @param heightMapWidth is the width of the buffer image.
  24683. * @param heightMapHeight is the height of the buffer image.
  24684. * @param minHeight is the lower limit of the displacement.
  24685. * @param maxHeight is the upper limit of the displacement.
  24686. * @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.
  24687. * @param uvOffset is an optional vector2 used to offset UV.
  24688. * @param uvScale is an optional vector2 used to scale UV.
  24689. * @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.
  24690. * @returns the Mesh.
  24691. */
  24692. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24693. /**
  24694. * Modify the mesh to get a flat shading rendering.
  24695. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24696. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24697. * @returns current mesh
  24698. */
  24699. convertToFlatShadedMesh(): Mesh;
  24700. /**
  24701. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24702. * In other words, more vertices, no more indices and a single bigger VBO.
  24703. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24704. * @returns current mesh
  24705. */
  24706. convertToUnIndexedMesh(): Mesh;
  24707. /**
  24708. * Inverses facet orientations.
  24709. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24710. * @param flipNormals will also inverts the normals
  24711. * @returns current mesh
  24712. */
  24713. flipFaces(flipNormals?: boolean): Mesh;
  24714. /**
  24715. * Creates a new InstancedMesh object from the mesh model.
  24716. * Warning : this method is not supported for Line mesh and LineSystem
  24717. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24718. * @param name defines the name of the new instance
  24719. * @returns a new InstancedMesh
  24720. */
  24721. createInstance(name: string): InstancedMesh;
  24722. /**
  24723. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24724. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24725. * @returns the current mesh
  24726. */
  24727. synchronizeInstances(): Mesh;
  24728. /**
  24729. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24730. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24731. * This should be used together with the simplification to avoid disappearing triangles.
  24732. * @param successCallback an optional success callback to be called after the optimization finished.
  24733. * @returns the current mesh
  24734. */
  24735. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24736. /**
  24737. * Serialize current mesh
  24738. * @param serializationObject defines the object which will receive the serialization data
  24739. */
  24740. serialize(serializationObject: any): void;
  24741. /** @hidden */
  24742. _syncGeometryWithMorphTargetManager(): void;
  24743. /**
  24744. * Returns a new Mesh object parsed from the source provided.
  24745. * @param parsedMesh is the source
  24746. * @param scene defines the hosting scene
  24747. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24748. * @returns a new Mesh
  24749. */
  24750. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24751. /**
  24752. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24753. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24754. * @param name defines the name of the mesh to create
  24755. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24756. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24757. * @param closePath creates a seam between the first and the last points of each path of the path array
  24758. * @param offset is taken in account only if the `pathArray` is containing a single path
  24759. * @param scene defines the hosting scene
  24760. * @param updatable defines if the mesh must be flagged as updatable
  24761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24762. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24763. * @returns a new Mesh
  24764. */
  24765. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24766. /**
  24767. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24768. * @param name defines the name of the mesh to create
  24769. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24770. * @param 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
  24771. * @param scene defines the hosting scene
  24772. * @param updatable defines if the mesh must be flagged as updatable
  24773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24774. * @returns a new Mesh
  24775. */
  24776. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24777. /**
  24778. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24779. * @param name defines the name of the mesh to create
  24780. * @param size sets the size (float) of each box side (default 1)
  24781. * @param scene defines the hosting scene
  24782. * @param updatable defines if the mesh must be flagged as updatable
  24783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24784. * @returns a new Mesh
  24785. */
  24786. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24787. /**
  24788. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24789. * @param name defines the name of the mesh to create
  24790. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24791. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24792. * @param scene defines the hosting scene
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24795. * @returns a new Mesh
  24796. */
  24797. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24798. /**
  24799. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24800. * @param name defines the name of the mesh to create
  24801. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24802. * @param diameterTop set the top cap diameter (floats, default 1)
  24803. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24804. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24805. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24806. * @param scene defines the hosting scene
  24807. * @param updatable defines if the mesh must be flagged as updatable
  24808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24809. * @returns a new Mesh
  24810. */
  24811. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24812. /**
  24813. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24814. * @param name defines the name of the mesh to create
  24815. * @param diameter sets the diameter size (float) of the torus (default 1)
  24816. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24817. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24818. * @param scene defines the hosting scene
  24819. * @param updatable defines if the mesh must be flagged as updatable
  24820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24821. * @returns a new Mesh
  24822. */
  24823. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24824. /**
  24825. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24826. * @param name defines the name of the mesh to create
  24827. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24828. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24829. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24830. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24831. * @param p the number of windings on X axis (positive integers, default 2)
  24832. * @param q the number of windings on Y axis (positive integers, default 3)
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @returns a new Mesh
  24837. */
  24838. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24839. /**
  24840. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24841. * @param name defines the name of the mesh to create
  24842. * @param points is an array successive Vector3
  24843. * @param scene defines the hosting scene
  24844. * @param updatable defines if the mesh must be flagged as updatable
  24845. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24846. * @returns a new Mesh
  24847. */
  24848. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24849. /**
  24850. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24851. * @param name defines the name of the mesh to create
  24852. * @param points is an array successive Vector3
  24853. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24854. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24855. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24856. * @param scene defines the hosting scene
  24857. * @param updatable defines if the mesh must be flagged as updatable
  24858. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24859. * @returns a new Mesh
  24860. */
  24861. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24862. /**
  24863. * Creates a polygon mesh.
  24864. * Please consider using the same method from the MeshBuilder class instead.
  24865. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24866. * 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.
  24867. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24868. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24869. * Remember you can only change the shape positions, not their number when updating a polygon.
  24870. */
  24871. /**
  24872. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24873. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24874. * @param name defines the name of the mesh to create
  24875. * @param 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
  24876. * @param scene defines the hosting scene
  24877. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24878. * @param updatable defines if the mesh must be flagged as updatable
  24879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24880. * @returns a new Mesh
  24881. */
  24882. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  24883. /**
  24884. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24886. * @param name defines the name of the mesh to create
  24887. * @param 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
  24888. * @param depth defines the height of extrusion
  24889. * @param scene defines the hosting scene
  24890. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24891. * @param updatable defines if the mesh must be flagged as updatable
  24892. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24893. * @returns a new Mesh
  24894. */
  24895. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  24896. /**
  24897. * Creates an extruded shape mesh.
  24898. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24899. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24900. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24901. * @param name defines the name of the mesh to create
  24902. * @param 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
  24903. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24904. * @param scale is the value to scale the shape
  24905. * @param rotation 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
  24906. * @param 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
  24907. * @param scene defines the hosting scene
  24908. * @param updatable defines if the mesh must be flagged as updatable
  24909. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24910. * @param 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/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24911. * @returns a new Mesh
  24912. */
  24913. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24914. /**
  24915. * Creates an custom extruded shape mesh.
  24916. * The custom extrusion is a parametric shape.
  24917. * It has no predefined shape. Its final shape will depend on the input parameters.
  24918. * Please consider using the same method from the MeshBuilder class instead
  24919. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24920. * @param name defines the name of the mesh to create
  24921. * @param 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
  24922. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24923. * @param scaleFunction is a custom Javascript function called on each path point
  24924. * @param rotationFunction is a custom Javascript function called on each path point
  24925. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24926. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24927. * @param 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
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @param 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/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  24932. * @returns a new Mesh
  24933. */
  24934. 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;
  24935. /**
  24936. * Creates lathe mesh.
  24937. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24938. * Please consider using the same method from the MeshBuilder class instead
  24939. * @param name defines the name of the mesh to create
  24940. * @param 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
  24941. * @param radius is the radius value of the lathe
  24942. * @param tessellation is the side number of the lathe.
  24943. * @param scene defines the hosting scene
  24944. * @param updatable defines if the mesh must be flagged as updatable
  24945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24946. * @returns a new Mesh
  24947. */
  24948. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24949. /**
  24950. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24951. * @param name defines the name of the mesh to create
  24952. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24953. * @param scene defines the hosting scene
  24954. * @param updatable defines if the mesh must be flagged as updatable
  24955. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24956. * @returns a new Mesh
  24957. */
  24958. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24959. /**
  24960. * Creates a ground mesh.
  24961. * Please consider using the same method from the MeshBuilder class instead
  24962. * @param name defines the name of the mesh to create
  24963. * @param width set the width of the ground
  24964. * @param height set the height of the ground
  24965. * @param subdivisions sets the number of subdivisions per side
  24966. * @param scene defines the hosting scene
  24967. * @param updatable defines if the mesh must be flagged as updatable
  24968. * @returns a new Mesh
  24969. */
  24970. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24971. /**
  24972. * Creates a tiled ground mesh.
  24973. * Please consider using the same method from the MeshBuilder class instead
  24974. * @param name defines the name of the mesh to create
  24975. * @param xmin set the ground minimum X coordinate
  24976. * @param zmin set the ground minimum Y coordinate
  24977. * @param xmax set the ground maximum X coordinate
  24978. * @param zmax set the ground maximum Z coordinate
  24979. * @param subdivisions is an 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
  24980. * @param precision is an 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
  24981. * @param scene defines the hosting scene
  24982. * @param updatable defines if the mesh must be flagged as updatable
  24983. * @returns a new Mesh
  24984. */
  24985. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24986. w: number;
  24987. h: number;
  24988. }, precision: {
  24989. w: number;
  24990. h: number;
  24991. }, scene: Scene, updatable?: boolean): Mesh;
  24992. /**
  24993. * Creates a ground mesh from a height map.
  24994. * Please consider using the same method from the MeshBuilder class instead
  24995. * @see http://doc.babylonjs.com/babylon101/height_map
  24996. * @param name defines the name of the mesh to create
  24997. * @param url sets the URL of the height map image resource
  24998. * @param width set the ground width size
  24999. * @param height set the ground height size
  25000. * @param subdivisions sets the number of subdivision per side
  25001. * @param minHeight is the minimum altitude on the ground
  25002. * @param maxHeight is the maximum altitude on the ground
  25003. * @param scene defines the hosting scene
  25004. * @param updatable defines if the mesh must be flagged as updatable
  25005. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25006. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25007. * @returns a new Mesh
  25008. */
  25009. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25010. /**
  25011. * Creates a tube mesh.
  25012. * The tube is a parametric shape.
  25013. * It has no predefined shape. Its final shape will depend on the input parameters.
  25014. * Please consider using the same method from the MeshBuilder class instead
  25015. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25016. * @param name defines the name of the mesh to create
  25017. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25018. * @param radius sets the tube radius size
  25019. * @param tessellation is the number of sides on the tubular surface
  25020. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. 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
  25021. * @param 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
  25022. * @param scene defines the hosting scene
  25023. * @param updatable defines if the mesh must be flagged as updatable
  25024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25025. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25026. * @returns a new Mesh
  25027. */
  25028. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25029. (i: number, distance: number): number;
  25030. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25031. /**
  25032. * Creates a polyhedron mesh.
  25033. * Please consider using the same method from the MeshBuilder class instead.
  25034. * * 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
  25035. * * The parameter `size` (positive float, default 1) sets the polygon size
  25036. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25037. * * 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`
  25038. * * 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
  25039. * * 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)`)
  25040. * * 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
  25041. * * 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
  25042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25043. * * 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
  25044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25045. * @param name defines the name of the mesh to create
  25046. * @param options defines the options used to create the mesh
  25047. * @param scene defines the hosting scene
  25048. * @returns a new Mesh
  25049. */
  25050. static CreatePolyhedron(name: string, options: {
  25051. type?: number;
  25052. size?: number;
  25053. sizeX?: number;
  25054. sizeY?: number;
  25055. sizeZ?: number;
  25056. custom?: any;
  25057. faceUV?: Vector4[];
  25058. faceColors?: Color4[];
  25059. updatable?: boolean;
  25060. sideOrientation?: number;
  25061. }, scene: Scene): Mesh;
  25062. /**
  25063. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25064. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25065. * * 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`)
  25066. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25067. * * 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
  25068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25069. * * 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
  25070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25071. * @param name defines the name of the mesh
  25072. * @param options defines the options used to create the mesh
  25073. * @param scene defines the hosting scene
  25074. * @returns a new Mesh
  25075. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25076. */
  25077. static CreateIcoSphere(name: string, options: {
  25078. radius?: number;
  25079. flat?: boolean;
  25080. subdivisions?: number;
  25081. sideOrientation?: number;
  25082. updatable?: boolean;
  25083. }, scene: Scene): Mesh;
  25084. /**
  25085. * Creates a decal mesh.
  25086. * Please consider using the same method from the MeshBuilder class instead.
  25087. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25088. * @param name defines the name of the mesh
  25089. * @param sourceMesh defines the mesh receiving the decal
  25090. * @param position sets the position of the decal in world coordinates
  25091. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25092. * @param size sets the decal scaling
  25093. * @param angle sets the angle to rotate the decal
  25094. * @returns a new Mesh
  25095. */
  25096. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25097. /**
  25098. * Prepare internal position array for software CPU skinning
  25099. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25100. */
  25101. setPositionsForCPUSkinning(): Float32Array;
  25102. /**
  25103. * Prepare internal normal array for software CPU skinning
  25104. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25105. */
  25106. setNormalsForCPUSkinning(): Float32Array;
  25107. /**
  25108. * Updates the vertex buffer by applying transformation from the bones
  25109. * @param skeleton defines the skeleton to apply to current mesh
  25110. * @returns the current mesh
  25111. */
  25112. applySkeleton(skeleton: Skeleton): Mesh;
  25113. /**
  25114. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25115. * @param meshes defines the list of meshes to scan
  25116. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25117. */
  25118. static MinMax(meshes: AbstractMesh[]): {
  25119. min: Vector3;
  25120. max: Vector3;
  25121. };
  25122. /**
  25123. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25124. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25125. * @returns a vector3
  25126. */
  25127. static Center(meshesOrMinMaxVector: {
  25128. min: Vector3;
  25129. max: Vector3;
  25130. } | AbstractMesh[]): Vector3;
  25131. /**
  25132. * Merge the array of meshes into a single mesh for performance reasons.
  25133. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25134. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25135. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25136. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25137. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25138. * @returns a new mesh
  25139. */
  25140. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  25141. }
  25142. }
  25143. declare module BABYLON {
  25144. /**
  25145. * Define an interface for all classes that will get and set the data on vertices
  25146. */
  25147. interface IGetSetVerticesData {
  25148. isVerticesDataPresent(kind: string): boolean;
  25149. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25150. /**
  25151. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25152. * @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.
  25153. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25154. * @returns the indices array or an empty array if the mesh has no geometry
  25155. */
  25156. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25157. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25158. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25159. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25160. }
  25161. /**
  25162. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25163. */
  25164. class VertexData {
  25165. /**
  25166. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25167. */
  25168. positions: Nullable<FloatArray>;
  25169. /**
  25170. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25171. */
  25172. normals: Nullable<FloatArray>;
  25173. /**
  25174. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25175. */
  25176. tangents: Nullable<FloatArray>;
  25177. /**
  25178. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25179. */
  25180. uvs: Nullable<FloatArray>;
  25181. /**
  25182. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25183. */
  25184. uvs2: Nullable<FloatArray>;
  25185. /**
  25186. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25187. */
  25188. uvs3: Nullable<FloatArray>;
  25189. /**
  25190. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25191. */
  25192. uvs4: Nullable<FloatArray>;
  25193. /**
  25194. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25195. */
  25196. uvs5: Nullable<FloatArray>;
  25197. /**
  25198. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25199. */
  25200. uvs6: Nullable<FloatArray>;
  25201. /**
  25202. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25203. */
  25204. colors: Nullable<FloatArray>;
  25205. /**
  25206. * 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).
  25207. */
  25208. matricesIndices: Nullable<FloatArray>;
  25209. /**
  25210. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25211. */
  25212. matricesWeights: Nullable<FloatArray>;
  25213. /**
  25214. * An array extending the number of possible indices
  25215. */
  25216. matricesIndicesExtra: Nullable<FloatArray>;
  25217. /**
  25218. * An array extending the number of possible weights when the number of indices is extended
  25219. */
  25220. matricesWeightsExtra: Nullable<FloatArray>;
  25221. /**
  25222. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25223. */
  25224. indices: Nullable<IndicesArray>;
  25225. /**
  25226. * Uses the passed data array to set the set the values for the specified kind of data
  25227. * @param data a linear array of floating numbers
  25228. * @param kind the type of data that is being set, eg positions, colors etc
  25229. */
  25230. set(data: FloatArray, kind: string): void;
  25231. /**
  25232. * Associates the vertexData to the passed Mesh.
  25233. * Sets it as updatable or not (default `false`)
  25234. * @param mesh the mesh the vertexData is applied to
  25235. * @param updatable when used and having the value true allows new data to update the vertexData
  25236. * @returns the VertexData
  25237. */
  25238. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25239. /**
  25240. * Associates the vertexData to the passed Geometry.
  25241. * Sets it as updatable or not (default `false`)
  25242. * @param geometry the geometry the vertexData is applied to
  25243. * @param updatable when used and having the value true allows new data to update the vertexData
  25244. * @returns VertexData
  25245. */
  25246. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25247. /**
  25248. * Updates the associated mesh
  25249. * @param mesh the mesh to be updated
  25250. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25251. * @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
  25252. * @returns VertexData
  25253. */
  25254. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  25255. /**
  25256. * Updates the associated geometry
  25257. * @param geometry the geometry to be updated
  25258. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25259. * @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
  25260. * @returns VertexData.
  25261. */
  25262. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  25263. private _applyTo;
  25264. private _update;
  25265. /**
  25266. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25267. * @param matrix the transforming matrix
  25268. * @returns the VertexData
  25269. */
  25270. transform(matrix: Matrix): VertexData;
  25271. /**
  25272. * Merges the passed VertexData into the current one
  25273. * @param other the VertexData to be merged into the current one
  25274. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25275. * @returns the modified VertexData
  25276. */
  25277. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25278. private _mergeElement;
  25279. private _validate;
  25280. /**
  25281. * Serializes the VertexData
  25282. * @returns a serialized object
  25283. */
  25284. serialize(): any;
  25285. /**
  25286. * Extracts the vertexData from a mesh
  25287. * @param mesh the mesh from which to extract the VertexData
  25288. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25289. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25290. * @returns the object VertexData associated to the passed mesh
  25291. */
  25292. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25293. /**
  25294. * Extracts the vertexData from the geometry
  25295. * @param geometry the geometry from which to extract the VertexData
  25296. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25297. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25298. * @returns the object VertexData associated to the passed mesh
  25299. */
  25300. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25301. private static _ExtractFrom;
  25302. /**
  25303. * Creates the VertexData for a Ribbon
  25304. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25305. * * pathArray array of paths, each of which an array of successive Vector3
  25306. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25307. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25308. * * 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
  25309. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25310. * * 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)
  25311. * * 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)
  25312. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25313. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25314. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25315. * @returns the VertexData of the ribbon
  25316. */
  25317. static CreateRibbon(options: {
  25318. pathArray: Vector3[][];
  25319. closeArray?: boolean;
  25320. closePath?: boolean;
  25321. offset?: number;
  25322. sideOrientation?: number;
  25323. frontUVs?: Vector4;
  25324. backUVs?: Vector4;
  25325. invertUV?: boolean;
  25326. uvs?: Vector2[];
  25327. colors?: Color4[];
  25328. }): VertexData;
  25329. /**
  25330. * Creates the VertexData for a box
  25331. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25332. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25333. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25334. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25335. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25336. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25337. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25338. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25339. * * 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)
  25340. * * 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)
  25341. * @returns the VertexData of the box
  25342. */
  25343. static CreateBox(options: {
  25344. size?: number;
  25345. width?: number;
  25346. height?: number;
  25347. depth?: number;
  25348. faceUV?: Vector4[];
  25349. faceColors?: Color4[];
  25350. sideOrientation?: number;
  25351. frontUVs?: Vector4;
  25352. backUVs?: Vector4;
  25353. }): VertexData;
  25354. /**
  25355. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25356. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25357. * * segments sets the number of horizontal strips optional, default 32
  25358. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25359. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25360. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25361. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25362. * * 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
  25363. * * 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
  25364. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25365. * * 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)
  25366. * * 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)
  25367. * @returns the VertexData of the ellipsoid
  25368. */
  25369. static CreateSphere(options: {
  25370. segments?: number;
  25371. diameter?: number;
  25372. diameterX?: number;
  25373. diameterY?: number;
  25374. diameterZ?: number;
  25375. arc?: number;
  25376. slice?: number;
  25377. sideOrientation?: number;
  25378. frontUVs?: Vector4;
  25379. backUVs?: Vector4;
  25380. }): VertexData;
  25381. /**
  25382. * Creates the VertexData for a cylinder, cone or prism
  25383. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25384. * * height sets the height (y direction) of the cylinder, optional, default 2
  25385. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25386. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25387. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25388. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25389. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25390. * * 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
  25391. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25392. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25393. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25394. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25395. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25396. * * 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)
  25397. * * 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)
  25398. * @returns the VertexData of the cylinder, cone or prism
  25399. */
  25400. static CreateCylinder(options: {
  25401. height?: number;
  25402. diameterTop?: number;
  25403. diameterBottom?: number;
  25404. diameter?: number;
  25405. tessellation?: number;
  25406. subdivisions?: number;
  25407. arc?: number;
  25408. faceColors?: Color4[];
  25409. faceUV?: Vector4[];
  25410. hasRings?: boolean;
  25411. enclose?: boolean;
  25412. sideOrientation?: number;
  25413. frontUVs?: Vector4;
  25414. backUVs?: Vector4;
  25415. }): VertexData;
  25416. /**
  25417. * Creates the VertexData for a torus
  25418. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25419. * * diameter the diameter of the torus, optional default 1
  25420. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25421. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25422. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25423. * * 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)
  25424. * * 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)
  25425. * @returns the VertexData of the torus
  25426. */
  25427. static CreateTorus(options: {
  25428. diameter?: number;
  25429. thickness?: number;
  25430. tessellation?: number;
  25431. sideOrientation?: number;
  25432. frontUVs?: Vector4;
  25433. backUVs?: Vector4;
  25434. }): VertexData;
  25435. /**
  25436. * Creates the VertexData of the LineSystem
  25437. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25438. * - lines an array of lines, each line being an array of successive Vector3
  25439. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25440. * @returns the VertexData of the LineSystem
  25441. */
  25442. static CreateLineSystem(options: {
  25443. lines: Vector3[][];
  25444. colors?: Nullable<Color4[][]>;
  25445. }): VertexData;
  25446. /**
  25447. * Create the VertexData for a DashedLines
  25448. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25449. * - points an array successive Vector3
  25450. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25451. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25452. * - dashNb the intended total number of dashes, optional, default 200
  25453. * @returns the VertexData for the DashedLines
  25454. */
  25455. static CreateDashedLines(options: {
  25456. points: Vector3[];
  25457. dashSize?: number;
  25458. gapSize?: number;
  25459. dashNb?: number;
  25460. }): VertexData;
  25461. /**
  25462. * Creates the VertexData for a Ground
  25463. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25464. * - width the width (x direction) of the ground, optional, default 1
  25465. * - height the height (z direction) of the ground, optional, default 1
  25466. * - subdivisions the number of subdivisions per side, optional, default 1
  25467. * @returns the VertexData of the Ground
  25468. */
  25469. static CreateGround(options: {
  25470. width?: number;
  25471. height?: number;
  25472. subdivisions?: number;
  25473. subdivisionsX?: number;
  25474. subdivisionsY?: number;
  25475. }): VertexData;
  25476. /**
  25477. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25478. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25479. * * xmin the ground minimum X coordinate, optional, default -1
  25480. * * zmin the ground minimum Z coordinate, optional, default -1
  25481. * * xmax the ground maximum X coordinate, optional, default 1
  25482. * * zmax the ground maximum Z coordinate, optional, default 1
  25483. * * 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}
  25484. * * 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}
  25485. * @returns the VertexData of the TiledGround
  25486. */
  25487. static CreateTiledGround(options: {
  25488. xmin: number;
  25489. zmin: number;
  25490. xmax: number;
  25491. zmax: number;
  25492. subdivisions?: {
  25493. w: number;
  25494. h: number;
  25495. };
  25496. precision?: {
  25497. w: number;
  25498. h: number;
  25499. };
  25500. }): VertexData;
  25501. /**
  25502. * Creates the VertexData of the Ground designed from a heightmap
  25503. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25504. * * width the width (x direction) of the ground
  25505. * * height the height (z direction) of the ground
  25506. * * subdivisions the number of subdivisions per side
  25507. * * minHeight the minimum altitude on the ground, optional, default 0
  25508. * * maxHeight the maximum altitude on the ground, optional default 1
  25509. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25510. * * buffer the array holding the image color data
  25511. * * bufferWidth the width of image
  25512. * * bufferHeight the height of image
  25513. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25514. * @returns the VertexData of the Ground designed from a heightmap
  25515. */
  25516. static CreateGroundFromHeightMap(options: {
  25517. width: number;
  25518. height: number;
  25519. subdivisions: number;
  25520. minHeight: number;
  25521. maxHeight: number;
  25522. colorFilter: Color3;
  25523. buffer: Uint8Array;
  25524. bufferWidth: number;
  25525. bufferHeight: number;
  25526. alphaFilter: number;
  25527. }): VertexData;
  25528. /**
  25529. * Creates the VertexData for a Plane
  25530. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25531. * * size sets the width and height of the plane to the value of size, optional default 1
  25532. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25533. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25534. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25535. * * 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)
  25536. * * 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)
  25537. * @returns the VertexData of the box
  25538. */
  25539. static CreatePlane(options: {
  25540. size?: number;
  25541. width?: number;
  25542. height?: number;
  25543. sideOrientation?: number;
  25544. frontUVs?: Vector4;
  25545. backUVs?: Vector4;
  25546. }): VertexData;
  25547. /**
  25548. * Creates the VertexData of the Disc or regular Polygon
  25549. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25550. * * radius the radius of the disc, optional default 0.5
  25551. * * tessellation the number of polygon sides, optional, default 64
  25552. * * 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
  25553. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25554. * * 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)
  25555. * * 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)
  25556. * @returns the VertexData of the box
  25557. */
  25558. static CreateDisc(options: {
  25559. radius?: number;
  25560. tessellation?: number;
  25561. arc?: number;
  25562. sideOrientation?: number;
  25563. frontUVs?: Vector4;
  25564. backUVs?: Vector4;
  25565. }): VertexData;
  25566. /**
  25567. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25568. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25569. * @param polygon a mesh built from polygonTriangulation.build()
  25570. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25571. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25572. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25573. * @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)
  25574. * @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)
  25575. * @returns the VertexData of the Polygon
  25576. */
  25577. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  25578. /**
  25579. * Creates the VertexData of the IcoSphere
  25580. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25581. * * radius the radius of the IcoSphere, optional default 1
  25582. * * radiusX allows stretching in the x direction, optional, default radius
  25583. * * radiusY allows stretching in the y direction, optional, default radius
  25584. * * radiusZ allows stretching in the z direction, optional, default radius
  25585. * * flat when true creates a flat shaded mesh, optional, default true
  25586. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25587. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25588. * * 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)
  25589. * * 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)
  25590. * @returns the VertexData of the IcoSphere
  25591. */
  25592. static CreateIcoSphere(options: {
  25593. radius?: number;
  25594. radiusX?: number;
  25595. radiusY?: number;
  25596. radiusZ?: number;
  25597. flat?: boolean;
  25598. subdivisions?: number;
  25599. sideOrientation?: number;
  25600. frontUVs?: Vector4;
  25601. backUVs?: Vector4;
  25602. }): VertexData;
  25603. /**
  25604. * Creates the VertexData for a Polyhedron
  25605. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25606. * * type provided types are:
  25607. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25608. * * 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)
  25609. * * size the size of the IcoSphere, optional default 1
  25610. * * sizeX allows stretching in the x direction, optional, default size
  25611. * * sizeY allows stretching in the y direction, optional, default size
  25612. * * sizeZ allows stretching in the z direction, optional, default size
  25613. * * 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
  25614. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25615. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25616. * * flat when true creates a flat shaded mesh, optional, default true
  25617. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25618. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25619. * * 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)
  25620. * * 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)
  25621. * @returns the VertexData of the Polyhedron
  25622. */
  25623. static CreatePolyhedron(options: {
  25624. type?: number;
  25625. size?: number;
  25626. sizeX?: number;
  25627. sizeY?: number;
  25628. sizeZ?: number;
  25629. custom?: any;
  25630. faceUV?: Vector4[];
  25631. faceColors?: Color4[];
  25632. flat?: boolean;
  25633. sideOrientation?: number;
  25634. frontUVs?: Vector4;
  25635. backUVs?: Vector4;
  25636. }): VertexData;
  25637. /**
  25638. * Creates the VertexData for a TorusKnot
  25639. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25640. * * radius the radius of the torus knot, optional, default 2
  25641. * * tube the thickness of the tube, optional, default 0.5
  25642. * * radialSegments the number of sides on each tube segments, optional, default 32
  25643. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25644. * * p the number of windings around the z axis, optional, default 2
  25645. * * q the number of windings around the x axis, optional, default 3
  25646. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25647. * * 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)
  25648. * * 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)
  25649. * @returns the VertexData of the Torus Knot
  25650. */
  25651. static CreateTorusKnot(options: {
  25652. radius?: number;
  25653. tube?: number;
  25654. radialSegments?: number;
  25655. tubularSegments?: number;
  25656. p?: number;
  25657. q?: number;
  25658. sideOrientation?: number;
  25659. frontUVs?: Vector4;
  25660. backUVs?: Vector4;
  25661. }): VertexData;
  25662. /**
  25663. * Compute normals for given positions and indices
  25664. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25665. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25666. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25667. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25668. * * facetNormals : optional array of facet normals (vector3)
  25669. * * facetPositions : optional array of facet positions (vector3)
  25670. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25671. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25672. * * bInfo : optional bounding info, required for facetPartitioning computation
  25673. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25674. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25675. * * useRightHandedSystem: optional boolean to for right handed system computation
  25676. * * depthSort : optional boolean to enable the facet depth sort computation
  25677. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25678. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25679. */
  25680. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25681. facetNormals?: any;
  25682. facetPositions?: any;
  25683. facetPartitioning?: any;
  25684. ratio?: number;
  25685. bInfo?: any;
  25686. bbSize?: Vector3;
  25687. subDiv?: any;
  25688. useRightHandedSystem?: boolean;
  25689. depthSort?: boolean;
  25690. distanceTo?: Vector3;
  25691. depthSortedFacets?: any;
  25692. }): void;
  25693. private static _ComputeSides;
  25694. /**
  25695. * Applies VertexData created from the imported parameters to the geometry
  25696. * @param parsedVertexData the parsed data from an imported file
  25697. * @param geometry the geometry to apply the VertexData to
  25698. */
  25699. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25700. }
  25701. }
  25702. declare module BABYLON {
  25703. /**
  25704. * Class containing static functions to help procedurally build meshes
  25705. */
  25706. class MeshBuilder {
  25707. private static updateSideOrientation;
  25708. /**
  25709. * Creates a box mesh
  25710. * * The parameter `size` sets the size (float) of each box side (default 1)
  25711. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  25712. * * 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)
  25713. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  25714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25715. * * 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
  25716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25717. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  25718. * @param name defines the name of the mesh
  25719. * @param options defines the options used to create the mesh
  25720. * @param scene defines the hosting scene
  25721. * @returns the box mesh
  25722. */
  25723. static CreateBox(name: string, options: {
  25724. size?: number;
  25725. width?: number;
  25726. height?: number;
  25727. depth?: number;
  25728. faceUV?: Vector4[];
  25729. faceColors?: Color4[];
  25730. sideOrientation?: number;
  25731. frontUVs?: Vector4;
  25732. backUVs?: Vector4;
  25733. updatable?: boolean;
  25734. }, scene?: Nullable<Scene>): Mesh;
  25735. /**
  25736. * Creates a sphere mesh
  25737. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  25738. * * 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 of `diameter`)
  25739. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  25740. * * 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
  25741. * * 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)
  25742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25743. * * 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
  25744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25745. * @param name defines the name of the mesh
  25746. * @param options defines the options used to create the mesh
  25747. * @param scene defines the hosting scene
  25748. * @returns the sphere mesh
  25749. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  25750. */
  25751. static CreateSphere(name: string, options: {
  25752. segments?: number;
  25753. diameter?: number;
  25754. diameterX?: number;
  25755. diameterY?: number;
  25756. diameterZ?: number;
  25757. arc?: number;
  25758. slice?: number;
  25759. sideOrientation?: number;
  25760. frontUVs?: Vector4;
  25761. backUVs?: Vector4;
  25762. updatable?: boolean;
  25763. }, scene: any): Mesh;
  25764. /**
  25765. * Creates a plane polygonal mesh. By default, this is a disc
  25766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25767. * * 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
  25768. * * 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
  25769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25770. * * 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
  25771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25772. * @param name defines the name of the mesh
  25773. * @param options defines the options used to create the mesh
  25774. * @param scene defines the hosting scene
  25775. * @returns the plane polygonal mesh
  25776. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25777. */
  25778. static CreateDisc(name: string, options: {
  25779. radius?: number;
  25780. tessellation?: number;
  25781. arc?: number;
  25782. updatable?: boolean;
  25783. sideOrientation?: number;
  25784. frontUVs?: Vector4;
  25785. backUVs?: Vector4;
  25786. }, scene?: Nullable<Scene>): Mesh;
  25787. /**
  25788. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25789. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25790. * * 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 of `radius`)
  25791. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25792. * * 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
  25793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25794. * * 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
  25795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25796. * @param name defines the name of the mesh
  25797. * @param options defines the options used to create the mesh
  25798. * @param scene defines the hosting scene
  25799. * @returns the icosahedron mesh
  25800. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25801. */
  25802. static CreateIcoSphere(name: string, options: {
  25803. radius?: number;
  25804. radiusX?: number;
  25805. radiusY?: number;
  25806. radiusZ?: number;
  25807. flat?: boolean;
  25808. subdivisions?: number;
  25809. sideOrientation?: number;
  25810. frontUVs?: Vector4;
  25811. backUVs?: Vector4;
  25812. updatable?: boolean;
  25813. }, scene: Scene): Mesh;
  25814. /**
  25815. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  25816. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  25817. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  25818. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  25819. * * 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
  25820. * * 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
  25821. * * 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
  25822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25823. * * 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
  25824. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  25825. * * 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
  25826. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  25827. * * 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
  25828. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  25829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25830. * @param name defines the name of the mesh
  25831. * @param options defines the options used to create the mesh
  25832. * @param scene defines the hosting scene
  25833. * @returns the ribbon mesh
  25834. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  25835. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  25836. */
  25837. static CreateRibbon(name: string, options: {
  25838. pathArray: Vector3[][];
  25839. closeArray?: boolean;
  25840. closePath?: boolean;
  25841. offset?: number;
  25842. updatable?: boolean;
  25843. sideOrientation?: number;
  25844. frontUVs?: Vector4;
  25845. backUVs?: Vector4;
  25846. instance?: Mesh;
  25847. invertUV?: boolean;
  25848. uvs?: Vector2[];
  25849. colors?: Color4[];
  25850. }, scene?: Nullable<Scene>): Mesh;
  25851. /**
  25852. * Creates a cylinder or a cone mesh
  25853. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  25854. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  25855. * * 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.
  25856. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  25857. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  25858. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  25859. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  25860. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  25861. * * 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).
  25862. * * 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
  25863. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  25864. * * 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
  25865. * * 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.
  25866. * * If `enclose` is false, a ring surface is one element.
  25867. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  25868. * * 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
  25869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25870. * * 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
  25871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25872. * @param name defines the name of the mesh
  25873. * @param options defines the options used to create the mesh
  25874. * @param scene defines the hosting scene
  25875. * @returns the cylinder mesh
  25876. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  25877. */
  25878. static CreateCylinder(name: string, options: {
  25879. height?: number;
  25880. diameterTop?: number;
  25881. diameterBottom?: number;
  25882. diameter?: number;
  25883. tessellation?: number;
  25884. subdivisions?: number;
  25885. arc?: number;
  25886. faceColors?: Color4[];
  25887. faceUV?: Vector4[];
  25888. updatable?: boolean;
  25889. hasRings?: boolean;
  25890. enclose?: boolean;
  25891. sideOrientation?: number;
  25892. frontUVs?: Vector4;
  25893. backUVs?: Vector4;
  25894. }, scene: any): Mesh;
  25895. /**
  25896. * Creates a torus mesh
  25897. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  25898. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  25899. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  25900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25901. * * 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
  25902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25903. * @param name defines the name of the mesh
  25904. * @param options defines the options used to create the mesh
  25905. * @param scene defines the hosting scene
  25906. * @returns the torus mesh
  25907. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  25908. */
  25909. static CreateTorus(name: string, options: {
  25910. diameter?: number;
  25911. thickness?: number;
  25912. tessellation?: number;
  25913. updatable?: boolean;
  25914. sideOrientation?: number;
  25915. frontUVs?: Vector4;
  25916. backUVs?: Vector4;
  25917. }, scene: any): Mesh;
  25918. /**
  25919. * Creates a torus knot mesh
  25920. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  25921. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  25922. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  25923. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  25924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25925. * * 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
  25926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25927. * @param name defines the name of the mesh
  25928. * @param options defines the options used to create the mesh
  25929. * @param scene defines the hosting scene
  25930. * @returns the torus knot mesh
  25931. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  25932. */
  25933. static CreateTorusKnot(name: string, options: {
  25934. radius?: number;
  25935. tube?: number;
  25936. radialSegments?: number;
  25937. tubularSegments?: number;
  25938. p?: number;
  25939. q?: number;
  25940. updatable?: boolean;
  25941. sideOrientation?: number;
  25942. frontUVs?: Vector4;
  25943. backUVs?: Vector4;
  25944. }, scene: any): Mesh;
  25945. /**
  25946. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  25947. * * 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
  25948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  25949. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  25950. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  25951. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  25952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  25953. * * 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
  25954. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  25955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25956. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  25957. * @param name defines the name of the new line system
  25958. * @param options defines the options used to create the line system
  25959. * @param scene defines the hosting scene
  25960. * @returns a new line system mesh
  25961. */
  25962. static CreateLineSystem(name: string, options: {
  25963. lines: Vector3[][];
  25964. updatable?: boolean;
  25965. instance?: Nullable<LinesMesh>;
  25966. colors?: Nullable<Color4[][]>;
  25967. useVertexAlpha?: boolean;
  25968. }, scene: Nullable<Scene>): LinesMesh;
  25969. /**
  25970. * Creates a line mesh
  25971. * 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
  25972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  25973. * * The parameter `points` is an array successive Vector3
  25974. * * 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
  25975. * * The optional parameter `colors` is an array of successive Color4, one per line point
  25976. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  25977. * * When updating an instance, remember that only point positions can change, not the number of points
  25978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25979. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  25980. * @param name defines the name of the new line system
  25981. * @param options defines the options used to create the line system
  25982. * @param scene defines the hosting scene
  25983. * @returns a new line mesh
  25984. */
  25985. static CreateLines(name: string, options: {
  25986. points: Vector3[];
  25987. updatable?: boolean;
  25988. instance?: Nullable<LinesMesh>;
  25989. colors?: Color4[];
  25990. useVertexAlpha?: boolean;
  25991. }, scene?: Nullable<Scene>): LinesMesh;
  25992. /**
  25993. * Creates a dashed line mesh
  25994. * * 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
  25995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  25996. * * The parameter `points` is an array successive Vector3
  25997. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  25998. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  25999. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26000. * * 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
  26001. * * When updating an instance, remember that only point positions can change, not the number of points
  26002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26003. * @param name defines the name of the mesh
  26004. * @param options defines the options used to create the mesh
  26005. * @param scene defines the hosting scene
  26006. * @returns the dashed line mesh
  26007. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  26008. */
  26009. static CreateDashedLines(name: string, options: {
  26010. points: Vector3[];
  26011. dashSize?: number;
  26012. gapSize?: number;
  26013. dashNb?: number;
  26014. updatable?: boolean;
  26015. instance?: LinesMesh;
  26016. }, scene?: Nullable<Scene>): LinesMesh;
  26017. /**
  26018. * 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.
  26019. * * 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.
  26020. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  26021. * * 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.
  26022. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  26023. * * 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
  26024. * * 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
  26025. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  26026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26027. * * 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
  26028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  26029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26030. * @param name defines the name of the mesh
  26031. * @param options defines the options used to create the mesh
  26032. * @param scene defines the hosting scene
  26033. * @returns the extruded shape mesh
  26034. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  26035. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26036. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26037. */
  26038. static ExtrudeShape(name: string, options: {
  26039. shape: Vector3[];
  26040. path: Vector3[];
  26041. scale?: number;
  26042. rotation?: number;
  26043. cap?: number;
  26044. updatable?: boolean;
  26045. sideOrientation?: number;
  26046. frontUVs?: Vector4;
  26047. backUVs?: Vector4;
  26048. instance?: Mesh;
  26049. invertUV?: boolean;
  26050. }, scene?: Nullable<Scene>): Mesh;
  26051. /**
  26052. * Creates an custom extruded shape mesh.
  26053. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  26054. * * 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.
  26055. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  26056. * * 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
  26057. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  26058. * * 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
  26059. * * It must returns a float value that will be the scale value applied to the shape on each path point
  26060. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26061. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  26062. * * 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
  26063. * * 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
  26064. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  26065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26066. * * 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
  26067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  26068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26069. * @param name defines the name of the mesh
  26070. * @param options defines the options used to create the mesh
  26071. * @param scene defines the hosting scene
  26072. * @returns the custom extruded shape mesh
  26073. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  26074. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  26075. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26076. */
  26077. static ExtrudeShapeCustom(name: string, options: {
  26078. shape: Vector3[];
  26079. path: Vector3[];
  26080. scaleFunction?: any;
  26081. rotationFunction?: any;
  26082. ribbonCloseArray?: boolean;
  26083. ribbonClosePath?: boolean;
  26084. cap?: number;
  26085. updatable?: boolean;
  26086. sideOrientation?: number;
  26087. frontUVs?: Vector4;
  26088. backUVs?: Vector4;
  26089. instance?: Mesh;
  26090. invertUV?: boolean;
  26091. }, scene: Scene): Mesh;
  26092. /**
  26093. * Creates lathe mesh.
  26094. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  26095. * * 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
  26096. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  26097. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  26098. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  26099. * * 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
  26100. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  26101. * * 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
  26102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26103. * * 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
  26104. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  26105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26106. * @param name defines the name of the mesh
  26107. * @param options defines the options used to create the mesh
  26108. * @param scene defines the hosting scene
  26109. * @returns the lathe mesh
  26110. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  26111. */
  26112. static CreateLathe(name: string, options: {
  26113. shape: Vector3[];
  26114. radius?: number;
  26115. tessellation?: number;
  26116. clip?: number;
  26117. arc?: number;
  26118. closed?: boolean;
  26119. updatable?: boolean;
  26120. sideOrientation?: number;
  26121. frontUVs?: Vector4;
  26122. backUVs?: Vector4;
  26123. cap?: number;
  26124. invertUV?: boolean;
  26125. }, scene: Scene): Mesh;
  26126. /**
  26127. * Creates a plane mesh
  26128. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  26129. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  26130. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  26131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26132. * * 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
  26133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26134. * @param name defines the name of the mesh
  26135. * @param options defines the options used to create the mesh
  26136. * @param scene defines the hosting scene
  26137. * @returns the plane mesh
  26138. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  26139. */
  26140. static CreatePlane(name: string, options: {
  26141. size?: number;
  26142. width?: number;
  26143. height?: number;
  26144. sideOrientation?: number;
  26145. frontUVs?: Vector4;
  26146. backUVs?: Vector4;
  26147. updatable?: boolean;
  26148. sourcePlane?: Plane;
  26149. }, scene: Scene): Mesh;
  26150. /**
  26151. * Creates a ground mesh
  26152. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  26153. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  26154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26155. * @param name defines the name of the mesh
  26156. * @param options defines the options used to create the mesh
  26157. * @param scene defines the hosting scene
  26158. * @returns the ground mesh
  26159. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  26160. */
  26161. static CreateGround(name: string, options: {
  26162. width?: number;
  26163. height?: number;
  26164. subdivisions?: number;
  26165. subdivisionsX?: number;
  26166. subdivisionsY?: number;
  26167. updatable?: boolean;
  26168. }, scene: any): Mesh;
  26169. /**
  26170. * Creates a tiled ground mesh
  26171. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  26172. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  26173. * * 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
  26174. * * 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
  26175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26176. * @param name defines the name of the mesh
  26177. * @param options defines the options used to create the mesh
  26178. * @param scene defines the hosting scene
  26179. * @returns the tiled ground mesh
  26180. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  26181. */
  26182. static CreateTiledGround(name: string, options: {
  26183. xmin: number;
  26184. zmin: number;
  26185. xmax: number;
  26186. zmax: number;
  26187. subdivisions?: {
  26188. w: number;
  26189. h: number;
  26190. };
  26191. precision?: {
  26192. w: number;
  26193. h: number;
  26194. };
  26195. updatable?: boolean;
  26196. }, scene: Scene): Mesh;
  26197. /**
  26198. * Creates a ground mesh from a height map
  26199. * * The parameter `url` sets the URL of the height map image resource.
  26200. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  26201. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  26202. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  26203. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  26204. * * 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.
  26205. * * 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).
  26206. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26208. * @param name defines the name of the mesh
  26209. * @param url defines the url to the height map
  26210. * @param options defines the options used to create the mesh
  26211. * @param scene defines the hosting scene
  26212. * @returns the ground mesh
  26213. * @see http://doc.babylonjs.com/babylon101/height_map
  26214. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  26215. */
  26216. static CreateGroundFromHeightMap(name: string, url: string, options: {
  26217. width?: number;
  26218. height?: number;
  26219. subdivisions?: number;
  26220. minHeight?: number;
  26221. maxHeight?: number;
  26222. colorFilter?: Color3;
  26223. alphaFilter?: number;
  26224. updatable?: boolean;
  26225. onReady?: (mesh: GroundMesh) => void;
  26226. }, scene: Scene): GroundMesh;
  26227. /**
  26228. * Creates a polygon mesh
  26229. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  26230. * * 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
  26231. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26233. * * 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)
  26234. * * Remember you can only change the shape positions, not their number when updating a polygon
  26235. * @param name defines the name of the mesh
  26236. * @param options defines the options used to create the mesh
  26237. * @param scene defines the hosting scene
  26238. * @returns the polygon mesh
  26239. */
  26240. static CreatePolygon(name: string, options: {
  26241. shape: Vector3[];
  26242. holes?: Vector3[][];
  26243. depth?: number;
  26244. faceUV?: Vector4[];
  26245. faceColors?: Color4[];
  26246. updatable?: boolean;
  26247. sideOrientation?: number;
  26248. frontUVs?: Vector4;
  26249. backUVs?: Vector4;
  26250. }, scene: Scene): Mesh;
  26251. /**
  26252. * Creates an extruded polygon mesh, with depth in the Y direction.
  26253. * * 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)
  26254. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  26255. * @param name defines the name of the mesh
  26256. * @param options defines the options used to create the mesh
  26257. * @param scene defines the hosting scene
  26258. * @returns the polygon mesh
  26259. */
  26260. static ExtrudePolygon(name: string, options: {
  26261. shape: Vector3[];
  26262. holes?: Vector3[][];
  26263. depth?: number;
  26264. faceUV?: Vector4[];
  26265. faceColors?: Color4[];
  26266. updatable?: boolean;
  26267. sideOrientation?: number;
  26268. frontUVs?: Vector4;
  26269. backUVs?: Vector4;
  26270. }, scene: Scene): Mesh;
  26271. /**
  26272. * Creates a tube mesh.
  26273. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  26274. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  26275. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  26276. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  26277. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  26278. * * 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)
  26279. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  26280. * * 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
  26281. * * 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
  26282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26283. * * 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
  26284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  26285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26286. * @param name defines the name of the mesh
  26287. * @param options defines the options used to create the mesh
  26288. * @param scene defines the hosting scene
  26289. * @returns the tube mesh
  26290. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  26291. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  26292. */
  26293. static CreateTube(name: string, options: {
  26294. path: Vector3[];
  26295. radius?: number;
  26296. tessellation?: number;
  26297. radiusFunction?: {
  26298. (i: number, distance: number): number;
  26299. };
  26300. cap?: number;
  26301. arc?: number;
  26302. updatable?: boolean;
  26303. sideOrientation?: number;
  26304. frontUVs?: Vector4;
  26305. backUVs?: Vector4;
  26306. instance?: Mesh;
  26307. invertUV?: boolean;
  26308. }, scene: Scene): Mesh;
  26309. /**
  26310. * Creates a polyhedron mesh
  26311. * * 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
  26312. * * The parameter `size` (positive float, default 1) sets the polygon size
  26313. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26314. * * 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`
  26315. * * 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
  26316. * * 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)`)
  26317. * * 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
  26318. * * 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
  26319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26320. * * 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
  26321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26322. * @param name defines the name of the mesh
  26323. * @param options defines the options used to create the mesh
  26324. * @param scene defines the hosting scene
  26325. * @returns the polyhedron mesh
  26326. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  26327. */
  26328. static CreatePolyhedron(name: string, options: {
  26329. type?: number;
  26330. size?: number;
  26331. sizeX?: number;
  26332. sizeY?: number;
  26333. sizeZ?: number;
  26334. custom?: any;
  26335. faceUV?: Vector4[];
  26336. faceColors?: Color4[];
  26337. flat?: boolean;
  26338. updatable?: boolean;
  26339. sideOrientation?: number;
  26340. frontUVs?: Vector4;
  26341. backUVs?: Vector4;
  26342. }, scene: Scene): Mesh;
  26343. /**
  26344. * Creates a decal mesh.
  26345. * 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
  26346. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  26347. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  26348. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  26349. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  26350. * @param name defines the name of the mesh
  26351. * @param sourceMesh defines the mesh where the decal must be applied
  26352. * @param options defines the options used to create the mesh
  26353. * @param scene defines the hosting scene
  26354. * @returns the decal mesh
  26355. * @see http://doc.babylonjs.com/how_to/decals
  26356. */
  26357. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  26358. position?: Vector3;
  26359. normal?: Vector3;
  26360. size?: Vector3;
  26361. angle?: number;
  26362. }): Mesh;
  26363. private static _ExtrudeShapeGeneric;
  26364. }
  26365. }
  26366. declare module BABYLON {
  26367. /**
  26368. * Class used to represent a specific level of detail of a mesh
  26369. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26370. */
  26371. class MeshLODLevel {
  26372. /** Defines the distance where this level should star being displayed */
  26373. distance: number;
  26374. /** Defines the mesh to use to render this level */
  26375. mesh: Nullable<Mesh>;
  26376. /**
  26377. * Creates a new LOD level
  26378. * @param distance defines the distance where this level should star being displayed
  26379. * @param mesh defines the mesh to use to render this level
  26380. */
  26381. constructor(
  26382. /** Defines the distance where this level should star being displayed */
  26383. distance: number,
  26384. /** Defines the mesh to use to render this level */
  26385. mesh: Nullable<Mesh>);
  26386. }
  26387. }
  26388. declare module BABYLON {
  26389. /**
  26390. * A simplifier interface for future simplification implementations.
  26391. */
  26392. interface ISimplifier {
  26393. /**
  26394. * Simplification of a given mesh according to the given settings.
  26395. * Since this requires computation, it is assumed that the function runs async.
  26396. * @param settings The settings of the simplification, including quality and distance
  26397. * @param successCallback A callback that will be called after the mesh was simplified.
  26398. * @param errorCallback in case of an error, this callback will be called. optional.
  26399. */
  26400. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  26401. }
  26402. /**
  26403. * Expected simplification settings.
  26404. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  26405. */
  26406. interface ISimplificationSettings {
  26407. quality: number;
  26408. distance: number;
  26409. optimizeMesh?: boolean;
  26410. }
  26411. class SimplificationSettings implements ISimplificationSettings {
  26412. quality: number;
  26413. distance: number;
  26414. optimizeMesh?: boolean | undefined;
  26415. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  26416. }
  26417. interface ISimplificationTask {
  26418. settings: Array<ISimplificationSettings>;
  26419. simplificationType: SimplificationType;
  26420. mesh: Mesh;
  26421. successCallback?: () => void;
  26422. parallelProcessing: boolean;
  26423. }
  26424. class SimplificationQueue {
  26425. private _simplificationArray;
  26426. running: boolean;
  26427. constructor();
  26428. addTask(task: ISimplificationTask): void;
  26429. executeNext(): void;
  26430. runSimplification(task: ISimplificationTask): void;
  26431. private getSimplifier;
  26432. }
  26433. /**
  26434. * The implemented types of simplification
  26435. * At the moment only Quadratic Error Decimation is implemented
  26436. */
  26437. enum SimplificationType {
  26438. /** Quadratic error decimation */
  26439. QUADRATIC = 0
  26440. }
  26441. class DecimationTriangle {
  26442. vertices: Array<DecimationVertex>;
  26443. normal: Vector3;
  26444. error: Array<number>;
  26445. deleted: boolean;
  26446. isDirty: boolean;
  26447. borderFactor: number;
  26448. deletePending: boolean;
  26449. originalOffset: number;
  26450. constructor(vertices: Array<DecimationVertex>);
  26451. }
  26452. class DecimationVertex {
  26453. position: Vector3;
  26454. id: number;
  26455. q: QuadraticMatrix;
  26456. isBorder: boolean;
  26457. triangleStart: number;
  26458. triangleCount: number;
  26459. originalOffsets: Array<number>;
  26460. constructor(position: Vector3, id: number);
  26461. updatePosition(newPosition: Vector3): void;
  26462. }
  26463. class QuadraticMatrix {
  26464. data: Array<number>;
  26465. constructor(data?: Array<number>);
  26466. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  26467. addInPlace(matrix: QuadraticMatrix): void;
  26468. addArrayInPlace(data: Array<number>): void;
  26469. add(matrix: QuadraticMatrix): QuadraticMatrix;
  26470. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  26471. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  26472. }
  26473. class Reference {
  26474. vertexId: number;
  26475. triangleId: number;
  26476. constructor(vertexId: number, triangleId: number);
  26477. }
  26478. /**
  26479. * An implementation of the Quadratic Error simplification algorithm.
  26480. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  26481. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  26482. * @author RaananW
  26483. */
  26484. class QuadraticErrorSimplification implements ISimplifier {
  26485. private _mesh;
  26486. private triangles;
  26487. private vertices;
  26488. private references;
  26489. private _reconstructedMesh;
  26490. syncIterations: number;
  26491. aggressiveness: number;
  26492. decimationIterations: number;
  26493. boundingBoxEpsilon: number;
  26494. constructor(_mesh: Mesh);
  26495. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  26496. private runDecimation;
  26497. private initWithMesh;
  26498. private init;
  26499. private reconstructMesh;
  26500. private initDecimatedMesh;
  26501. private isFlipped;
  26502. private updateTriangles;
  26503. private identifyBorder;
  26504. private updateMesh;
  26505. private vertexError;
  26506. private calculateError;
  26507. }
  26508. }
  26509. declare module BABYLON {
  26510. interface Scene {
  26511. /** @hidden (Backing field) */
  26512. _simplificationQueue: SimplificationQueue;
  26513. /**
  26514. * Gets or sets the simplification queue attached to the scene
  26515. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  26516. */
  26517. simplificationQueue: SimplificationQueue;
  26518. }
  26519. interface Mesh {
  26520. /**
  26521. * Simplify the mesh according to the given array of settings.
  26522. * Function will return immediately and will simplify async
  26523. * @param settings a collection of simplification settings
  26524. * @param parallelProcessing should all levels calculate parallel or one after the other
  26525. * @param simplificationType the type of simplification to run
  26526. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  26527. * @returns the current mesh
  26528. */
  26529. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  26530. }
  26531. /**
  26532. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  26533. * created in a scene
  26534. */
  26535. class SimplicationQueueSceneComponent implements ISceneComponent {
  26536. /**
  26537. * The component name helpfull to identify the component in the list of scene components.
  26538. */
  26539. readonly name: string;
  26540. /**
  26541. * The scene the component belongs to.
  26542. */
  26543. scene: Scene;
  26544. /**
  26545. * Creates a new instance of the component for the given scene
  26546. * @param scene Defines the scene to register the component in
  26547. */
  26548. constructor(scene: Scene);
  26549. /**
  26550. * Registers the component in a given scene
  26551. */
  26552. register(): void;
  26553. /**
  26554. * Rebuilds the elements related to this component in case of
  26555. * context lost for instance.
  26556. */
  26557. rebuild(): void;
  26558. /**
  26559. * Disposes the component and the associated ressources
  26560. */
  26561. dispose(): void;
  26562. private _beforeCameraUpdate;
  26563. }
  26564. }
  26565. declare module BABYLON {
  26566. class Polygon {
  26567. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  26568. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  26569. static Parse(input: string): Vector2[];
  26570. static StartingAt(x: number, y: number): Path2;
  26571. }
  26572. class PolygonMeshBuilder {
  26573. private _points;
  26574. private _outlinepoints;
  26575. private _holes;
  26576. private _name;
  26577. private _scene;
  26578. private _epoints;
  26579. private _eholes;
  26580. private _addToepoint;
  26581. constructor(name: string, contours: Path2, scene: Scene);
  26582. constructor(name: string, contours: Vector2[], scene: Scene);
  26583. addHole(hole: Vector2[]): PolygonMeshBuilder;
  26584. build(updatable?: boolean, depth?: number): Mesh;
  26585. private addSide;
  26586. }
  26587. }
  26588. declare module BABYLON {
  26589. class BaseSubMesh {
  26590. /** @hidden */
  26591. _materialDefines: Nullable<MaterialDefines>;
  26592. /** @hidden */
  26593. _materialEffect: Nullable<Effect>;
  26594. readonly effect: Nullable<Effect>;
  26595. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26596. }
  26597. class SubMesh extends BaseSubMesh implements ICullable {
  26598. materialIndex: number;
  26599. verticesStart: number;
  26600. verticesCount: number;
  26601. indexStart: number;
  26602. indexCount: number;
  26603. linesIndexCount: number;
  26604. private _mesh;
  26605. private _renderingMesh;
  26606. private _boundingInfo;
  26607. private _linesIndexBuffer;
  26608. /** @hidden */
  26609. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26610. /** @hidden */
  26611. _trianglePlanes: Plane[];
  26612. /** @hidden */
  26613. _lastColliderTransformMatrix: Matrix;
  26614. /** @hidden */
  26615. _renderId: number;
  26616. /** @hidden */
  26617. _alphaIndex: number;
  26618. /** @hidden */
  26619. _distanceToCamera: number;
  26620. /** @hidden */
  26621. _id: number;
  26622. private _currentMaterial;
  26623. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26624. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  26625. readonly IsGlobal: boolean;
  26626. /**
  26627. * Returns the submesh BoudingInfo object.
  26628. */
  26629. getBoundingInfo(): BoundingInfo;
  26630. /**
  26631. * Sets the submesh BoundingInfo.
  26632. * Return the SubMesh.
  26633. */
  26634. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26635. /**
  26636. * Returns the mesh of the current submesh.
  26637. */
  26638. getMesh(): AbstractMesh;
  26639. /**
  26640. * Returns the rendering mesh of the submesh.
  26641. */
  26642. getRenderingMesh(): Mesh;
  26643. /**
  26644. * Returns the submesh material.
  26645. */
  26646. getMaterial(): Nullable<Material>;
  26647. /**
  26648. * Sets a new updated BoundingInfo object to the submesh.
  26649. * Returns the SubMesh.
  26650. */
  26651. refreshBoundingInfo(): SubMesh;
  26652. /** @hidden */
  26653. _checkCollision(collider: Collider): boolean;
  26654. /**
  26655. * Updates the submesh BoundingInfo.
  26656. * Returns the Submesh.
  26657. */
  26658. updateBoundingInfo(world: Matrix): SubMesh;
  26659. /**
  26660. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26661. * Boolean returned.
  26662. */
  26663. isInFrustum(frustumPlanes: Plane[]): boolean;
  26664. /**
  26665. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  26666. * Boolean returned.
  26667. */
  26668. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26669. /**
  26670. * Renders the submesh.
  26671. * Returns it.
  26672. */
  26673. render(enableAlphaMode: boolean): SubMesh;
  26674. /**
  26675. * Returns a new Index Buffer.
  26676. * Type returned : WebGLBuffer.
  26677. */
  26678. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  26679. /**
  26680. * True is the passed Ray intersects the submesh bounding box.
  26681. * Boolean returned.
  26682. */
  26683. canIntersects(ray: Ray): boolean;
  26684. /**
  26685. * Returns an object IntersectionInfo.
  26686. */
  26687. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  26688. /** @hidden */
  26689. _rebuild(): void;
  26690. /**
  26691. * Creates a new Submesh from the passed Mesh.
  26692. */
  26693. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26694. /**
  26695. * Disposes the Submesh.
  26696. * Returns nothing.
  26697. */
  26698. dispose(): void;
  26699. /**
  26700. * Creates a new Submesh from the passed parameters :
  26701. * - materialIndex (integer) : the index of the main mesh material.
  26702. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  26703. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  26704. * - mesh (Mesh) : the main mesh to create the submesh from.
  26705. * - renderingMesh (optional Mesh) : rendering mesh.
  26706. */
  26707. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26708. }
  26709. }
  26710. declare module BABYLON {
  26711. class TransformNode extends Node {
  26712. static BILLBOARDMODE_NONE: number;
  26713. static BILLBOARDMODE_X: number;
  26714. static BILLBOARDMODE_Y: number;
  26715. static BILLBOARDMODE_Z: number;
  26716. static BILLBOARDMODE_ALL: number;
  26717. private _forward;
  26718. private _forwardInverted;
  26719. private _up;
  26720. private _right;
  26721. private _rightInverted;
  26722. private _position;
  26723. private _rotation;
  26724. private _rotationQuaternion;
  26725. protected _scaling: Vector3;
  26726. protected _isDirty: boolean;
  26727. private _transformToBoneReferal;
  26728. /**
  26729. * Set the billboard mode. Default is 0.
  26730. *
  26731. * | Value | Type | Description |
  26732. * | --- | --- | --- |
  26733. * | 0 | BILLBOARDMODE_NONE | |
  26734. * | 1 | BILLBOARDMODE_X | |
  26735. * | 2 | BILLBOARDMODE_Y | |
  26736. * | 4 | BILLBOARDMODE_Z | |
  26737. * | 7 | BILLBOARDMODE_ALL | |
  26738. *
  26739. */
  26740. billboardMode: number;
  26741. scalingDeterminant: number;
  26742. infiniteDistance: boolean;
  26743. /**
  26744. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26745. * By default the system will update normals to compensate
  26746. */
  26747. ignoreNonUniformScaling: boolean;
  26748. /** @hidden */
  26749. _poseMatrix: Matrix;
  26750. private _localWorld;
  26751. private _absolutePosition;
  26752. private _pivotMatrix;
  26753. private _pivotMatrixInverse;
  26754. private _postMultiplyPivotMatrix;
  26755. protected _isWorldMatrixFrozen: boolean;
  26756. /**
  26757. * An event triggered after the world matrix is updated
  26758. */
  26759. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26760. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26761. /**
  26762. * Gets a string identifying the name of the class
  26763. * @returns "TransformNode" string
  26764. */
  26765. getClassName(): string;
  26766. /**
  26767. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26768. */
  26769. position: Vector3;
  26770. /**
  26771. * 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)).
  26772. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26773. */
  26774. rotation: Vector3;
  26775. /**
  26776. * 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)).
  26777. */
  26778. scaling: Vector3;
  26779. /**
  26780. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  26781. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26782. */
  26783. rotationQuaternion: Nullable<Quaternion>;
  26784. /**
  26785. * The forward direction of that transform in world space.
  26786. */
  26787. readonly forward: Vector3;
  26788. /**
  26789. * The up direction of that transform in world space.
  26790. */
  26791. readonly up: Vector3;
  26792. /**
  26793. * The right direction of that transform in world space.
  26794. */
  26795. readonly right: Vector3;
  26796. /**
  26797. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26798. * Returns the TransformNode.
  26799. */
  26800. updatePoseMatrix(matrix: Matrix): TransformNode;
  26801. /**
  26802. * Returns the mesh Pose matrix.
  26803. * Returned object : Matrix
  26804. */
  26805. getPoseMatrix(): Matrix;
  26806. /** @hidden */
  26807. _isSynchronized(): boolean;
  26808. /** @hidden */
  26809. _initCache(): void;
  26810. markAsDirty(property: string): TransformNode;
  26811. /**
  26812. * Returns the current mesh absolute position.
  26813. * Returns a Vector3.
  26814. */
  26815. readonly absolutePosition: Vector3;
  26816. /**
  26817. * Sets a new matrix to apply before all other transformation
  26818. * @param matrix defines the transform matrix
  26819. * @returns the current TransformNode
  26820. */
  26821. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26822. /**
  26823. * Sets a new pivot matrix to the current node
  26824. * @param matrix defines the new pivot matrix to use
  26825. * @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
  26826. * @returns the current TransformNode
  26827. */
  26828. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  26829. /**
  26830. * Returns the mesh pivot matrix.
  26831. * Default : Identity.
  26832. * A Matrix is returned.
  26833. */
  26834. getPivotMatrix(): Matrix;
  26835. /**
  26836. * Prevents the World matrix to be computed any longer.
  26837. * Returns the TransformNode.
  26838. */
  26839. freezeWorldMatrix(): TransformNode;
  26840. /**
  26841. * Allows back the World matrix computation.
  26842. * Returns the TransformNode.
  26843. */
  26844. unfreezeWorldMatrix(): this;
  26845. /**
  26846. * True if the World matrix has been frozen.
  26847. * Returns a boolean.
  26848. */
  26849. readonly isWorldMatrixFrozen: boolean;
  26850. /**
  26851. * Retuns the mesh absolute position in the World.
  26852. * Returns a Vector3.
  26853. */
  26854. getAbsolutePosition(): Vector3;
  26855. /**
  26856. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26857. * Returns the TransformNode.
  26858. */
  26859. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26860. /**
  26861. * Sets the mesh position in its local space.
  26862. * Returns the TransformNode.
  26863. */
  26864. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26865. /**
  26866. * Returns the mesh position in the local space from the current World matrix values.
  26867. * Returns a new Vector3.
  26868. */
  26869. getPositionExpressedInLocalSpace(): Vector3;
  26870. /**
  26871. * Translates the mesh along the passed Vector3 in its local space.
  26872. * Returns the TransformNode.
  26873. */
  26874. locallyTranslate(vector3: Vector3): TransformNode;
  26875. private static _lookAtVectorCache;
  26876. /**
  26877. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26878. * @param targetPoint the position (must be in same space as current mesh) to look at
  26879. * @param yawCor optional yaw (y-axis) correction in radians
  26880. * @param pitchCor optional pitch (x-axis) correction in radians
  26881. * @param rollCor optional roll (z-axis) correction in radians
  26882. * @param space the choosen space of the target
  26883. * @returns the TransformNode.
  26884. */
  26885. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26886. /**
  26887. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26888. * This Vector3 is expressed in the World space.
  26889. */
  26890. getDirection(localAxis: Vector3): Vector3;
  26891. /**
  26892. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26893. * localAxis is expressed in the mesh local space.
  26894. * result is computed in the Wordl space from the mesh World matrix.
  26895. * Returns the TransformNode.
  26896. */
  26897. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26898. /**
  26899. * Sets a new pivot point to the current node
  26900. * @param point defines the new pivot point to use
  26901. * @param space defines if the point is in world or local space (local by default)
  26902. * @returns the current TransformNode
  26903. */
  26904. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26905. /**
  26906. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26907. */
  26908. getPivotPoint(): Vector3;
  26909. /**
  26910. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26911. * Returns the TransformNode.
  26912. */
  26913. getPivotPointToRef(result: Vector3): TransformNode;
  26914. /**
  26915. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26916. */
  26917. getAbsolutePivotPoint(): Vector3;
  26918. /**
  26919. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26920. * Returns the TransformNode.
  26921. */
  26922. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26923. /**
  26924. * Defines the passed node as the parent of the current node.
  26925. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26926. * Returns the TransformNode.
  26927. */
  26928. setParent(node: Nullable<Node>): TransformNode;
  26929. private _nonUniformScaling;
  26930. readonly nonUniformScaling: boolean;
  26931. /** @hidden */
  26932. _updateNonUniformScalingState(value: boolean): boolean;
  26933. /**
  26934. * Attach the current TransformNode to another TransformNode associated with a bone
  26935. * @param bone Bone affecting the TransformNode
  26936. * @param affectedTransformNode TransformNode associated with the bone
  26937. */
  26938. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26939. detachFromBone(): TransformNode;
  26940. private static _rotationAxisCache;
  26941. /**
  26942. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26943. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  26944. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26945. * The passed axis is also normalized.
  26946. * Returns the TransformNode.
  26947. */
  26948. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26949. /**
  26950. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26951. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26952. * The passed axis is also normalized.
  26953. * Returns the TransformNode.
  26954. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26955. */
  26956. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26957. /**
  26958. * Translates the mesh along the axis vector for the passed distance in the given space.
  26959. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  26960. * Returns the TransformNode.
  26961. */
  26962. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26963. /**
  26964. * Adds a rotation step to the mesh current rotation.
  26965. * x, y, z are Euler angles expressed in radians.
  26966. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26967. * This means this rotation is made in the mesh local space only.
  26968. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26969. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26970. * ```javascript
  26971. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26972. * ```
  26973. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26974. * 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.
  26975. * Returns the TransformNode.
  26976. */
  26977. addRotation(x: number, y: number, z: number): TransformNode;
  26978. /**
  26979. * Computes the world matrix of the node
  26980. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26981. * @returns the world matrix
  26982. */
  26983. computeWorldMatrix(force?: boolean): Matrix;
  26984. protected _afterComputeWorldMatrix(): void;
  26985. /**
  26986. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26987. * @param func: callback function to add
  26988. *
  26989. * Returns the TransformNode.
  26990. */
  26991. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26992. /**
  26993. * Removes a registered callback function.
  26994. * Returns the TransformNode.
  26995. */
  26996. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26997. /**
  26998. * Clone the current transform node
  26999. * Returns the new transform node
  27000. * @param name Name of the new clone
  27001. * @param newParent New parent for the clone
  27002. * @param doNotCloneChildren Do not clone children hierarchy
  27003. */
  27004. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27005. serialize(currentSerializationObject?: any): any;
  27006. /**
  27007. * Returns a new TransformNode object parsed from the source provided.
  27008. * The parameter `parsedMesh` is the source.
  27009. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27010. */
  27011. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27012. /**
  27013. * Releases resources associated with this transform node.
  27014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27016. */
  27017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27018. }
  27019. }
  27020. declare module BABYLON {
  27021. class VertexBuffer {
  27022. /** @hidden */
  27023. _buffer: Buffer;
  27024. private _kind;
  27025. private _size;
  27026. private _ownsBuffer;
  27027. private _instanced;
  27028. private _instanceDivisor;
  27029. /**
  27030. * The byte type.
  27031. */
  27032. static readonly BYTE: number;
  27033. /**
  27034. * The unsigned byte type.
  27035. */
  27036. static readonly UNSIGNED_BYTE: number;
  27037. /**
  27038. * The short type.
  27039. */
  27040. static readonly SHORT: number;
  27041. /**
  27042. * The unsigned short type.
  27043. */
  27044. static readonly UNSIGNED_SHORT: number;
  27045. /**
  27046. * The integer type.
  27047. */
  27048. static readonly INT: number;
  27049. /**
  27050. * The unsigned integer type.
  27051. */
  27052. static readonly UNSIGNED_INT: number;
  27053. /**
  27054. * The float type.
  27055. */
  27056. static readonly FLOAT: number;
  27057. /**
  27058. * Gets or sets the instance divisor when in instanced mode
  27059. */
  27060. instanceDivisor: number;
  27061. /**
  27062. * Gets the byte stride.
  27063. */
  27064. readonly byteStride: number;
  27065. /**
  27066. * Gets the byte offset.
  27067. */
  27068. readonly byteOffset: number;
  27069. /**
  27070. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  27071. */
  27072. readonly normalized: boolean;
  27073. /**
  27074. * Gets the data type of each component in the array.
  27075. */
  27076. readonly type: number;
  27077. /**
  27078. * Constructor
  27079. * @param engine the engine
  27080. * @param data the data to use for this vertex buffer
  27081. * @param kind the vertex buffer kind
  27082. * @param updatable whether the data is updatable
  27083. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  27084. * @param stride the stride (optional)
  27085. * @param instanced whether the buffer is instanced (optional)
  27086. * @param offset the offset of the data (optional)
  27087. * @param size the number of components (optional)
  27088. * @param type the type of the component (optional)
  27089. * @param normalized whether the data contains normalized data (optional)
  27090. * @param useBytes set to true if stride and offset are in bytes (optional)
  27091. */
  27092. 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);
  27093. /** @hidden */
  27094. _rebuild(): void;
  27095. /**
  27096. * Returns the kind of the VertexBuffer (string).
  27097. */
  27098. getKind(): string;
  27099. /**
  27100. * Boolean : is the VertexBuffer updatable ?
  27101. */
  27102. isUpdatable(): boolean;
  27103. /**
  27104. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  27105. */
  27106. getData(): Nullable<DataArray>;
  27107. /**
  27108. * Returns the WebGLBuffer associated to the VertexBuffer.
  27109. */
  27110. getBuffer(): Nullable<WebGLBuffer>;
  27111. /**
  27112. * Returns the stride as a multiple of the type byte length.
  27113. * DEPRECATED. Use byteStride instead.
  27114. */
  27115. getStrideSize(): number;
  27116. /**
  27117. * Returns the offset as a multiple of the type byte length.
  27118. * DEPRECATED. Use byteOffset instead.
  27119. */
  27120. getOffset(): number;
  27121. /**
  27122. * Returns the number of components per vertex attribute (integer).
  27123. */
  27124. getSize(): number;
  27125. /**
  27126. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  27127. */
  27128. getIsInstanced(): boolean;
  27129. /**
  27130. * Returns the instancing divisor, zero for non-instanced (integer).
  27131. */
  27132. getInstanceDivisor(): number;
  27133. /**
  27134. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  27135. * Returns the created WebGLBuffer.
  27136. */
  27137. create(data?: DataArray): void;
  27138. /**
  27139. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  27140. * This function will create a new buffer if the current one is not updatable
  27141. * Returns the updated WebGLBuffer.
  27142. */
  27143. update(data: DataArray): void;
  27144. /**
  27145. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  27146. * Returns the directly updated WebGLBuffer.
  27147. * @param data the new data
  27148. * @param offset the new offset
  27149. * @param useBytes set to true if the offset is in bytes
  27150. */
  27151. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  27152. /**
  27153. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  27154. */
  27155. dispose(): void;
  27156. /**
  27157. * Enumerates each value of this vertex buffer as numbers.
  27158. * @param count the number of values to enumerate
  27159. * @param callback the callback function called for each value
  27160. */
  27161. forEach(count: number, callback: (value: number, index: number) => void): void;
  27162. private static _PositionKind;
  27163. private static _NormalKind;
  27164. private static _TangentKind;
  27165. private static _UVKind;
  27166. private static _UV2Kind;
  27167. private static _UV3Kind;
  27168. private static _UV4Kind;
  27169. private static _UV5Kind;
  27170. private static _UV6Kind;
  27171. private static _ColorKind;
  27172. private static _MatricesIndicesKind;
  27173. private static _MatricesWeightsKind;
  27174. private static _MatricesIndicesExtraKind;
  27175. private static _MatricesWeightsExtraKind;
  27176. static readonly PositionKind: string;
  27177. static readonly NormalKind: string;
  27178. static readonly TangentKind: string;
  27179. static readonly UVKind: string;
  27180. static readonly UV2Kind: string;
  27181. static readonly UV3Kind: string;
  27182. static readonly UV4Kind: string;
  27183. static readonly UV5Kind: string;
  27184. static readonly UV6Kind: string;
  27185. static readonly ColorKind: string;
  27186. static readonly MatricesIndicesKind: string;
  27187. static readonly MatricesWeightsKind: string;
  27188. static readonly MatricesIndicesExtraKind: string;
  27189. static readonly MatricesWeightsExtraKind: string;
  27190. /**
  27191. * Deduces the stride given a kind.
  27192. * @param kind The kind string to deduce
  27193. * @returns The deduced stride
  27194. */
  27195. static DeduceStride(kind: string): number;
  27196. /**
  27197. * Gets the byte length of the given type.
  27198. * @param type the type
  27199. * @returns the number of bytes
  27200. */
  27201. static GetTypeByteLength(type: number): number;
  27202. /**
  27203. * Enumerates each value of the given parameters as numbers.
  27204. * @param data the data to enumerate
  27205. * @param byteOffset the byte offset of the data
  27206. * @param byteStride the byte stride of the data
  27207. * @param componentCount the number of components per element
  27208. * @param componentType the type of the component
  27209. * @param count the total number of components
  27210. * @param normalized whether the data is normalized
  27211. * @param callback the callback function called for each value
  27212. */
  27213. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  27214. private static _GetFloatValue;
  27215. }
  27216. }
  27217. declare module BABYLON {
  27218. /**
  27219. * Defines a target to use with MorphTargetManager
  27220. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27221. */
  27222. class MorphTarget implements IAnimatable {
  27223. /** defines the name of the target */
  27224. name: string;
  27225. /**
  27226. * Gets or sets the list of animations
  27227. */
  27228. animations: Animation[];
  27229. private _scene;
  27230. private _positions;
  27231. private _normals;
  27232. private _tangents;
  27233. private _influence;
  27234. /**
  27235. * Observable raised when the influence changes
  27236. */
  27237. onInfluenceChanged: Observable<boolean>;
  27238. /**
  27239. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27240. */
  27241. influence: number;
  27242. private _animationPropertiesOverride;
  27243. /**
  27244. * Gets or sets the animation properties override
  27245. */
  27246. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27247. /**
  27248. * Creates a new MorphTarget
  27249. * @param name defines the name of the target
  27250. * @param influence defines the influence to use
  27251. */
  27252. constructor(
  27253. /** defines the name of the target */
  27254. name: string, influence?: number, scene?: Nullable<Scene>);
  27255. /**
  27256. * Gets a boolean defining if the target contains position data
  27257. */
  27258. readonly hasPositions: boolean;
  27259. /**
  27260. * Gets a boolean defining if the target contains normal data
  27261. */
  27262. readonly hasNormals: boolean;
  27263. /**
  27264. * Gets a boolean defining if the target contains tangent data
  27265. */
  27266. readonly hasTangents: boolean;
  27267. /**
  27268. * Affects position data to this target
  27269. * @param data defines the position data to use
  27270. */
  27271. setPositions(data: Nullable<FloatArray>): void;
  27272. /**
  27273. * Gets the position data stored in this target
  27274. * @returns a FloatArray containing the position data (or null if not present)
  27275. */
  27276. getPositions(): Nullable<FloatArray>;
  27277. /**
  27278. * Affects normal data to this target
  27279. * @param data defines the normal data to use
  27280. */
  27281. setNormals(data: Nullable<FloatArray>): void;
  27282. /**
  27283. * Gets the normal data stored in this target
  27284. * @returns a FloatArray containing the normal data (or null if not present)
  27285. */
  27286. getNormals(): Nullable<FloatArray>;
  27287. /**
  27288. * Affects tangent data to this target
  27289. * @param data defines the tangent data to use
  27290. */
  27291. setTangents(data: Nullable<FloatArray>): void;
  27292. /**
  27293. * Gets the tangent data stored in this target
  27294. * @returns a FloatArray containing the tangent data (or null if not present)
  27295. */
  27296. getTangents(): Nullable<FloatArray>;
  27297. /**
  27298. * Serializes the current target into a Serialization object
  27299. * @returns the serialized object
  27300. */
  27301. serialize(): any;
  27302. /**
  27303. * Creates a new target from serialized data
  27304. * @param serializationObject defines the serialized data to use
  27305. * @returns a new MorphTarget
  27306. */
  27307. static Parse(serializationObject: any): MorphTarget;
  27308. /**
  27309. * Creates a MorphTarget from mesh data
  27310. * @param mesh defines the source mesh
  27311. * @param name defines the name to use for the new target
  27312. * @param influence defines the influence to attach to the target
  27313. * @returns a new MorphTarget
  27314. */
  27315. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27316. }
  27317. }
  27318. declare module BABYLON {
  27319. /**
  27320. * This class is used to deform meshes using morphing between different targets
  27321. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27322. */
  27323. class MorphTargetManager {
  27324. private _targets;
  27325. private _targetObservable;
  27326. private _activeTargets;
  27327. private _scene;
  27328. private _influences;
  27329. private _supportsNormals;
  27330. private _supportsTangents;
  27331. private _vertexCount;
  27332. private _uniqueId;
  27333. private _tempInfluences;
  27334. /**
  27335. * Creates a new MorphTargetManager
  27336. * @param scene defines the current scene
  27337. */
  27338. constructor(scene?: Nullable<Scene>);
  27339. /**
  27340. * Gets the unique ID of this manager
  27341. */
  27342. readonly uniqueId: number;
  27343. /**
  27344. * Gets the number of vertices handled by this manager
  27345. */
  27346. readonly vertexCount: number;
  27347. /**
  27348. * Gets a boolean indicating if this manager supports morphing of normals
  27349. */
  27350. readonly supportsNormals: boolean;
  27351. /**
  27352. * Gets a boolean indicating if this manager supports morphing of tangents
  27353. */
  27354. readonly supportsTangents: boolean;
  27355. /**
  27356. * Gets the number of targets stored in this manager
  27357. */
  27358. readonly numTargets: number;
  27359. /**
  27360. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27361. */
  27362. readonly numInfluencers: number;
  27363. /**
  27364. * Gets the list of influences (one per target)
  27365. */
  27366. readonly influences: Float32Array;
  27367. /**
  27368. * Gets the active target at specified index. An active target is a target with an influence > 0
  27369. * @param index defines the index to check
  27370. * @returns the requested target
  27371. */
  27372. getActiveTarget(index: number): MorphTarget;
  27373. /**
  27374. * Gets the target at specified index
  27375. * @param index defines the index to check
  27376. * @returns the requested target
  27377. */
  27378. getTarget(index: number): MorphTarget;
  27379. /**
  27380. * Add a new target to this manager
  27381. * @param target defines the target to add
  27382. */
  27383. addTarget(target: MorphTarget): void;
  27384. /**
  27385. * Removes a target from the manager
  27386. * @param target defines the target to remove
  27387. */
  27388. removeTarget(target: MorphTarget): void;
  27389. /**
  27390. * Serializes the current manager into a Serialization object
  27391. * @returns the serialized object
  27392. */
  27393. serialize(): any;
  27394. private _syncActiveTargets;
  27395. /**
  27396. * Syncrhonize the targets with all the meshes using this morph target manager
  27397. */
  27398. synchronize(): void;
  27399. /**
  27400. * Creates a new MorphTargetManager from serialized data
  27401. * @param serializationObject defines the serialized data
  27402. * @param scene defines the hosting scene
  27403. * @returns the new MorphTargetManager
  27404. */
  27405. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27406. }
  27407. }
  27408. declare module BABYLON {
  27409. /**
  27410. * This represents the base class for particle system in Babylon.
  27411. * 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.
  27412. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  27413. * @example https://doc.babylonjs.com/babylon101/particles
  27414. */
  27415. class BaseParticleSystem {
  27416. /**
  27417. * Source color is added to the destination color without alpha affecting the result
  27418. */
  27419. static BLENDMODE_ONEONE: number;
  27420. /**
  27421. * Blend current color and particle color using particle’s alpha
  27422. */
  27423. static BLENDMODE_STANDARD: number;
  27424. /**
  27425. * Add current color and particle color multiplied by particle’s alpha
  27426. */
  27427. static BLENDMODE_ADD: number;
  27428. /**
  27429. * Multiply current color with particle color
  27430. */
  27431. static BLENDMODE_MULTIPLY: number;
  27432. /**
  27433. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  27434. */
  27435. static BLENDMODE_MULTIPLYADD: number;
  27436. /**
  27437. * List of animations used by the particle system.
  27438. */
  27439. animations: Animation[];
  27440. /**
  27441. * The id of the Particle system.
  27442. */
  27443. id: string;
  27444. /**
  27445. * The friendly name of the Particle system.
  27446. */
  27447. name: string;
  27448. /**
  27449. * The rendering group used by the Particle system to chose when to render.
  27450. */
  27451. renderingGroupId: number;
  27452. /**
  27453. * The emitter represents the Mesh or position we are attaching the particle system to.
  27454. */
  27455. emitter: Nullable<AbstractMesh | Vector3>;
  27456. /**
  27457. * The maximum number of particles to emit per frame
  27458. */
  27459. emitRate: number;
  27460. /**
  27461. * If you want to launch only a few particles at once, that can be done, as well.
  27462. */
  27463. manualEmitCount: number;
  27464. /**
  27465. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  27466. */
  27467. updateSpeed: number;
  27468. /**
  27469. * The amount of time the particle system is running (depends of the overall update speed).
  27470. */
  27471. targetStopDuration: number;
  27472. /**
  27473. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  27474. */
  27475. disposeOnStop: boolean;
  27476. /**
  27477. * Minimum power of emitting particles.
  27478. */
  27479. minEmitPower: number;
  27480. /**
  27481. * Maximum power of emitting particles.
  27482. */
  27483. maxEmitPower: number;
  27484. /**
  27485. * Minimum life time of emitting particles.
  27486. */
  27487. minLifeTime: number;
  27488. /**
  27489. * Maximum life time of emitting particles.
  27490. */
  27491. maxLifeTime: number;
  27492. /**
  27493. * Minimum Size of emitting particles.
  27494. */
  27495. minSize: number;
  27496. /**
  27497. * Maximum Size of emitting particles.
  27498. */
  27499. maxSize: number;
  27500. /**
  27501. * Minimum scale of emitting particles on X axis.
  27502. */
  27503. minScaleX: number;
  27504. /**
  27505. * Maximum scale of emitting particles on X axis.
  27506. */
  27507. maxScaleX: number;
  27508. /**
  27509. * Minimum scale of emitting particles on Y axis.
  27510. */
  27511. minScaleY: number;
  27512. /**
  27513. * Maximum scale of emitting particles on Y axis.
  27514. */
  27515. maxScaleY: number;
  27516. /**
  27517. * Gets or sets the minimal initial rotation in radians.
  27518. */
  27519. minInitialRotation: number;
  27520. /**
  27521. * Gets or sets the maximal initial rotation in radians.
  27522. */
  27523. maxInitialRotation: number;
  27524. /**
  27525. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  27526. */
  27527. minAngularSpeed: number;
  27528. /**
  27529. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  27530. */
  27531. maxAngularSpeed: number;
  27532. /**
  27533. * The texture used to render each particle. (this can be a spritesheet)
  27534. */
  27535. particleTexture: Nullable<Texture>;
  27536. /**
  27537. * The layer mask we are rendering the particles through.
  27538. */
  27539. layerMask: number;
  27540. /**
  27541. * This can help using your own shader to render the particle system.
  27542. * The according effect will be created
  27543. */
  27544. customShader: any;
  27545. /**
  27546. * By default particle system starts as soon as they are created. This prevents the
  27547. * automatic start to happen and let you decide when to start emitting particles.
  27548. */
  27549. preventAutoStart: boolean;
  27550. /**
  27551. * Gets or sets a texture used to add random noise to particle positions
  27552. */
  27553. noiseTexture: Nullable<ProceduralTexture>;
  27554. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  27555. noiseStrength: Vector3;
  27556. /**
  27557. * Callback triggered when the particle animation is ending.
  27558. */
  27559. onAnimationEnd: Nullable<() => void>;
  27560. /**
  27561. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  27562. */
  27563. blendMode: number;
  27564. /**
  27565. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  27566. * to override the particles.
  27567. */
  27568. forceDepthWrite: boolean;
  27569. /** 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 */
  27570. preWarmCycles: number;
  27571. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  27572. preWarmStepOffset: number;
  27573. /**
  27574. * 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)
  27575. */
  27576. spriteCellChangeSpeed: number;
  27577. /**
  27578. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  27579. */
  27580. startSpriteCellID: number;
  27581. /**
  27582. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  27583. */
  27584. endSpriteCellID: number;
  27585. /**
  27586. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  27587. */
  27588. spriteCellWidth: number;
  27589. /**
  27590. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  27591. */
  27592. spriteCellHeight: number;
  27593. /**
  27594. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  27595. */
  27596. spriteRandomStartCell: boolean;
  27597. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  27598. translationPivot: Vector2;
  27599. /** @hidden */
  27600. protected _isAnimationSheetEnabled: boolean;
  27601. /**
  27602. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  27603. */
  27604. beginAnimationOnStart: boolean;
  27605. /**
  27606. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  27607. */
  27608. beginAnimationFrom: number;
  27609. /**
  27610. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  27611. */
  27612. beginAnimationTo: number;
  27613. /**
  27614. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  27615. */
  27616. beginAnimationLoop: boolean;
  27617. /**
  27618. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  27619. */
  27620. isAnimationSheetEnabled: boolean;
  27621. /**
  27622. * Get hosting scene
  27623. * @returns the scene
  27624. */
  27625. getScene(): Scene;
  27626. /**
  27627. * You can use gravity if you want to give an orientation to your particles.
  27628. */
  27629. gravity: Vector3;
  27630. protected _colorGradients: Nullable<Array<ColorGradient>>;
  27631. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  27632. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  27633. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  27634. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  27635. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  27636. protected _dragGradients: Nullable<Array<FactorGradient>>;
  27637. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  27638. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  27639. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  27640. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  27641. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  27642. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  27643. /**
  27644. * Defines the delay in milliseconds before starting the system (0 by default)
  27645. */
  27646. startDelay: number;
  27647. /**
  27648. * Gets the current list of drag gradients.
  27649. * You must use addDragGradient and removeDragGradient to udpate this list
  27650. * @returns the list of drag gradients
  27651. */
  27652. getDragGradients(): Nullable<Array<FactorGradient>>;
  27653. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  27654. limitVelocityDamping: number;
  27655. /**
  27656. * Gets the current list of limit velocity gradients.
  27657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  27658. * @returns the list of limit velocity gradients
  27659. */
  27660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  27661. /**
  27662. * Gets the current list of color gradients.
  27663. * You must use addColorGradient and removeColorGradient to udpate this list
  27664. * @returns the list of color gradients
  27665. */
  27666. getColorGradients(): Nullable<Array<ColorGradient>>;
  27667. /**
  27668. * Gets the current list of size gradients.
  27669. * You must use addSizeGradient and removeSizeGradient to udpate this list
  27670. * @returns the list of size gradients
  27671. */
  27672. getSizeGradients(): Nullable<Array<FactorGradient>>;
  27673. /**
  27674. * Gets the current list of color remap gradients.
  27675. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  27676. * @returns the list of color remap gradients
  27677. */
  27678. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  27679. /**
  27680. * Gets the current list of alpha remap gradients.
  27681. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  27682. * @returns the list of alpha remap gradients
  27683. */
  27684. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  27685. /**
  27686. * Gets the current list of life time gradients.
  27687. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  27688. * @returns the list of life time gradients
  27689. */
  27690. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  27691. /**
  27692. * Gets the current list of angular speed gradients.
  27693. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  27694. * @returns the list of angular speed gradients
  27695. */
  27696. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  27697. /**
  27698. * Gets the current list of velocity gradients.
  27699. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  27700. * @returns the list of velocity gradients
  27701. */
  27702. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  27703. /**
  27704. * Gets the current list of start size gradients.
  27705. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  27706. * @returns the list of start size gradients
  27707. */
  27708. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  27709. /**
  27710. * Gets the current list of emit rate gradients.
  27711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  27712. * @returns the list of emit rate gradients
  27713. */
  27714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  27715. /**
  27716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27717. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27718. */
  27719. direction1: Vector3;
  27720. /**
  27721. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27722. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27723. */
  27724. direction2: Vector3;
  27725. /**
  27726. * 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.
  27727. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27728. */
  27729. minEmitBox: Vector3;
  27730. /**
  27731. * 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.
  27732. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27733. */
  27734. maxEmitBox: Vector3;
  27735. /**
  27736. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  27737. */
  27738. color1: Color4;
  27739. /**
  27740. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  27741. */
  27742. color2: Color4;
  27743. /**
  27744. * Color the particle will have at the end of its lifetime
  27745. */
  27746. colorDead: Color4;
  27747. /**
  27748. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  27749. */
  27750. textureMask: Color4;
  27751. /**
  27752. * The particle emitter type defines the emitter used by the particle system.
  27753. * It can be for example box, sphere, or cone...
  27754. */
  27755. particleEmitterType: IParticleEmitterType;
  27756. /** @hidden */
  27757. _isSubEmitter: boolean;
  27758. /**
  27759. * Gets or sets the billboard mode to use when isBillboardBased = true.
  27760. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  27761. */
  27762. billboardMode: number;
  27763. protected _isBillboardBased: boolean;
  27764. /**
  27765. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  27766. */
  27767. isBillboardBased: boolean;
  27768. /**
  27769. * The scene the particle system belongs to.
  27770. */
  27771. protected _scene: Scene;
  27772. /**
  27773. * Local cache of defines for image processing.
  27774. */
  27775. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  27776. /**
  27777. * Default configuration related to image processing available in the standard Material.
  27778. */
  27779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27780. /**
  27781. * Gets the image processing configuration used either in this material.
  27782. */
  27783. /**
  27784. * Sets the Default image processing configuration used either in the this material.
  27785. *
  27786. * If sets to null, the scene one is in use.
  27787. */
  27788. imageProcessingConfiguration: ImageProcessingConfiguration;
  27789. /**
  27790. * Attaches a new image processing configuration to the Standard Material.
  27791. * @param configuration
  27792. */
  27793. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27794. /** @hidden */
  27795. protected _reset(): void;
  27796. /** @hidden */
  27797. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  27798. /**
  27799. * Instantiates a particle system.
  27800. * 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.
  27801. * @param name The name of the particle system
  27802. */
  27803. constructor(name: string);
  27804. /**
  27805. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  27806. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  27807. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  27808. * @returns the emitter
  27809. */
  27810. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  27811. /**
  27812. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  27813. * @param radius The radius of the hemisphere to emit from
  27814. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  27815. * @returns the emitter
  27816. */
  27817. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  27818. /**
  27819. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  27820. * @param radius The radius of the sphere to emit from
  27821. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  27822. * @returns the emitter
  27823. */
  27824. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  27825. /**
  27826. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  27827. * @param radius The radius of the sphere to emit from
  27828. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  27829. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  27830. * @returns the emitter
  27831. */
  27832. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  27833. /**
  27834. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  27835. * @param radius The radius of the emission cylinder
  27836. * @param height The height of the emission cylinder
  27837. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  27838. * @param directionRandomizer How much to randomize the particle direction [0-1]
  27839. * @returns the emitter
  27840. */
  27841. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  27842. /**
  27843. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  27844. * @param radius The radius of the cylinder to emit from
  27845. * @param height The height of the emission cylinder
  27846. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  27847. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  27848. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  27849. * @returns the emitter
  27850. */
  27851. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  27852. /**
  27853. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  27854. * @param radius The radius of the cone to emit from
  27855. * @param angle The base angle of the cone
  27856. * @returns the emitter
  27857. */
  27858. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  27859. /**
  27860. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  27861. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  27862. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  27863. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  27864. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  27865. * @returns the emitter
  27866. */
  27867. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  27868. }
  27869. }
  27870. declare module BABYLON {
  27871. /**
  27872. * This represents a GPU particle system in Babylon
  27873. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  27874. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  27875. */
  27876. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  27877. /**
  27878. * The layer mask we are rendering the particles through.
  27879. */
  27880. layerMask: number;
  27881. private _capacity;
  27882. private _activeCount;
  27883. private _currentActiveCount;
  27884. private _accumulatedCount;
  27885. private _renderEffect;
  27886. private _updateEffect;
  27887. private _buffer0;
  27888. private _buffer1;
  27889. private _spriteBuffer;
  27890. private _updateVAO;
  27891. private _renderVAO;
  27892. private _targetIndex;
  27893. private _sourceBuffer;
  27894. private _targetBuffer;
  27895. private _engine;
  27896. private _currentRenderId;
  27897. private _started;
  27898. private _stopped;
  27899. private _timeDelta;
  27900. private _randomTexture;
  27901. private _randomTexture2;
  27902. private _attributesStrideSize;
  27903. private _updateEffectOptions;
  27904. private _randomTextureSize;
  27905. private _actualFrame;
  27906. private readonly _rawTextureWidth;
  27907. /**
  27908. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  27909. */
  27910. static readonly IsSupported: boolean;
  27911. /**
  27912. * An event triggered when the system is disposed.
  27913. */
  27914. onDisposeObservable: Observable<GPUParticleSystem>;
  27915. /**
  27916. * Gets the maximum number of particles active at the same time.
  27917. * @returns The max number of active particles.
  27918. */
  27919. getCapacity(): number;
  27920. /**
  27921. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  27922. * to override the particles.
  27923. */
  27924. forceDepthWrite: boolean;
  27925. /**
  27926. * Gets or set the number of active particles
  27927. */
  27928. activeParticleCount: number;
  27929. private _preWarmDone;
  27930. /**
  27931. * Is this system ready to be used/rendered
  27932. * @return true if the system is ready
  27933. */
  27934. isReady(): boolean;
  27935. /**
  27936. * Gets if the system has been started. (Note: this will still be true after stop is called)
  27937. * @returns True if it has been started, otherwise false.
  27938. */
  27939. isStarted(): boolean;
  27940. /**
  27941. * Starts the particle system and begins to emit
  27942. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  27943. */
  27944. start(delay?: number): void;
  27945. /**
  27946. * Stops the particle system.
  27947. */
  27948. stop(): void;
  27949. /**
  27950. * Remove all active particles
  27951. */
  27952. reset(): void;
  27953. /**
  27954. * Returns the string "GPUParticleSystem"
  27955. * @returns a string containing the class name
  27956. */
  27957. getClassName(): string;
  27958. private _colorGradientsTexture;
  27959. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  27960. /**
  27961. * Adds a new color gradient
  27962. * @param gradient defines the gradient to use (between 0 and 1)
  27963. * @param color1 defines the color to affect to the specified gradient
  27964. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  27965. * @returns the current particle system
  27966. */
  27967. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  27968. /**
  27969. * Remove a specific color gradient
  27970. * @param gradient defines the gradient to remove
  27971. * @returns the current particle system
  27972. */
  27973. removeColorGradient(gradient: number): GPUParticleSystem;
  27974. private _angularSpeedGradientsTexture;
  27975. private _sizeGradientsTexture;
  27976. private _velocityGradientsTexture;
  27977. private _limitVelocityGradientsTexture;
  27978. private _dragGradientsTexture;
  27979. private _addFactorGradient;
  27980. /**
  27981. * Adds a new size gradient
  27982. * @param gradient defines the gradient to use (between 0 and 1)
  27983. * @param factor defines the size factor to affect to the specified gradient
  27984. * @returns the current particle system
  27985. */
  27986. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  27987. /**
  27988. * Remove a specific size gradient
  27989. * @param gradient defines the gradient to remove
  27990. * @returns the current particle system
  27991. */
  27992. removeSizeGradient(gradient: number): GPUParticleSystem;
  27993. /**
  27994. * Adds a new angular speed gradient
  27995. * @param gradient defines the gradient to use (between 0 and 1)
  27996. * @param factor defines the angular speed to affect to the specified gradient
  27997. * @returns the current particle system
  27998. */
  27999. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  28000. /**
  28001. * Remove a specific angular speed gradient
  28002. * @param gradient defines the gradient to remove
  28003. * @returns the current particle system
  28004. */
  28005. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  28006. /**
  28007. * Adds a new velocity gradient
  28008. * @param gradient defines the gradient to use (between 0 and 1)
  28009. * @param factor defines the velocity to affect to the specified gradient
  28010. * @returns the current particle system
  28011. */
  28012. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  28013. /**
  28014. * Remove a specific velocity gradient
  28015. * @param gradient defines the gradient to remove
  28016. * @returns the current particle system
  28017. */
  28018. removeVelocityGradient(gradient: number): GPUParticleSystem;
  28019. /**
  28020. * Adds a new limit velocity gradient
  28021. * @param gradient defines the gradient to use (between 0 and 1)
  28022. * @param factor defines the limit velocity value to affect to the specified gradient
  28023. * @returns the current particle system
  28024. */
  28025. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  28026. /**
  28027. * Remove a specific limit velocity gradient
  28028. * @param gradient defines the gradient to remove
  28029. * @returns the current particle system
  28030. */
  28031. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  28032. /**
  28033. * Adds a new drag gradient
  28034. * @param gradient defines the gradient to use (between 0 and 1)
  28035. * @param factor defines the drag value to affect to the specified gradient
  28036. * @returns the current particle system
  28037. */
  28038. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  28039. /**
  28040. * Remove a specific drag gradient
  28041. * @param gradient defines the gradient to remove
  28042. * @returns the current particle system
  28043. */
  28044. removeDragGradient(gradient: number): GPUParticleSystem;
  28045. /**
  28046. * Not supported by GPUParticleSystem
  28047. * @param gradient defines the gradient to use (between 0 and 1)
  28048. * @param factor defines the emit rate value to affect to the specified gradient
  28049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28050. * @returns the current particle system
  28051. */
  28052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28053. /**
  28054. * Not supported by GPUParticleSystem
  28055. * @param gradient defines the gradient to remove
  28056. * @returns the current particle system
  28057. */
  28058. removeEmitRateGradient(gradient: number): IParticleSystem;
  28059. /**
  28060. * Not supported by GPUParticleSystem
  28061. * @param gradient defines the gradient to use (between 0 and 1)
  28062. * @param factor defines the start size value to affect to the specified gradient
  28063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28064. * @returns the current particle system
  28065. */
  28066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28067. /**
  28068. * Not supported by GPUParticleSystem
  28069. * @param gradient defines the gradient to remove
  28070. * @returns the current particle system
  28071. */
  28072. removeStartSizeGradient(gradient: number): IParticleSystem;
  28073. /**
  28074. * Not supported by GPUParticleSystem
  28075. * @param gradient defines the gradient to use (between 0 and 1)
  28076. * @param min defines the color remap minimal range
  28077. * @param max defines the color remap maximal range
  28078. * @returns the current particle system
  28079. */
  28080. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28081. /**
  28082. * Not supported by GPUParticleSystem
  28083. * @param gradient defines the gradient to remove
  28084. * @returns the current particle system
  28085. */
  28086. removeColorRemapGradient(gradient: number): IParticleSystem;
  28087. /**
  28088. * Not supported by GPUParticleSystem
  28089. * @param gradient defines the gradient to use (between 0 and 1)
  28090. * @param min defines the alpha remap minimal range
  28091. * @param max defines the alpha remap maximal range
  28092. * @returns the current particle system
  28093. */
  28094. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28095. /**
  28096. * Not supported by GPUParticleSystem
  28097. * @param gradient defines the gradient to remove
  28098. * @returns the current particle system
  28099. */
  28100. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  28101. /**
  28102. * Not supported by GPUParticleSystem
  28103. * @param gradient defines the gradient to use (between 0 and 1)
  28104. * @param color defines the color to affect to the specified gradient
  28105. * @returns the current particle system
  28106. */
  28107. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  28108. /**
  28109. * Not supported by GPUParticleSystem
  28110. * @param gradient defines the gradient to remove
  28111. * @returns the current particle system
  28112. */
  28113. removeRampGradient(gradient: number): IParticleSystem;
  28114. /**
  28115. * Not supported by GPUParticleSystem
  28116. * @returns the list of ramp gradients
  28117. */
  28118. getRampGradients(): Nullable<Array<Color3Gradient>>;
  28119. /**
  28120. * Not supported by GPUParticleSystem
  28121. * Gets or sets a boolean indicating that ramp gradients must be used
  28122. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  28123. */
  28124. useRampGradients: boolean;
  28125. /**
  28126. * Not supported by GPUParticleSystem
  28127. * @param gradient defines the gradient to use (between 0 and 1)
  28128. * @param factor defines the life time factor to affect to the specified gradient
  28129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28130. * @returns the current particle system
  28131. */
  28132. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28133. /**
  28134. * Not supported by GPUParticleSystem
  28135. * @param gradient defines the gradient to remove
  28136. * @returns the current particle system
  28137. */
  28138. removeLifeTimeGradient(gradient: number): IParticleSystem;
  28139. /**
  28140. * Instantiates a GPU particle system.
  28141. * 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.
  28142. * @param name The name of the particle system
  28143. * @param options The options used to create the system
  28144. * @param scene The scene the particle system belongs to
  28145. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  28146. */
  28147. constructor(name: string, options: Partial<{
  28148. capacity: number;
  28149. randomTextureSize: number;
  28150. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  28151. protected _reset(): void;
  28152. private _createUpdateVAO;
  28153. private _createRenderVAO;
  28154. private _initialize;
  28155. /** @hidden */
  28156. _recreateUpdateEffect(): void;
  28157. /** @hidden */
  28158. _recreateRenderEffect(): void;
  28159. /**
  28160. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  28161. * @param preWarm defines if we are in the pre-warmimg phase
  28162. */
  28163. animate(preWarm?: boolean): void;
  28164. private _createFactorGradientTexture;
  28165. private _createSizeGradientTexture;
  28166. private _createAngularSpeedGradientTexture;
  28167. private _createVelocityGradientTexture;
  28168. private _createLimitVelocityGradientTexture;
  28169. private _createDragGradientTexture;
  28170. private _createColorGradientTexture;
  28171. /**
  28172. * Renders the particle system in its current state
  28173. * @param preWarm defines if the system should only update the particles but not render them
  28174. * @returns the current number of particles
  28175. */
  28176. render(preWarm?: boolean): number;
  28177. /**
  28178. * Rebuilds the particle system
  28179. */
  28180. rebuild(): void;
  28181. private _releaseBuffers;
  28182. private _releaseVAOs;
  28183. /**
  28184. * Disposes the particle system and free the associated resources
  28185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  28186. */
  28187. dispose(disposeTexture?: boolean): void;
  28188. /**
  28189. * Clones the particle system.
  28190. * @param name The name of the cloned object
  28191. * @param newEmitter The new emitter to use
  28192. * @returns the cloned particle system
  28193. */
  28194. clone(name: string, newEmitter: any): GPUParticleSystem;
  28195. /**
  28196. * Serializes the particle system to a JSON object.
  28197. * @returns the JSON object
  28198. */
  28199. serialize(): any;
  28200. /**
  28201. * Parses a JSON object to create a GPU particle system.
  28202. * @param parsedParticleSystem The JSON object to parse
  28203. * @param scene The scene to create the particle system in
  28204. * @param rootUrl The root url to use to load external dependencies like texture
  28205. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  28206. * @returns the parsed GPU particle system
  28207. */
  28208. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  28209. }
  28210. }
  28211. declare module BABYLON {
  28212. /**
  28213. * Interface representing a particle system in Babylon.js.
  28214. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  28215. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  28216. */
  28217. interface IParticleSystem {
  28218. /**
  28219. * List of animations used by the particle system.
  28220. */
  28221. animations: Animation[];
  28222. /**
  28223. * The id of the Particle system.
  28224. */
  28225. id: string;
  28226. /**
  28227. * The name of the Particle system.
  28228. */
  28229. name: string;
  28230. /**
  28231. * The emitter represents the Mesh or position we are attaching the particle system to.
  28232. */
  28233. emitter: Nullable<AbstractMesh | Vector3>;
  28234. /**
  28235. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  28236. */
  28237. isBillboardBased: boolean;
  28238. /**
  28239. * The rendering group used by the Particle system to chose when to render.
  28240. */
  28241. renderingGroupId: number;
  28242. /**
  28243. * The layer mask we are rendering the particles through.
  28244. */
  28245. layerMask: number;
  28246. /**
  28247. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  28248. */
  28249. updateSpeed: number;
  28250. /**
  28251. * The amount of time the particle system is running (depends of the overall update speed).
  28252. */
  28253. targetStopDuration: number;
  28254. /**
  28255. * The texture used to render each particle. (this can be a spritesheet)
  28256. */
  28257. particleTexture: Nullable<Texture>;
  28258. /**
  28259. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  28260. */
  28261. blendMode: number;
  28262. /**
  28263. * Minimum life time of emitting particles.
  28264. */
  28265. minLifeTime: number;
  28266. /**
  28267. * Maximum life time of emitting particles.
  28268. */
  28269. maxLifeTime: number;
  28270. /**
  28271. * Minimum Size of emitting particles.
  28272. */
  28273. minSize: number;
  28274. /**
  28275. * Maximum Size of emitting particles.
  28276. */
  28277. maxSize: number;
  28278. /**
  28279. * Minimum scale of emitting particles on X axis.
  28280. */
  28281. minScaleX: number;
  28282. /**
  28283. * Maximum scale of emitting particles on X axis.
  28284. */
  28285. maxScaleX: number;
  28286. /**
  28287. * Minimum scale of emitting particles on Y axis.
  28288. */
  28289. minScaleY: number;
  28290. /**
  28291. * Maximum scale of emitting particles on Y axis.
  28292. */
  28293. maxScaleY: number;
  28294. /**
  28295. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  28296. */
  28297. color1: Color4;
  28298. /**
  28299. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  28300. */
  28301. color2: Color4;
  28302. /**
  28303. * Color the particle will have at the end of its lifetime.
  28304. */
  28305. colorDead: Color4;
  28306. /**
  28307. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  28308. */
  28309. emitRate: number;
  28310. /**
  28311. * You can use gravity if you want to give an orientation to your particles.
  28312. */
  28313. gravity: Vector3;
  28314. /**
  28315. * Minimum power of emitting particles.
  28316. */
  28317. minEmitPower: number;
  28318. /**
  28319. * Maximum power of emitting particles.
  28320. */
  28321. maxEmitPower: number;
  28322. /**
  28323. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  28324. */
  28325. minAngularSpeed: number;
  28326. /**
  28327. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  28328. */
  28329. maxAngularSpeed: number;
  28330. /**
  28331. * Gets or sets the minimal initial rotation in radians.
  28332. */
  28333. minInitialRotation: number;
  28334. /**
  28335. * Gets or sets the maximal initial rotation in radians.
  28336. */
  28337. maxInitialRotation: number;
  28338. /**
  28339. * The particle emitter type defines the emitter used by the particle system.
  28340. * It can be for example box, sphere, or cone...
  28341. */
  28342. particleEmitterType: Nullable<IParticleEmitterType>;
  28343. /**
  28344. * Defines the delay in milliseconds before starting the system (0 by default)
  28345. */
  28346. startDelay: number;
  28347. /**
  28348. * 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
  28349. */
  28350. preWarmCycles: number;
  28351. /**
  28352. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  28353. */
  28354. preWarmStepOffset: number;
  28355. /**
  28356. * 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)
  28357. */
  28358. spriteCellChangeSpeed: number;
  28359. /**
  28360. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  28361. */
  28362. startSpriteCellID: number;
  28363. /**
  28364. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  28365. */
  28366. endSpriteCellID: number;
  28367. /**
  28368. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  28369. */
  28370. spriteCellWidth: number;
  28371. /**
  28372. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  28373. */
  28374. spriteCellHeight: number;
  28375. /**
  28376. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  28377. */
  28378. spriteRandomStartCell: boolean;
  28379. /**
  28380. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  28381. */
  28382. isAnimationSheetEnabled: boolean;
  28383. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  28384. translationPivot: Vector2;
  28385. /**
  28386. * Gets or sets a texture used to add random noise to particle positions
  28387. */
  28388. noiseTexture: Nullable<BaseTexture>;
  28389. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  28390. noiseStrength: Vector3;
  28391. /**
  28392. * Gets or sets the billboard mode to use when isBillboardBased = true.
  28393. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  28394. */
  28395. billboardMode: number;
  28396. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  28397. limitVelocityDamping: number;
  28398. /**
  28399. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  28400. */
  28401. beginAnimationOnStart: boolean;
  28402. /**
  28403. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  28404. */
  28405. beginAnimationFrom: number;
  28406. /**
  28407. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  28408. */
  28409. beginAnimationTo: number;
  28410. /**
  28411. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  28412. */
  28413. beginAnimationLoop: boolean;
  28414. /**
  28415. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  28416. */
  28417. disposeOnStop: boolean;
  28418. /**
  28419. * Gets the maximum number of particles active at the same time.
  28420. * @returns The max number of active particles.
  28421. */
  28422. getCapacity(): number;
  28423. /**
  28424. * Gets if the system has been started. (Note: this will still be true after stop is called)
  28425. * @returns True if it has been started, otherwise false.
  28426. */
  28427. isStarted(): boolean;
  28428. /**
  28429. * Animates the particle system for this frame.
  28430. */
  28431. animate(): void;
  28432. /**
  28433. * Renders the particle system in its current state.
  28434. * @returns the current number of particles
  28435. */
  28436. render(): number;
  28437. /**
  28438. * Dispose the particle system and frees its associated resources.
  28439. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  28440. */
  28441. dispose(disposeTexture?: boolean): void;
  28442. /**
  28443. * Clones the particle system.
  28444. * @param name The name of the cloned object
  28445. * @param newEmitter The new emitter to use
  28446. * @returns the cloned particle system
  28447. */
  28448. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  28449. /**
  28450. * Serializes the particle system to a JSON object.
  28451. * @returns the JSON object
  28452. */
  28453. serialize(): any;
  28454. /**
  28455. * Rebuild the particle system
  28456. */
  28457. rebuild(): void;
  28458. /**
  28459. * Starts the particle system and begins to emit
  28460. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  28461. */
  28462. start(delay?: number): void;
  28463. /**
  28464. * Stops the particle system.
  28465. */
  28466. stop(): void;
  28467. /**
  28468. * Remove all active particles
  28469. */
  28470. reset(): void;
  28471. /**
  28472. * Is this system ready to be used/rendered
  28473. * @return true if the system is ready
  28474. */
  28475. isReady(): boolean;
  28476. /**
  28477. * Adds a new color gradient
  28478. * @param gradient defines the gradient to use (between 0 and 1)
  28479. * @param color1 defines the color to affect to the specified gradient
  28480. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  28481. * @returns the current particle system
  28482. */
  28483. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  28484. /**
  28485. * Remove a specific color gradient
  28486. * @param gradient defines the gradient to remove
  28487. * @returns the current particle system
  28488. */
  28489. removeColorGradient(gradient: number): IParticleSystem;
  28490. /**
  28491. * Adds a new size gradient
  28492. * @param gradient defines the gradient to use (between 0 and 1)
  28493. * @param factor defines the size factor to affect to the specified gradient
  28494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28495. * @returns the current particle system
  28496. */
  28497. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28498. /**
  28499. * Remove a specific size gradient
  28500. * @param gradient defines the gradient to remove
  28501. * @returns the current particle system
  28502. */
  28503. removeSizeGradient(gradient: number): IParticleSystem;
  28504. /**
  28505. * Gets the current list of color gradients.
  28506. * You must use addColorGradient and removeColorGradient to udpate this list
  28507. * @returns the list of color gradients
  28508. */
  28509. getColorGradients(): Nullable<Array<ColorGradient>>;
  28510. /**
  28511. * Gets the current list of size gradients.
  28512. * You must use addSizeGradient and removeSizeGradient to udpate this list
  28513. * @returns the list of size gradients
  28514. */
  28515. getSizeGradients(): Nullable<Array<FactorGradient>>;
  28516. /**
  28517. * Gets the current list of angular speed gradients.
  28518. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  28519. * @returns the list of angular speed gradients
  28520. */
  28521. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  28522. /**
  28523. * Adds a new angular speed gradient
  28524. * @param gradient defines the gradient to use (between 0 and 1)
  28525. * @param factor defines the angular speed to affect to the specified gradient
  28526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28527. * @returns the current particle system
  28528. */
  28529. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28530. /**
  28531. * Remove a specific angular speed gradient
  28532. * @param gradient defines the gradient to remove
  28533. * @returns the current particle system
  28534. */
  28535. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  28536. /**
  28537. * Gets the current list of velocity gradients.
  28538. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  28539. * @returns the list of velocity gradients
  28540. */
  28541. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  28542. /**
  28543. * Adds a new velocity gradient
  28544. * @param gradient defines the gradient to use (between 0 and 1)
  28545. * @param factor defines the velocity to affect to the specified gradient
  28546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28547. * @returns the current particle system
  28548. */
  28549. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28550. /**
  28551. * Remove a specific velocity gradient
  28552. * @param gradient defines the gradient to remove
  28553. * @returns the current particle system
  28554. */
  28555. removeVelocityGradient(gradient: number): IParticleSystem;
  28556. /**
  28557. * Gets the current list of limit velocity gradients.
  28558. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  28559. * @returns the list of limit velocity gradients
  28560. */
  28561. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  28562. /**
  28563. * Adds a new limit velocity gradient
  28564. * @param gradient defines the gradient to use (between 0 and 1)
  28565. * @param factor defines the limit velocity to affect to the specified gradient
  28566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28567. * @returns the current particle system
  28568. */
  28569. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28570. /**
  28571. * Remove a specific limit velocity gradient
  28572. * @param gradient defines the gradient to remove
  28573. * @returns the current particle system
  28574. */
  28575. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  28576. /**
  28577. * Adds a new drag gradient
  28578. * @param gradient defines the gradient to use (between 0 and 1)
  28579. * @param factor defines the drag to affect to the specified gradient
  28580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28581. * @returns the current particle system
  28582. */
  28583. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28584. /**
  28585. * Remove a specific drag gradient
  28586. * @param gradient defines the gradient to remove
  28587. * @returns the current particle system
  28588. */
  28589. removeDragGradient(gradient: number): IParticleSystem;
  28590. /**
  28591. * Gets the current list of drag gradients.
  28592. * You must use addDragGradient and removeDragGradient to udpate this list
  28593. * @returns the list of drag gradients
  28594. */
  28595. getDragGradients(): Nullable<Array<FactorGradient>>;
  28596. /**
  28597. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  28598. * @param gradient defines the gradient to use (between 0 and 1)
  28599. * @param factor defines the emit rate to affect to the specified gradient
  28600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28601. * @returns the current particle system
  28602. */
  28603. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28604. /**
  28605. * Remove a specific emit rate gradient
  28606. * @param gradient defines the gradient to remove
  28607. * @returns the current particle system
  28608. */
  28609. removeEmitRateGradient(gradient: number): IParticleSystem;
  28610. /**
  28611. * Gets the current list of emit rate gradients.
  28612. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  28613. * @returns the list of emit rate gradients
  28614. */
  28615. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  28616. /**
  28617. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  28618. * @param gradient defines the gradient to use (between 0 and 1)
  28619. * @param factor defines the start size to affect to the specified gradient
  28620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28621. * @returns the current particle system
  28622. */
  28623. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28624. /**
  28625. * Remove a specific start size gradient
  28626. * @param gradient defines the gradient to remove
  28627. * @returns the current particle system
  28628. */
  28629. removeStartSizeGradient(gradient: number): IParticleSystem;
  28630. /**
  28631. * Gets the current list of start size gradients.
  28632. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  28633. * @returns the list of start size gradients
  28634. */
  28635. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  28636. /**
  28637. * Adds a new life time gradient
  28638. * @param gradient defines the gradient to use (between 0 and 1)
  28639. * @param factor defines the life time factor to affect to the specified gradient
  28640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28641. * @returns the current particle system
  28642. */
  28643. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28644. /**
  28645. * Remove a specific life time gradient
  28646. * @param gradient defines the gradient to remove
  28647. * @returns the current particle system
  28648. */
  28649. removeLifeTimeGradient(gradient: number): IParticleSystem;
  28650. /**
  28651. * Gets the current list of life time gradients.
  28652. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  28653. * @returns the list of life time gradients
  28654. */
  28655. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  28656. /**
  28657. * Gets the current list of color gradients.
  28658. * You must use addColorGradient and removeColorGradient to udpate this list
  28659. * @returns the list of color gradients
  28660. */
  28661. getColorGradients(): Nullable<Array<ColorGradient>>;
  28662. /**
  28663. * Adds a new ramp gradient used to remap particle colors
  28664. * @param gradient defines the gradient to use (between 0 and 1)
  28665. * @param color defines the color to affect to the specified gradient
  28666. * @returns the current particle system
  28667. */
  28668. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  28669. /**
  28670. * Gets the current list of ramp gradients.
  28671. * You must use addRampGradient and removeRampGradient to udpate this list
  28672. * @returns the list of ramp gradients
  28673. */
  28674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  28675. /** Gets or sets a boolean indicating that ramp gradients must be used
  28676. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  28677. */
  28678. useRampGradients: boolean;
  28679. /**
  28680. * Adds a new color remap gradient
  28681. * @param gradient defines the gradient to use (between 0 and 1)
  28682. * @param min defines the color remap minimal range
  28683. * @param max defines the color remap maximal range
  28684. * @returns the current particle system
  28685. */
  28686. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28687. /**
  28688. * Gets the current list of color remap gradients.
  28689. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  28690. * @returns the list of color remap gradients
  28691. */
  28692. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  28693. /**
  28694. * Adds a new alpha remap gradient
  28695. * @param gradient defines the gradient to use (between 0 and 1)
  28696. * @param min defines the alpha remap minimal range
  28697. * @param max defines the alpha remap maximal range
  28698. * @returns the current particle system
  28699. */
  28700. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28701. /**
  28702. * Gets the current list of alpha remap gradients.
  28703. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  28704. * @returns the list of alpha remap gradients
  28705. */
  28706. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  28707. /**
  28708. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  28709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  28710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  28711. * @returns the emitter
  28712. */
  28713. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  28714. /**
  28715. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  28716. * @param radius The radius of the hemisphere to emit from
  28717. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  28718. * @returns the emitter
  28719. */
  28720. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  28721. /**
  28722. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  28723. * @param radius The radius of the sphere to emit from
  28724. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  28725. * @returns the emitter
  28726. */
  28727. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  28728. /**
  28729. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  28730. * @param radius The radius of the sphere to emit from
  28731. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  28732. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  28733. * @returns the emitter
  28734. */
  28735. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  28736. /**
  28737. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  28738. * @param radius The radius of the emission cylinder
  28739. * @param height The height of the emission cylinder
  28740. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  28741. * @param directionRandomizer How much to randomize the particle direction [0-1]
  28742. * @returns the emitter
  28743. */
  28744. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  28745. /**
  28746. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  28747. * @param radius The radius of the cylinder to emit from
  28748. * @param height The height of the emission cylinder
  28749. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  28750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  28751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  28752. * @returns the emitter
  28753. */
  28754. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  28755. /**
  28756. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  28757. * @param radius The radius of the cone to emit from
  28758. * @param angle The base angle of the cone
  28759. * @returns the emitter
  28760. */
  28761. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  28762. /**
  28763. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  28764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  28765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  28766. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  28767. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  28768. * @returns the emitter
  28769. */
  28770. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  28771. /**
  28772. * Get hosting scene
  28773. * @returns the scene
  28774. */
  28775. getScene(): Scene;
  28776. }
  28777. }
  28778. declare module BABYLON {
  28779. /**
  28780. * A particle represents one of the element emitted by a particle system.
  28781. * This is mainly define by its coordinates, direction, velocity and age.
  28782. */
  28783. class Particle {
  28784. /**
  28785. * The particle system the particle belongs to.
  28786. */
  28787. particleSystem: ParticleSystem;
  28788. private static _Count;
  28789. /**
  28790. * Unique ID of the particle
  28791. */
  28792. id: number;
  28793. /**
  28794. * The world position of the particle in the scene.
  28795. */
  28796. position: Vector3;
  28797. /**
  28798. * The world direction of the particle in the scene.
  28799. */
  28800. direction: Vector3;
  28801. /**
  28802. * The color of the particle.
  28803. */
  28804. color: Color4;
  28805. /**
  28806. * The color change of the particle per step.
  28807. */
  28808. colorStep: Color4;
  28809. /**
  28810. * Defines how long will the life of the particle be.
  28811. */
  28812. lifeTime: number;
  28813. /**
  28814. * The current age of the particle.
  28815. */
  28816. age: number;
  28817. /**
  28818. * The current size of the particle.
  28819. */
  28820. size: number;
  28821. /**
  28822. * The current scale of the particle.
  28823. */
  28824. scale: Vector2;
  28825. /**
  28826. * The current angle of the particle.
  28827. */
  28828. angle: number;
  28829. /**
  28830. * Defines how fast is the angle changing.
  28831. */
  28832. angularSpeed: number;
  28833. /**
  28834. * Defines the cell index used by the particle to be rendered from a sprite.
  28835. */
  28836. cellIndex: number;
  28837. /**
  28838. * The information required to support color remapping
  28839. */
  28840. remapData: Vector4;
  28841. /** @hidden */
  28842. _randomCellOffset?: number;
  28843. /** @hidden */
  28844. _initialDirection: Nullable<Vector3>;
  28845. /** @hidden */
  28846. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  28847. /** @hidden */
  28848. _initialStartSpriteCellID: number;
  28849. _initialEndSpriteCellID: number;
  28850. /** @hidden */
  28851. _currentColorGradient: Nullable<ColorGradient>;
  28852. /** @hidden */
  28853. _currentColor1: Color4;
  28854. /** @hidden */
  28855. _currentColor2: Color4;
  28856. /** @hidden */
  28857. _currentSizeGradient: Nullable<FactorGradient>;
  28858. /** @hidden */
  28859. _currentSize1: number;
  28860. /** @hidden */
  28861. _currentSize2: number;
  28862. /** @hidden */
  28863. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  28864. /** @hidden */
  28865. _currentAngularSpeed1: number;
  28866. /** @hidden */
  28867. _currentAngularSpeed2: number;
  28868. /** @hidden */
  28869. _currentVelocityGradient: Nullable<FactorGradient>;
  28870. /** @hidden */
  28871. _currentVelocity1: number;
  28872. /** @hidden */
  28873. _currentVelocity2: number;
  28874. /** @hidden */
  28875. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  28876. /** @hidden */
  28877. _currentLimitVelocity1: number;
  28878. /** @hidden */
  28879. _currentLimitVelocity2: number;
  28880. /** @hidden */
  28881. _currentDragGradient: Nullable<FactorGradient>;
  28882. /** @hidden */
  28883. _currentDrag1: number;
  28884. /** @hidden */
  28885. _currentDrag2: number;
  28886. /** @hidden */
  28887. _randomNoiseCoordinates1: Vector3;
  28888. /** @hidden */
  28889. _randomNoiseCoordinates2: Vector3;
  28890. /**
  28891. * Creates a new instance Particle
  28892. * @param particleSystem the particle system the particle belongs to
  28893. */
  28894. constructor(
  28895. /**
  28896. * The particle system the particle belongs to.
  28897. */
  28898. particleSystem: ParticleSystem);
  28899. private updateCellInfoFromSystem;
  28900. /**
  28901. * Defines how the sprite cell index is updated for the particle
  28902. */
  28903. updateCellIndex(): void;
  28904. /** @hidden */
  28905. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  28906. /** @hidden */
  28907. _inheritParticleInfoToSubEmitters(): void;
  28908. /** @hidden */
  28909. _reset(): void;
  28910. /**
  28911. * Copy the properties of particle to another one.
  28912. * @param other the particle to copy the information to.
  28913. */
  28914. copyTo(other: Particle): void;
  28915. }
  28916. }
  28917. declare module BABYLON {
  28918. /**
  28919. * This class is made for on one-liner static method to help creating particle system set.
  28920. */
  28921. class ParticleHelper {
  28922. /**
  28923. * Gets or sets base Assets URL
  28924. */
  28925. static BaseAssetsUrl: string;
  28926. /**
  28927. * Create a default particle system that you can tweak
  28928. * @param emitter defines the emitter to use
  28929. * @param capacity defines the system capacity (default is 500 particles)
  28930. * @param scene defines the hosting scene
  28931. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  28932. * @returns the new Particle system
  28933. */
  28934. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  28935. /**
  28936. * This is the main static method (one-liner) of this helper to create different particle systems
  28937. * @param type This string represents the type to the particle system to create
  28938. * @param scene The scene where the particle system should live
  28939. * @param gpu If the system will use gpu
  28940. * @returns the ParticleSystemSet created
  28941. */
  28942. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  28943. /**
  28944. * Static function used to export a particle system to a ParticleSystemSet variable.
  28945. * Please note that the emitter shape is not exported
  28946. * @param system defines the particle systems to export
  28947. */
  28948. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  28949. }
  28950. }
  28951. declare module BABYLON {
  28952. /**
  28953. * This represents a particle system in Babylon.
  28954. * 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.
  28955. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  28956. * @example https://doc.babylonjs.com/babylon101/particles
  28957. */
  28958. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  28959. /**
  28960. * Billboard mode will only apply to Y axis
  28961. */
  28962. static readonly BILLBOARDMODE_Y: number;
  28963. /**
  28964. * Billboard mode will apply to all axes
  28965. */
  28966. static readonly BILLBOARDMODE_ALL: number;
  28967. /**
  28968. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  28969. */
  28970. static readonly BILLBOARDMODE_STRETCHED: number;
  28971. /**
  28972. * This function can be defined to provide custom update for active particles.
  28973. * This function will be called instead of regular update (age, position, color, etc.).
  28974. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  28975. */
  28976. updateFunction: (particles: Particle[]) => void;
  28977. private _emitterWorldMatrix;
  28978. /**
  28979. * This function can be defined to specify initial direction for every new particle.
  28980. * It by default use the emitterType defined function
  28981. */
  28982. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  28983. /**
  28984. * This function can be defined to specify initial position for every new particle.
  28985. * It by default use the emitterType defined function
  28986. */
  28987. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  28988. /**
  28989. * @hidden
  28990. */
  28991. _inheritedVelocityOffset: Vector3;
  28992. /**
  28993. * An event triggered when the system is disposed
  28994. */
  28995. onDisposeObservable: Observable<ParticleSystem>;
  28996. private _onDisposeObserver;
  28997. /**
  28998. * Sets a callback that will be triggered when the system is disposed
  28999. */
  29000. onDispose: () => void;
  29001. private _particles;
  29002. private _epsilon;
  29003. private _capacity;
  29004. private _stockParticles;
  29005. private _newPartsExcess;
  29006. private _vertexData;
  29007. private _vertexBuffer;
  29008. private _vertexBuffers;
  29009. private _spriteBuffer;
  29010. private _indexBuffer;
  29011. private _effect;
  29012. private _customEffect;
  29013. private _cachedDefines;
  29014. private _scaledColorStep;
  29015. private _colorDiff;
  29016. private _scaledDirection;
  29017. private _scaledGravity;
  29018. private _currentRenderId;
  29019. private _alive;
  29020. private _useInstancing;
  29021. private _started;
  29022. private _stopped;
  29023. private _actualFrame;
  29024. private _scaledUpdateSpeed;
  29025. private _vertexBufferSize;
  29026. /** @hidden */
  29027. _currentEmitRateGradient: Nullable<FactorGradient>;
  29028. /** @hidden */
  29029. _currentEmitRate1: number;
  29030. /** @hidden */
  29031. _currentEmitRate2: number;
  29032. /** @hidden */
  29033. _currentStartSizeGradient: Nullable<FactorGradient>;
  29034. /** @hidden */
  29035. _currentStartSize1: number;
  29036. /** @hidden */
  29037. _currentStartSize2: number;
  29038. private readonly _rawTextureWidth;
  29039. private _rampGradientsTexture;
  29040. private _useRampGradients;
  29041. /** Gets or sets a boolean indicating that ramp gradients must be used
  29042. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  29043. */
  29044. useRampGradients: boolean;
  29045. /**
  29046. * 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.
  29047. * 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: [])
  29048. */
  29049. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  29050. private _subEmitters;
  29051. /**
  29052. * @hidden
  29053. * If the particle systems emitter should be disposed when the particle system is disposed
  29054. */
  29055. _disposeEmitterOnDispose: boolean;
  29056. /**
  29057. * The current active Sub-systems, this property is used by the root particle system only.
  29058. */
  29059. activeSubSystems: Array<ParticleSystem>;
  29060. private _rootParticleSystem;
  29061. /**
  29062. * Gets the current list of active particles
  29063. */
  29064. readonly particles: Particle[];
  29065. /**
  29066. * Returns the string "ParticleSystem"
  29067. * @returns a string containing the class name
  29068. */
  29069. getClassName(): string;
  29070. /**
  29071. * Instantiates a particle system.
  29072. * 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.
  29073. * @param name The name of the particle system
  29074. * @param capacity The max number of particles alive at the same time
  29075. * @param scene The scene the particle system belongs to
  29076. * @param customEffect a custom effect used to change the way particles are rendered by default
  29077. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  29078. * @param epsilon Offset used to render the particles
  29079. */
  29080. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  29081. private _addFactorGradient;
  29082. private _removeFactorGradient;
  29083. /**
  29084. * Adds a new life time gradient
  29085. * @param gradient defines the gradient to use (between 0 and 1)
  29086. * @param factor defines the life time factor to affect to the specified gradient
  29087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29088. * @returns the current particle system
  29089. */
  29090. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29091. /**
  29092. * Remove a specific life time gradient
  29093. * @param gradient defines the gradient to remove
  29094. * @returns the current particle system
  29095. */
  29096. removeLifeTimeGradient(gradient: number): IParticleSystem;
  29097. /**
  29098. * Adds a new size gradient
  29099. * @param gradient defines the gradient to use (between 0 and 1)
  29100. * @param factor defines the size factor to affect to the specified gradient
  29101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29102. * @returns the current particle system
  29103. */
  29104. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29105. /**
  29106. * Remove a specific size gradient
  29107. * @param gradient defines the gradient to remove
  29108. * @returns the current particle system
  29109. */
  29110. removeSizeGradient(gradient: number): IParticleSystem;
  29111. /**
  29112. * Adds a new color remap gradient
  29113. * @param gradient defines the gradient to use (between 0 and 1)
  29114. * @param min defines the color remap minimal range
  29115. * @param max defines the color remap maximal range
  29116. * @returns the current particle system
  29117. */
  29118. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29119. /**
  29120. * Remove a specific color remap gradient
  29121. * @param gradient defines the gradient to remove
  29122. * @returns the current particle system
  29123. */
  29124. removeColorRemapGradient(gradient: number): IParticleSystem;
  29125. /**
  29126. * Adds a new alpha remap gradient
  29127. * @param gradient defines the gradient to use (between 0 and 1)
  29128. * @param min defines the alpha remap minimal range
  29129. * @param max defines the alpha remap maximal range
  29130. * @returns the current particle system
  29131. */
  29132. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29133. /**
  29134. * Remove a specific alpha remap gradient
  29135. * @param gradient defines the gradient to remove
  29136. * @returns the current particle system
  29137. */
  29138. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  29139. /**
  29140. * Adds a new angular speed gradient
  29141. * @param gradient defines the gradient to use (between 0 and 1)
  29142. * @param factor defines the angular speed to affect to the specified gradient
  29143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29144. * @returns the current particle system
  29145. */
  29146. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29147. /**
  29148. * Remove a specific angular speed gradient
  29149. * @param gradient defines the gradient to remove
  29150. * @returns the current particle system
  29151. */
  29152. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  29153. /**
  29154. * Adds a new velocity gradient
  29155. * @param gradient defines the gradient to use (between 0 and 1)
  29156. * @param factor defines the velocity to affect to the specified gradient
  29157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29158. * @returns the current particle system
  29159. */
  29160. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29161. /**
  29162. * Remove a specific velocity gradient
  29163. * @param gradient defines the gradient to remove
  29164. * @returns the current particle system
  29165. */
  29166. removeVelocityGradient(gradient: number): IParticleSystem;
  29167. /**
  29168. * Adds a new limit velocity gradient
  29169. * @param gradient defines the gradient to use (between 0 and 1)
  29170. * @param factor defines the limit velocity value to affect to the specified gradient
  29171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29172. * @returns the current particle system
  29173. */
  29174. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29175. /**
  29176. * Remove a specific limit velocity gradient
  29177. * @param gradient defines the gradient to remove
  29178. * @returns the current particle system
  29179. */
  29180. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  29181. /**
  29182. * Adds a new drag gradient
  29183. * @param gradient defines the gradient to use (between 0 and 1)
  29184. * @param factor defines the drag value to affect to the specified gradient
  29185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29186. * @returns the current particle system
  29187. */
  29188. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29189. /**
  29190. * Remove a specific drag gradient
  29191. * @param gradient defines the gradient to remove
  29192. * @returns the current particle system
  29193. */
  29194. removeDragGradient(gradient: number): IParticleSystem;
  29195. /**
  29196. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  29197. * @param gradient defines the gradient to use (between 0 and 1)
  29198. * @param factor defines the emit rate value to affect to the specified gradient
  29199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29200. * @returns the current particle system
  29201. */
  29202. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29203. /**
  29204. * Remove a specific emit rate gradient
  29205. * @param gradient defines the gradient to remove
  29206. * @returns the current particle system
  29207. */
  29208. removeEmitRateGradient(gradient: number): IParticleSystem;
  29209. /**
  29210. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  29211. * @param gradient defines the gradient to use (between 0 and 1)
  29212. * @param factor defines the start size value to affect to the specified gradient
  29213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29214. * @returns the current particle system
  29215. */
  29216. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29217. /**
  29218. * Remove a specific start size gradient
  29219. * @param gradient defines the gradient to remove
  29220. * @returns the current particle system
  29221. */
  29222. removeStartSizeGradient(gradient: number): IParticleSystem;
  29223. private _createRampGradientTexture;
  29224. /**
  29225. * Gets the current list of ramp gradients.
  29226. * You must use addRampGradient and removeRampGradient to udpate this list
  29227. * @returns the list of ramp gradients
  29228. */
  29229. getRampGradients(): Nullable<Array<Color3Gradient>>;
  29230. /**
  29231. * Adds a new ramp gradient used to remap particle colors
  29232. * @param gradient defines the gradient to use (between 0 and 1)
  29233. * @param color defines the color to affect to the specified gradient
  29234. * @returns the current particle system
  29235. */
  29236. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  29237. /**
  29238. * Remove a specific ramp gradient
  29239. * @param gradient defines the gradient to remove
  29240. * @returns the current particle system
  29241. */
  29242. removeRampGradient(gradient: number): ParticleSystem;
  29243. /**
  29244. * Adds a new color gradient
  29245. * @param gradient defines the gradient to use (between 0 and 1)
  29246. * @param color1 defines the color to affect to the specified gradient
  29247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  29248. */
  29249. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  29250. /**
  29251. * Remove a specific color gradient
  29252. * @param gradient defines the gradient to remove
  29253. */
  29254. removeColorGradient(gradient: number): IParticleSystem;
  29255. private _fetchR;
  29256. protected _reset(): void;
  29257. private _resetEffect;
  29258. private _createVertexBuffers;
  29259. private _createIndexBuffer;
  29260. /**
  29261. * Gets the maximum number of particles active at the same time.
  29262. * @returns The max number of active particles.
  29263. */
  29264. getCapacity(): number;
  29265. /**
  29266. * Gets whether there are still active particles in the system.
  29267. * @returns True if it is alive, otherwise false.
  29268. */
  29269. isAlive(): boolean;
  29270. /**
  29271. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29272. * @returns True if it has been started, otherwise false.
  29273. */
  29274. isStarted(): boolean;
  29275. private _prepareSubEmitterInternalArray;
  29276. /**
  29277. * Starts the particle system and begins to emit
  29278. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  29279. */
  29280. start(delay?: number): void;
  29281. /**
  29282. * Stops the particle system.
  29283. * @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.
  29284. */
  29285. stop(stopSubEmitters?: boolean): void;
  29286. /**
  29287. * Remove all active particles
  29288. */
  29289. reset(): void;
  29290. /**
  29291. * @hidden (for internal use only)
  29292. */
  29293. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  29294. /**
  29295. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  29296. * Its lifetime will start back at 0.
  29297. */
  29298. recycleParticle: (particle: Particle) => void;
  29299. private _stopSubEmitters;
  29300. private _createParticle;
  29301. private _removeFromRoot;
  29302. private _emitFromParticle;
  29303. private _update;
  29304. /** @hidden */
  29305. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  29306. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  29307. private _getEffect;
  29308. /**
  29309. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  29310. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  29311. */
  29312. animate(preWarmOnly?: boolean): void;
  29313. private _appendParticleVertices;
  29314. /**
  29315. * Rebuilds the particle system.
  29316. */
  29317. rebuild(): void;
  29318. /**
  29319. * Is this system ready to be used/rendered
  29320. * @return true if the system is ready
  29321. */
  29322. isReady(): boolean;
  29323. private _render;
  29324. /**
  29325. * Renders the particle system in its current state.
  29326. * @returns the current number of particles
  29327. */
  29328. render(): number;
  29329. /**
  29330. * Disposes the particle system and free the associated resources
  29331. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  29332. */
  29333. dispose(disposeTexture?: boolean): void;
  29334. /**
  29335. * Clones the particle system.
  29336. * @param name The name of the cloned object
  29337. * @param newEmitter The new emitter to use
  29338. * @returns the cloned particle system
  29339. */
  29340. clone(name: string, newEmitter: any): ParticleSystem;
  29341. /**
  29342. * Serializes the particle system to a JSON object.
  29343. * @returns the JSON object
  29344. */
  29345. serialize(): any;
  29346. /** @hidden */
  29347. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  29348. /** @hidden */
  29349. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  29350. /**
  29351. * Parses a JSON object to create a particle system.
  29352. * @param parsedParticleSystem The JSON object to parse
  29353. * @param scene The scene to create the particle system in
  29354. * @param rootUrl The root url to use to load external dependencies like texture
  29355. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  29356. * @returns the Parsed particle system
  29357. */
  29358. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  29359. }
  29360. }
  29361. declare module BABYLON {
  29362. interface Engine {
  29363. /**
  29364. * Create an effect to use with particle systems.
  29365. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  29366. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  29367. * @param uniformsNames defines a list of attribute names
  29368. * @param samplers defines an array of string used to represent textures
  29369. * @param defines defines the string containing the defines to use to compile the shaders
  29370. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29371. * @param onCompiled defines a function to call when the effect creation is successful
  29372. * @param onError defines a function to call when the effect creation has failed
  29373. * @returns the new Effect
  29374. */
  29375. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  29376. }
  29377. interface Mesh {
  29378. /**
  29379. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  29380. * @returns an array of IParticleSystem
  29381. */
  29382. getEmittedParticleSystems(): IParticleSystem[];
  29383. /**
  29384. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  29385. * @returns an array of IParticleSystem
  29386. */
  29387. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  29388. }
  29389. }
  29390. declare module BABYLON {
  29391. /**
  29392. * Represents a set of particle systems working together to create a specific effect
  29393. */
  29394. class ParticleSystemSet implements IDisposable {
  29395. private _emitterCreationOptions;
  29396. private _emitterNode;
  29397. /**
  29398. * Gets the particle system list
  29399. */
  29400. systems: IParticleSystem[];
  29401. /**
  29402. * Gets the emitter node used with this set
  29403. */
  29404. readonly emitterNode: Nullable<TransformNode>;
  29405. /**
  29406. * Creates a new emitter mesh as a sphere
  29407. * @param options defines the options used to create the sphere
  29408. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  29409. * @param scene defines the hosting scene
  29410. */
  29411. setEmitterAsSphere(options: {
  29412. diameter: number;
  29413. segments: number;
  29414. color: Color3;
  29415. }, renderingGroupId: number, scene: Scene): void;
  29416. /**
  29417. * Starts all particle systems of the set
  29418. * @param emitter defines an optional mesh to use as emitter for the particle systems
  29419. */
  29420. start(emitter?: AbstractMesh): void;
  29421. /**
  29422. * Release all associated resources
  29423. */
  29424. dispose(): void;
  29425. /**
  29426. * Serialize the set into a JSON compatible object
  29427. * @returns a JSON compatible representation of the set
  29428. */
  29429. serialize(): any;
  29430. /**
  29431. * Parse a new ParticleSystemSet from a serialized source
  29432. * @param data defines a JSON compatible representation of the set
  29433. * @param scene defines the hosting scene
  29434. * @param gpu defines if we want GPU particles or CPU particles
  29435. * @returns a new ParticleSystemSet
  29436. */
  29437. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  29438. }
  29439. }
  29440. declare module BABYLON {
  29441. /**
  29442. * Represents one particle of a solid particle system.
  29443. */
  29444. class SolidParticle {
  29445. /**
  29446. * particle global index
  29447. */
  29448. idx: number;
  29449. /**
  29450. * The color of the particle
  29451. */
  29452. color: Nullable<Color4>;
  29453. /**
  29454. * The world space position of the particle.
  29455. */
  29456. position: Vector3;
  29457. /**
  29458. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  29459. */
  29460. rotation: Vector3;
  29461. /**
  29462. * The world space rotation quaternion of the particle.
  29463. */
  29464. rotationQuaternion: Nullable<Quaternion>;
  29465. /**
  29466. * The scaling of the particle.
  29467. */
  29468. scaling: Vector3;
  29469. /**
  29470. * The uvs of the particle.
  29471. */
  29472. uvs: Vector4;
  29473. /**
  29474. * The current speed of the particle.
  29475. */
  29476. velocity: Vector3;
  29477. /**
  29478. * The pivot point in the particle local space.
  29479. */
  29480. pivot: Vector3;
  29481. /**
  29482. * Must the particle be translated from its pivot point in its local space ?
  29483. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  29484. * Default : false
  29485. */
  29486. translateFromPivot: boolean;
  29487. /**
  29488. * Is the particle active or not ?
  29489. */
  29490. alive: boolean;
  29491. /**
  29492. * Is the particle visible or not ?
  29493. */
  29494. isVisible: boolean;
  29495. /**
  29496. * Index of this particle in the global "positions" array (Internal use)
  29497. * @hidden
  29498. */
  29499. _pos: number;
  29500. /**
  29501. * @hidden Index of this particle in the global "indices" array (Internal use)
  29502. */
  29503. _ind: number;
  29504. /**
  29505. * @hidden ModelShape of this particle (Internal use)
  29506. */
  29507. _model: ModelShape;
  29508. /**
  29509. * ModelShape id of this particle
  29510. */
  29511. shapeId: number;
  29512. /**
  29513. * Index of the particle in its shape id (Internal use)
  29514. */
  29515. idxInShape: number;
  29516. /**
  29517. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  29518. */
  29519. _modelBoundingInfo: BoundingInfo;
  29520. /**
  29521. * @hidden Particle BoundingInfo object (Internal use)
  29522. */
  29523. _boundingInfo: BoundingInfo;
  29524. /**
  29525. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  29526. */
  29527. _sps: SolidParticleSystem;
  29528. /**
  29529. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  29530. */
  29531. _stillInvisible: boolean;
  29532. /**
  29533. * @hidden Last computed particle rotation matrix
  29534. */
  29535. _rotationMatrix: number[];
  29536. /**
  29537. * Parent particle Id, if any.
  29538. * Default null.
  29539. */
  29540. parentId: Nullable<number>;
  29541. /**
  29542. * @hidden Internal global position in the SPS.
  29543. */
  29544. _globalPosition: Vector3;
  29545. /**
  29546. * Creates a Solid Particle object.
  29547. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  29548. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  29549. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  29550. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  29551. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  29552. * @param shapeId (integer) is the model shape identifier in the SPS.
  29553. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  29554. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  29555. */
  29556. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  29557. /**
  29558. * Legacy support, changed scale to scaling
  29559. */
  29560. /**
  29561. * Legacy support, changed scale to scaling
  29562. */
  29563. scale: Vector3;
  29564. /**
  29565. * Legacy support, changed quaternion to rotationQuaternion
  29566. */
  29567. /**
  29568. * Legacy support, changed quaternion to rotationQuaternion
  29569. */
  29570. quaternion: Nullable<Quaternion>;
  29571. /**
  29572. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  29573. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  29574. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  29575. * @returns true if it intersects
  29576. */
  29577. intersectsMesh(target: Mesh | SolidParticle): boolean;
  29578. }
  29579. /**
  29580. * Represents the shape of the model used by one particle of a solid particle system.
  29581. * SPS internal tool, don't use it manually.
  29582. */
  29583. class ModelShape {
  29584. /**
  29585. * The shape id
  29586. * @hidden
  29587. */
  29588. shapeID: number;
  29589. /**
  29590. * flat array of model positions (internal use)
  29591. * @hidden
  29592. */
  29593. _shape: Vector3[];
  29594. /**
  29595. * flat array of model UVs (internal use)
  29596. * @hidden
  29597. */
  29598. _shapeUV: number[];
  29599. /**
  29600. * length of the shape in the model indices array (internal use)
  29601. * @hidden
  29602. */
  29603. _indicesLength: number;
  29604. /**
  29605. * Custom position function (internal use)
  29606. * @hidden
  29607. */
  29608. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29609. /**
  29610. * Custom vertex function (internal use)
  29611. * @hidden
  29612. */
  29613. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29614. /**
  29615. * 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.
  29616. * SPS internal tool, don't use it manually.
  29617. * @hidden
  29618. */
  29619. 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>);
  29620. }
  29621. /**
  29622. * Represents a Depth Sorted Particle in the solid particle system.
  29623. */
  29624. class DepthSortedParticle {
  29625. /**
  29626. * Index of the particle in the "indices" array
  29627. */
  29628. ind: number;
  29629. /**
  29630. * Length of the particle shape in the "indices" array
  29631. */
  29632. indicesLength: number;
  29633. /**
  29634. * Squared distance from the particle to the camera
  29635. */
  29636. sqDistance: number;
  29637. }
  29638. }
  29639. declare module BABYLON {
  29640. /**
  29641. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29642. *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.
  29643. * The SPS is also a particle system. It provides some methods to manage the particles.
  29644. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29645. *
  29646. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  29647. */
  29648. class SolidParticleSystem implements IDisposable {
  29649. /**
  29650. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29651. * Example : var p = SPS.particles[i];
  29652. */
  29653. particles: SolidParticle[];
  29654. /**
  29655. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29656. */
  29657. nbParticles: number;
  29658. /**
  29659. * If the particles must ever face the camera (default false). Useful for planar particles.
  29660. */
  29661. billboard: boolean;
  29662. /**
  29663. * Recompute normals when adding a shape
  29664. */
  29665. recomputeNormals: boolean;
  29666. /**
  29667. * This a counter ofr your own usage. It's not set by any SPS functions.
  29668. */
  29669. counter: number;
  29670. /**
  29671. * The SPS name. This name is also given to the underlying mesh.
  29672. */
  29673. name: string;
  29674. /**
  29675. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29676. */
  29677. mesh: Mesh;
  29678. /**
  29679. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29680. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  29681. */
  29682. vars: any;
  29683. /**
  29684. * This array is populated when the SPS is set as 'pickable'.
  29685. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29686. * Each element of this array is an object `{idx: int, faceId: int}`.
  29687. * `idx` is the picked particle index in the `SPS.particles` array
  29688. * `faceId` is the picked face index counted within this particle.
  29689. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  29690. */
  29691. pickedParticles: {
  29692. idx: number;
  29693. faceId: number;
  29694. }[];
  29695. /**
  29696. * This array is populated when `enableDepthSort` is set to true.
  29697. * Each element of this array is an instance of the class DepthSortedParticle.
  29698. */
  29699. depthSortedParticles: DepthSortedParticle[];
  29700. /**
  29701. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29702. * @hidden
  29703. */
  29704. _bSphereOnly: boolean;
  29705. /**
  29706. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29707. * @hidden
  29708. */
  29709. _bSphereRadiusFactor: number;
  29710. private _scene;
  29711. private _positions;
  29712. private _indices;
  29713. private _normals;
  29714. private _colors;
  29715. private _uvs;
  29716. private _indices32;
  29717. private _positions32;
  29718. private _normals32;
  29719. private _fixedNormal32;
  29720. private _colors32;
  29721. private _uvs32;
  29722. private _index;
  29723. private _updatable;
  29724. private _pickable;
  29725. private _isVisibilityBoxLocked;
  29726. private _alwaysVisible;
  29727. private _depthSort;
  29728. private _shapeCounter;
  29729. private _copy;
  29730. private _shape;
  29731. private _shapeUV;
  29732. private _color;
  29733. private _computeParticleColor;
  29734. private _computeParticleTexture;
  29735. private _computeParticleRotation;
  29736. private _computeParticleVertex;
  29737. private _computeBoundingBox;
  29738. private _depthSortParticles;
  29739. private _cam_axisZ;
  29740. private _cam_axisY;
  29741. private _cam_axisX;
  29742. private _axisZ;
  29743. private _camera;
  29744. private _particle;
  29745. private _camDir;
  29746. private _camInvertedPosition;
  29747. private _rotMatrix;
  29748. private _invertMatrix;
  29749. private _rotated;
  29750. private _quaternion;
  29751. private _vertex;
  29752. private _normal;
  29753. private _yaw;
  29754. private _pitch;
  29755. private _roll;
  29756. private _halfroll;
  29757. private _halfpitch;
  29758. private _halfyaw;
  29759. private _sinRoll;
  29760. private _cosRoll;
  29761. private _sinPitch;
  29762. private _cosPitch;
  29763. private _sinYaw;
  29764. private _cosYaw;
  29765. private _mustUnrotateFixedNormals;
  29766. private _minimum;
  29767. private _maximum;
  29768. private _minBbox;
  29769. private _maxBbox;
  29770. private _particlesIntersect;
  29771. private _depthSortFunction;
  29772. private _needs32Bits;
  29773. private _pivotBackTranslation;
  29774. private _scaledPivot;
  29775. private _particleHasParent;
  29776. private _parent;
  29777. /**
  29778. * Creates a SPS (Solid Particle System) object.
  29779. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29780. * @param scene (Scene) is the scene in which the SPS is added.
  29781. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29782. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29783. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29784. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29785. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  29786. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  29787. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  29788. */
  29789. constructor(name: string, scene: Scene, options?: {
  29790. updatable?: boolean;
  29791. isPickable?: boolean;
  29792. enableDepthSort?: boolean;
  29793. particleIntersection?: boolean;
  29794. boundingSphereOnly?: boolean;
  29795. bSphereRadiusFactor?: number;
  29796. });
  29797. /**
  29798. * Builds the SPS underlying mesh. Returns a standard Mesh.
  29799. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  29800. * @returns the created mesh
  29801. */
  29802. buildMesh(): Mesh;
  29803. /**
  29804. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  29805. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  29806. * Thus the particles generated from `digest()` have their property `position` set yet.
  29807. * @param mesh ( Mesh ) is the mesh to be digested
  29808. * @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
  29809. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  29810. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  29811. * @returns the current SPS
  29812. */
  29813. digest(mesh: Mesh, options?: {
  29814. facetNb?: number;
  29815. number?: number;
  29816. delta?: number;
  29817. }): SolidParticleSystem;
  29818. private _unrotateFixedNormals;
  29819. private _resetCopy;
  29820. private _meshBuilder;
  29821. private _posToShape;
  29822. private _uvsToShapeUV;
  29823. private _addParticle;
  29824. /**
  29825. * Adds some particles to the SPS from the model shape. Returns the shape id.
  29826. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  29827. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  29828. * @param nb (positive integer) the number of particles to be created from this model
  29829. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  29830. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  29831. * @returns the number of shapes in the system
  29832. */
  29833. addShape(mesh: Mesh, nb: number, options?: {
  29834. positionFunction?: any;
  29835. vertexFunction?: any;
  29836. }): number;
  29837. private _rebuildParticle;
  29838. /**
  29839. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  29840. * @returns the SPS.
  29841. */
  29842. rebuildMesh(): SolidParticleSystem;
  29843. /**
  29844. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  29845. * This method calls `updateParticle()` for each particle of the SPS.
  29846. * For an animated SPS, it is usually called within the render loop.
  29847. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  29848. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  29849. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  29850. * @returns the SPS.
  29851. */
  29852. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  29853. private _quaternionRotationYPR;
  29854. private _quaternionToRotationMatrix;
  29855. /**
  29856. * Disposes the SPS.
  29857. */
  29858. dispose(): void;
  29859. /**
  29860. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  29861. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29862. * @returns the SPS.
  29863. */
  29864. refreshVisibleSize(): SolidParticleSystem;
  29865. /**
  29866. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  29867. * @param size the size (float) of the visibility box
  29868. * note : this doesn't lock the SPS mesh bounding box.
  29869. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29870. */
  29871. setVisibilityBox(size: number): void;
  29872. /**
  29873. * Gets whether the SPS as always visible or not
  29874. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29875. */
  29876. /**
  29877. * Sets the SPS as always visible or not
  29878. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29879. */
  29880. isAlwaysVisible: boolean;
  29881. /**
  29882. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  29883. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29884. */
  29885. /**
  29886. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  29887. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29888. */
  29889. isVisibilityBoxLocked: boolean;
  29890. /**
  29891. * Tells to `setParticles()` to compute the particle rotations or not.
  29892. * Default value : true. The SPS is faster when it's set to false.
  29893. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  29894. */
  29895. /**
  29896. * Gets if `setParticles()` computes the particle rotations or not.
  29897. * Default value : true. The SPS is faster when it's set to false.
  29898. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  29899. */
  29900. computeParticleRotation: boolean;
  29901. /**
  29902. * Tells to `setParticles()` to compute the particle colors or not.
  29903. * Default value : true. The SPS is faster when it's set to false.
  29904. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  29905. */
  29906. /**
  29907. * Gets if `setParticles()` computes the particle colors or not.
  29908. * Default value : true. The SPS is faster when it's set to false.
  29909. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  29910. */
  29911. computeParticleColor: boolean;
  29912. /**
  29913. * Gets if `setParticles()` computes the particle textures or not.
  29914. * Default value : true. The SPS is faster when it's set to false.
  29915. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  29916. */
  29917. computeParticleTexture: boolean;
  29918. /**
  29919. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  29920. * Default value : false. The SPS is faster when it's set to false.
  29921. * Note : the particle custom vertex positions aren't stored values.
  29922. */
  29923. /**
  29924. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  29925. * Default value : false. The SPS is faster when it's set to false.
  29926. * Note : the particle custom vertex positions aren't stored values.
  29927. */
  29928. computeParticleVertex: boolean;
  29929. /**
  29930. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  29931. */
  29932. /**
  29933. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  29934. */
  29935. computeBoundingBox: boolean;
  29936. /**
  29937. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  29938. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  29939. * Default : `true`
  29940. */
  29941. /**
  29942. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  29943. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  29944. * Default : `true`
  29945. */
  29946. depthSortParticles: boolean;
  29947. /**
  29948. * This function does nothing. It may be overwritten to set all the particle first values.
  29949. * The SPS doesn't call this function, you may have to call it by your own.
  29950. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  29951. */
  29952. initParticles(): void;
  29953. /**
  29954. * This function does nothing. It may be overwritten to recycle a particle.
  29955. * The SPS doesn't call this function, you may have to call it by your own.
  29956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  29957. * @param particle The particle to recycle
  29958. * @returns the recycled particle
  29959. */
  29960. recycleParticle(particle: SolidParticle): SolidParticle;
  29961. /**
  29962. * Updates a particle : this function should be overwritten by the user.
  29963. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  29964. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  29965. * @example : just set a particle position or velocity and recycle conditions
  29966. * @param particle The particle to update
  29967. * @returns the updated particle
  29968. */
  29969. updateParticle(particle: SolidParticle): SolidParticle;
  29970. /**
  29971. * Updates a vertex of a particle : it can be overwritten by the user.
  29972. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  29973. * @param particle the current particle
  29974. * @param vertex the current index of the current particle
  29975. * @param pt the index of the current vertex in the particle shape
  29976. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  29977. * @example : just set a vertex particle position
  29978. * @returns the updated vertex
  29979. */
  29980. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  29981. /**
  29982. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  29983. * This does nothing and may be overwritten by the user.
  29984. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29985. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29986. * @param update the boolean update value actually passed to setParticles()
  29987. */
  29988. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  29989. /**
  29990. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  29991. * This will be passed three parameters.
  29992. * This does nothing and may be overwritten by the user.
  29993. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29994. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29995. * @param update the boolean update value actually passed to setParticles()
  29996. */
  29997. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  29998. }
  29999. }
  30000. declare module BABYLON {
  30001. /**
  30002. * Type of sub emitter
  30003. */
  30004. enum SubEmitterType {
  30005. /**
  30006. * Attached to the particle over it's lifetime
  30007. */
  30008. ATTACHED = 0,
  30009. /**
  30010. * Created when the particle dies
  30011. */
  30012. END = 1
  30013. }
  30014. /**
  30015. * Sub emitter class used to emit particles from an existing particle
  30016. */
  30017. class SubEmitter {
  30018. /**
  30019. * the particle system to be used by the sub emitter
  30020. */
  30021. particleSystem: ParticleSystem;
  30022. /**
  30023. * Type of the submitter (Default: END)
  30024. */
  30025. type: SubEmitterType;
  30026. /**
  30027. * 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)
  30028. * Note: This only is supported when using an emitter of type Mesh
  30029. */
  30030. inheritDirection: boolean;
  30031. /**
  30032. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  30033. */
  30034. inheritedVelocityAmount: number;
  30035. /**
  30036. * Creates a sub emitter
  30037. * @param particleSystem the particle system to be used by the sub emitter
  30038. */
  30039. constructor(
  30040. /**
  30041. * the particle system to be used by the sub emitter
  30042. */
  30043. particleSystem: ParticleSystem);
  30044. /**
  30045. * Clones the sub emitter
  30046. * @returns the cloned sub emitter
  30047. */
  30048. clone(): SubEmitter;
  30049. /**
  30050. * Serialize current object to a JSON object
  30051. * @returns the serialized object
  30052. */
  30053. serialize(): any;
  30054. /**
  30055. * Creates a new SubEmitter from a serialized JSON version
  30056. * @param serializationObject defines the JSON object to read from
  30057. * @param scene defines the hosting scene
  30058. * @param rootUrl defines the rootUrl for data loading
  30059. * @returns a new SubEmitter
  30060. */
  30061. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  30062. /** Release associated resources */
  30063. dispose(): void;
  30064. }
  30065. }
  30066. declare module BABYLON {
  30067. /**
  30068. * Interface used to describe a physics joint
  30069. */
  30070. interface PhysicsImpostorJoint {
  30071. /** Defines the main impostor to which the joint is linked */
  30072. mainImpostor: PhysicsImpostor;
  30073. /** Defines the impostor that is connected to the main impostor using this joint */
  30074. connectedImpostor: PhysicsImpostor;
  30075. /** Defines the joint itself */
  30076. joint: PhysicsJoint;
  30077. }
  30078. /** @hidden */
  30079. interface IPhysicsEnginePlugin {
  30080. world: any;
  30081. name: string;
  30082. setGravity(gravity: Vector3): void;
  30083. setTimeStep(timeStep: number): void;
  30084. getTimeStep(): number;
  30085. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  30086. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30087. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  30088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  30089. removePhysicsBody(impostor: PhysicsImpostor): void;
  30090. generateJoint(joint: PhysicsImpostorJoint): void;
  30091. removeJoint(joint: PhysicsImpostorJoint): void;
  30092. isSupported(): boolean;
  30093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  30094. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  30095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  30097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30098. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  30099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  30100. getBodyMass(impostor: PhysicsImpostor): number;
  30101. getBodyFriction(impostor: PhysicsImpostor): number;
  30102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  30103. getBodyRestitution(impostor: PhysicsImpostor): number;
  30104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  30105. sleepBody(impostor: PhysicsImpostor): void;
  30106. wakeUpBody(impostor: PhysicsImpostor): void;
  30107. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  30108. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  30109. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30110. getRadius(impostor: PhysicsImpostor): number;
  30111. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  30112. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  30113. dispose(): void;
  30114. }
  30115. /**
  30116. * Interface used to define a physics engine
  30117. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30118. */
  30119. interface IPhysicsEngine {
  30120. /**
  30121. * Gets the gravity vector used by the simulation
  30122. */
  30123. gravity: Vector3;
  30124. /**
  30125. * Sets the gravity vector used by the simulation
  30126. * @param gravity defines the gravity vector to use
  30127. */
  30128. setGravity(gravity: Vector3): void;
  30129. /**
  30130. * Set the time step of the physics engine.
  30131. * Default is 1/60.
  30132. * To slow it down, enter 1/600 for example.
  30133. * To speed it up, 1/30
  30134. * @param newTimeStep the new timestep to apply to this world.
  30135. */
  30136. setTimeStep(newTimeStep: number): void;
  30137. /**
  30138. * Get the time step of the physics engine.
  30139. * @returns the current time step
  30140. */
  30141. getTimeStep(): number;
  30142. /**
  30143. * Release all resources
  30144. */
  30145. dispose(): void;
  30146. /**
  30147. * Gets the name of the current physics plugin
  30148. * @returns the name of the plugin
  30149. */
  30150. getPhysicsPluginName(): string;
  30151. /**
  30152. * Adding a new impostor for the impostor tracking.
  30153. * This will be done by the impostor itself.
  30154. * @param impostor the impostor to add
  30155. */
  30156. addImpostor(impostor: PhysicsImpostor): void;
  30157. /**
  30158. * Remove an impostor from the engine.
  30159. * This impostor and its mesh will not longer be updated by the physics engine.
  30160. * @param impostor the impostor to remove
  30161. */
  30162. removeImpostor(impostor: PhysicsImpostor): void;
  30163. /**
  30164. * Add a joint to the physics engine
  30165. * @param mainImpostor defines the main impostor to which the joint is added.
  30166. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30167. * @param joint defines the joint that will connect both impostors.
  30168. */
  30169. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30170. /**
  30171. * Removes a joint from the simulation
  30172. * @param mainImpostor defines the impostor used with the joint
  30173. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30174. * @param joint defines the joint to remove
  30175. */
  30176. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30177. /**
  30178. * Gets the current plugin used to run the simulation
  30179. * @returns current plugin
  30180. */
  30181. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30182. /**
  30183. * Gets the list of physic impostors
  30184. * @returns an array of PhysicsImpostor
  30185. */
  30186. getImpostors(): Array<PhysicsImpostor>;
  30187. /**
  30188. * Gets the impostor for a physics enabled object
  30189. * @param object defines the object impersonated by the impostor
  30190. * @returns the PhysicsImpostor or null if not found
  30191. */
  30192. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30193. /**
  30194. * Gets the impostor for a physics body object
  30195. * @param body defines physics body used by the impostor
  30196. * @returns the PhysicsImpostor or null if not found
  30197. */
  30198. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30199. /**
  30200. * Called by the scene. No need to call it.
  30201. * @param delta defines the timespam between frames
  30202. */
  30203. _step(delta: number): void;
  30204. }
  30205. }
  30206. declare module BABYLON {
  30207. /**
  30208. * Class used to control physics engine
  30209. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30210. */
  30211. class PhysicsEngine implements IPhysicsEngine {
  30212. private _physicsPlugin;
  30213. /**
  30214. * Global value used to control the smallest number supported by the simulation
  30215. */
  30216. static Epsilon: number;
  30217. private _impostors;
  30218. private _joints;
  30219. /**
  30220. * Gets the gravity vector used by the simulation
  30221. */
  30222. gravity: Vector3;
  30223. /**
  30224. * Creates a new Physics Engine
  30225. * @param gravity defines the gravity vector used by the simulation
  30226. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  30227. */
  30228. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  30229. /**
  30230. * Sets the gravity vector used by the simulation
  30231. * @param gravity defines the gravity vector to use
  30232. */
  30233. setGravity(gravity: Vector3): void;
  30234. /**
  30235. * Set the time step of the physics engine.
  30236. * Default is 1/60.
  30237. * To slow it down, enter 1/600 for example.
  30238. * To speed it up, 1/30
  30239. * @param newTimeStep defines the new timestep to apply to this world.
  30240. */
  30241. setTimeStep(newTimeStep?: number): void;
  30242. /**
  30243. * Get the time step of the physics engine.
  30244. * @returns the current time step
  30245. */
  30246. getTimeStep(): number;
  30247. /**
  30248. * Release all resources
  30249. */
  30250. dispose(): void;
  30251. /**
  30252. * Gets the name of the current physics plugin
  30253. * @returns the name of the plugin
  30254. */
  30255. getPhysicsPluginName(): string;
  30256. /**
  30257. * Adding a new impostor for the impostor tracking.
  30258. * This will be done by the impostor itself.
  30259. * @param impostor the impostor to add
  30260. */
  30261. addImpostor(impostor: PhysicsImpostor): void;
  30262. /**
  30263. * Remove an impostor from the engine.
  30264. * This impostor and its mesh will not longer be updated by the physics engine.
  30265. * @param impostor the impostor to remove
  30266. */
  30267. removeImpostor(impostor: PhysicsImpostor): void;
  30268. /**
  30269. * Add a joint to the physics engine
  30270. * @param mainImpostor defines the main impostor to which the joint is added.
  30271. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30272. * @param joint defines the joint that will connect both impostors.
  30273. */
  30274. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30275. /**
  30276. * Removes a joint from the simulation
  30277. * @param mainImpostor defines the impostor used with the joint
  30278. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30279. * @param joint defines the joint to remove
  30280. */
  30281. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30282. /**
  30283. * Called by the scene. No need to call it.
  30284. * @param delta defines the timespam between frames
  30285. */
  30286. _step(delta: number): void;
  30287. /**
  30288. * Gets the current plugin used to run the simulation
  30289. * @returns current plugin
  30290. */
  30291. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30292. /**
  30293. * Gets the list of physic impostors
  30294. * @returns an array of PhysicsImpostor
  30295. */
  30296. getImpostors(): Array<PhysicsImpostor>;
  30297. /**
  30298. * Gets the impostor for a physics enabled object
  30299. * @param object defines the object impersonated by the impostor
  30300. * @returns the PhysicsImpostor or null if not found
  30301. */
  30302. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30303. /**
  30304. * Gets the impostor for a physics body object
  30305. * @param body defines physics body used by the impostor
  30306. * @returns the PhysicsImpostor or null if not found
  30307. */
  30308. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30309. }
  30310. }
  30311. declare module BABYLON {
  30312. interface Scene {
  30313. /** @hidden (Backing field) */
  30314. _physicsEngine: Nullable<IPhysicsEngine>;
  30315. /**
  30316. * Gets the current physics engine
  30317. * @returns a IPhysicsEngine or null if none attached
  30318. */
  30319. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30320. /**
  30321. * Enables physics to the current scene
  30322. * @param gravity defines the scene's gravity for the physics engine
  30323. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30324. * @return a boolean indicating if the physics engine was initialized
  30325. */
  30326. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30327. /**
  30328. * Disables and disposes the physics engine associated with the scene
  30329. */
  30330. disablePhysicsEngine(): void;
  30331. /**
  30332. * Gets a boolean indicating if there is an active physics engine
  30333. * @returns a boolean indicating if there is an active physics engine
  30334. */
  30335. isPhysicsEnabled(): boolean;
  30336. /**
  30337. * Deletes a physics compound impostor
  30338. * @param compound defines the compound to delete
  30339. */
  30340. deleteCompoundImpostor(compound: any): void;
  30341. /**
  30342. * An event triggered when physic simulation is about to be run
  30343. */
  30344. onBeforePhysicsObservable: Observable<Scene>;
  30345. /**
  30346. * An event triggered when physic simulation has been done
  30347. */
  30348. onAfterPhysicsObservable: Observable<Scene>;
  30349. }
  30350. interface AbstractMesh {
  30351. /** @hidden */
  30352. _physicsImpostor: Nullable<PhysicsImpostor>;
  30353. /**
  30354. * Gets or sets impostor used for physic simulation
  30355. * @see http://doc.babylonjs.com/features/physics_engine
  30356. */
  30357. physicsImpostor: Nullable<PhysicsImpostor>;
  30358. /**
  30359. * Gets the current physics impostor
  30360. * @see http://doc.babylonjs.com/features/physics_engine
  30361. * @returns a physics impostor or null
  30362. */
  30363. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30364. /** Apply a physic impulse to the mesh
  30365. * @param force defines the force to apply
  30366. * @param contactPoint defines where to apply the force
  30367. * @returns the current mesh
  30368. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30369. */
  30370. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30371. /**
  30372. * Creates a physic joint between two meshes
  30373. * @param otherMesh defines the other mesh to use
  30374. * @param pivot1 defines the pivot to use on this mesh
  30375. * @param pivot2 defines the pivot to use on the other mesh
  30376. * @param options defines additional options (can be plugin dependent)
  30377. * @returns the current mesh
  30378. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30379. */
  30380. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30381. /** @hidden */
  30382. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30383. }
  30384. /**
  30385. * Defines the physics engine scene component responsible to manage a physics engine
  30386. */
  30387. class PhysicsEngineSceneComponent implements ISceneComponent {
  30388. /**
  30389. * The component name helpful to identify the component in the list of scene components.
  30390. */
  30391. readonly name: string;
  30392. /**
  30393. * The scene the component belongs to.
  30394. */
  30395. scene: Scene;
  30396. /**
  30397. * Creates a new instance of the component for the given scene
  30398. * @param scene Defines the scene to register the component in
  30399. */
  30400. constructor(scene: Scene);
  30401. /**
  30402. * Registers the component in a given scene
  30403. */
  30404. register(): void;
  30405. /**
  30406. * Rebuilds the elements related to this component in case of
  30407. * context lost for instance.
  30408. */
  30409. rebuild(): void;
  30410. /**
  30411. * Disposes the component and the associated ressources
  30412. */
  30413. dispose(): void;
  30414. }
  30415. }
  30416. declare module BABYLON {
  30417. class PhysicsHelper {
  30418. private _scene;
  30419. private _physicsEngine;
  30420. constructor(scene: Scene);
  30421. /**
  30422. * @param {Vector3} origin the origin of the explosion
  30423. * @param {number} radius the explosion radius
  30424. * @param {number} strength the explosion strength
  30425. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  30426. */
  30427. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30428. /**
  30429. * @param {Vector3} origin the origin of the explosion
  30430. * @param {number} radius the explosion radius
  30431. * @param {number} strength the explosion strength
  30432. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  30433. */
  30434. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30435. /**
  30436. * @param {Vector3} origin the origin of the explosion
  30437. * @param {number} radius the explosion radius
  30438. * @param {number} strength the explosion strength
  30439. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  30440. */
  30441. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30442. /**
  30443. * @param {Vector3} origin the origin of the updraft
  30444. * @param {number} radius the radius of the updraft
  30445. * @param {number} strength the strength of the updraft
  30446. * @param {number} height the height of the updraft
  30447. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  30448. */
  30449. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30450. /**
  30451. * @param {Vector3} origin the of the vortex
  30452. * @param {number} radius the radius of the vortex
  30453. * @param {number} strength the strength of the vortex
  30454. * @param {number} height the height of the vortex
  30455. */
  30456. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30457. }
  30458. /***** Radial explosion *****/
  30459. class PhysicsRadialExplosionEvent {
  30460. private _scene;
  30461. private _sphere;
  30462. private _sphereOptions;
  30463. private _rays;
  30464. private _dataFetched;
  30465. constructor(scene: Scene);
  30466. /**
  30467. * Returns the data related to the radial explosion event (sphere & rays).
  30468. * @returns {PhysicsRadialExplosionEventData}
  30469. */
  30470. getData(): PhysicsRadialExplosionEventData;
  30471. /**
  30472. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30473. * @param impostor
  30474. * @param {Vector3} origin the origin of the explosion
  30475. * @param {number} radius the explosion radius
  30476. * @param {number} strength the explosion strength
  30477. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  30478. * @returns {Nullable<PhysicsForceAndContactPoint>}
  30479. */
  30480. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30481. /**
  30482. * Disposes the sphere.
  30483. * @param {bolean} force
  30484. */
  30485. dispose(force?: boolean): void;
  30486. /*** Helpers ***/
  30487. private _prepareSphere;
  30488. private _intersectsWithSphere;
  30489. }
  30490. /***** Gravitational Field *****/
  30491. class PhysicsGravitationalFieldEvent {
  30492. private _physicsHelper;
  30493. private _scene;
  30494. private _origin;
  30495. private _radius;
  30496. private _strength;
  30497. private _falloff;
  30498. private _tickCallback;
  30499. private _sphere;
  30500. private _dataFetched;
  30501. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30502. /**
  30503. * Returns the data related to the gravitational field event (sphere).
  30504. * @returns {PhysicsGravitationalFieldEventData}
  30505. */
  30506. getData(): PhysicsGravitationalFieldEventData;
  30507. /**
  30508. * Enables the gravitational field.
  30509. */
  30510. enable(): void;
  30511. /**
  30512. * Disables the gravitational field.
  30513. */
  30514. disable(): void;
  30515. /**
  30516. * Disposes the sphere.
  30517. * @param {bolean} force
  30518. */
  30519. dispose(force?: boolean): void;
  30520. private _tick;
  30521. }
  30522. /***** Updraft *****/
  30523. class PhysicsUpdraftEvent {
  30524. private _scene;
  30525. private _origin;
  30526. private _radius;
  30527. private _strength;
  30528. private _height;
  30529. private _updraftMode;
  30530. private _physicsEngine;
  30531. private _originTop;
  30532. private _originDirection;
  30533. private _tickCallback;
  30534. private _cylinder;
  30535. private _cylinderPosition;
  30536. private _dataFetched;
  30537. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30538. /**
  30539. * Returns the data related to the updraft event (cylinder).
  30540. * @returns {PhysicsUpdraftEventData}
  30541. */
  30542. getData(): PhysicsUpdraftEventData;
  30543. /**
  30544. * Enables the updraft.
  30545. */
  30546. enable(): void;
  30547. /**
  30548. * Disables the cortex.
  30549. */
  30550. disable(): void;
  30551. /**
  30552. * Disposes the sphere.
  30553. * @param {bolean} force
  30554. */
  30555. dispose(force?: boolean): void;
  30556. private getImpostorForceAndContactPoint;
  30557. private _tick;
  30558. /*** Helpers ***/
  30559. private _prepareCylinder;
  30560. private _intersectsWithCylinder;
  30561. }
  30562. /***** Vortex *****/
  30563. class PhysicsVortexEvent {
  30564. private _scene;
  30565. private _origin;
  30566. private _radius;
  30567. private _strength;
  30568. private _height;
  30569. private _physicsEngine;
  30570. private _originTop;
  30571. private _centripetalForceThreshold;
  30572. private _updraftMultiplier;
  30573. private _tickCallback;
  30574. private _cylinder;
  30575. private _cylinderPosition;
  30576. private _dataFetched;
  30577. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30578. /**
  30579. * Returns the data related to the vortex event (cylinder).
  30580. * @returns {PhysicsVortexEventData}
  30581. */
  30582. getData(): PhysicsVortexEventData;
  30583. /**
  30584. * Enables the vortex.
  30585. */
  30586. enable(): void;
  30587. /**
  30588. * Disables the cortex.
  30589. */
  30590. disable(): void;
  30591. /**
  30592. * Disposes the sphere.
  30593. * @param {bolean} force
  30594. */
  30595. dispose(force?: boolean): void;
  30596. private getImpostorForceAndContactPoint;
  30597. private _tick;
  30598. /*** Helpers ***/
  30599. private _prepareCylinder;
  30600. private _intersectsWithCylinder;
  30601. }
  30602. /***** Enums *****/
  30603. /**
  30604. * The strenght of the force in correspondence to the distance of the affected object
  30605. */
  30606. enum PhysicsRadialImpulseFalloff {
  30607. /** Defines that impulse is constant in strength across it's whole radius */
  30608. Constant = 0,
  30609. /** DEfines that impulse gets weaker if it's further from the origin */
  30610. Linear = 1
  30611. }
  30612. /**
  30613. * The strenght of the force in correspondence to the distance of the affected object
  30614. */
  30615. enum PhysicsUpdraftMode {
  30616. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30617. Center = 0,
  30618. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30619. Perpendicular = 1
  30620. }
  30621. /***** Data interfaces *****/
  30622. interface PhysicsForceAndContactPoint {
  30623. force: Vector3;
  30624. contactPoint: Vector3;
  30625. }
  30626. interface PhysicsRadialExplosionEventData {
  30627. sphere: Mesh;
  30628. rays: Array<Ray>;
  30629. }
  30630. interface PhysicsGravitationalFieldEventData {
  30631. sphere: Mesh;
  30632. }
  30633. interface PhysicsUpdraftEventData {
  30634. cylinder: Mesh;
  30635. }
  30636. interface PhysicsVortexEventData {
  30637. cylinder: Mesh;
  30638. }
  30639. }
  30640. declare module BABYLON {
  30641. interface PhysicsImpostorParameters {
  30642. mass: number;
  30643. friction?: number;
  30644. restitution?: number;
  30645. nativeOptions?: any;
  30646. ignoreParent?: boolean;
  30647. disableBidirectionalTransformation?: boolean;
  30648. }
  30649. interface IPhysicsEnabledObject {
  30650. position: Vector3;
  30651. rotationQuaternion: Nullable<Quaternion>;
  30652. scaling: Vector3;
  30653. rotation?: Vector3;
  30654. parent?: any;
  30655. getBoundingInfo(): BoundingInfo;
  30656. computeWorldMatrix(force: boolean): Matrix;
  30657. getWorldMatrix?(): Matrix;
  30658. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  30659. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  30660. getIndices?(): Nullable<IndicesArray>;
  30661. getScene?(): Scene;
  30662. getAbsolutePosition(): Vector3;
  30663. getAbsolutePivotPoint(): Vector3;
  30664. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  30665. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  30666. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  30667. getClassName(): string;
  30668. }
  30669. class PhysicsImpostor {
  30670. object: IPhysicsEnabledObject;
  30671. type: number;
  30672. private _options;
  30673. private _scene?;
  30674. static DEFAULT_OBJECT_SIZE: Vector3;
  30675. static IDENTITY_QUATERNION: Quaternion;
  30676. private _physicsEngine;
  30677. private _physicsBody;
  30678. private _bodyUpdateRequired;
  30679. private _onBeforePhysicsStepCallbacks;
  30680. private _onAfterPhysicsStepCallbacks;
  30681. private _onPhysicsCollideCallbacks;
  30682. private _deltaPosition;
  30683. private _deltaRotation;
  30684. private _deltaRotationConjugated;
  30685. private _parent;
  30686. private _isDisposed;
  30687. private static _tmpVecs;
  30688. private static _tmpQuat;
  30689. readonly isDisposed: boolean;
  30690. mass: number;
  30691. friction: number;
  30692. restitution: number;
  30693. uniqueId: number;
  30694. private _joints;
  30695. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  30696. /**
  30697. * This function will completly initialize this impostor.
  30698. * It will create a new body - but only if this mesh has no parent.
  30699. * If it has, this impostor will not be used other than to define the impostor
  30700. * of the child mesh.
  30701. * @hidden
  30702. */
  30703. _init(): void;
  30704. private _getPhysicsParent;
  30705. /**
  30706. * Should a new body be generated.
  30707. */
  30708. isBodyInitRequired(): boolean;
  30709. setScalingUpdated(updated: boolean): void;
  30710. /**
  30711. * Force a regeneration of this or the parent's impostor's body.
  30712. * Use under cautious - This will remove all joints already implemented.
  30713. */
  30714. forceUpdate(): void;
  30715. /**
  30716. * Gets the body that holds this impostor. Either its own, or its parent.
  30717. */
  30718. /**
  30719. * Set the physics body. Used mainly by the physics engine/plugin
  30720. */
  30721. physicsBody: any;
  30722. parent: Nullable<PhysicsImpostor>;
  30723. resetUpdateFlags(): void;
  30724. getObjectExtendSize(): Vector3;
  30725. getObjectCenter(): Vector3;
  30726. /**
  30727. * Get a specific parametes from the options parameter.
  30728. */
  30729. getParam(paramName: string): any;
  30730. /**
  30731. * Sets a specific parameter in the options given to the physics plugin
  30732. */
  30733. setParam(paramName: string, value: number): void;
  30734. /**
  30735. * Specifically change the body's mass option. Won't recreate the physics body object
  30736. */
  30737. setMass(mass: number): void;
  30738. getLinearVelocity(): Nullable<Vector3>;
  30739. setLinearVelocity(velocity: Nullable<Vector3>): void;
  30740. getAngularVelocity(): Nullable<Vector3>;
  30741. setAngularVelocity(velocity: Nullable<Vector3>): void;
  30742. /**
  30743. * Execute a function with the physics plugin native code.
  30744. * Provide a function the will have two variables - the world object and the physics body object.
  30745. */
  30746. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  30747. /**
  30748. * Register a function that will be executed before the physics world is stepping forward.
  30749. */
  30750. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30751. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30752. /**
  30753. * Register a function that will be executed after the physics step
  30754. */
  30755. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30756. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30757. /**
  30758. * register a function that will be executed when this impostor collides against a different body.
  30759. */
  30760. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  30761. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  30762. private _tmpQuat;
  30763. private _tmpQuat2;
  30764. getParentsRotation(): Quaternion;
  30765. /**
  30766. * this function is executed by the physics engine.
  30767. */
  30768. beforeStep: () => void;
  30769. /**
  30770. * this function is executed by the physics engine.
  30771. */
  30772. afterStep: () => void;
  30773. /**
  30774. * Legacy collision detection event support
  30775. */
  30776. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  30777. onCollide: (e: {
  30778. body: any;
  30779. }) => void;
  30780. /**
  30781. * Apply a force
  30782. */
  30783. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30784. /**
  30785. * Apply an impulse
  30786. */
  30787. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30788. /**
  30789. * A help function to create a joint.
  30790. */
  30791. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  30792. /**
  30793. * Add a joint to this impostor with a different impostor.
  30794. */
  30795. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  30796. /**
  30797. * Will keep this body still, in a sleep mode.
  30798. */
  30799. sleep(): PhysicsImpostor;
  30800. /**
  30801. * Wake the body up.
  30802. */
  30803. wakeUp(): PhysicsImpostor;
  30804. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30805. dispose(): void;
  30806. setDeltaPosition(position: Vector3): void;
  30807. setDeltaRotation(rotation: Quaternion): void;
  30808. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  30809. getRadius(): number;
  30810. /**
  30811. * Sync a bone with this impostor
  30812. * @param bone The bone to sync to the impostor.
  30813. * @param boneMesh The mesh that the bone is influencing.
  30814. * @param jointPivot The pivot of the joint / bone in local space.
  30815. * @param distToJoint Optional distance from the impostor to the joint.
  30816. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30817. */
  30818. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  30819. /**
  30820. * Sync impostor to a bone
  30821. * @param bone The bone that the impostor will be synced to.
  30822. * @param boneMesh The mesh that the bone is influencing.
  30823. * @param jointPivot The pivot of the joint / bone in local space.
  30824. * @param distToJoint Optional distance from the impostor to the joint.
  30825. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30826. * @param boneAxis Optional vector3 axis the bone is aligned with
  30827. */
  30828. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  30829. static NoImpostor: number;
  30830. static SphereImpostor: number;
  30831. static BoxImpostor: number;
  30832. static PlaneImpostor: number;
  30833. static MeshImpostor: number;
  30834. static CylinderImpostor: number;
  30835. static ParticleImpostor: number;
  30836. static HeightmapImpostor: number;
  30837. }
  30838. }
  30839. declare module BABYLON {
  30840. interface PhysicsJointData {
  30841. mainPivot?: Vector3;
  30842. connectedPivot?: Vector3;
  30843. mainAxis?: Vector3;
  30844. connectedAxis?: Vector3;
  30845. collision?: boolean;
  30846. nativeParams?: any;
  30847. }
  30848. /**
  30849. * This is a holder class for the physics joint created by the physics plugin.
  30850. * It holds a set of functions to control the underlying joint.
  30851. */
  30852. class PhysicsJoint {
  30853. type: number;
  30854. jointData: PhysicsJointData;
  30855. private _physicsJoint;
  30856. protected _physicsPlugin: IPhysicsEnginePlugin;
  30857. constructor(type: number, jointData: PhysicsJointData);
  30858. physicsJoint: any;
  30859. physicsPlugin: IPhysicsEnginePlugin;
  30860. /**
  30861. * Execute a function that is physics-plugin specific.
  30862. * @param {Function} func the function that will be executed.
  30863. * It accepts two parameters: the physics world and the physics joint.
  30864. */
  30865. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  30866. static DistanceJoint: number;
  30867. static HingeJoint: number;
  30868. static BallAndSocketJoint: number;
  30869. static WheelJoint: number;
  30870. static SliderJoint: number;
  30871. static PrismaticJoint: number;
  30872. static UniversalJoint: number;
  30873. static Hinge2Joint: number;
  30874. static PointToPointJoint: number;
  30875. static SpringJoint: number;
  30876. static LockJoint: number;
  30877. }
  30878. /**
  30879. * A class representing a physics distance joint.
  30880. */
  30881. class DistanceJoint extends PhysicsJoint {
  30882. constructor(jointData: DistanceJointData);
  30883. /**
  30884. * Update the predefined distance.
  30885. */
  30886. updateDistance(maxDistance: number, minDistance?: number): void;
  30887. }
  30888. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  30889. constructor(type: number, jointData: PhysicsJointData);
  30890. /**
  30891. * Set the motor values.
  30892. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30893. * @param {number} force the force to apply
  30894. * @param {number} maxForce max force for this motor.
  30895. */
  30896. setMotor(force?: number, maxForce?: number): void;
  30897. /**
  30898. * Set the motor's limits.
  30899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30900. */
  30901. setLimit(upperLimit: number, lowerLimit?: number): void;
  30902. }
  30903. /**
  30904. * This class represents a single hinge physics joint
  30905. */
  30906. class HingeJoint extends MotorEnabledJoint {
  30907. constructor(jointData: PhysicsJointData);
  30908. /**
  30909. * Set the motor values.
  30910. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30911. * @param {number} force the force to apply
  30912. * @param {number} maxForce max force for this motor.
  30913. */
  30914. setMotor(force?: number, maxForce?: number): void;
  30915. /**
  30916. * Set the motor's limits.
  30917. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30918. */
  30919. setLimit(upperLimit: number, lowerLimit?: number): void;
  30920. }
  30921. /**
  30922. * This class represents a dual hinge physics joint (same as wheel joint)
  30923. */
  30924. class Hinge2Joint extends MotorEnabledJoint {
  30925. constructor(jointData: PhysicsJointData);
  30926. /**
  30927. * Set the motor values.
  30928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30929. * @param {number} force the force to apply
  30930. * @param {number} maxForce max force for this motor.
  30931. * @param {motorIndex} the motor's index, 0 or 1.
  30932. */
  30933. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  30934. /**
  30935. * Set the motor limits.
  30936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30937. * @param {number} upperLimit the upper limit
  30938. * @param {number} lowerLimit lower limit
  30939. * @param {motorIndex} the motor's index, 0 or 1.
  30940. */
  30941. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30942. }
  30943. interface IMotorEnabledJoint {
  30944. physicsJoint: any;
  30945. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  30946. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30947. }
  30948. interface DistanceJointData extends PhysicsJointData {
  30949. maxDistance: number;
  30950. }
  30951. interface SpringJointData extends PhysicsJointData {
  30952. length: number;
  30953. stiffness: number;
  30954. damping: number;
  30955. /** this callback will be called when applying the force to the impostors. */
  30956. forceApplicationCallback: () => void;
  30957. }
  30958. }
  30959. declare module BABYLON {
  30960. interface Scene {
  30961. /**
  30962. * The list of reflection probes added to the scene
  30963. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  30964. */
  30965. reflectionProbes: Array<ReflectionProbe>;
  30966. }
  30967. /**
  30968. * Class used to generate realtime reflection / refraction cube textures
  30969. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  30970. */
  30971. class ReflectionProbe {
  30972. /** defines the name of the probe */
  30973. name: string;
  30974. private _scene;
  30975. private _renderTargetTexture;
  30976. private _projectionMatrix;
  30977. private _viewMatrix;
  30978. private _target;
  30979. private _add;
  30980. private _attachedMesh;
  30981. private _invertYAxis;
  30982. /** Gets or sets probe position (center of the cube map) */
  30983. position: Vector3;
  30984. /**
  30985. * Creates a new reflection probe
  30986. * @param name defines the name of the probe
  30987. * @param size defines the texture resolution (for each face)
  30988. * @param scene defines the hosting scene
  30989. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  30990. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  30991. */
  30992. constructor(
  30993. /** defines the name of the probe */
  30994. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  30995. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  30996. samples: number;
  30997. /** Gets or sets the refresh rate to use (on every frame by default) */
  30998. refreshRate: number;
  30999. /**
  31000. * Gets the hosting scene
  31001. * @returns a Scene
  31002. */
  31003. getScene(): Scene;
  31004. /** Gets the internal CubeTexture used to render to */
  31005. readonly cubeTexture: RenderTargetTexture;
  31006. /** Gets the list of meshes to render */
  31007. readonly renderList: Nullable<AbstractMesh[]>;
  31008. /**
  31009. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  31010. * @param mesh defines the mesh to attach to
  31011. */
  31012. attachToMesh(mesh: AbstractMesh): void;
  31013. /**
  31014. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  31015. * @param renderingGroupId The rendering group id corresponding to its index
  31016. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  31017. */
  31018. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  31019. /**
  31020. * Clean all associated resources
  31021. */
  31022. dispose(): void;
  31023. }
  31024. }
  31025. declare module BABYLON {
  31026. /**
  31027. * Postprocess used to generate anaglyphic rendering
  31028. */
  31029. class AnaglyphPostProcess extends PostProcess {
  31030. private _passedProcess;
  31031. /**
  31032. * Creates a new AnaglyphPostProcess
  31033. * @param name defines postprocess name
  31034. * @param options defines creation options or target ratio scale
  31035. * @param rigCameras defines cameras using this postprocess
  31036. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  31037. * @param engine defines hosting engine
  31038. * @param reusable defines if the postprocess will be reused multiple times per frame
  31039. */
  31040. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  31041. }
  31042. }
  31043. declare module BABYLON {
  31044. class BlackAndWhitePostProcess extends PostProcess {
  31045. degree: number;
  31046. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31047. }
  31048. }
  31049. declare module BABYLON {
  31050. /**
  31051. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  31052. */
  31053. class BloomEffect extends PostProcessRenderEffect {
  31054. private bloomScale;
  31055. /**
  31056. * @hidden Internal
  31057. */
  31058. _effects: Array<PostProcess>;
  31059. /**
  31060. * @hidden Internal
  31061. */
  31062. _downscale: ExtractHighlightsPostProcess;
  31063. private _blurX;
  31064. private _blurY;
  31065. private _merge;
  31066. /**
  31067. * The luminance threshold to find bright areas of the image to bloom.
  31068. */
  31069. threshold: number;
  31070. /**
  31071. * The strength of the bloom.
  31072. */
  31073. weight: number;
  31074. /**
  31075. * Specifies the size of the bloom blur kernel, relative to the final output size
  31076. */
  31077. kernel: number;
  31078. /**
  31079. * Creates a new instance of @see BloomEffect
  31080. * @param scene The scene the effect belongs to.
  31081. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  31082. * @param bloomKernel The size of the kernel to be used when applying the blur.
  31083. * @param bloomWeight The the strength of bloom.
  31084. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  31085. * @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)
  31086. */
  31087. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  31088. /**
  31089. * Disposes each of the internal effects for a given camera.
  31090. * @param camera The camera to dispose the effect on.
  31091. */
  31092. disposeEffects(camera: Camera): void;
  31093. /**
  31094. * @hidden Internal
  31095. */
  31096. _updateEffects(): void;
  31097. /**
  31098. * Internal
  31099. * @returns if all the contained post processes are ready.
  31100. * @hidden
  31101. */
  31102. _isReady(): boolean;
  31103. }
  31104. }
  31105. declare module BABYLON {
  31106. /**
  31107. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  31108. */
  31109. class BloomMergePostProcess extends PostProcess {
  31110. /** Weight of the bloom to be added to the original input. */
  31111. weight: number;
  31112. /**
  31113. * Creates a new instance of @see BloomMergePostProcess
  31114. * @param name The name of the effect.
  31115. * @param originalFromInput Post process which's input will be used for the merge.
  31116. * @param blurred Blurred highlights post process which's output will be used.
  31117. * @param weight Weight of the bloom to be added to the original input.
  31118. * @param options The required width/height ratio to downsize to before computing the render pass.
  31119. * @param camera The camera to apply the render pass to.
  31120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31121. * @param engine The engine which the post process will be applied. (default: current engine)
  31122. * @param reusable If the post process can be reused on the same frame. (default: false)
  31123. * @param textureType Type of textures used when performing the post process. (default: 0)
  31124. * @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)
  31125. */
  31126. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  31127. /** Weight of the bloom to be added to the original input. */
  31128. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31129. }
  31130. }
  31131. declare module BABYLON {
  31132. /**
  31133. * The Blur Post Process which blurs an image based on a kernel and direction.
  31134. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  31135. */
  31136. class BlurPostProcess extends PostProcess {
  31137. /** The direction in which to blur the image. */
  31138. direction: Vector2;
  31139. private blockCompilation;
  31140. protected _kernel: number;
  31141. protected _idealKernel: number;
  31142. protected _packedFloat: boolean;
  31143. private _staticDefines;
  31144. /**
  31145. * Sets the length in pixels of the blur sample region
  31146. */
  31147. /**
  31148. * Gets the length in pixels of the blur sample region
  31149. */
  31150. kernel: number;
  31151. /**
  31152. * Sets wether or not the blur needs to unpack/repack floats
  31153. */
  31154. /**
  31155. * Gets wether or not the blur is unpacking/repacking floats
  31156. */
  31157. packedFloat: boolean;
  31158. /**
  31159. * Creates a new instance BlurPostProcess
  31160. * @param name The name of the effect.
  31161. * @param direction The direction in which to blur the image.
  31162. * @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.
  31163. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  31164. * @param camera The camera to apply the render pass to.
  31165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31166. * @param engine The engine which the post process will be applied. (default: current engine)
  31167. * @param reusable If the post process can be reused on the same frame. (default: false)
  31168. * @param textureType Type of textures used when performing the post process. (default: 0)
  31169. * @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)
  31170. */
  31171. constructor(name: string,
  31172. /** The direction in which to blur the image. */
  31173. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  31174. /**
  31175. * Updates the effect with the current post process compile time values and recompiles the shader.
  31176. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  31177. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  31178. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  31179. * @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
  31180. * @param onCompiled Called when the shader has been compiled.
  31181. * @param onError Called if there is an error when compiling a shader.
  31182. */
  31183. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  31184. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  31185. /**
  31186. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  31187. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  31188. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  31189. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  31190. * The gaps between physical kernels are compensated for in the weighting of the samples
  31191. * @param idealKernel Ideal blur kernel.
  31192. * @return Nearest best kernel.
  31193. */
  31194. protected _nearestBestKernel(idealKernel: number): number;
  31195. /**
  31196. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  31197. * @param x The point on the Gaussian distribution to sample.
  31198. * @return the value of the Gaussian function at x.
  31199. */
  31200. protected _gaussianWeight(x: number): number;
  31201. /**
  31202. * Generates a string that can be used as a floating point number in GLSL.
  31203. * @param x Value to print.
  31204. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  31205. * @return GLSL float string.
  31206. */
  31207. protected _glslFloat(x: number, decimalFigures?: number): string;
  31208. }
  31209. }
  31210. declare module BABYLON {
  31211. /**
  31212. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  31213. */
  31214. class ChromaticAberrationPostProcess extends PostProcess {
  31215. /**
  31216. * The amount of seperation of rgb channels (default: 30)
  31217. */
  31218. aberrationAmount: number;
  31219. /**
  31220. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  31221. */
  31222. radialIntensity: number;
  31223. /**
  31224. * 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))
  31225. */
  31226. direction: Vector2;
  31227. /**
  31228. * 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))
  31229. */
  31230. centerPosition: Vector2;
  31231. /**
  31232. * Creates a new instance ChromaticAberrationPostProcess
  31233. * @param name The name of the effect.
  31234. * @param screenWidth The width of the screen to apply the effect on.
  31235. * @param screenHeight The height of the screen to apply the effect on.
  31236. * @param options The required width/height ratio to downsize to before computing the render pass.
  31237. * @param camera The camera to apply the render pass to.
  31238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31239. * @param engine The engine which the post process will be applied. (default: current engine)
  31240. * @param reusable If the post process can be reused on the same frame. (default: false)
  31241. * @param textureType Type of textures used when performing the post process. (default: 0)
  31242. * @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)
  31243. */
  31244. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31245. }
  31246. }
  31247. declare module BABYLON {
  31248. /**
  31249. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  31250. */
  31251. class CircleOfConfusionPostProcess extends PostProcess {
  31252. /**
  31253. * 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.
  31254. */
  31255. lensSize: number;
  31256. /**
  31257. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  31258. */
  31259. fStop: number;
  31260. /**
  31261. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  31262. */
  31263. focusDistance: number;
  31264. /**
  31265. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  31266. */
  31267. focalLength: number;
  31268. private _depthTexture;
  31269. /**
  31270. * Creates a new instance CircleOfConfusionPostProcess
  31271. * @param name The name of the effect.
  31272. * @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.
  31273. * @param options The required width/height ratio to downsize to before computing the render pass.
  31274. * @param camera The camera to apply the render pass to.
  31275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31276. * @param engine The engine which the post process will be applied. (default: current engine)
  31277. * @param reusable If the post process can be reused on the same frame. (default: false)
  31278. * @param textureType Type of textures used when performing the post process. (default: 0)
  31279. * @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)
  31280. */
  31281. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31282. /**
  31283. * 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.
  31284. */
  31285. depthTexture: RenderTargetTexture;
  31286. }
  31287. }
  31288. declare module BABYLON {
  31289. class ColorCorrectionPostProcess extends PostProcess {
  31290. private _colorTableTexture;
  31291. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31292. }
  31293. }
  31294. declare module BABYLON {
  31295. /**
  31296. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  31297. * input texture to perform effects such as edge detection or sharpening
  31298. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  31299. */
  31300. class ConvolutionPostProcess extends PostProcess {
  31301. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  31302. kernel: number[];
  31303. /**
  31304. * Creates a new instance ConvolutionPostProcess
  31305. * @param name The name of the effect.
  31306. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  31307. * @param options The required width/height ratio to downsize to before computing the render pass.
  31308. * @param camera The camera to apply the render pass to.
  31309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31310. * @param engine The engine which the post process will be applied. (default: current engine)
  31311. * @param reusable If the post process can be reused on the same frame. (default: false)
  31312. * @param textureType Type of textures used when performing the post process. (default: 0)
  31313. */
  31314. constructor(name: string,
  31315. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  31316. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  31317. /**
  31318. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  31319. */
  31320. static EdgeDetect0Kernel: number[];
  31321. /**
  31322. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  31323. */
  31324. static EdgeDetect1Kernel: number[];
  31325. /**
  31326. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  31327. */
  31328. static EdgeDetect2Kernel: number[];
  31329. /**
  31330. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  31331. */
  31332. static SharpenKernel: number[];
  31333. /**
  31334. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  31335. */
  31336. static EmbossKernel: number[];
  31337. /**
  31338. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  31339. */
  31340. static GaussianKernel: number[];
  31341. }
  31342. }
  31343. declare module BABYLON {
  31344. /**
  31345. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  31346. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  31347. * based on samples that have a large difference in distance than the center pixel.
  31348. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  31349. */
  31350. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  31351. direction: Vector2;
  31352. /**
  31353. * Creates a new instance CircleOfConfusionPostProcess
  31354. * @param name The name of the effect.
  31355. * @param scene The scene the effect belongs to.
  31356. * @param direction The direction the blur should be applied.
  31357. * @param kernel The size of the kernel used to blur.
  31358. * @param options The required width/height ratio to downsize to before computing the render pass.
  31359. * @param camera The camera to apply the render pass to.
  31360. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  31361. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  31362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31363. * @param engine The engine which the post process will be applied. (default: current engine)
  31364. * @param reusable If the post process can be reused on the same frame. (default: false)
  31365. * @param textureType Type of textures used when performing the post process. (default: 0)
  31366. * @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)
  31367. */
  31368. 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);
  31369. }
  31370. }
  31371. declare module BABYLON {
  31372. /**
  31373. * Specifies the level of max blur that should be applied when using the depth of field effect
  31374. */
  31375. enum DepthOfFieldEffectBlurLevel {
  31376. /**
  31377. * Subtle blur
  31378. */
  31379. Low = 0,
  31380. /**
  31381. * Medium blur
  31382. */
  31383. Medium = 1,
  31384. /**
  31385. * Large blur
  31386. */
  31387. High = 2
  31388. }
  31389. /**
  31390. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  31391. */
  31392. class DepthOfFieldEffect extends PostProcessRenderEffect {
  31393. private _circleOfConfusion;
  31394. /**
  31395. * @hidden Internal, blurs from high to low
  31396. */
  31397. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  31398. private _depthOfFieldBlurY;
  31399. private _dofMerge;
  31400. /**
  31401. * @hidden Internal post processes in depth of field effect
  31402. */
  31403. _effects: Array<PostProcess>;
  31404. /**
  31405. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  31406. */
  31407. focalLength: number;
  31408. /**
  31409. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  31410. */
  31411. fStop: number;
  31412. /**
  31413. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  31414. */
  31415. focusDistance: number;
  31416. /**
  31417. * 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.
  31418. */
  31419. lensSize: number;
  31420. /**
  31421. * Creates a new instance DepthOfFieldEffect
  31422. * @param scene The scene the effect belongs to.
  31423. * @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.
  31424. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  31425. * @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)
  31426. */
  31427. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  31428. /**
  31429. * 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.
  31430. */
  31431. depthTexture: RenderTargetTexture;
  31432. /**
  31433. * Disposes each of the internal effects for a given camera.
  31434. * @param camera The camera to dispose the effect on.
  31435. */
  31436. disposeEffects(camera: Camera): void;
  31437. /**
  31438. * @hidden Internal
  31439. */
  31440. _updateEffects(): void;
  31441. /**
  31442. * Internal
  31443. * @returns if all the contained post processes are ready.
  31444. * @hidden
  31445. */
  31446. _isReady(): boolean;
  31447. }
  31448. }
  31449. declare module BABYLON {
  31450. /**
  31451. * Options to be set when merging outputs from the default pipeline.
  31452. */
  31453. class DepthOfFieldMergePostProcessOptions {
  31454. /**
  31455. * The original image to merge on top of
  31456. */
  31457. originalFromInput: PostProcess;
  31458. /**
  31459. * Parameters to perform the merge of the depth of field effect
  31460. */
  31461. depthOfField?: {
  31462. circleOfConfusion: PostProcess;
  31463. blurSteps: Array<PostProcess>;
  31464. };
  31465. /**
  31466. * Parameters to perform the merge of bloom effect
  31467. */
  31468. bloom?: {
  31469. blurred: PostProcess;
  31470. weight: number;
  31471. };
  31472. }
  31473. /**
  31474. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  31475. */
  31476. class DepthOfFieldMergePostProcess extends PostProcess {
  31477. private blurSteps;
  31478. /**
  31479. * Creates a new instance of DepthOfFieldMergePostProcess
  31480. * @param name The name of the effect.
  31481. * @param originalFromInput Post process which's input will be used for the merge.
  31482. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  31483. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  31484. * @param options The required width/height ratio to downsize to before computing the render pass.
  31485. * @param camera The camera to apply the render pass to.
  31486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31487. * @param engine The engine which the post process will be applied. (default: current engine)
  31488. * @param reusable If the post process can be reused on the same frame. (default: false)
  31489. * @param textureType Type of textures used when performing the post process. (default: 0)
  31490. * @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)
  31491. */
  31492. 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);
  31493. /**
  31494. * Updates the effect with the current post process compile time values and recompiles the shader.
  31495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  31496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  31497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  31498. * @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
  31499. * @param onCompiled Called when the shader has been compiled.
  31500. * @param onError Called if there is an error when compiling a shader.
  31501. */
  31502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  31503. }
  31504. }
  31505. declare module BABYLON {
  31506. class DisplayPassPostProcess extends PostProcess {
  31507. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31508. }
  31509. }
  31510. declare module BABYLON {
  31511. /**
  31512. * 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.
  31513. */
  31514. class ExtractHighlightsPostProcess extends PostProcess {
  31515. /**
  31516. * The luminance threshold, pixels below this value will be set to black.
  31517. */
  31518. threshold: number;
  31519. /** @hidden */
  31520. _exposure: number;
  31521. /**
  31522. * Post process which has the input texture to be used when performing highlight extraction
  31523. * @hidden
  31524. */
  31525. _inputPostProcess: Nullable<PostProcess>;
  31526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31527. }
  31528. }
  31529. declare module BABYLON {
  31530. class FilterPostProcess extends PostProcess {
  31531. kernelMatrix: Matrix;
  31532. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31533. }
  31534. }
  31535. declare module BABYLON {
  31536. class FxaaPostProcess extends PostProcess {
  31537. texelWidth: number;
  31538. texelHeight: number;
  31539. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  31540. private _getDefines;
  31541. }
  31542. }
  31543. declare module BABYLON {
  31544. /**
  31545. * The GrainPostProcess adds noise to the image at mid luminance levels
  31546. */
  31547. class GrainPostProcess extends PostProcess {
  31548. /**
  31549. * The intensity of the grain added (default: 30)
  31550. */
  31551. intensity: number;
  31552. /**
  31553. * If the grain should be randomized on every frame
  31554. */
  31555. animated: boolean;
  31556. /**
  31557. * Creates a new instance of @see GrainPostProcess
  31558. * @param name The name of the effect.
  31559. * @param options The required width/height ratio to downsize to before computing the render pass.
  31560. * @param camera The camera to apply the render pass to.
  31561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31562. * @param engine The engine which the post process will be applied. (default: current engine)
  31563. * @param reusable If the post process can be reused on the same frame. (default: false)
  31564. * @param textureType Type of textures used when performing the post process. (default: 0)
  31565. * @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)
  31566. */
  31567. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31568. }
  31569. }
  31570. declare module BABYLON {
  31571. class HighlightsPostProcess extends PostProcess {
  31572. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  31573. }
  31574. }
  31575. declare module BABYLON {
  31576. class ImageProcessingPostProcess extends PostProcess {
  31577. /**
  31578. * Default configuration related to image processing available in the PBR Material.
  31579. */
  31580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31581. /**
  31582. * Gets the image processing configuration used either in this material.
  31583. */
  31584. /**
  31585. * Sets the Default image processing configuration used either in the this material.
  31586. *
  31587. * If sets to null, the scene one is in use.
  31588. */
  31589. imageProcessingConfiguration: ImageProcessingConfiguration;
  31590. /**
  31591. * Keep track of the image processing observer to allow dispose and replace.
  31592. */
  31593. private _imageProcessingObserver;
  31594. /**
  31595. * Attaches a new image processing configuration to the PBR Material.
  31596. * @param configuration
  31597. */
  31598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  31599. /**
  31600. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  31601. */
  31602. /**
  31603. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  31604. */
  31605. colorCurves: Nullable<ColorCurves>;
  31606. /**
  31607. * Gets wether the color curves effect is enabled.
  31608. */
  31609. /**
  31610. * Sets wether the color curves effect is enabled.
  31611. */
  31612. colorCurvesEnabled: boolean;
  31613. /**
  31614. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  31615. */
  31616. /**
  31617. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  31618. */
  31619. colorGradingTexture: Nullable<BaseTexture>;
  31620. /**
  31621. * Gets wether the color grading effect is enabled.
  31622. */
  31623. /**
  31624. * Gets wether the color grading effect is enabled.
  31625. */
  31626. colorGradingEnabled: boolean;
  31627. /**
  31628. * Gets exposure used in the effect.
  31629. */
  31630. /**
  31631. * Sets exposure used in the effect.
  31632. */
  31633. exposure: number;
  31634. /**
  31635. * Gets wether tonemapping is enabled or not.
  31636. */
  31637. /**
  31638. * Sets wether tonemapping is enabled or not
  31639. */
  31640. toneMappingEnabled: boolean;
  31641. /**
  31642. * Gets contrast used in the effect.
  31643. */
  31644. /**
  31645. * Sets contrast used in the effect.
  31646. */
  31647. contrast: number;
  31648. /**
  31649. * Gets Vignette stretch size.
  31650. */
  31651. /**
  31652. * Sets Vignette stretch size.
  31653. */
  31654. vignetteStretch: number;
  31655. /**
  31656. * Gets Vignette centre X Offset.
  31657. */
  31658. /**
  31659. * Sets Vignette centre X Offset.
  31660. */
  31661. vignetteCentreX: number;
  31662. /**
  31663. * Gets Vignette centre Y Offset.
  31664. */
  31665. /**
  31666. * Sets Vignette centre Y Offset.
  31667. */
  31668. vignetteCentreY: number;
  31669. /**
  31670. * Gets Vignette weight or intensity of the vignette effect.
  31671. */
  31672. /**
  31673. * Sets Vignette weight or intensity of the vignette effect.
  31674. */
  31675. vignetteWeight: number;
  31676. /**
  31677. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31678. * if vignetteEnabled is set to true.
  31679. */
  31680. /**
  31681. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31682. * if vignetteEnabled is set to true.
  31683. */
  31684. vignetteColor: Color4;
  31685. /**
  31686. * Gets Camera field of view used by the Vignette effect.
  31687. */
  31688. /**
  31689. * Sets Camera field of view used by the Vignette effect.
  31690. */
  31691. vignetteCameraFov: number;
  31692. /**
  31693. * Gets the vignette blend mode allowing different kind of effect.
  31694. */
  31695. /**
  31696. * Sets the vignette blend mode allowing different kind of effect.
  31697. */
  31698. vignetteBlendMode: number;
  31699. /**
  31700. * Gets wether the vignette effect is enabled.
  31701. */
  31702. /**
  31703. * Sets wether the vignette effect is enabled.
  31704. */
  31705. vignetteEnabled: boolean;
  31706. private _fromLinearSpace;
  31707. /**
  31708. * Gets wether the input of the processing is in Gamma or Linear Space.
  31709. */
  31710. /**
  31711. * Sets wether the input of the processing is in Gamma or Linear Space.
  31712. */
  31713. fromLinearSpace: boolean;
  31714. /**
  31715. * Defines cache preventing GC.
  31716. */
  31717. private _defines;
  31718. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  31719. getClassName(): string;
  31720. protected _updateParameters(): void;
  31721. dispose(camera?: Camera): void;
  31722. }
  31723. }
  31724. declare module BABYLON {
  31725. class PassPostProcess extends PostProcess {
  31726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31727. }
  31728. }
  31729. declare module BABYLON {
  31730. type PostProcessOptions = {
  31731. width: number;
  31732. height: number;
  31733. };
  31734. /**
  31735. * PostProcess can be used to apply a shader to a texture after it has been rendered
  31736. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  31737. */
  31738. class PostProcess {
  31739. /** Name of the PostProcess. */
  31740. name: string;
  31741. /**
  31742. * Width of the texture to apply the post process on
  31743. */
  31744. width: number;
  31745. /**
  31746. * Height of the texture to apply the post process on
  31747. */
  31748. height: number;
  31749. /**
  31750. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  31751. * @hidden
  31752. */
  31753. _outputTexture: Nullable<InternalTexture>;
  31754. /**
  31755. * Sampling mode used by the shader
  31756. * See https://doc.babylonjs.com/classes/3.1/texture
  31757. */
  31758. renderTargetSamplingMode: number;
  31759. /**
  31760. * Clear color to use when screen clearing
  31761. */
  31762. clearColor: Color4;
  31763. /**
  31764. * If the buffer needs to be cleared before applying the post process. (default: true)
  31765. * Should be set to false if shader will overwrite all previous pixels.
  31766. */
  31767. autoClear: boolean;
  31768. /**
  31769. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  31770. */
  31771. alphaMode: number;
  31772. /**
  31773. * Sets the setAlphaBlendConstants of the babylon engine
  31774. */
  31775. alphaConstants: Color4;
  31776. /**
  31777. * Animations to be used for the post processing
  31778. */
  31779. animations: Animation[];
  31780. /**
  31781. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  31782. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  31783. */
  31784. enablePixelPerfectMode: boolean;
  31785. /**
  31786. * Force the postprocess to be applied without taking in account viewport
  31787. */
  31788. forceFullscreenViewport: boolean;
  31789. /**
  31790. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  31791. *
  31792. * | Value | Type | Description |
  31793. * | ----- | ----------------------------------- | ----------- |
  31794. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  31795. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  31796. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  31797. *
  31798. */
  31799. scaleMode: number;
  31800. /**
  31801. * Force textures to be a power of two (default: false)
  31802. */
  31803. alwaysForcePOT: boolean;
  31804. private _samples;
  31805. /**
  31806. * Number of sample textures (default: 1)
  31807. */
  31808. samples: number;
  31809. /**
  31810. * Modify the scale of the post process to be the same as the viewport (default: false)
  31811. */
  31812. adaptScaleToCurrentViewport: boolean;
  31813. private _camera;
  31814. private _scene;
  31815. private _engine;
  31816. private _options;
  31817. private _reusable;
  31818. private _textureType;
  31819. /**
  31820. * Smart array of input and output textures for the post process.
  31821. * @hidden
  31822. */
  31823. _textures: SmartArray<InternalTexture>;
  31824. /**
  31825. * The index in _textures that corresponds to the output texture.
  31826. * @hidden
  31827. */
  31828. _currentRenderTextureInd: number;
  31829. private _effect;
  31830. private _samplers;
  31831. private _fragmentUrl;
  31832. private _vertexUrl;
  31833. private _parameters;
  31834. private _scaleRatio;
  31835. protected _indexParameters: any;
  31836. private _shareOutputWithPostProcess;
  31837. private _texelSize;
  31838. private _forcedOutputTexture;
  31839. /**
  31840. * An event triggered when the postprocess is activated.
  31841. */
  31842. onActivateObservable: Observable<Camera>;
  31843. private _onActivateObserver;
  31844. /**
  31845. * A function that is added to the onActivateObservable
  31846. */
  31847. onActivate: Nullable<(camera: Camera) => void>;
  31848. /**
  31849. * An event triggered when the postprocess changes its size.
  31850. */
  31851. onSizeChangedObservable: Observable<PostProcess>;
  31852. private _onSizeChangedObserver;
  31853. /**
  31854. * A function that is added to the onSizeChangedObservable
  31855. */
  31856. onSizeChanged: (postProcess: PostProcess) => void;
  31857. /**
  31858. * An event triggered when the postprocess applies its effect.
  31859. */
  31860. onApplyObservable: Observable<Effect>;
  31861. private _onApplyObserver;
  31862. /**
  31863. * A function that is added to the onApplyObservable
  31864. */
  31865. onApply: (effect: Effect) => void;
  31866. /**
  31867. * An event triggered before rendering the postprocess
  31868. */
  31869. onBeforeRenderObservable: Observable<Effect>;
  31870. private _onBeforeRenderObserver;
  31871. /**
  31872. * A function that is added to the onBeforeRenderObservable
  31873. */
  31874. onBeforeRender: (effect: Effect) => void;
  31875. /**
  31876. * An event triggered after rendering the postprocess
  31877. */
  31878. onAfterRenderObservable: Observable<Effect>;
  31879. private _onAfterRenderObserver;
  31880. /**
  31881. * A function that is added to the onAfterRenderObservable
  31882. */
  31883. onAfterRender: (efect: Effect) => void;
  31884. /**
  31885. * 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
  31886. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  31887. */
  31888. inputTexture: InternalTexture;
  31889. /**
  31890. * Gets the camera which post process is applied to.
  31891. * @returns The camera the post process is applied to.
  31892. */
  31893. getCamera(): Camera;
  31894. /**
  31895. * Gets the texel size of the postprocess.
  31896. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  31897. */
  31898. readonly texelSize: Vector2;
  31899. /**
  31900. * Creates a new instance PostProcess
  31901. * @param name The name of the PostProcess.
  31902. * @param fragmentUrl The url of the fragment shader to be used.
  31903. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  31904. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  31905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  31906. * @param camera The camera to apply the render pass to.
  31907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31908. * @param engine The engine which the post process will be applied. (default: current engine)
  31909. * @param reusable If the post process can be reused on the same frame. (default: false)
  31910. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  31911. * @param textureType Type of textures used when performing the post process. (default: 0)
  31912. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  31913. * @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
  31914. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  31915. */
  31916. constructor(
  31917. /** Name of the PostProcess. */
  31918. 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);
  31919. /**
  31920. * Gets the engine which this post process belongs to.
  31921. * @returns The engine the post process was enabled with.
  31922. */
  31923. getEngine(): Engine;
  31924. /**
  31925. * The effect that is created when initializing the post process.
  31926. * @returns The created effect corrisponding the the postprocess.
  31927. */
  31928. getEffect(): Effect;
  31929. /**
  31930. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  31931. * @param postProcess The post process to share the output with.
  31932. * @returns This post process.
  31933. */
  31934. shareOutputWith(postProcess: PostProcess): PostProcess;
  31935. /**
  31936. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  31937. * This should be called if the post process that shares output with this post process is disabled/disposed.
  31938. */
  31939. useOwnOutput(): void;
  31940. /**
  31941. * Updates the effect with the current post process compile time values and recompiles the shader.
  31942. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  31943. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  31944. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  31945. * @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
  31946. * @param onCompiled Called when the shader has been compiled.
  31947. * @param onError Called if there is an error when compiling a shader.
  31948. */
  31949. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  31950. /**
  31951. * The post process is reusable if it can be used multiple times within one frame.
  31952. * @returns If the post process is reusable
  31953. */
  31954. isReusable(): boolean;
  31955. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  31956. markTextureDirty(): void;
  31957. /**
  31958. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  31959. * 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.
  31960. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  31961. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  31962. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  31963. * @returns The target texture that was bound to be written to.
  31964. */
  31965. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  31966. /**
  31967. * If the post process is supported.
  31968. */
  31969. readonly isSupported: boolean;
  31970. /**
  31971. * The aspect ratio of the output texture.
  31972. */
  31973. readonly aspectRatio: number;
  31974. /**
  31975. * Get a value indicating if the post-process is ready to be used
  31976. * @returns true if the post-process is ready (shader is compiled)
  31977. */
  31978. isReady(): boolean;
  31979. /**
  31980. * Binds all textures and uniforms to the shader, this will be run on every pass.
  31981. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  31982. */
  31983. apply(): Nullable<Effect>;
  31984. private _disposeTextures;
  31985. /**
  31986. * Disposes the post process.
  31987. * @param camera The camera to dispose the post process on.
  31988. */
  31989. dispose(camera?: Camera): void;
  31990. }
  31991. }
  31992. declare module BABYLON {
  31993. /**
  31994. * PostProcessManager is used to manage one or more post processes or post process pipelines
  31995. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  31996. */
  31997. class PostProcessManager {
  31998. private _scene;
  31999. private _indexBuffer;
  32000. private _vertexBuffers;
  32001. /**
  32002. * Creates a new instance PostProcess
  32003. * @param scene The scene that the post process is associated with.
  32004. */
  32005. constructor(scene: Scene);
  32006. private _prepareBuffers;
  32007. private _buildIndexBuffer;
  32008. /**
  32009. * Rebuilds the vertex buffers of the manager.
  32010. * @hidden
  32011. */
  32012. _rebuild(): void;
  32013. /**
  32014. * Prepares a frame to be run through a post process.
  32015. * @param sourceTexture The input texture to the post procesess. (default: null)
  32016. * @param postProcesses An array of post processes to be run. (default: null)
  32017. * @returns True if the post processes were able to be run.
  32018. * @hidden
  32019. */
  32020. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  32021. /**
  32022. * Manually render a set of post processes to a texture.
  32023. * @param postProcesses An array of post processes to be run.
  32024. * @param targetTexture The target texture to render to.
  32025. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  32026. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  32027. * @param lodLevel defines which lod of the texture to render to
  32028. */
  32029. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  32030. /**
  32031. * Finalize the result of the output of the postprocesses.
  32032. * @param doNotPresent If true the result will not be displayed to the screen.
  32033. * @param targetTexture The target texture to render to.
  32034. * @param faceIndex The index of the face to bind the target texture to.
  32035. * @param postProcesses The array of post processes to render.
  32036. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  32037. * @hidden
  32038. */
  32039. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  32040. /**
  32041. * Disposes of the post process manager.
  32042. */
  32043. dispose(): void;
  32044. }
  32045. }
  32046. declare module BABYLON {
  32047. class RefractionPostProcess extends PostProcess {
  32048. color: Color3;
  32049. depth: number;
  32050. colorLevel: number;
  32051. private _refTexture;
  32052. private _ownRefractionTexture;
  32053. /**
  32054. * Gets or sets the refraction texture
  32055. * Please note that you are responsible for disposing the texture if you set it manually
  32056. */
  32057. refractionTexture: Texture;
  32058. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  32059. dispose(camera: Camera): void;
  32060. }
  32061. }
  32062. declare module BABYLON {
  32063. /**
  32064. * The SharpenPostProcess applies a sharpen kernel to every pixel
  32065. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  32066. */
  32067. class SharpenPostProcess extends PostProcess {
  32068. /**
  32069. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  32070. */
  32071. colorAmount: number;
  32072. /**
  32073. * How much sharpness should be applied (default: 0.3)
  32074. */
  32075. edgeAmount: number;
  32076. /**
  32077. * Creates a new instance ConvolutionPostProcess
  32078. * @param name The name of the effect.
  32079. * @param options The required width/height ratio to downsize to before computing the render pass.
  32080. * @param camera The camera to apply the render pass to.
  32081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32082. * @param engine The engine which the post process will be applied. (default: current engine)
  32083. * @param reusable If the post process can be reused on the same frame. (default: false)
  32084. * @param textureType Type of textures used when performing the post process. (default: 0)
  32085. * @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)
  32086. */
  32087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  32088. }
  32089. }
  32090. declare module BABYLON {
  32091. class StereoscopicInterlacePostProcess extends PostProcess {
  32092. private _stepSize;
  32093. private _passedProcess;
  32094. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  32095. }
  32096. }
  32097. declare module BABYLON {
  32098. /** Defines operator used for tonemapping */
  32099. enum TonemappingOperator {
  32100. /** Hable */
  32101. Hable = 0,
  32102. /** Reinhard */
  32103. Reinhard = 1,
  32104. /** HejiDawson */
  32105. HejiDawson = 2,
  32106. /** Photographic */
  32107. Photographic = 3
  32108. }
  32109. /**
  32110. * Defines a post process to apply tone mapping
  32111. */
  32112. class TonemapPostProcess extends PostProcess {
  32113. private _operator;
  32114. /** Defines the required exposure adjustement */
  32115. exposureAdjustment: number;
  32116. /**
  32117. * Creates a new TonemapPostProcess
  32118. * @param name defines the name of the postprocess
  32119. * @param _operator defines the operator to use
  32120. * @param exposureAdjustment defines the required exposure adjustement
  32121. * @param camera defines the camera to use (can be null)
  32122. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  32123. * @param engine defines the hosting engine (can be ignore if camera is set)
  32124. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32125. */
  32126. constructor(name: string, _operator: TonemappingOperator,
  32127. /** Defines the required exposure adjustement */
  32128. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  32129. }
  32130. }
  32131. declare module BABYLON {
  32132. class VolumetricLightScatteringPostProcess extends PostProcess {
  32133. private _volumetricLightScatteringPass;
  32134. private _volumetricLightScatteringRTT;
  32135. private _viewPort;
  32136. private _screenCoordinates;
  32137. private _cachedDefines;
  32138. /**
  32139. * If not undefined, the mesh position is computed from the attached node position
  32140. */
  32141. attachedNode: {
  32142. position: Vector3;
  32143. };
  32144. /**
  32145. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  32146. */
  32147. customMeshPosition: Vector3;
  32148. /**
  32149. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  32150. */
  32151. useCustomMeshPosition: boolean;
  32152. /**
  32153. * If the post-process should inverse the light scattering direction
  32154. */
  32155. invert: boolean;
  32156. /**
  32157. * The internal mesh used by the post-process
  32158. */
  32159. mesh: Mesh;
  32160. useDiffuseColor: boolean;
  32161. /**
  32162. * Array containing the excluded meshes not rendered in the internal pass
  32163. */
  32164. excludedMeshes: AbstractMesh[];
  32165. /**
  32166. * Controls the overall intensity of the post-process
  32167. */
  32168. exposure: number;
  32169. /**
  32170. * Dissipates each sample's contribution in range [0, 1]
  32171. */
  32172. decay: number;
  32173. /**
  32174. * Controls the overall intensity of each sample
  32175. */
  32176. weight: number;
  32177. /**
  32178. * Controls the density of each sample
  32179. */
  32180. density: number;
  32181. /**
  32182. * @constructor
  32183. * @param {string} name - The post-process name
  32184. * @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)
  32185. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  32186. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  32187. * @param {number} samples - The post-process quality, default 100
  32188. * @param {number} samplingMode - The post-process filtering mode
  32189. * @param {BABYLON.Engine} engine - The babylon engine
  32190. * @param {boolean} reusable - If the post-process is reusable
  32191. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  32192. */
  32193. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  32194. getClassName(): string;
  32195. private _isReady;
  32196. /**
  32197. * Sets the new light position for light scattering effect
  32198. * @param {BABYLON.Vector3} The new custom light position
  32199. */
  32200. setCustomMeshPosition(position: Vector3): void;
  32201. /**
  32202. * Returns the light position for light scattering effect
  32203. * @return {BABYLON.Vector3} The custom light position
  32204. */
  32205. getCustomMeshPosition(): Vector3;
  32206. /**
  32207. * Disposes the internal assets and detaches the post-process from the camera
  32208. */
  32209. dispose(camera: Camera): void;
  32210. /**
  32211. * Returns the render target texture used by the post-process
  32212. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  32213. */
  32214. getPass(): RenderTargetTexture;
  32215. private _meshExcluded;
  32216. private _createPass;
  32217. private _updateMeshScreenCoordinates;
  32218. /**
  32219. * Creates a default mesh for the Volumeric Light Scattering post-process
  32220. * @param {string} The mesh name
  32221. * @param {BABYLON.Scene} The scene where to create the mesh
  32222. * @return {BABYLON.Mesh} the default mesh
  32223. */
  32224. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  32225. }
  32226. }
  32227. declare module BABYLON {
  32228. class VRDistortionCorrectionPostProcess extends PostProcess {
  32229. private _isRightEye;
  32230. private _distortionFactors;
  32231. private _postProcessScaleFactor;
  32232. private _lensCenterOffset;
  32233. private _scaleIn;
  32234. private _scaleFactor;
  32235. private _lensCenter;
  32236. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  32237. }
  32238. }
  32239. declare module BABYLON {
  32240. interface Scene {
  32241. /** @hidden (Backing field) */
  32242. _boundingBoxRenderer: BoundingBoxRenderer;
  32243. /** @hidden (Backing field) */
  32244. _forceShowBoundingBoxes: boolean;
  32245. /**
  32246. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  32247. */
  32248. forceShowBoundingBoxes: boolean;
  32249. /**
  32250. * Gets the bounding box renderer associated with the scene
  32251. * @returns a BoundingBoxRenderer
  32252. */
  32253. getBoundingBoxRenderer(): BoundingBoxRenderer;
  32254. }
  32255. interface AbstractMesh {
  32256. /** @hidden (Backing field) */
  32257. _showBoundingBox: boolean;
  32258. /**
  32259. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  32260. */
  32261. showBoundingBox: boolean;
  32262. }
  32263. /**
  32264. * Component responsible of rendering the bounding box of the meshes in a scene.
  32265. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  32266. */
  32267. class BoundingBoxRenderer implements ISceneComponent {
  32268. /**
  32269. * The component name helpfull to identify the component in the list of scene components.
  32270. */
  32271. readonly name: string;
  32272. /**
  32273. * The scene the component belongs to.
  32274. */
  32275. scene: Scene;
  32276. /**
  32277. * Color of the bounding box lines placed in front of an object
  32278. */
  32279. frontColor: Color3;
  32280. /**
  32281. * Color of the bounding box lines placed behind an object
  32282. */
  32283. backColor: Color3;
  32284. /**
  32285. * Defines if the renderer should show the back lines or not
  32286. */
  32287. showBackLines: boolean;
  32288. /**
  32289. * @hidden
  32290. */
  32291. renderList: SmartArray<BoundingBox>;
  32292. private _colorShader;
  32293. private _vertexBuffers;
  32294. private _indexBuffer;
  32295. /**
  32296. * Instantiates a new bounding box renderer in a scene.
  32297. * @param scene the scene the renderer renders in
  32298. */
  32299. constructor(scene: Scene);
  32300. /**
  32301. * Registers the component in a given scene
  32302. */
  32303. register(): void;
  32304. private _evaluateSubMesh;
  32305. private _activeMesh;
  32306. private _prepareRessources;
  32307. private _createIndexBuffer;
  32308. /**
  32309. * Rebuilds the elements related to this component in case of
  32310. * context lost for instance.
  32311. */
  32312. rebuild(): void;
  32313. /**
  32314. * @hidden
  32315. */
  32316. reset(): void;
  32317. /**
  32318. * Render the bounding boxes of a specific rendering group
  32319. * @param renderingGroupId defines the rendering group to render
  32320. */
  32321. render(renderingGroupId: number): void;
  32322. /**
  32323. * In case of occlusion queries, we can render the occlusion bounding box through this method
  32324. * @param mesh Define the mesh to render the occlusion bounding box for
  32325. */
  32326. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  32327. /**
  32328. * Dispose and release the resources attached to this renderer.
  32329. */
  32330. dispose(): void;
  32331. }
  32332. }
  32333. declare module BABYLON {
  32334. /**
  32335. * This represents a depth renderer in Babylon.
  32336. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  32337. */
  32338. class DepthRenderer {
  32339. private _scene;
  32340. private _depthMap;
  32341. private _effect;
  32342. private _cachedDefines;
  32343. private _camera;
  32344. /**
  32345. * Specifiess that the depth renderer will only be used within
  32346. * the camera it is created for.
  32347. * This can help forcing its rendering during the camera processing.
  32348. */
  32349. useOnlyInActiveCamera: boolean;
  32350. /**
  32351. * Instantiates a depth renderer
  32352. * @param scene The scene the renderer belongs to
  32353. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  32354. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  32355. */
  32356. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  32357. /**
  32358. * Creates the depth rendering effect and checks if the effect is ready.
  32359. * @param subMesh The submesh to be used to render the depth map of
  32360. * @param useInstances If multiple world instances should be used
  32361. * @returns if the depth renderer is ready to render the depth map
  32362. */
  32363. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32364. /**
  32365. * Gets the texture which the depth map will be written to.
  32366. * @returns The depth map texture
  32367. */
  32368. getDepthMap(): RenderTargetTexture;
  32369. /**
  32370. * Disposes of the depth renderer.
  32371. */
  32372. dispose(): void;
  32373. }
  32374. }
  32375. declare module BABYLON {
  32376. interface Scene {
  32377. /** @hidden (Backing field) */
  32378. _depthRenderer: {
  32379. [id: string]: DepthRenderer;
  32380. };
  32381. /**
  32382. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  32383. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  32384. * @returns the created depth renderer
  32385. */
  32386. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  32387. /**
  32388. * Disables a depth renderer for a given camera
  32389. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  32390. */
  32391. disableDepthRenderer(camera?: Nullable<Camera>): void;
  32392. }
  32393. /**
  32394. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  32395. * in several rendering techniques.
  32396. */
  32397. class DepthRendererSceneComponent implements ISceneComponent {
  32398. /**
  32399. * The component name helpfull to identify the component in the list of scene components.
  32400. */
  32401. readonly name: string;
  32402. /**
  32403. * The scene the component belongs to.
  32404. */
  32405. scene: Scene;
  32406. /**
  32407. * Creates a new instance of the component for the given scene
  32408. * @param scene Defines the scene to register the component in
  32409. */
  32410. constructor(scene: Scene);
  32411. /**
  32412. * Registers the component in a given scene
  32413. */
  32414. register(): void;
  32415. /**
  32416. * Rebuilds the elements related to this component in case of
  32417. * context lost for instance.
  32418. */
  32419. rebuild(): void;
  32420. /**
  32421. * Disposes the component and the associated ressources
  32422. */
  32423. dispose(): void;
  32424. private _gatherRenderTargets;
  32425. private _gatherActiveCameraRenderTargets;
  32426. }
  32427. }
  32428. declare module BABYLON {
  32429. interface AbstractMesh {
  32430. /**
  32431. * Disables the mesh edge rendering mode
  32432. * @returns the currentAbstractMesh
  32433. */
  32434. disableEdgesRendering(): AbstractMesh;
  32435. /**
  32436. * Enables the edge rendering mode on the mesh.
  32437. * This mode makes the mesh edges visible
  32438. * @param epsilon defines the maximal distance between two angles to detect a face
  32439. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32440. * @returns the currentAbstractMesh
  32441. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32442. */
  32443. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32444. /**
  32445. * Gets the edgesRenderer associated with the mesh
  32446. */
  32447. edgesRenderer: Nullable<EdgesRenderer>;
  32448. }
  32449. interface LinesMesh {
  32450. /**
  32451. * Enables the edge rendering mode on the mesh.
  32452. * This mode makes the mesh edges visible
  32453. * @param epsilon defines the maximal distance between two angles to detect a face
  32454. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32455. * @returns the currentAbstractMesh
  32456. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32457. */
  32458. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32459. }
  32460. /**
  32461. * Defines the minimum contract an Edges renderer should follow.
  32462. */
  32463. interface IEdgesRenderer extends IDisposable {
  32464. /**
  32465. * Gets or sets a boolean indicating if the edgesRenderer is active
  32466. */
  32467. isEnabled: boolean;
  32468. /**
  32469. * Renders the edges of the attached mesh,
  32470. */
  32471. render(): void;
  32472. /**
  32473. * Checks wether or not the edges renderer is ready to render.
  32474. * @return true if ready, otherwise false.
  32475. */
  32476. isReady(): boolean;
  32477. }
  32478. /**
  32479. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  32480. */
  32481. class EdgesRenderer implements IEdgesRenderer {
  32482. /**
  32483. * Define the size of the edges with an orthographic camera
  32484. */
  32485. edgesWidthScalerForOrthographic: number;
  32486. /**
  32487. * Define the size of the edges with a perspective camera
  32488. */
  32489. edgesWidthScalerForPerspective: number;
  32490. protected _source: AbstractMesh;
  32491. protected _linesPositions: number[];
  32492. protected _linesNormals: number[];
  32493. protected _linesIndices: number[];
  32494. protected _epsilon: number;
  32495. protected _indicesCount: number;
  32496. protected _lineShader: ShaderMaterial;
  32497. protected _ib: WebGLBuffer;
  32498. protected _buffers: {
  32499. [key: string]: Nullable<VertexBuffer>;
  32500. };
  32501. protected _checkVerticesInsteadOfIndices: boolean;
  32502. private _meshRebuildObserver;
  32503. private _meshDisposeObserver;
  32504. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  32505. isEnabled: boolean;
  32506. /**
  32507. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  32508. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  32509. * @param source Mesh used to create edges
  32510. * @param epsilon sum of angles in adjacency to check for edge
  32511. * @param checkVerticesInsteadOfIndices
  32512. * @param generateEdgesLines - should generate Lines or only prepare resources.
  32513. */
  32514. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  32515. protected _prepareRessources(): void;
  32516. /** @hidden */
  32517. _rebuild(): void;
  32518. /**
  32519. * Releases the required resources for the edges renderer
  32520. */
  32521. dispose(): void;
  32522. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  32523. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  32524. /**
  32525. * Checks if the pair of p0 and p1 is en edge
  32526. * @param faceIndex
  32527. * @param edge
  32528. * @param faceNormals
  32529. * @param p0
  32530. * @param p1
  32531. * @private
  32532. */
  32533. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  32534. /**
  32535. * Generates lines edges from adjacencjes
  32536. * @private
  32537. */
  32538. _generateEdgesLines(): void;
  32539. /**
  32540. * Checks wether or not the edges renderer is ready to render.
  32541. * @return true if ready, otherwise false.
  32542. */
  32543. isReady(): boolean;
  32544. /**
  32545. * Renders the edges of the attached mesh,
  32546. */
  32547. render(): void;
  32548. }
  32549. }
  32550. declare module BABYLON {
  32551. /**
  32552. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  32553. */
  32554. class GeometryBufferRenderer {
  32555. private _scene;
  32556. private _multiRenderTarget;
  32557. private _ratio;
  32558. private _enablePosition;
  32559. protected _effect: Effect;
  32560. protected _cachedDefines: string;
  32561. /**
  32562. * Set the render list (meshes to be rendered) used in the G buffer.
  32563. */
  32564. renderList: Mesh[];
  32565. /**
  32566. * Gets wether or not G buffer are supported by the running hardware.
  32567. * This requires draw buffer supports
  32568. */
  32569. readonly isSupported: boolean;
  32570. /**
  32571. * Gets wether or not position are enabled for the G buffer.
  32572. */
  32573. /**
  32574. * Sets wether or not position are enabled for the G buffer.
  32575. */
  32576. enablePosition: boolean;
  32577. /**
  32578. * Gets the scene associated with the buffer.
  32579. */
  32580. readonly scene: Scene;
  32581. /**
  32582. * Gets the ratio used by the buffer during its creation.
  32583. * How big is the buffer related to the main canvas.
  32584. */
  32585. readonly ratio: number;
  32586. /**
  32587. * Creates a new G Buffer for the scene
  32588. * @param scene The scene the buffer belongs to
  32589. * @param ratio How big is the buffer related to the main canvas.
  32590. */
  32591. constructor(scene: Scene, ratio?: number);
  32592. /**
  32593. * Checks wether everything is ready to render a submesh to the G buffer.
  32594. * @param subMesh the submesh to check readiness for
  32595. * @param useInstances is the mesh drawn using instance or not
  32596. * @returns true if ready otherwise false
  32597. */
  32598. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32599. /**
  32600. * Gets the current underlying G Buffer.
  32601. * @returns the buffer
  32602. */
  32603. getGBuffer(): MultiRenderTarget;
  32604. /**
  32605. * Gets the number of samples used to render the buffer (anti aliasing).
  32606. */
  32607. /**
  32608. * Sets the number of samples used to render the buffer (anti aliasing).
  32609. */
  32610. samples: number;
  32611. /**
  32612. * Disposes the renderer and frees up associated resources.
  32613. */
  32614. dispose(): void;
  32615. protected _createRenderTargets(): void;
  32616. }
  32617. }
  32618. declare module BABYLON {
  32619. interface Scene {
  32620. /** @hidden (Backing field) */
  32621. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  32622. /**
  32623. * Gets or Sets the current geometry buffer associated to the scene.
  32624. */
  32625. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  32626. /**
  32627. * Enables a GeometryBufferRender and associates it with the scene
  32628. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  32629. * @returns the GeometryBufferRenderer
  32630. */
  32631. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  32632. /**
  32633. * Disables the GeometryBufferRender associated with the scene
  32634. */
  32635. disableGeometryBufferRenderer(): void;
  32636. }
  32637. /**
  32638. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  32639. * in several rendering techniques.
  32640. */
  32641. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  32642. /**
  32643. * The component name helpful to identify the component in the list of scene components.
  32644. */
  32645. readonly name: string;
  32646. /**
  32647. * The scene the component belongs to.
  32648. */
  32649. scene: Scene;
  32650. /**
  32651. * Creates a new instance of the component for the given scene
  32652. * @param scene Defines the scene to register the component in
  32653. */
  32654. constructor(scene: Scene);
  32655. /**
  32656. * Registers the component in a given scene
  32657. */
  32658. register(): void;
  32659. /**
  32660. * Rebuilds the elements related to this component in case of
  32661. * context lost for instance.
  32662. */
  32663. rebuild(): void;
  32664. /**
  32665. * Disposes the component and the associated ressources
  32666. */
  32667. dispose(): void;
  32668. private _gatherRenderTargets;
  32669. }
  32670. }
  32671. declare module BABYLON {
  32672. /**
  32673. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  32674. */
  32675. class LineEdgesRenderer extends EdgesRenderer {
  32676. /**
  32677. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  32678. * @param source LineMesh used to generate edges
  32679. * @param epsilon not important (specified angle for edge detection)
  32680. * @param checkVerticesInsteadOfIndices not important for LineMesh
  32681. */
  32682. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  32683. /**
  32684. * Always create the edge since its a line so only important things are p0 and p1
  32685. * @param faceIndex not important for LineMesh
  32686. * @param edge not important for LineMesh
  32687. * @param faceNormals not important for LineMesh
  32688. * @param p0 beginnig of line
  32689. * @param p1 end of line
  32690. */
  32691. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  32692. /**
  32693. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  32694. */
  32695. _generateEdgesLines(): void;
  32696. }
  32697. }
  32698. declare module BABYLON {
  32699. interface Scene {
  32700. /** @hidden */
  32701. _outlineRenderer: OutlineRenderer;
  32702. /**
  32703. * Gets the outline renderer associated with the scene
  32704. * @returns a OutlineRenderer
  32705. */
  32706. getOutlineRenderer(): OutlineRenderer;
  32707. }
  32708. interface AbstractMesh {
  32709. /** @hidden (Backing field) */
  32710. _renderOutline: boolean;
  32711. /**
  32712. * Gets or sets a boolean indicating if the outline must be rendered as well
  32713. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  32714. */
  32715. renderOutline: boolean;
  32716. /** @hidden (Backing field) */
  32717. _renderOverlay: boolean;
  32718. /**
  32719. * Gets or sets a boolean indicating if the overlay must be rendered as well
  32720. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  32721. */
  32722. renderOverlay: boolean;
  32723. }
  32724. /**
  32725. * This class is responsible to draw bothe outline/overlay of meshes.
  32726. * It should not be used directly but through the available method on mesh.
  32727. */
  32728. class OutlineRenderer implements ISceneComponent {
  32729. /**
  32730. * The name of the component. Each component must have a unique name.
  32731. */
  32732. name: string;
  32733. /**
  32734. * The scene the component belongs to.
  32735. */
  32736. scene: Scene;
  32737. /**
  32738. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  32739. */
  32740. zOffset: number;
  32741. private _engine;
  32742. private _effect;
  32743. private _cachedDefines;
  32744. private _savedDepthWrite;
  32745. /**
  32746. * Instantiates a new outline renderer. (There could be only one per scene).
  32747. * @param scene Defines the scene it belongs to
  32748. */
  32749. constructor(scene: Scene);
  32750. /**
  32751. * Register the component to one instance of a scene.
  32752. */
  32753. register(): void;
  32754. /**
  32755. * Rebuilds the elements related to this component in case of
  32756. * context lost for instance.
  32757. */
  32758. rebuild(): void;
  32759. /**
  32760. * Disposes the component and the associated ressources.
  32761. */
  32762. dispose(): void;
  32763. /**
  32764. * Renders the outline in the canvas.
  32765. * @param subMesh Defines the sumesh to render
  32766. * @param batch Defines the batch of meshes in case of instances
  32767. * @param useOverlay Defines if the rendering is for the overlay or the outline
  32768. */
  32769. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  32770. /**
  32771. * Returns whether or not the outline renderer is ready for a given submesh.
  32772. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  32773. * @param subMesh Defines the submesh to check readyness for
  32774. * @param useInstances Defines wheter wee are trying to render instances or not
  32775. * @returns true if ready otherwise false
  32776. */
  32777. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32778. private _beforeRenderingMesh;
  32779. private _afterRenderingMesh;
  32780. }
  32781. }
  32782. declare module BABYLON {
  32783. /**
  32784. * This represents the object necessary to create a rendering group.
  32785. * This is exclusively used and created by the rendering manager.
  32786. * To modify the behavior, you use the available helpers in your scene or meshes.
  32787. * @hidden
  32788. */
  32789. class RenderingGroup {
  32790. index: number;
  32791. private _scene;
  32792. private _opaqueSubMeshes;
  32793. private _transparentSubMeshes;
  32794. private _alphaTestSubMeshes;
  32795. private _depthOnlySubMeshes;
  32796. private _particleSystems;
  32797. private _spriteManagers;
  32798. private _opaqueSortCompareFn;
  32799. private _alphaTestSortCompareFn;
  32800. private _transparentSortCompareFn;
  32801. private _renderOpaque;
  32802. private _renderAlphaTest;
  32803. private _renderTransparent;
  32804. private _edgesRenderers;
  32805. onBeforeTransparentRendering: () => void;
  32806. /**
  32807. * Set the opaque sort comparison function.
  32808. * If null the sub meshes will be render in the order they were created
  32809. */
  32810. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  32811. /**
  32812. * Set the alpha test sort comparison function.
  32813. * If null the sub meshes will be render in the order they were created
  32814. */
  32815. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  32816. /**
  32817. * Set the transparent sort comparison function.
  32818. * If null the sub meshes will be render in the order they were created
  32819. */
  32820. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  32821. /**
  32822. * Creates a new rendering group.
  32823. * @param index The rendering group index
  32824. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  32825. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  32826. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  32827. */
  32828. 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>);
  32829. /**
  32830. * Render all the sub meshes contained in the group.
  32831. * @param customRenderFunction Used to override the default render behaviour of the group.
  32832. * @returns true if rendered some submeshes.
  32833. */
  32834. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  32835. /**
  32836. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  32837. * @param subMeshes The submeshes to render
  32838. */
  32839. private renderOpaqueSorted;
  32840. /**
  32841. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  32842. * @param subMeshes The submeshes to render
  32843. */
  32844. private renderAlphaTestSorted;
  32845. /**
  32846. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  32847. * @param subMeshes The submeshes to render
  32848. */
  32849. private renderTransparentSorted;
  32850. /**
  32851. * Renders the submeshes in a specified order.
  32852. * @param subMeshes The submeshes to sort before render
  32853. * @param sortCompareFn The comparison function use to sort
  32854. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  32855. * @param transparent Specifies to activate blending if true
  32856. */
  32857. private static renderSorted;
  32858. /**
  32859. * Renders the submeshes in the order they were dispatched (no sort applied).
  32860. * @param subMeshes The submeshes to render
  32861. */
  32862. private static renderUnsorted;
  32863. /**
  32864. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  32865. * are rendered back to front if in the same alpha index.
  32866. *
  32867. * @param a The first submesh
  32868. * @param b The second submesh
  32869. * @returns The result of the comparison
  32870. */
  32871. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  32872. /**
  32873. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  32874. * are rendered back to front.
  32875. *
  32876. * @param a The first submesh
  32877. * @param b The second submesh
  32878. * @returns The result of the comparison
  32879. */
  32880. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  32881. /**
  32882. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  32883. * are rendered front to back (prevent overdraw).
  32884. *
  32885. * @param a The first submesh
  32886. * @param b The second submesh
  32887. * @returns The result of the comparison
  32888. */
  32889. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  32890. /**
  32891. * Resets the different lists of submeshes to prepare a new frame.
  32892. */
  32893. prepare(): void;
  32894. dispose(): void;
  32895. /**
  32896. * Inserts the submesh in its correct queue depending on its material.
  32897. * @param subMesh The submesh to dispatch
  32898. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  32899. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  32900. */
  32901. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  32902. dispatchSprites(spriteManager: ISpriteManager): void;
  32903. dispatchParticles(particleSystem: IParticleSystem): void;
  32904. private _renderParticles;
  32905. private _renderSprites;
  32906. }
  32907. }
  32908. declare module BABYLON {
  32909. /**
  32910. * Interface describing the different options available in the rendering manager
  32911. * regarding Auto Clear between groups.
  32912. */
  32913. interface IRenderingManagerAutoClearSetup {
  32914. /**
  32915. * Defines whether or not autoclear is enable.
  32916. */
  32917. autoClear: boolean;
  32918. /**
  32919. * Defines whether or not to autoclear the depth buffer.
  32920. */
  32921. depth: boolean;
  32922. /**
  32923. * Defines whether or not to autoclear the stencil buffer.
  32924. */
  32925. stencil: boolean;
  32926. }
  32927. /**
  32928. * This is the manager responsible of all the rendering for meshes sprites and particles.
  32929. * It is enable to manage the different groups as well as the different necessary sort functions.
  32930. * This should not be used directly aside of the few static configurations
  32931. */
  32932. class RenderingManager {
  32933. /**
  32934. * The max id used for rendering groups (not included)
  32935. */
  32936. static MAX_RENDERINGGROUPS: number;
  32937. /**
  32938. * The min id used for rendering groups (included)
  32939. */
  32940. static MIN_RENDERINGGROUPS: number;
  32941. /**
  32942. * Used to globally prevent autoclearing scenes.
  32943. */
  32944. static AUTOCLEAR: boolean;
  32945. /**
  32946. * @hidden
  32947. */
  32948. _useSceneAutoClearSetup: boolean;
  32949. private _scene;
  32950. private _renderingGroups;
  32951. private _depthStencilBufferAlreadyCleaned;
  32952. private _autoClearDepthStencil;
  32953. private _customOpaqueSortCompareFn;
  32954. private _customAlphaTestSortCompareFn;
  32955. private _customTransparentSortCompareFn;
  32956. private _renderingGroupInfo;
  32957. /**
  32958. * Instantiates a new rendering group for a particular scene
  32959. * @param scene Defines the scene the groups belongs to
  32960. */
  32961. constructor(scene: Scene);
  32962. private _clearDepthStencilBuffer;
  32963. /**
  32964. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  32965. * @hidden
  32966. */
  32967. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  32968. /**
  32969. * Resets the different information of the group to prepare a new frame
  32970. * @hidden
  32971. */
  32972. reset(): void;
  32973. /**
  32974. * Dispose and release the group and its associated resources.
  32975. * @hidden
  32976. */
  32977. dispose(): void;
  32978. /**
  32979. * Clear the info related to rendering groups preventing retention points during dispose.
  32980. */
  32981. freeRenderingGroups(): void;
  32982. private _prepareRenderingGroup;
  32983. /**
  32984. * Add a sprite manager to the rendering manager in order to render it this frame.
  32985. * @param spriteManager Define the sprite manager to render
  32986. */
  32987. dispatchSprites(spriteManager: ISpriteManager): void;
  32988. /**
  32989. * Add a particle system to the rendering manager in order to render it this frame.
  32990. * @param particleSystem Define the particle system to render
  32991. */
  32992. dispatchParticles(particleSystem: IParticleSystem): void;
  32993. /**
  32994. * Add a submesh to the manager in order to render it this frame
  32995. * @param subMesh The submesh to dispatch
  32996. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  32997. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  32998. */
  32999. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  33000. /**
  33001. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33002. * This allowed control for front to back rendering or reversly depending of the special needs.
  33003. *
  33004. * @param renderingGroupId The rendering group id corresponding to its index
  33005. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33006. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33007. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33008. */
  33009. 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;
  33010. /**
  33011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33012. *
  33013. * @param renderingGroupId The rendering group id corresponding to its index
  33014. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33015. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33016. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33017. */
  33018. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33019. /**
  33020. * Gets the current auto clear configuration for one rendering group of the rendering
  33021. * manager.
  33022. * @param index the rendering group index to get the information for
  33023. * @returns The auto clear setup for the requested rendering group
  33024. */
  33025. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33026. }
  33027. }
  33028. declare module BABYLON {
  33029. /**
  33030. * Renders a layer on top of an existing scene
  33031. */
  33032. class UtilityLayerRenderer implements IDisposable {
  33033. /** the original scene that will be rendered on top of */
  33034. originalScene: Scene;
  33035. private _pointerCaptures;
  33036. private _lastPointerEvents;
  33037. private static _DefaultUtilityLayer;
  33038. private static _DefaultKeepDepthUtilityLayer;
  33039. /**
  33040. * 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)
  33041. */
  33042. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  33043. /**
  33044. * 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)
  33045. */
  33046. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  33047. /**
  33048. * The scene that is rendered on top of the original scene
  33049. */
  33050. utilityLayerScene: Scene;
  33051. /**
  33052. * If the utility layer should automatically be rendered on top of existing scene
  33053. */
  33054. shouldRender: boolean;
  33055. /**
  33056. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  33057. */
  33058. onlyCheckPointerDownEvents: boolean;
  33059. /**
  33060. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  33061. */
  33062. processAllEvents: boolean;
  33063. /**
  33064. * Observable raised when the pointer move from the utility layer scene to the main scene
  33065. */
  33066. onPointerOutObservable: Observable<number>;
  33067. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  33068. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  33069. private _afterRenderObserver;
  33070. private _sceneDisposeObserver;
  33071. private _originalPointerObserver;
  33072. /**
  33073. * Instantiates a UtilityLayerRenderer
  33074. * @param originalScene the original scene that will be rendered on top of
  33075. */
  33076. constructor(
  33077. /** the original scene that will be rendered on top of */
  33078. originalScene: Scene);
  33079. private _notifyObservers;
  33080. /**
  33081. * Renders the utility layers scene on top of the original scene
  33082. */
  33083. render(): void;
  33084. /**
  33085. * Disposes of the renderer
  33086. */
  33087. dispose(): void;
  33088. private _updateCamera;
  33089. }
  33090. }
  33091. declare module BABYLON {
  33092. class Sprite {
  33093. name: string;
  33094. position: Vector3;
  33095. color: Color4;
  33096. width: number;
  33097. height: number;
  33098. angle: number;
  33099. cellIndex: number;
  33100. invertU: number;
  33101. invertV: number;
  33102. disposeWhenFinishedAnimating: boolean;
  33103. animations: Animation[];
  33104. isPickable: boolean;
  33105. actionManager: ActionManager;
  33106. private _animationStarted;
  33107. private _loopAnimation;
  33108. private _fromIndex;
  33109. private _toIndex;
  33110. private _delay;
  33111. private _direction;
  33112. private _manager;
  33113. private _time;
  33114. private _onAnimationEnd;
  33115. /**
  33116. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  33117. */
  33118. isVisible: boolean;
  33119. size: number;
  33120. constructor(name: string, manager: ISpriteManager);
  33121. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  33122. stopAnimation(): void;
  33123. /** @hidden */
  33124. _animate(deltaTime: number): void;
  33125. dispose(): void;
  33126. }
  33127. }
  33128. declare module BABYLON {
  33129. /**
  33130. * Defines the minimum interface to fullfil in order to be a sprite manager.
  33131. */
  33132. interface ISpriteManager extends IDisposable {
  33133. /**
  33134. * Restricts the camera to viewing objects with the same layerMask.
  33135. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  33136. */
  33137. layerMask: number;
  33138. /**
  33139. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33140. */
  33141. isPickable: boolean;
  33142. /**
  33143. * Specifies the rendering group id for this mesh (0 by default)
  33144. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33145. */
  33146. renderingGroupId: number;
  33147. /**
  33148. * Defines the list of sprites managed by the manager.
  33149. */
  33150. sprites: Array<Sprite>;
  33151. /**
  33152. * Tests the intersection of a sprite with a specific ray.
  33153. * @param ray The ray we are sending to test the collision
  33154. * @param camera The camera space we are sending rays in
  33155. * @param predicate A predicate allowing excluding sprites from the list of object to test
  33156. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  33157. * @returns picking info or null.
  33158. */
  33159. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33160. /**
  33161. * Renders the list of sprites on screen.
  33162. */
  33163. render(): void;
  33164. }
  33165. class SpriteManager implements ISpriteManager {
  33166. name: string;
  33167. sprites: Sprite[];
  33168. renderingGroupId: number;
  33169. layerMask: number;
  33170. fogEnabled: boolean;
  33171. isPickable: boolean;
  33172. cellWidth: number;
  33173. cellHeight: number;
  33174. /**
  33175. * An event triggered when the manager is disposed.
  33176. */
  33177. onDisposeObservable: Observable<SpriteManager>;
  33178. private _onDisposeObserver;
  33179. onDispose: () => void;
  33180. private _capacity;
  33181. private _spriteTexture;
  33182. private _epsilon;
  33183. private _scene;
  33184. private _vertexData;
  33185. private _buffer;
  33186. private _vertexBuffers;
  33187. private _indexBuffer;
  33188. private _effectBase;
  33189. private _effectFog;
  33190. texture: Texture;
  33191. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  33192. private _appendSpriteVertex;
  33193. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33194. render(): void;
  33195. dispose(): void;
  33196. }
  33197. }
  33198. declare module BABYLON {
  33199. interface Scene {
  33200. /** @hidden */
  33201. _pointerOverSprite: Nullable<Sprite>;
  33202. /** @hidden */
  33203. _pickedDownSprite: Nullable<Sprite>;
  33204. /** @hidden */
  33205. _tempSpritePickingRay: Nullable<Ray>;
  33206. /**
  33207. * All of the sprite managers added to this scene
  33208. * @see http://doc.babylonjs.com/babylon101/sprites
  33209. */
  33210. spriteManagers: Array<ISpriteManager>;
  33211. /**
  33212. * An event triggered when sprites rendering is about to start
  33213. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  33214. */
  33215. onBeforeSpritesRenderingObservable: Observable<Scene>;
  33216. /**
  33217. * An event triggered when sprites rendering is done
  33218. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  33219. */
  33220. onAfterSpritesRenderingObservable: Observable<Scene>;
  33221. /** @hidden */
  33222. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  33223. /** Launch a ray to try to pick a sprite in the scene
  33224. * @param x position on screen
  33225. * @param y position on screen
  33226. * @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
  33227. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33228. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33229. * @returns a PickingInfo
  33230. */
  33231. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  33232. /** Use the given ray to pick a sprite in the scene
  33233. * @param ray The ray (in world space) to use to pick meshes
  33234. * @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
  33235. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33236. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  33237. * @returns a PickingInfo
  33238. */
  33239. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  33240. /**
  33241. * Force the sprite under the pointer
  33242. * @param sprite defines the sprite to use
  33243. */
  33244. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  33245. /**
  33246. * Gets the sprite under the pointer
  33247. * @returns a Sprite or null if no sprite is under the pointer
  33248. */
  33249. getPointerOverSprite(): Nullable<Sprite>;
  33250. }
  33251. /**
  33252. * Defines the sprite scene component responsible to manage sprites
  33253. * in a given scene.
  33254. */
  33255. class SpriteSceneComponent implements ISceneComponent {
  33256. /**
  33257. * The component name helpfull to identify the component in the list of scene components.
  33258. */
  33259. readonly name: string;
  33260. /**
  33261. * The scene the component belongs to.
  33262. */
  33263. scene: Scene;
  33264. /** @hidden */
  33265. private _spritePredicate;
  33266. /**
  33267. * Creates a new instance of the component for the given scene
  33268. * @param scene Defines the scene to register the component in
  33269. */
  33270. constructor(scene: Scene);
  33271. /**
  33272. * Registers the component in a given scene
  33273. */
  33274. register(): void;
  33275. /**
  33276. * Rebuilds the elements related to this component in case of
  33277. * context lost for instance.
  33278. */
  33279. rebuild(): void;
  33280. /**
  33281. * Disposes the component and the associated ressources.
  33282. */
  33283. dispose(): void;
  33284. private _pickSpriteButKeepRay;
  33285. private _pointerMove;
  33286. private _pointerDown;
  33287. private _pointerUp;
  33288. }
  33289. }
  33290. declare module BABYLON {
  33291. /**
  33292. * @hidden
  33293. **/
  33294. class _AlphaState {
  33295. private _isAlphaBlendDirty;
  33296. private _isBlendFunctionParametersDirty;
  33297. private _isBlendEquationParametersDirty;
  33298. private _isBlendConstantsDirty;
  33299. private _alphaBlend;
  33300. private _blendFunctionParameters;
  33301. private _blendEquationParameters;
  33302. private _blendConstants;
  33303. /**
  33304. * Initializes the state.
  33305. */
  33306. constructor();
  33307. readonly isDirty: boolean;
  33308. alphaBlend: boolean;
  33309. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33310. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33311. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33312. reset(): void;
  33313. apply(gl: WebGLRenderingContext): void;
  33314. }
  33315. }
  33316. declare module BABYLON {
  33317. /**
  33318. * @hidden
  33319. **/
  33320. class _DepthCullingState {
  33321. private _isDepthTestDirty;
  33322. private _isDepthMaskDirty;
  33323. private _isDepthFuncDirty;
  33324. private _isCullFaceDirty;
  33325. private _isCullDirty;
  33326. private _isZOffsetDirty;
  33327. private _isFrontFaceDirty;
  33328. private _depthTest;
  33329. private _depthMask;
  33330. private _depthFunc;
  33331. private _cull;
  33332. private _cullFace;
  33333. private _zOffset;
  33334. private _frontFace;
  33335. /**
  33336. * Initializes the state.
  33337. */
  33338. constructor();
  33339. readonly isDirty: boolean;
  33340. zOffset: number;
  33341. cullFace: Nullable<number>;
  33342. cull: Nullable<boolean>;
  33343. depthFunc: Nullable<number>;
  33344. depthMask: boolean;
  33345. depthTest: boolean;
  33346. frontFace: Nullable<number>;
  33347. reset(): void;
  33348. apply(gl: WebGLRenderingContext): void;
  33349. }
  33350. }
  33351. declare module BABYLON {
  33352. /**
  33353. * @hidden
  33354. **/
  33355. class _StencilState {
  33356. private _isStencilTestDirty;
  33357. private _isStencilMaskDirty;
  33358. private _isStencilFuncDirty;
  33359. private _isStencilOpDirty;
  33360. private _stencilTest;
  33361. private _stencilMask;
  33362. private _stencilFunc;
  33363. private _stencilFuncRef;
  33364. private _stencilFuncMask;
  33365. private _stencilOpStencilFail;
  33366. private _stencilOpDepthFail;
  33367. private _stencilOpStencilDepthPass;
  33368. readonly isDirty: boolean;
  33369. stencilFunc: number;
  33370. stencilFuncRef: number;
  33371. stencilFuncMask: number;
  33372. stencilOpStencilFail: number;
  33373. stencilOpDepthFail: number;
  33374. stencilOpStencilDepthPass: number;
  33375. stencilMask: number;
  33376. stencilTest: boolean;
  33377. constructor();
  33378. reset(): void;
  33379. apply(gl: WebGLRenderingContext): void;
  33380. }
  33381. }
  33382. declare module BABYLON {
  33383. /**
  33384. * Class used to evalaute queries containing `and` and `or` operators
  33385. */
  33386. class AndOrNotEvaluator {
  33387. /**
  33388. * Evaluate a query
  33389. * @param query defines the query to evaluate
  33390. * @param evaluateCallback defines the callback used to filter result
  33391. * @returns true if the query matches
  33392. */
  33393. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  33394. private static _HandleParenthesisContent;
  33395. private static _SimplifyNegation;
  33396. }
  33397. }
  33398. declare module BABYLON {
  33399. /**
  33400. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  33401. */
  33402. enum AssetTaskState {
  33403. /**
  33404. * Initialization
  33405. */
  33406. INIT = 0,
  33407. /**
  33408. * Running
  33409. */
  33410. RUNNING = 1,
  33411. /**
  33412. * Done
  33413. */
  33414. DONE = 2,
  33415. /**
  33416. * Error
  33417. */
  33418. ERROR = 3
  33419. }
  33420. /**
  33421. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  33422. */
  33423. abstract class AbstractAssetTask {
  33424. /**
  33425. * Task name
  33426. */ name: string;
  33427. /**
  33428. * Callback called when the task is successful
  33429. */
  33430. onSuccess: (task: any) => void;
  33431. /**
  33432. * Callback called when the task is not successful
  33433. */
  33434. onError: (task: any, message?: string, exception?: any) => void;
  33435. /**
  33436. * Creates a new {BABYLON.AssetsManager}
  33437. * @param name defines the name of the task
  33438. */
  33439. constructor(
  33440. /**
  33441. * Task name
  33442. */ name: string);
  33443. private _isCompleted;
  33444. private _taskState;
  33445. private _errorObject;
  33446. /**
  33447. * Get if the task is completed
  33448. */
  33449. readonly isCompleted: boolean;
  33450. /**
  33451. * Gets the current state of the task
  33452. */
  33453. readonly taskState: AssetTaskState;
  33454. /**
  33455. * Gets the current error object (if task is in error)
  33456. */
  33457. readonly errorObject: {
  33458. message?: string;
  33459. exception?: any;
  33460. };
  33461. /**
  33462. * Internal only
  33463. * @hidden
  33464. */
  33465. _setErrorObject(message?: string, exception?: any): void;
  33466. /**
  33467. * Execute the current task
  33468. * @param scene defines the scene where you want your assets to be loaded
  33469. * @param onSuccess is a callback called when the task is successfully executed
  33470. * @param onError is a callback called if an error occurs
  33471. */
  33472. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33473. /**
  33474. * Execute the current task
  33475. * @param scene defines the scene where you want your assets to be loaded
  33476. * @param onSuccess is a callback called when the task is successfully executed
  33477. * @param onError is a callback called if an error occurs
  33478. */
  33479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33480. /**
  33481. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  33482. * This can be used with failed tasks that have the reason for failure fixed.
  33483. */
  33484. reset(): void;
  33485. private onErrorCallback;
  33486. private onDoneCallback;
  33487. }
  33488. /**
  33489. * Define the interface used by progress events raised during assets loading
  33490. */
  33491. interface IAssetsProgressEvent {
  33492. /**
  33493. * Defines the number of remaining tasks to process
  33494. */
  33495. remainingCount: number;
  33496. /**
  33497. * Defines the total number of tasks
  33498. */
  33499. totalCount: number;
  33500. /**
  33501. * Defines the task that was just processed
  33502. */
  33503. task: AbstractAssetTask;
  33504. }
  33505. /**
  33506. * Class used to share progress information about assets loading
  33507. */
  33508. class AssetsProgressEvent implements IAssetsProgressEvent {
  33509. /**
  33510. * Defines the number of remaining tasks to process
  33511. */
  33512. remainingCount: number;
  33513. /**
  33514. * Defines the total number of tasks
  33515. */
  33516. totalCount: number;
  33517. /**
  33518. * Defines the task that was just processed
  33519. */
  33520. task: AbstractAssetTask;
  33521. /**
  33522. * Creates a {BABYLON.AssetsProgressEvent}
  33523. * @param remainingCount defines the number of remaining tasks to process
  33524. * @param totalCount defines the total number of tasks
  33525. * @param task defines the task that was just processed
  33526. */
  33527. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  33528. }
  33529. /**
  33530. * Define a task used by {BABYLON.AssetsManager} to load meshes
  33531. */
  33532. class MeshAssetTask extends AbstractAssetTask {
  33533. /**
  33534. * Defines the name of the task
  33535. */
  33536. name: string;
  33537. /**
  33538. * Defines the list of mesh's names you want to load
  33539. */
  33540. meshesNames: any;
  33541. /**
  33542. * Defines the root url to use as a base to load your meshes and associated resources
  33543. */
  33544. rootUrl: string;
  33545. /**
  33546. * Defines the filename of the scene to load from
  33547. */
  33548. sceneFilename: string;
  33549. /**
  33550. * Gets the list of loaded meshes
  33551. */
  33552. loadedMeshes: Array<AbstractMesh>;
  33553. /**
  33554. * Gets the list of loaded particle systems
  33555. */
  33556. loadedParticleSystems: Array<IParticleSystem>;
  33557. /**
  33558. * Gets the list of loaded skeletons
  33559. */
  33560. loadedSkeletons: Array<Skeleton>;
  33561. /**
  33562. * Callback called when the task is successful
  33563. */
  33564. onSuccess: (task: MeshAssetTask) => void;
  33565. /**
  33566. * Callback called when the task is successful
  33567. */
  33568. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  33569. /**
  33570. * Creates a new {BABYLON.MeshAssetTask}
  33571. * @param name defines the name of the task
  33572. * @param meshesNames defines the list of mesh's names you want to load
  33573. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  33574. * @param sceneFilename defines the filename of the scene to load from
  33575. */
  33576. constructor(
  33577. /**
  33578. * Defines the name of the task
  33579. */
  33580. name: string,
  33581. /**
  33582. * Defines the list of mesh's names you want to load
  33583. */
  33584. meshesNames: any,
  33585. /**
  33586. * Defines the root url to use as a base to load your meshes and associated resources
  33587. */
  33588. rootUrl: string,
  33589. /**
  33590. * Defines the filename of the scene to load from
  33591. */
  33592. sceneFilename: string);
  33593. /**
  33594. * Execute the current task
  33595. * @param scene defines the scene where you want your assets to be loaded
  33596. * @param onSuccess is a callback called when the task is successfully executed
  33597. * @param onError is a callback called if an error occurs
  33598. */
  33599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33600. }
  33601. /**
  33602. * Define a task used by {BABYLON.AssetsManager} to load text content
  33603. */
  33604. class TextFileAssetTask extends AbstractAssetTask {
  33605. /**
  33606. * Defines the name of the task
  33607. */
  33608. name: string;
  33609. /**
  33610. * Defines the location of the file to load
  33611. */
  33612. url: string;
  33613. /**
  33614. * Gets the loaded text string
  33615. */
  33616. text: string;
  33617. /**
  33618. * Callback called when the task is successful
  33619. */
  33620. onSuccess: (task: TextFileAssetTask) => void;
  33621. /**
  33622. * Callback called when the task is successful
  33623. */
  33624. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  33625. /**
  33626. * Creates a new TextFileAssetTask object
  33627. * @param name defines the name of the task
  33628. * @param url defines the location of the file to load
  33629. */
  33630. constructor(
  33631. /**
  33632. * Defines the name of the task
  33633. */
  33634. name: string,
  33635. /**
  33636. * Defines the location of the file to load
  33637. */
  33638. url: string);
  33639. /**
  33640. * Execute the current task
  33641. * @param scene defines the scene where you want your assets to be loaded
  33642. * @param onSuccess is a callback called when the task is successfully executed
  33643. * @param onError is a callback called if an error occurs
  33644. */
  33645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33646. }
  33647. /**
  33648. * Define a task used by {BABYLON.AssetsManager} to load binary data
  33649. */
  33650. class BinaryFileAssetTask extends AbstractAssetTask {
  33651. /**
  33652. * Defines the name of the task
  33653. */
  33654. name: string;
  33655. /**
  33656. * Defines the location of the file to load
  33657. */
  33658. url: string;
  33659. /**
  33660. * Gets the lodaded data (as an array buffer)
  33661. */
  33662. data: ArrayBuffer;
  33663. /**
  33664. * Callback called when the task is successful
  33665. */
  33666. onSuccess: (task: BinaryFileAssetTask) => void;
  33667. /**
  33668. * Callback called when the task is successful
  33669. */
  33670. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  33671. /**
  33672. * Creates a new BinaryFileAssetTask object
  33673. * @param name defines the name of the new task
  33674. * @param url defines the location of the file to load
  33675. */
  33676. constructor(
  33677. /**
  33678. * Defines the name of the task
  33679. */
  33680. name: string,
  33681. /**
  33682. * Defines the location of the file to load
  33683. */
  33684. url: string);
  33685. /**
  33686. * Execute the current task
  33687. * @param scene defines the scene where you want your assets to be loaded
  33688. * @param onSuccess is a callback called when the task is successfully executed
  33689. * @param onError is a callback called if an error occurs
  33690. */
  33691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33692. }
  33693. /**
  33694. * Define a task used by {BABYLON.AssetsManager} to load images
  33695. */
  33696. class ImageAssetTask extends AbstractAssetTask {
  33697. /**
  33698. * Defines the name of the task
  33699. */
  33700. name: string;
  33701. /**
  33702. * Defines the location of the image to load
  33703. */
  33704. url: string;
  33705. /**
  33706. * Gets the loaded images
  33707. */
  33708. image: HTMLImageElement;
  33709. /**
  33710. * Callback called when the task is successful
  33711. */
  33712. onSuccess: (task: ImageAssetTask) => void;
  33713. /**
  33714. * Callback called when the task is successful
  33715. */
  33716. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  33717. /**
  33718. * Creates a new ImageAssetTask
  33719. * @param name defines the name of the task
  33720. * @param url defines the location of the image to load
  33721. */
  33722. constructor(
  33723. /**
  33724. * Defines the name of the task
  33725. */
  33726. name: string,
  33727. /**
  33728. * Defines the location of the image to load
  33729. */
  33730. url: string);
  33731. /**
  33732. * Execute the current task
  33733. * @param scene defines the scene where you want your assets to be loaded
  33734. * @param onSuccess is a callback called when the task is successfully executed
  33735. * @param onError is a callback called if an error occurs
  33736. */
  33737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33738. }
  33739. /**
  33740. * Defines the interface used by texture loading tasks
  33741. */
  33742. interface ITextureAssetTask<TEX extends BaseTexture> {
  33743. /**
  33744. * Gets the loaded texture
  33745. */
  33746. texture: TEX;
  33747. }
  33748. /**
  33749. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  33750. */
  33751. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  33752. /**
  33753. * Defines the name of the task
  33754. */
  33755. name: string;
  33756. /**
  33757. * Defines the location of the file to load
  33758. */
  33759. url: string;
  33760. /**
  33761. * Defines if mipmap should not be generated (default is false)
  33762. */
  33763. noMipmap?: boolean | undefined;
  33764. /**
  33765. * Defines if texture must be inverted on Y axis (default is false)
  33766. */
  33767. invertY?: boolean | undefined;
  33768. /**
  33769. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33770. */
  33771. samplingMode: number;
  33772. /**
  33773. * Gets the loaded texture
  33774. */
  33775. texture: Texture;
  33776. /**
  33777. * Callback called when the task is successful
  33778. */
  33779. onSuccess: (task: TextureAssetTask) => void;
  33780. /**
  33781. * Callback called when the task is successful
  33782. */
  33783. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  33784. /**
  33785. * Creates a new TextureAssetTask object
  33786. * @param name defines the name of the task
  33787. * @param url defines the location of the file to load
  33788. * @param noMipmap defines if mipmap should not be generated (default is false)
  33789. * @param invertY defines if texture must be inverted on Y axis (default is false)
  33790. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33791. */
  33792. constructor(
  33793. /**
  33794. * Defines the name of the task
  33795. */
  33796. name: string,
  33797. /**
  33798. * Defines the location of the file to load
  33799. */
  33800. url: string,
  33801. /**
  33802. * Defines if mipmap should not be generated (default is false)
  33803. */
  33804. noMipmap?: boolean | undefined,
  33805. /**
  33806. * Defines if texture must be inverted on Y axis (default is false)
  33807. */
  33808. invertY?: boolean | undefined,
  33809. /**
  33810. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33811. */
  33812. samplingMode?: number);
  33813. /**
  33814. * Execute the current task
  33815. * @param scene defines the scene where you want your assets to be loaded
  33816. * @param onSuccess is a callback called when the task is successfully executed
  33817. * @param onError is a callback called if an error occurs
  33818. */
  33819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33820. }
  33821. /**
  33822. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  33823. */
  33824. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  33825. /**
  33826. * Defines the name of the task
  33827. */
  33828. name: string;
  33829. /**
  33830. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  33831. */
  33832. url: string;
  33833. /**
  33834. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  33835. */
  33836. extensions?: string[] | undefined;
  33837. /**
  33838. * Defines if mipmaps should not be generated (default is false)
  33839. */
  33840. noMipmap?: boolean | undefined;
  33841. /**
  33842. * Defines the explicit list of files (undefined by default)
  33843. */
  33844. files?: string[] | undefined;
  33845. /**
  33846. * Gets the loaded texture
  33847. */
  33848. texture: CubeTexture;
  33849. /**
  33850. * Callback called when the task is successful
  33851. */
  33852. onSuccess: (task: CubeTextureAssetTask) => void;
  33853. /**
  33854. * Callback called when the task is successful
  33855. */
  33856. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  33857. /**
  33858. * Creates a new CubeTextureAssetTask
  33859. * @param name defines the name of the task
  33860. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  33861. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  33862. * @param noMipmap defines if mipmaps should not be generated (default is false)
  33863. * @param files defines the explicit list of files (undefined by default)
  33864. */
  33865. constructor(
  33866. /**
  33867. * Defines the name of the task
  33868. */
  33869. name: string,
  33870. /**
  33871. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  33872. */
  33873. url: string,
  33874. /**
  33875. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  33876. */
  33877. extensions?: string[] | undefined,
  33878. /**
  33879. * Defines if mipmaps should not be generated (default is false)
  33880. */
  33881. noMipmap?: boolean | undefined,
  33882. /**
  33883. * Defines the explicit list of files (undefined by default)
  33884. */
  33885. files?: string[] | undefined);
  33886. /**
  33887. * Execute the current task
  33888. * @param scene defines the scene where you want your assets to be loaded
  33889. * @param onSuccess is a callback called when the task is successfully executed
  33890. * @param onError is a callback called if an error occurs
  33891. */
  33892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33893. }
  33894. /**
  33895. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  33896. */
  33897. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  33898. /**
  33899. * Defines the name of the task
  33900. */
  33901. name: string;
  33902. /**
  33903. * Defines the location of the file to load
  33904. */
  33905. url: string;
  33906. /**
  33907. * Defines the desired size (the more it increases the longer the generation will be)
  33908. */
  33909. size: number;
  33910. /**
  33911. * Defines if mipmaps should not be generated (default is false)
  33912. */
  33913. noMipmap: boolean;
  33914. /**
  33915. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  33916. */
  33917. generateHarmonics: boolean;
  33918. /**
  33919. * 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)
  33920. */
  33921. gammaSpace: boolean;
  33922. /**
  33923. * Internal Use Only
  33924. */
  33925. reserved: boolean;
  33926. /**
  33927. * Gets the loaded texture
  33928. */
  33929. texture: HDRCubeTexture;
  33930. /**
  33931. * Callback called when the task is successful
  33932. */
  33933. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  33934. /**
  33935. * Callback called when the task is successful
  33936. */
  33937. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  33938. /**
  33939. * Creates a new HDRCubeTextureAssetTask object
  33940. * @param name defines the name of the task
  33941. * @param url defines the location of the file to load
  33942. * @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.
  33943. * @param noMipmap defines if mipmaps should not be generated (default is false)
  33944. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  33945. * @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)
  33946. * @param reserved Internal use only
  33947. */
  33948. constructor(
  33949. /**
  33950. * Defines the name of the task
  33951. */
  33952. name: string,
  33953. /**
  33954. * Defines the location of the file to load
  33955. */
  33956. url: string,
  33957. /**
  33958. * Defines the desired size (the more it increases the longer the generation will be)
  33959. */
  33960. size: number,
  33961. /**
  33962. * Defines if mipmaps should not be generated (default is false)
  33963. */
  33964. noMipmap?: boolean,
  33965. /**
  33966. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  33967. */
  33968. generateHarmonics?: boolean,
  33969. /**
  33970. * 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)
  33971. */
  33972. gammaSpace?: boolean,
  33973. /**
  33974. * Internal Use Only
  33975. */
  33976. reserved?: boolean);
  33977. /**
  33978. * Execute the current task
  33979. * @param scene defines the scene where you want your assets to be loaded
  33980. * @param onSuccess is a callback called when the task is successfully executed
  33981. * @param onError is a callback called if an error occurs
  33982. */
  33983. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33984. }
  33985. /**
  33986. * This class can be used to easily import assets into a scene
  33987. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  33988. */
  33989. class AssetsManager {
  33990. private _scene;
  33991. private _isLoading;
  33992. protected _tasks: AbstractAssetTask[];
  33993. protected _waitingTasksCount: number;
  33994. protected _totalTasksCount: number;
  33995. /**
  33996. * Callback called when all tasks are processed
  33997. */
  33998. onFinish: (tasks: AbstractAssetTask[]) => void;
  33999. /**
  34000. * Callback called when a task is successful
  34001. */
  34002. onTaskSuccess: (task: AbstractAssetTask) => void;
  34003. /**
  34004. * Callback called when a task had an error
  34005. */
  34006. onTaskError: (task: AbstractAssetTask) => void;
  34007. /**
  34008. * Callback called when a task is done (whatever the result is)
  34009. */
  34010. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  34011. /**
  34012. * Observable called when all tasks are processed
  34013. */
  34014. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  34015. /**
  34016. * Observable called when a task had an error
  34017. */
  34018. onTaskErrorObservable: Observable<AbstractAssetTask>;
  34019. /**
  34020. * Observable called when a task is successful
  34021. */
  34022. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  34023. /**
  34024. * Observable called when a task is done (whatever the result is)
  34025. */
  34026. onProgressObservable: Observable<IAssetsProgressEvent>;
  34027. /**
  34028. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  34029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34030. */
  34031. useDefaultLoadingScreen: boolean;
  34032. /**
  34033. * Creates a new AssetsManager
  34034. * @param scene defines the scene to work on
  34035. */
  34036. constructor(scene: Scene);
  34037. /**
  34038. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  34039. * @param taskName defines the name of the new task
  34040. * @param meshesNames defines the name of meshes to load
  34041. * @param rootUrl defines the root url to use to locate files
  34042. * @param sceneFilename defines the filename of the scene file
  34043. * @returns a new {BABYLON.MeshAssetTask} object
  34044. */
  34045. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  34046. /**
  34047. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  34048. * @param taskName defines the name of the new task
  34049. * @param url defines the url of the file to load
  34050. * @returns a new {BABYLON.TextFileAssetTask} object
  34051. */
  34052. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  34053. /**
  34054. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  34055. * @param taskName defines the name of the new task
  34056. * @param url defines the url of the file to load
  34057. * @returns a new {BABYLON.BinaryFileAssetTask} object
  34058. */
  34059. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  34060. /**
  34061. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  34062. * @param taskName defines the name of the new task
  34063. * @param url defines the url of the file to load
  34064. * @returns a new {BABYLON.ImageAssetTask} object
  34065. */
  34066. addImageTask(taskName: string, url: string): ImageAssetTask;
  34067. /**
  34068. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  34069. * @param taskName defines the name of the new task
  34070. * @param url defines the url of the file to load
  34071. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  34072. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  34073. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  34074. * @returns a new {BABYLON.TextureAssetTask} object
  34075. */
  34076. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  34077. /**
  34078. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  34079. * @param taskName defines the name of the new task
  34080. * @param url defines the url of the file to load
  34081. * @param extensions defines the extension to use to load the cube map (can be null)
  34082. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  34083. * @param files defines the list of files to load (can be null)
  34084. * @returns a new {BABYLON.CubeTextureAssetTask} object
  34085. */
  34086. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  34087. /**
  34088. *
  34089. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  34090. * @param taskName defines the name of the new task
  34091. * @param url defines the url of the file to load
  34092. * @param size defines the size you want for the cubemap (can be null)
  34093. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  34094. * @param generateHarmonics defines if you want to automatically generate (true by default)
  34095. * @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)
  34096. * @param reserved Internal use only
  34097. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  34098. */
  34099. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  34100. /**
  34101. * Remove a task from the assets manager.
  34102. * @param task the task to remove
  34103. */
  34104. removeTask(task: AbstractAssetTask): void;
  34105. private _decreaseWaitingTasksCount;
  34106. private _runTask;
  34107. /**
  34108. * Reset the {BABYLON.AssetsManager} and remove all tasks
  34109. * @return the current instance of the {BABYLON.AssetsManager}
  34110. */
  34111. reset(): AssetsManager;
  34112. /**
  34113. * Start the loading process
  34114. * @return the current instance of the {BABYLON.AssetsManager}
  34115. */
  34116. load(): AssetsManager;
  34117. }
  34118. }
  34119. declare module BABYLON {
  34120. /**
  34121. * Class used to enable access to IndexedDB
  34122. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  34123. */
  34124. class Database {
  34125. private callbackManifestChecked;
  34126. private currentSceneUrl;
  34127. private db;
  34128. private _enableSceneOffline;
  34129. private _enableTexturesOffline;
  34130. private manifestVersionFound;
  34131. private mustUpdateRessources;
  34132. private hasReachedQuota;
  34133. private isSupported;
  34134. private idbFactory;
  34135. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  34136. static IsUASupportingBlobStorage: boolean;
  34137. /** Gets a boolean indicating if Database storate is enabled */
  34138. static IDBStorageEnabled: boolean;
  34139. /**
  34140. * Gets a boolean indicating if scene must be saved in the database
  34141. */
  34142. readonly enableSceneOffline: boolean;
  34143. /**
  34144. * Gets a boolean indicating if textures must be saved in the database
  34145. */
  34146. readonly enableTexturesOffline: boolean;
  34147. /**
  34148. * Creates a new Database
  34149. * @param urlToScene defines the url to load the scene
  34150. * @param callbackManifestChecked defines the callback to use when manifest is checked
  34151. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  34152. */
  34153. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  34154. private static _ParseURL;
  34155. private static _ReturnFullUrlLocation;
  34156. private _checkManifestFile;
  34157. /**
  34158. * Open the database and make it available
  34159. * @param successCallback defines the callback to call on success
  34160. * @param errorCallback defines the callback to call on error
  34161. */
  34162. openAsync(successCallback: () => void, errorCallback: () => void): void;
  34163. /**
  34164. * Loads an image from the database
  34165. * @param url defines the url to load from
  34166. * @param image defines the target DOM image
  34167. */
  34168. loadImageFromDB(url: string, image: HTMLImageElement): void;
  34169. private _loadImageFromDBAsync;
  34170. private _saveImageIntoDBAsync;
  34171. private _checkVersionFromDB;
  34172. private _loadVersionFromDBAsync;
  34173. private _saveVersionIntoDBAsync;
  34174. /**
  34175. * Loads a file from database
  34176. * @param url defines the URL to load from
  34177. * @param sceneLoaded defines a callback to call on success
  34178. * @param progressCallBack defines a callback to call when progress changed
  34179. * @param errorCallback defines a callback to call on error
  34180. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  34181. */
  34182. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  34183. private _loadFileFromDBAsync;
  34184. private _saveFileIntoDBAsync;
  34185. }
  34186. }
  34187. declare module BABYLON {
  34188. interface DDSInfo {
  34189. width: number;
  34190. height: number;
  34191. mipmapCount: number;
  34192. isFourCC: boolean;
  34193. isRGB: boolean;
  34194. isLuminance: boolean;
  34195. isCube: boolean;
  34196. isCompressed: boolean;
  34197. dxgiFormat: number;
  34198. textureType: number;
  34199. /** Sphericle polynomial created for the dds texture */
  34200. sphericalPolynomial?: SphericalPolynomial;
  34201. }
  34202. class DDSTools {
  34203. static StoreLODInAlphaChannel: boolean;
  34204. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  34205. private static _FloatView;
  34206. private static _Int32View;
  34207. private static _ToHalfFloat;
  34208. private static _FromHalfFloat;
  34209. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  34210. private static _GetHalfFloatRGBAArrayBuffer;
  34211. private static _GetFloatRGBAArrayBuffer;
  34212. private static _GetFloatAsUIntRGBAArrayBuffer;
  34213. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  34214. private static _GetRGBAArrayBuffer;
  34215. private static _ExtractLongWordOrder;
  34216. private static _GetRGBArrayBuffer;
  34217. private static _GetLuminanceArrayBuffer;
  34218. /**
  34219. * Uploads DDS Levels to a Babylon Texture
  34220. * @hidden
  34221. */
  34222. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  34223. }
  34224. }
  34225. declare module BABYLON {
  34226. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34227. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34228. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34229. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34230. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34231. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34232. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34233. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34234. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34235. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34236. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34237. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34238. /**
  34239. * Decorator used to define property that can be serialized as reference to a camera
  34240. * @param sourceName defines the name of the property to decorate
  34241. */
  34242. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34243. class SerializationHelper {
  34244. static Serialize<T>(entity: T, serializationObject?: any): any;
  34245. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34246. static Clone<T>(creationFunction: () => T, source: T): T;
  34247. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34248. }
  34249. }
  34250. declare module BABYLON {
  34251. /**
  34252. * Wrapper class for promise with external resolve and reject.
  34253. */
  34254. class Deferred<T> {
  34255. /**
  34256. * The promise associated with this deferred object.
  34257. */
  34258. readonly promise: Promise<T>;
  34259. private _resolve;
  34260. private _reject;
  34261. /**
  34262. * The resolve method of the promise associated with this deferred object.
  34263. */
  34264. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  34265. /**
  34266. * The reject method of the promise associated with this deferred object.
  34267. */
  34268. readonly reject: (reason?: any) => void;
  34269. /**
  34270. * Constructor for this deferred object.
  34271. */
  34272. constructor();
  34273. }
  34274. }
  34275. declare module BABYLON {
  34276. /**
  34277. * Raw texture data and descriptor sufficient for WebGL texture upload
  34278. */
  34279. interface EnvironmentTextureInfo {
  34280. /**
  34281. * Version of the environment map
  34282. */
  34283. version: number;
  34284. /**
  34285. * Width of image
  34286. */
  34287. width: number;
  34288. /**
  34289. * Irradiance information stored in the file.
  34290. */
  34291. irradiance: any;
  34292. /**
  34293. * Specular information stored in the file.
  34294. */
  34295. specular: any;
  34296. }
  34297. /**
  34298. * Sets of helpers addressing the serialization and deserialization of environment texture
  34299. * stored in a BabylonJS env file.
  34300. * Those files are usually stored as .env files.
  34301. */
  34302. class EnvironmentTextureTools {
  34303. /**
  34304. * Magic number identifying the env file.
  34305. */
  34306. private static _MagicBytes;
  34307. /**
  34308. * Gets the environment info from an env file.
  34309. * @param data The array buffer containing the .env bytes.
  34310. * @returns the environment file info (the json header) if successfully parsed.
  34311. */
  34312. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  34313. /**
  34314. * Creates an environment texture from a loaded cube texture.
  34315. * @param texture defines the cube texture to convert in env file
  34316. * @return a promise containing the environment data if succesfull.
  34317. */
  34318. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  34319. /**
  34320. * Creates a JSON representation of the spherical data.
  34321. * @param texture defines the texture containing the polynomials
  34322. * @return the JSON representation of the spherical info
  34323. */
  34324. private static _CreateEnvTextureIrradiance;
  34325. /**
  34326. * Uploads the texture info contained in the env file to the GPU.
  34327. * @param texture defines the internal texture to upload to
  34328. * @param arrayBuffer defines the buffer cotaining the data to load
  34329. * @param info defines the texture info retrieved through the GetEnvInfo method
  34330. * @returns a promise
  34331. */
  34332. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  34333. /**
  34334. * Uploads the levels of image data to the GPU.
  34335. * @param texture defines the internal texture to upload to
  34336. * @param imageData defines the array buffer views of image data [mipmap][face]
  34337. * @returns a promise
  34338. */
  34339. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  34340. /**
  34341. * Uploads spherical polynomials information to the texture.
  34342. * @param texture defines the texture we are trying to upload the information to
  34343. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  34344. */
  34345. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  34346. }
  34347. }
  34348. declare module BABYLON {
  34349. class FilesInput {
  34350. static FilesToLoad: {
  34351. [key: string]: File;
  34352. };
  34353. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  34354. private _engine;
  34355. private _currentScene;
  34356. private _sceneLoadedCallback;
  34357. private _progressCallback;
  34358. private _additionalRenderLoopLogicCallback;
  34359. private _textureLoadingCallback;
  34360. private _startingProcessingFilesCallback;
  34361. private _onReloadCallback;
  34362. private _errorCallback;
  34363. private _elementToMonitor;
  34364. private _sceneFileToLoad;
  34365. private _filesToLoad;
  34366. 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);
  34367. private _dragEnterHandler;
  34368. private _dragOverHandler;
  34369. private _dropHandler;
  34370. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  34371. dispose(): void;
  34372. private renderFunction;
  34373. private drag;
  34374. private drop;
  34375. private _traverseFolder;
  34376. private _processFiles;
  34377. loadFiles(event: any): void;
  34378. private _processReload;
  34379. reload(): void;
  34380. }
  34381. }
  34382. declare module BABYLON {
  34383. /**
  34384. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34385. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34386. */
  34387. class KhronosTextureContainer {
  34388. arrayBuffer: any;
  34389. static HEADER_LEN: number;
  34390. static COMPRESSED_2D: number;
  34391. static COMPRESSED_3D: number;
  34392. static TEX_2D: number;
  34393. static TEX_3D: number;
  34394. glType: number;
  34395. glTypeSize: number;
  34396. glFormat: number;
  34397. glInternalFormat: number;
  34398. glBaseInternalFormat: number;
  34399. pixelWidth: number;
  34400. pixelHeight: number;
  34401. pixelDepth: number;
  34402. numberOfArrayElements: number;
  34403. numberOfFaces: number;
  34404. numberOfMipmapLevels: number;
  34405. bytesOfKeyValueData: number;
  34406. loadType: number;
  34407. /**
  34408. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  34409. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  34410. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  34411. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  34412. */
  34413. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  34414. switchEndainness(val: number): number;
  34415. /**
  34416. * Uploads KTX content to a Babylon Texture.
  34417. * It is assumed that the texture has already been created & is currently bound
  34418. * @hidden
  34419. */
  34420. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  34421. private _upload2DCompressedLevels;
  34422. }
  34423. }
  34424. declare module BABYLON {
  34425. /**
  34426. * A class serves as a medium between the observable and its observers
  34427. */
  34428. class EventState {
  34429. /**
  34430. * Create a new EventState
  34431. * @param mask defines the mask associated with this state
  34432. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  34433. * @param target defines the original target of the state
  34434. * @param currentTarget defines the current target of the state
  34435. */
  34436. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  34437. /**
  34438. * Initialize the current event state
  34439. * @param mask defines the mask associated with this state
  34440. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  34441. * @param target defines the original target of the state
  34442. * @param currentTarget defines the current target of the state
  34443. * @returns the current event state
  34444. */
  34445. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  34446. /**
  34447. * An Observer can set this property to true to prevent subsequent observers of being notified
  34448. */
  34449. skipNextObservers: boolean;
  34450. /**
  34451. * Get the mask value that were used to trigger the event corresponding to this EventState object
  34452. */
  34453. mask: number;
  34454. /**
  34455. * The object that originally notified the event
  34456. */
  34457. target?: any;
  34458. /**
  34459. * The current object in the bubbling phase
  34460. */
  34461. currentTarget?: any;
  34462. /**
  34463. * This will be populated with the return value of the last function that was executed.
  34464. * If it is the first function in the callback chain it will be the event data.
  34465. */
  34466. lastReturnValue?: any;
  34467. }
  34468. /**
  34469. * Represent an Observer registered to a given Observable object.
  34470. */
  34471. class Observer<T> {
  34472. /**
  34473. * Defines the callback to call when the observer is notified
  34474. */
  34475. callback: (eventData: T, eventState: EventState) => void;
  34476. /**
  34477. * Defines the mask of the observer (used to filter notifications)
  34478. */
  34479. mask: number;
  34480. /**
  34481. * Defines the current scope used to restore the JS context
  34482. */
  34483. scope: any;
  34484. /** @hidden */
  34485. _willBeUnregistered: boolean;
  34486. /**
  34487. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  34488. */
  34489. unregisterOnNextCall: boolean;
  34490. /**
  34491. * Creates a new observer
  34492. * @param callback defines the callback to call when the observer is notified
  34493. * @param mask defines the mask of the observer (used to filter notifications)
  34494. * @param scope defines the current scope used to restore the JS context
  34495. */
  34496. constructor(
  34497. /**
  34498. * Defines the callback to call when the observer is notified
  34499. */
  34500. callback: (eventData: T, eventState: EventState) => void,
  34501. /**
  34502. * Defines the mask of the observer (used to filter notifications)
  34503. */
  34504. mask: number,
  34505. /**
  34506. * Defines the current scope used to restore the JS context
  34507. */
  34508. scope?: any);
  34509. }
  34510. /**
  34511. * Represent a list of observers registered to multiple Observables object.
  34512. */
  34513. class MultiObserver<T> {
  34514. private _observers;
  34515. private _observables;
  34516. /**
  34517. * Release associated resources
  34518. */
  34519. dispose(): void;
  34520. /**
  34521. * Raise a callback when one of the observable will notify
  34522. * @param observables defines a list of observables to watch
  34523. * @param callback defines the callback to call on notification
  34524. * @param mask defines the mask used to filter notifications
  34525. * @param scope defines the current scope used to restore the JS context
  34526. * @returns the new MultiObserver
  34527. */
  34528. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  34529. }
  34530. /**
  34531. * The Observable class is a simple implementation of the Observable pattern.
  34532. *
  34533. * 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.
  34534. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  34535. * 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).
  34536. * 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.
  34537. */
  34538. class Observable<T> {
  34539. private _observers;
  34540. private _eventState;
  34541. private _onObserverAdded;
  34542. /**
  34543. * Creates a new observable
  34544. * @param onObserverAdded defines a callback to call when a new observer is added
  34545. */
  34546. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  34547. /**
  34548. * Create a new Observer with the specified callback
  34549. * @param callback the callback that will be executed for that Observer
  34550. * @param mask the mask used to filter observers
  34551. * @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.
  34552. * @param scope optional scope for the callback to be called from
  34553. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  34554. * @returns the new observer created for the callback
  34555. */
  34556. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  34557. /**
  34558. * Create a new Observer with the specified callback and unregisters after the next notification
  34559. * @param callback the callback that will be executed for that Observer
  34560. * @returns the new observer created for the callback
  34561. */
  34562. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  34563. /**
  34564. * Remove an Observer from the Observable object
  34565. * @param observer the instance of the Observer to remove
  34566. * @returns false if it doesn't belong to this Observable
  34567. */
  34568. remove(observer: Nullable<Observer<T>>): boolean;
  34569. /**
  34570. * Remove a callback from the Observable object
  34571. * @param callback the callback to remove
  34572. * @param scope optional scope. If used only the callbacks with this scope will be removed
  34573. * @returns false if it doesn't belong to this Observable
  34574. */
  34575. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  34576. private _deferUnregister;
  34577. private _remove;
  34578. /**
  34579. * Notify all Observers by calling their respective callback with the given data
  34580. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  34581. * @param eventData defines the data to send to all observers
  34582. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  34583. * @param target defines the original target of the state
  34584. * @param currentTarget defines the current target of the state
  34585. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  34586. */
  34587. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  34588. /**
  34589. * Calling this will execute each callback, expecting it to be a promise or return a value.
  34590. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  34591. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  34592. * and it is crucial that all callbacks will be executed.
  34593. * The order of the callbacks is kept, callbacks are not executed parallel.
  34594. *
  34595. * @param eventData The data to be sent to each callback
  34596. * @param mask is used to filter observers defaults to -1
  34597. * @param target defines the callback target (see EventState)
  34598. * @param currentTarget defines he current object in the bubbling phase
  34599. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  34600. */
  34601. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  34602. /**
  34603. * Notify a specific observer
  34604. * @param observer defines the observer to notify
  34605. * @param eventData defines the data to be sent to each callback
  34606. * @param mask is used to filter observers defaults to -1
  34607. */
  34608. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  34609. /**
  34610. * Gets a boolean indicating if the observable has at least one observer
  34611. * @returns true is the Observable has at least one Observer registered
  34612. */
  34613. hasObservers(): boolean;
  34614. /**
  34615. * Clear the list of observers
  34616. */
  34617. clear(): void;
  34618. /**
  34619. * Clone the current observable
  34620. * @returns a new observable
  34621. */
  34622. clone(): Observable<T>;
  34623. /**
  34624. * Does this observable handles observer registered with a given mask
  34625. * @param mask defines the mask to be tested
  34626. * @return whether or not one observer registered with the given mask is handeled
  34627. **/
  34628. hasSpecificMask(mask?: number): boolean;
  34629. }
  34630. }
  34631. declare module BABYLON {
  34632. /**
  34633. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34634. */
  34635. class PerformanceMonitor {
  34636. private _enabled;
  34637. private _rollingFrameTime;
  34638. private _lastFrameTimeMs;
  34639. /**
  34640. * constructor
  34641. * @param frameSampleSize The number of samples required to saturate the sliding window
  34642. */
  34643. constructor(frameSampleSize?: number);
  34644. /**
  34645. * Samples current frame
  34646. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34647. */
  34648. sampleFrame(timeMs?: number): void;
  34649. /**
  34650. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34651. * @return Average frame time in milliseconds
  34652. */
  34653. readonly averageFrameTime: number;
  34654. /**
  34655. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34656. * @return Frame time variance in milliseconds squared
  34657. */
  34658. readonly averageFrameTimeVariance: number;
  34659. /**
  34660. * Returns the frame time of the most recent frame
  34661. * @return Frame time in milliseconds
  34662. */
  34663. readonly instantaneousFrameTime: number;
  34664. /**
  34665. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34666. * @return Framerate in frames per second
  34667. */
  34668. readonly averageFPS: number;
  34669. /**
  34670. * Returns the average framerate in frames per second using the most recent frame time
  34671. * @return Framerate in frames per second
  34672. */
  34673. readonly instantaneousFPS: number;
  34674. /**
  34675. * Returns true if enough samples have been taken to completely fill the sliding window
  34676. * @return true if saturated
  34677. */
  34678. readonly isSaturated: boolean;
  34679. /**
  34680. * Enables contributions to the sliding window sample set
  34681. */
  34682. enable(): void;
  34683. /**
  34684. * Disables contributions to the sliding window sample set
  34685. * Samples will not be interpolated over the disabled period
  34686. */
  34687. disable(): void;
  34688. /**
  34689. * Returns true if sampling is enabled
  34690. * @return true if enabled
  34691. */
  34692. readonly isEnabled: boolean;
  34693. /**
  34694. * Resets performance monitor
  34695. */
  34696. reset(): void;
  34697. }
  34698. /**
  34699. * RollingAverage
  34700. *
  34701. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34702. */
  34703. class RollingAverage {
  34704. /**
  34705. * Current average
  34706. */
  34707. average: number;
  34708. /**
  34709. * Current variance
  34710. */
  34711. variance: number;
  34712. protected _samples: Array<number>;
  34713. protected _sampleCount: number;
  34714. protected _pos: number;
  34715. protected _m2: number;
  34716. /**
  34717. * constructor
  34718. * @param length The number of samples required to saturate the sliding window
  34719. */
  34720. constructor(length: number);
  34721. /**
  34722. * Adds a sample to the sample set
  34723. * @param v The sample value
  34724. */
  34725. add(v: number): void;
  34726. /**
  34727. * Returns previously added values or null if outside of history or outside the sliding window domain
  34728. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34729. * @return Value previously recorded with add() or null if outside of range
  34730. */
  34731. history(i: number): number;
  34732. /**
  34733. * Returns true if enough samples have been taken to completely fill the sliding window
  34734. * @return true if sample-set saturated
  34735. */
  34736. isSaturated(): boolean;
  34737. /**
  34738. * Resets the rolling average (equivalent to 0 samples taken so far)
  34739. */
  34740. reset(): void;
  34741. /**
  34742. * Wraps a value around the sample range boundaries
  34743. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34744. * @return Wrapped position in sample range
  34745. */
  34746. protected _wrapPosition(i: number): number;
  34747. }
  34748. }
  34749. declare module BABYLON {
  34750. /**
  34751. * Helper class that provides a small promise polyfill
  34752. */
  34753. class PromisePolyfill {
  34754. /**
  34755. * Static function used to check if the polyfill is required
  34756. * If this is the case then the function will inject the polyfill to window.Promise
  34757. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34758. */
  34759. static Apply(force?: boolean): void;
  34760. }
  34761. }
  34762. declare module BABYLON {
  34763. /**
  34764. * Defines the root class used to create scene optimization to use with SceneOptimizer
  34765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34766. */
  34767. class SceneOptimization {
  34768. /**
  34769. * Defines the priority of this optimization (0 by default which means first in the list)
  34770. */
  34771. priority: number;
  34772. /**
  34773. * Gets a string describing the action executed by the current optimization
  34774. * @returns description string
  34775. */
  34776. getDescription(): string;
  34777. /**
  34778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34779. * @param scene defines the current scene where to apply this optimization
  34780. * @param optimizer defines the current optimizer
  34781. * @returns true if everything that can be done was applied
  34782. */
  34783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34784. /**
  34785. * Creates the SceneOptimization object
  34786. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34787. * @param desc defines the description associated with the optimization
  34788. */
  34789. constructor(
  34790. /**
  34791. * Defines the priority of this optimization (0 by default which means first in the list)
  34792. */
  34793. priority?: number);
  34794. }
  34795. /**
  34796. * Defines an optimization used to reduce the size of render target textures
  34797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34798. */
  34799. class TextureOptimization extends SceneOptimization {
  34800. /**
  34801. * Defines the priority of this optimization (0 by default which means first in the list)
  34802. */
  34803. priority: number;
  34804. /**
  34805. * 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
  34806. */
  34807. maximumSize: number;
  34808. /**
  34809. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  34810. */
  34811. step: number;
  34812. /**
  34813. * Gets a string describing the action executed by the current optimization
  34814. * @returns description string
  34815. */
  34816. getDescription(): string;
  34817. /**
  34818. * Creates the TextureOptimization object
  34819. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34820. * @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
  34821. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  34822. */
  34823. constructor(
  34824. /**
  34825. * Defines the priority of this optimization (0 by default which means first in the list)
  34826. */
  34827. priority?: number,
  34828. /**
  34829. * 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
  34830. */
  34831. maximumSize?: number,
  34832. /**
  34833. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  34834. */
  34835. step?: number);
  34836. /**
  34837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34838. * @param scene defines the current scene where to apply this optimization
  34839. * @param optimizer defines the current optimizer
  34840. * @returns true if everything that can be done was applied
  34841. */
  34842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34843. }
  34844. /**
  34845. * Defines an optimization used to increase or decrease the rendering resolution
  34846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34847. */
  34848. class HardwareScalingOptimization extends SceneOptimization {
  34849. /**
  34850. * Defines the priority of this optimization (0 by default which means first in the list)
  34851. */
  34852. priority: number;
  34853. /**
  34854. * Defines the maximum scale to use (2 by default)
  34855. */
  34856. maximumScale: number;
  34857. /**
  34858. * Defines the step to use between two passes (0.5 by default)
  34859. */
  34860. step: number;
  34861. private _currentScale;
  34862. private _directionOffset;
  34863. /**
  34864. * Gets a string describing the action executed by the current optimization
  34865. * @return description string
  34866. */
  34867. getDescription(): string;
  34868. /**
  34869. * Creates the HardwareScalingOptimization object
  34870. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34871. * @param maximumScale defines the maximum scale to use (2 by default)
  34872. * @param step defines the step to use between two passes (0.5 by default)
  34873. */
  34874. constructor(
  34875. /**
  34876. * Defines the priority of this optimization (0 by default which means first in the list)
  34877. */
  34878. priority?: number,
  34879. /**
  34880. * Defines the maximum scale to use (2 by default)
  34881. */
  34882. maximumScale?: number,
  34883. /**
  34884. * Defines the step to use between two passes (0.5 by default)
  34885. */
  34886. step?: number);
  34887. /**
  34888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34889. * @param scene defines the current scene where to apply this optimization
  34890. * @param optimizer defines the current optimizer
  34891. * @returns true if everything that can be done was applied
  34892. */
  34893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34894. }
  34895. /**
  34896. * Defines an optimization used to remove shadows
  34897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34898. */
  34899. class ShadowsOptimization extends SceneOptimization {
  34900. /**
  34901. * Gets a string describing the action executed by the current optimization
  34902. * @return description string
  34903. */
  34904. getDescription(): string;
  34905. /**
  34906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34907. * @param scene defines the current scene where to apply this optimization
  34908. * @param optimizer defines the current optimizer
  34909. * @returns true if everything that can be done was applied
  34910. */
  34911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34912. }
  34913. /**
  34914. * Defines an optimization used to turn post-processes off
  34915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34916. */
  34917. class PostProcessesOptimization extends SceneOptimization {
  34918. /**
  34919. * Gets a string describing the action executed by the current optimization
  34920. * @return description string
  34921. */
  34922. getDescription(): string;
  34923. /**
  34924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34925. * @param scene defines the current scene where to apply this optimization
  34926. * @param optimizer defines the current optimizer
  34927. * @returns true if everything that can be done was applied
  34928. */
  34929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34930. }
  34931. /**
  34932. * Defines an optimization used to turn lens flares off
  34933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34934. */
  34935. class LensFlaresOptimization extends SceneOptimization {
  34936. /**
  34937. * Gets a string describing the action executed by the current optimization
  34938. * @return description string
  34939. */
  34940. getDescription(): string;
  34941. /**
  34942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34943. * @param scene defines the current scene where to apply this optimization
  34944. * @param optimizer defines the current optimizer
  34945. * @returns true if everything that can be done was applied
  34946. */
  34947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34948. }
  34949. /**
  34950. * Defines an optimization based on user defined callback.
  34951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34952. */
  34953. class CustomOptimization extends SceneOptimization {
  34954. /**
  34955. * Callback called to apply the custom optimization.
  34956. */
  34957. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  34958. /**
  34959. * Callback called to get custom description
  34960. */
  34961. onGetDescription: () => string;
  34962. /**
  34963. * Gets a string describing the action executed by the current optimization
  34964. * @returns description string
  34965. */
  34966. getDescription(): string;
  34967. /**
  34968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34969. * @param scene defines the current scene where to apply this optimization
  34970. * @param optimizer defines the current optimizer
  34971. * @returns true if everything that can be done was applied
  34972. */
  34973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34974. }
  34975. /**
  34976. * Defines an optimization used to turn particles off
  34977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34978. */
  34979. class ParticlesOptimization extends SceneOptimization {
  34980. /**
  34981. * Gets a string describing the action executed by the current optimization
  34982. * @return description string
  34983. */
  34984. getDescription(): string;
  34985. /**
  34986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34987. * @param scene defines the current scene where to apply this optimization
  34988. * @param optimizer defines the current optimizer
  34989. * @returns true if everything that can be done was applied
  34990. */
  34991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34992. }
  34993. /**
  34994. * Defines an optimization used to turn render targets off
  34995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34996. */
  34997. class RenderTargetsOptimization extends SceneOptimization {
  34998. /**
  34999. * Gets a string describing the action executed by the current optimization
  35000. * @return description string
  35001. */
  35002. getDescription(): string;
  35003. /**
  35004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  35005. * @param scene defines the current scene where to apply this optimization
  35006. * @param optimizer defines the current optimizer
  35007. * @returns true if everything that can be done was applied
  35008. */
  35009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  35010. }
  35011. /**
  35012. * Defines an optimization used to merge meshes with compatible materials
  35013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  35014. */
  35015. class MergeMeshesOptimization extends SceneOptimization {
  35016. private static _UpdateSelectionTree;
  35017. /**
  35018. * Gets or sets a boolean which defines if optimization octree has to be updated
  35019. */
  35020. /**
  35021. * Gets or sets a boolean which defines if optimization octree has to be updated
  35022. */
  35023. static UpdateSelectionTree: boolean;
  35024. /**
  35025. * Gets a string describing the action executed by the current optimization
  35026. * @return description string
  35027. */
  35028. getDescription(): string;
  35029. private _canBeMerged;
  35030. /**
  35031. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  35032. * @param scene defines the current scene where to apply this optimization
  35033. * @param optimizer defines the current optimizer
  35034. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  35035. * @returns true if everything that can be done was applied
  35036. */
  35037. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  35038. }
  35039. /**
  35040. * Defines a list of options used by SceneOptimizer
  35041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  35042. */
  35043. class SceneOptimizerOptions {
  35044. /**
  35045. * Defines the target frame rate to reach (60 by default)
  35046. */
  35047. targetFrameRate: number;
  35048. /**
  35049. * Defines the interval between two checkes (2000ms by default)
  35050. */
  35051. trackerDuration: number;
  35052. /**
  35053. * Gets the list of optimizations to apply
  35054. */
  35055. optimizations: SceneOptimization[];
  35056. /**
  35057. * Creates a new list of options used by SceneOptimizer
  35058. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  35059. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  35060. */
  35061. constructor(
  35062. /**
  35063. * Defines the target frame rate to reach (60 by default)
  35064. */
  35065. targetFrameRate?: number,
  35066. /**
  35067. * Defines the interval between two checkes (2000ms by default)
  35068. */
  35069. trackerDuration?: number);
  35070. /**
  35071. * Add a new optimization
  35072. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  35073. * @returns the current SceneOptimizerOptions
  35074. */
  35075. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  35076. /**
  35077. * Add a new custom optimization
  35078. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  35079. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  35080. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  35081. * @returns the current SceneOptimizerOptions
  35082. */
  35083. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  35084. /**
  35085. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  35086. * @param targetFrameRate defines the target frame rate (60 by default)
  35087. * @returns a SceneOptimizerOptions object
  35088. */
  35089. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  35090. /**
  35091. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  35092. * @param targetFrameRate defines the target frame rate (60 by default)
  35093. * @returns a SceneOptimizerOptions object
  35094. */
  35095. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  35096. /**
  35097. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  35098. * @param targetFrameRate defines the target frame rate (60 by default)
  35099. * @returns a SceneOptimizerOptions object
  35100. */
  35101. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  35102. }
  35103. /**
  35104. * Class used to run optimizations in order to reach a target frame rate
  35105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  35106. */
  35107. class SceneOptimizer implements IDisposable {
  35108. private _isRunning;
  35109. private _options;
  35110. private _scene;
  35111. private _currentPriorityLevel;
  35112. private _targetFrameRate;
  35113. private _trackerDuration;
  35114. private _currentFrameRate;
  35115. private _sceneDisposeObserver;
  35116. private _improvementMode;
  35117. /**
  35118. * Defines an observable called when the optimizer reaches the target frame rate
  35119. */
  35120. onSuccessObservable: Observable<SceneOptimizer>;
  35121. /**
  35122. * Defines an observable called when the optimizer enables an optimization
  35123. */
  35124. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  35125. /**
  35126. * Defines an observable called when the optimizer is not able to reach the target frame rate
  35127. */
  35128. onFailureObservable: Observable<SceneOptimizer>;
  35129. /**
  35130. * Gets a boolean indicating if the optimizer is in improvement mode
  35131. */
  35132. readonly isInImprovementMode: boolean;
  35133. /**
  35134. * Gets the current priority level (0 at start)
  35135. */
  35136. readonly currentPriorityLevel: number;
  35137. /**
  35138. * Gets the current frame rate checked by the SceneOptimizer
  35139. */
  35140. readonly currentFrameRate: number;
  35141. /**
  35142. * Gets or sets the current target frame rate (60 by default)
  35143. */
  35144. /**
  35145. * Gets or sets the current target frame rate (60 by default)
  35146. */
  35147. targetFrameRate: number;
  35148. /**
  35149. * Gets or sets the current interval between two checks (every 2000ms by default)
  35150. */
  35151. /**
  35152. * Gets or sets the current interval between two checks (every 2000ms by default)
  35153. */
  35154. trackerDuration: number;
  35155. /**
  35156. * Gets the list of active optimizations
  35157. */
  35158. readonly optimizations: SceneOptimization[];
  35159. /**
  35160. * Creates a new SceneOptimizer
  35161. * @param scene defines the scene to work on
  35162. * @param options defines the options to use with the SceneOptimizer
  35163. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  35164. * @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)
  35165. */
  35166. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  35167. /**
  35168. * Stops the current optimizer
  35169. */
  35170. stop(): void;
  35171. /**
  35172. * Reset the optimizer to initial step (current priority level = 0)
  35173. */
  35174. reset(): void;
  35175. /**
  35176. * Start the optimizer. By default it will try to reach a specific framerate
  35177. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  35178. */
  35179. start(): void;
  35180. private _checkCurrentState;
  35181. /**
  35182. * Release all resources
  35183. */
  35184. dispose(): void;
  35185. /**
  35186. * Helper function to create a SceneOptimizer with one single line of code
  35187. * @param scene defines the scene to work on
  35188. * @param options defines the options to use with the SceneOptimizer
  35189. * @param onSuccess defines a callback to call on success
  35190. * @param onFailure defines a callback to call on failure
  35191. * @returns the new SceneOptimizer object
  35192. */
  35193. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  35194. }
  35195. }
  35196. declare module BABYLON {
  35197. class SceneSerializer {
  35198. static ClearCache(): void;
  35199. static Serialize(scene: Scene): any;
  35200. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  35201. }
  35202. }
  35203. declare module BABYLON {
  35204. /**
  35205. * Defines an array and its length.
  35206. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  35207. */
  35208. interface ISmartArrayLike<T> {
  35209. /**
  35210. * The data of the array.
  35211. */
  35212. data: Array<T>;
  35213. /**
  35214. * The active length of the array.
  35215. */
  35216. length: number;
  35217. }
  35218. /**
  35219. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  35220. */
  35221. class SmartArray<T> implements ISmartArrayLike<T> {
  35222. /**
  35223. * The full set of data from the array.
  35224. */
  35225. data: Array<T>;
  35226. /**
  35227. * The active length of the array.
  35228. */
  35229. length: number;
  35230. protected _id: number;
  35231. /**
  35232. * Instantiates a Smart Array.
  35233. * @param capacity defines the default capacity of the array.
  35234. */
  35235. constructor(capacity: number);
  35236. /**
  35237. * Pushes a value at the end of the active data.
  35238. * @param value defines the object to push in the array.
  35239. */
  35240. push(value: T): void;
  35241. /**
  35242. * Iterates over the active data and apply the lambda to them.
  35243. * @param func defines the action to apply on each value.
  35244. */
  35245. forEach(func: (content: T) => void): void;
  35246. /**
  35247. * Sorts the full sets of data.
  35248. * @param compareFn defines the comparison function to apply.
  35249. */
  35250. sort(compareFn: (a: T, b: T) => number): void;
  35251. /**
  35252. * Resets the active data to an empty array.
  35253. */
  35254. reset(): void;
  35255. /**
  35256. * Releases all the data from the array as well as the array.
  35257. */
  35258. dispose(): void;
  35259. /**
  35260. * Concats the active data with a given array.
  35261. * @param array defines the data to concatenate with.
  35262. */
  35263. concat(array: any): void;
  35264. /**
  35265. * Returns the position of a value in the active data.
  35266. * @param value defines the value to find the index for
  35267. * @returns the index if found in the active data otherwise -1
  35268. */
  35269. indexOf(value: T): number;
  35270. /**
  35271. * Returns whether an element is part of the active data.
  35272. * @param value defines the value to look for
  35273. * @returns true if found in the active data otherwise false
  35274. */
  35275. contains(value: T): boolean;
  35276. private static _GlobalId;
  35277. }
  35278. /**
  35279. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  35280. * The data in this array can only be present once
  35281. */
  35282. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  35283. private _duplicateId;
  35284. /**
  35285. * Pushes a value at the end of the active data.
  35286. * THIS DOES NOT PREVENT DUPPLICATE DATA
  35287. * @param value defines the object to push in the array.
  35288. */
  35289. push(value: T): void;
  35290. /**
  35291. * Pushes a value at the end of the active data.
  35292. * If the data is already present, it won t be added again
  35293. * @param value defines the object to push in the array.
  35294. * @returns true if added false if it was already present
  35295. */
  35296. pushNoDuplicate(value: T): boolean;
  35297. /**
  35298. * Resets the active data to an empty array.
  35299. */
  35300. reset(): void;
  35301. /**
  35302. * Concats the active data with a given array.
  35303. * This ensures no dupplicate will be present in the result.
  35304. * @param array defines the data to concatenate with.
  35305. */
  35306. concatWithNoDuplicate(array: any): void;
  35307. }
  35308. }
  35309. declare module BABYLON {
  35310. /**
  35311. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35312. * The underlying implementation relies on an associative array to ensure the best performances.
  35313. * The value can be anything including 'null' but except 'undefined'
  35314. */
  35315. class StringDictionary<T> {
  35316. /**
  35317. * This will clear this dictionary and copy the content from the 'source' one.
  35318. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35319. * @param source the dictionary to take the content from and copy to this dictionary
  35320. */
  35321. copyFrom(source: StringDictionary<T>): void;
  35322. /**
  35323. * Get a value based from its key
  35324. * @param key the given key to get the matching value from
  35325. * @return the value if found, otherwise undefined is returned
  35326. */
  35327. get(key: string): T | undefined;
  35328. /**
  35329. * Get a value from its key or add it if it doesn't exist.
  35330. * This method will ensure you that a given key/data will be present in the dictionary.
  35331. * @param key the given key to get the matching value from
  35332. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35333. * The factory will only be invoked if there's no data for the given key.
  35334. * @return the value corresponding to the key.
  35335. */
  35336. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35337. /**
  35338. * Get a value from its key if present in the dictionary otherwise add it
  35339. * @param key the key to get the value from
  35340. * @param val if there's no such key/value pair in the dictionary add it with this value
  35341. * @return the value corresponding to the key
  35342. */
  35343. getOrAdd(key: string, val: T): T;
  35344. /**
  35345. * Check if there's a given key in the dictionary
  35346. * @param key the key to check for
  35347. * @return true if the key is present, false otherwise
  35348. */
  35349. contains(key: string): boolean;
  35350. /**
  35351. * Add a new key and its corresponding value
  35352. * @param key the key to add
  35353. * @param value the value corresponding to the key
  35354. * @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
  35355. */
  35356. add(key: string, value: T): boolean;
  35357. set(key: string, value: T): boolean;
  35358. /**
  35359. * Get the element of the given key and remove it from the dictionary
  35360. * @param key
  35361. */
  35362. getAndRemove(key: string): Nullable<T>;
  35363. /**
  35364. * Remove a key/value from the dictionary.
  35365. * @param key the key to remove
  35366. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35367. */
  35368. remove(key: string): boolean;
  35369. /**
  35370. * Clear the whole content of the dictionary
  35371. */
  35372. clear(): void;
  35373. readonly count: number;
  35374. /**
  35375. * Execute a callback on each key/val of the dictionary.
  35376. * Note that you can remove any element in this dictionary in the callback implementation
  35377. * @param callback the callback to execute on a given key/value pair
  35378. */
  35379. forEach(callback: (key: string, val: T) => void): void;
  35380. /**
  35381. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35382. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35383. * Note that you can remove any element in this dictionary in the callback implementation
  35384. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35385. */
  35386. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35387. private _count;
  35388. private _data;
  35389. }
  35390. }
  35391. declare module BABYLON {
  35392. class Tags {
  35393. static EnableFor(obj: any): void;
  35394. static DisableFor(obj: any): void;
  35395. static HasTags(obj: any): boolean;
  35396. static GetTags(obj: any, asString?: boolean): any;
  35397. static AddTagsTo(obj: any, tagsString: string): void;
  35398. static _AddTagTo(obj: any, tag: string): void;
  35399. static RemoveTagsFrom(obj: any, tagsString: string): void;
  35400. static _RemoveTagFrom(obj: any, tag: string): void;
  35401. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  35402. }
  35403. }
  35404. declare module BABYLON {
  35405. class TextureTools {
  35406. /**
  35407. * Uses the GPU to create a copy texture rescaled at a given size
  35408. * @param texture Texture to copy from
  35409. * @param width Desired width
  35410. * @param height Desired height
  35411. * @return Generated texture
  35412. */
  35413. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  35414. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  35415. private static _environmentBRDFBase64Texture;
  35416. }
  35417. }
  35418. declare module BABYLON {
  35419. class TGATools {
  35420. private static _TYPE_INDEXED;
  35421. private static _TYPE_RGB;
  35422. private static _TYPE_GREY;
  35423. private static _TYPE_RLE_INDEXED;
  35424. private static _TYPE_RLE_RGB;
  35425. private static _TYPE_RLE_GREY;
  35426. private static _ORIGIN_MASK;
  35427. private static _ORIGIN_SHIFT;
  35428. private static _ORIGIN_BL;
  35429. private static _ORIGIN_BR;
  35430. private static _ORIGIN_UL;
  35431. private static _ORIGIN_UR;
  35432. static GetTGAHeader(data: Uint8Array): any;
  35433. /**
  35434. * Uploads TGA content to a Babylon Texture
  35435. * @hidden
  35436. */
  35437. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  35438. 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;
  35439. 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;
  35440. 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;
  35441. 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;
  35442. 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;
  35443. 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;
  35444. }
  35445. }
  35446. declare module BABYLON {
  35447. interface IAnimatable {
  35448. animations: Array<Animation>;
  35449. }
  35450. /** Interface used by value gradients (color, factor, ...) */
  35451. interface IValueGradient {
  35452. /**
  35453. * Gets or sets the gradient value (between 0 and 1)
  35454. */
  35455. gradient: number;
  35456. }
  35457. /** Class used to store color4 gradient */
  35458. class ColorGradient implements IValueGradient {
  35459. /**
  35460. * Gets or sets the gradient value (between 0 and 1)
  35461. */
  35462. gradient: number;
  35463. /**
  35464. * Gets or sets first associated color
  35465. */
  35466. color1: Color4;
  35467. /**
  35468. * Gets or sets second associated color
  35469. */
  35470. color2?: Color4;
  35471. /**
  35472. * Will get a color picked randomly between color1 and color2.
  35473. * If color2 is undefined then color1 will be used
  35474. * @param result defines the target Color4 to store the result in
  35475. */
  35476. getColorToRef(result: Color4): void;
  35477. }
  35478. /** Class used to store color 3 gradient */
  35479. class Color3Gradient implements IValueGradient {
  35480. /**
  35481. * Gets or sets the gradient value (between 0 and 1)
  35482. */
  35483. gradient: number;
  35484. /**
  35485. * Gets or sets the associated color
  35486. */
  35487. color: Color3;
  35488. }
  35489. /** Class used to store factor gradient */
  35490. class FactorGradient implements IValueGradient {
  35491. /**
  35492. * Gets or sets the gradient value (between 0 and 1)
  35493. */
  35494. gradient: number;
  35495. /**
  35496. * Gets or sets first associated factor
  35497. */
  35498. factor1: number;
  35499. /**
  35500. * Gets or sets second associated factor
  35501. */
  35502. factor2?: number;
  35503. /**
  35504. * Will get a number picked randomly between factor1 and factor2.
  35505. * If factor2 is undefined then factor1 will be used
  35506. * @returns the picked number
  35507. */
  35508. getFactor(): number;
  35509. }
  35510. class LoadFileError extends Error {
  35511. request?: XMLHttpRequest | undefined;
  35512. private static _setPrototypeOf;
  35513. constructor(message: string, request?: XMLHttpRequest | undefined);
  35514. }
  35515. class RetryStrategy {
  35516. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  35517. }
  35518. interface IFileRequest {
  35519. /**
  35520. * Raised when the request is complete (success or error).
  35521. */
  35522. onCompleteObservable: Observable<IFileRequest>;
  35523. /**
  35524. * Aborts the request for a file.
  35525. */
  35526. abort: () => void;
  35527. }
  35528. class Tools {
  35529. static BaseUrl: string;
  35530. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  35531. /**
  35532. * Default behaviour for cors in the application.
  35533. * It can be a string if the expected behavior is identical in the entire app.
  35534. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35535. */
  35536. static CorsBehavior: string | ((url: string | string[]) => string);
  35537. static UseFallbackTexture: boolean;
  35538. /**
  35539. * Use this object to register external classes like custom textures or material
  35540. * to allow the laoders to instantiate them
  35541. */
  35542. static RegisteredExternalClasses: {
  35543. [key: string]: Object;
  35544. };
  35545. static fallbackTexture: string;
  35546. /**
  35547. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35548. * @param u defines the coordinate on X axis
  35549. * @param v defines the coordinate on Y axis
  35550. * @param width defines the width of the source data
  35551. * @param height defines the height of the source data
  35552. * @param pixels defines the source byte array
  35553. * @param color defines the output color
  35554. */
  35555. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  35556. /**
  35557. * Interpolates between a and b via alpha
  35558. * @param a The lower value (returned when alpha = 0)
  35559. * @param b The upper value (returned when alpha = 1)
  35560. * @param alpha The interpolation-factor
  35561. * @return The mixed value
  35562. */
  35563. static Mix(a: number, b: number, alpha: number): number;
  35564. static Instantiate(className: string): any;
  35565. /**
  35566. * Provides a slice function that will work even on IE
  35567. * @param data defines the array to slice
  35568. * @param start defines the start of the data (optional)
  35569. * @param end defines the end of the data (optional)
  35570. * @returns the new sliced array
  35571. */
  35572. static Slice<T>(data: T, start?: number, end?: number): T;
  35573. static SetImmediate(action: () => void): void;
  35574. static IsExponentOfTwo(value: number): boolean;
  35575. private static _tmpFloatArray;
  35576. /**
  35577. * Returns the nearest 32-bit single precision float representation of a Number
  35578. * @param value A Number. If the parameter is of a different type, it will get converted
  35579. * to a number or to NaN if it cannot be converted
  35580. * @returns number
  35581. */
  35582. static FloatRound(value: number): number;
  35583. /**
  35584. * Find the next highest power of two.
  35585. * @param x Number to start search from.
  35586. * @return Next highest power of two.
  35587. */
  35588. static CeilingPOT(x: number): number;
  35589. /**
  35590. * Find the next lowest power of two.
  35591. * @param x Number to start search from.
  35592. * @return Next lowest power of two.
  35593. */
  35594. static FloorPOT(x: number): number;
  35595. /**
  35596. * Find the nearest power of two.
  35597. * @param x Number to start search from.
  35598. * @return Next nearest power of two.
  35599. */
  35600. static NearestPOT(x: number): number;
  35601. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35602. static GetFilename(path: string): string;
  35603. /**
  35604. * Extracts the "folder" part of a path (everything before the filename).
  35605. * @param uri The URI to extract the info from
  35606. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35607. * @returns The "folder" part of the path
  35608. */
  35609. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35610. static GetDOMTextContent(element: HTMLElement): string;
  35611. static ToDegrees(angle: number): number;
  35612. static ToRadians(angle: number): number;
  35613. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  35614. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  35615. minimum: Vector3;
  35616. maximum: Vector3;
  35617. };
  35618. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  35619. minimum: Vector3;
  35620. maximum: Vector3;
  35621. };
  35622. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  35623. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  35624. minimum: Vector2;
  35625. maximum: Vector2;
  35626. };
  35627. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35628. static GetPointerPrefix(): string;
  35629. /**
  35630. * @param func - the function to be called
  35631. * @param requester - the object that will request the next frame. Falls back to window.
  35632. */
  35633. static QueueNewFrame(func: () => void, requester?: any): number;
  35634. static RequestFullscreen(element: HTMLElement): void;
  35635. static ExitFullscreen(): void;
  35636. /**
  35637. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35638. * @param url define the url we are trying
  35639. * @param element define the dom element where to configure the cors policy
  35640. */
  35641. static SetCorsBehavior(url: string | string[], element: {
  35642. crossOrigin: string | null;
  35643. }): void;
  35644. static CleanUrl(url: string): string;
  35645. static PreprocessUrl: (url: string) => string;
  35646. /**
  35647. * Loads an image as an HTMLImageElement.
  35648. * @param input url string, ArrayBuffer, or Blob to load
  35649. * @param onLoad callback called when the image successfully loads
  35650. * @param onError callback called when the image fails to load
  35651. * @param database database for caching
  35652. * @returns the HTMLImageElement of the loaded image
  35653. */
  35654. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  35655. 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;
  35656. /**
  35657. * Load a script (identified by an url). When the url returns, the
  35658. * content of this file is added into a new script element, attached to the DOM (body element)
  35659. */
  35660. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  35661. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35662. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  35663. static FileAsURL(content: string): string;
  35664. static Format(value: number, decimals?: number): string;
  35665. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  35666. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35667. static IsEmpty(obj: any): boolean;
  35668. static RegisterTopRootEvents(events: {
  35669. name: string;
  35670. handler: Nullable<(e: FocusEvent) => any>;
  35671. }[]): void;
  35672. static UnregisterTopRootEvents(events: {
  35673. name: string;
  35674. handler: Nullable<(e: FocusEvent) => any>;
  35675. }[]): void;
  35676. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35677. /**
  35678. * Converts the canvas data to blob.
  35679. * This acts as a polyfill for browsers not supporting the to blob function.
  35680. * @param canvas Defines the canvas to extract the data from
  35681. * @param successCallback Defines the callback triggered once the data are available
  35682. * @param mimeType Defines the mime type of the result
  35683. */
  35684. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35685. /**
  35686. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35687. * @param successCallback Defines the callback triggered once the data are available
  35688. * @param mimeType Defines the mime type of the result
  35689. * @param fileName The filename to download. If present, the result will automatically be downloaded
  35690. */
  35691. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35692. /**
  35693. * Downloads a blob in the browser
  35694. * @param blob defines the blob to download
  35695. * @param fileName defines the name of the downloaded file
  35696. */
  35697. static Download(blob: Blob, fileName: string): void;
  35698. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  35699. /**
  35700. * Generates an image screenshot from the specified camera.
  35701. *
  35702. * @param engine The engine to use for rendering
  35703. * @param camera The camera to use for rendering
  35704. * @param size This parameter can be set to a single number or to an object with the
  35705. * following (optional) properties: precision, width, height. If a single number is passed,
  35706. * it will be used for both width and height. If an object is passed, the screenshot size
  35707. * will be derived from the parameters. The precision property is a multiplier allowing
  35708. * rendering at a higher or lower resolution.
  35709. * @param successCallback The callback receives a single parameter which contains the
  35710. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35711. * src parameter of an <img> to display it.
  35712. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35713. * Check your browser for supported MIME types.
  35714. * @param samples Texture samples (default: 1)
  35715. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35716. * @param fileName A name for for the downloaded file.
  35717. * @constructor
  35718. */
  35719. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35720. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  35721. /**
  35722. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35723. * Be aware Math.random() could cause collisions, but:
  35724. * "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"
  35725. */
  35726. static RandomId(): string;
  35727. /**
  35728. * Test if the given uri is a base64 string.
  35729. * @param uri The uri to test
  35730. * @return True if the uri is a base64 string or false otherwise.
  35731. */
  35732. static IsBase64(uri: string): boolean;
  35733. /**
  35734. * Decode the given base64 uri.
  35735. * @param uri The uri to decode
  35736. * @return The decoded base64 data.
  35737. */
  35738. static DecodeBase64(uri: string): ArrayBuffer;
  35739. private static _NoneLogLevel;
  35740. private static _MessageLogLevel;
  35741. private static _WarningLogLevel;
  35742. private static _ErrorLogLevel;
  35743. private static _LogCache;
  35744. static errorsCount: number;
  35745. static OnNewCacheEntry: (entry: string) => void;
  35746. static readonly NoneLogLevel: number;
  35747. static readonly MessageLogLevel: number;
  35748. static readonly WarningLogLevel: number;
  35749. static readonly ErrorLogLevel: number;
  35750. static readonly AllLogLevel: number;
  35751. private static _AddLogEntry;
  35752. private static _FormatMessage;
  35753. private static _LogDisabled;
  35754. private static _LogEnabled;
  35755. private static _WarnDisabled;
  35756. private static _WarnEnabled;
  35757. private static _ErrorDisabled;
  35758. private static _ErrorEnabled;
  35759. static Log: (message: string) => void;
  35760. static Warn: (message: string) => void;
  35761. static Error: (message: string) => void;
  35762. static readonly LogCache: string;
  35763. static ClearLogCache(): void;
  35764. static LogLevels: number;
  35765. /**
  35766. * Check if the loaded document was accessed via `file:`-Protocol.
  35767. * @returns boolean
  35768. */
  35769. static IsFileURL(): boolean;
  35770. static IsWindowObjectExist(): boolean;
  35771. private static _PerformanceNoneLogLevel;
  35772. private static _PerformanceUserMarkLogLevel;
  35773. private static _PerformanceConsoleLogLevel;
  35774. private static _performance;
  35775. static readonly PerformanceNoneLogLevel: number;
  35776. static readonly PerformanceUserMarkLogLevel: number;
  35777. static readonly PerformanceConsoleLogLevel: number;
  35778. static PerformanceLogLevel: number;
  35779. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  35780. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  35781. static _StartUserMark(counterName: string, condition?: boolean): void;
  35782. static _EndUserMark(counterName: string, condition?: boolean): void;
  35783. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  35784. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  35785. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35786. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35787. static readonly Now: number;
  35788. /**
  35789. * This method will return the name of the class used to create the instance of the given object.
  35790. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35791. * @param object the object to get the class name from
  35792. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  35793. */
  35794. static GetClassName(object: any, isType?: boolean): string;
  35795. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35796. /**
  35797. * This method will return the name of the full name of the class, including its owning module (if any).
  35798. * 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).
  35799. * @param object the object to get the class name from
  35800. * @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.
  35801. */
  35802. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35803. /**
  35804. * 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.
  35805. * @param array
  35806. */
  35807. static arrayOrStringFeeder(array: any): (i: number) => number;
  35808. /**
  35809. * Compute the hashCode of a stream of number
  35810. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  35811. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  35812. * @return the hash code computed
  35813. */
  35814. static hashCodeFromStream(feeder: (index: number) => number): number;
  35815. /**
  35816. * Returns a promise that resolves after the given amount of time.
  35817. * @param delay Number of milliseconds to delay
  35818. * @returns Promise that resolves after the given amount of time
  35819. */
  35820. static DelayAsync(delay: number): Promise<void>;
  35821. /**
  35822. * Gets the current gradient from an array of IValueGradient
  35823. * @param ratio defines the current ratio to get
  35824. * @param gradients defines the array of IValueGradient
  35825. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  35826. */
  35827. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  35828. }
  35829. /**
  35830. * This class is used to track a performance counter which is number based.
  35831. * The user has access to many properties which give statistics of different nature
  35832. *
  35833. * The implementer can track two kinds of Performance Counter: time and count
  35834. * 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.
  35835. * 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.
  35836. */
  35837. class PerfCounter {
  35838. static Enabled: boolean;
  35839. /**
  35840. * Returns the smallest value ever
  35841. */
  35842. readonly min: number;
  35843. /**
  35844. * Returns the biggest value ever
  35845. */
  35846. readonly max: number;
  35847. /**
  35848. * Returns the average value since the performance counter is running
  35849. */
  35850. readonly average: number;
  35851. /**
  35852. * Returns the average value of the last second the counter was monitored
  35853. */
  35854. readonly lastSecAverage: number;
  35855. /**
  35856. * Returns the current value
  35857. */
  35858. readonly current: number;
  35859. readonly total: number;
  35860. readonly count: number;
  35861. constructor();
  35862. /**
  35863. * Call this method to start monitoring a new frame.
  35864. * 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.
  35865. */
  35866. fetchNewFrame(): void;
  35867. /**
  35868. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35869. * @param newCount the count value to add to the monitored count
  35870. * @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.
  35871. */
  35872. addCount(newCount: number, fetchResult: boolean): void;
  35873. /**
  35874. * Start monitoring this performance counter
  35875. */
  35876. beginMonitoring(): void;
  35877. /**
  35878. * Compute the time lapsed since the previous beginMonitoring() call.
  35879. * @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
  35880. */
  35881. endMonitoring(newFrame?: boolean): void;
  35882. private _fetchResult;
  35883. private _startMonitoringTime;
  35884. private _min;
  35885. private _max;
  35886. private _average;
  35887. private _current;
  35888. private _totalValueCount;
  35889. private _totalAccumulated;
  35890. private _lastSecAverage;
  35891. private _lastSecAccumulated;
  35892. private _lastSecTime;
  35893. private _lastSecValueCount;
  35894. }
  35895. /**
  35896. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35897. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35898. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35899. * @param name The name of the class, case should be preserved
  35900. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35901. */
  35902. function className(name: string, module?: string): (target: Object) => void;
  35903. /**
  35904. * An implementation of a loop for asynchronous functions.
  35905. */
  35906. class AsyncLoop {
  35907. /**
  35908. * Defines the number of iterations for the loop
  35909. */
  35910. iterations: number;
  35911. /**
  35912. * Defines the current index of the loop.
  35913. */
  35914. index: number;
  35915. private _done;
  35916. private _fn;
  35917. private _successCallback;
  35918. /**
  35919. * Constructor.
  35920. * @param iterations the number of iterations.
  35921. * @param func the function to run each iteration
  35922. * @param successCallback the callback that will be called upon succesful execution
  35923. * @param offset starting offset.
  35924. */
  35925. constructor(
  35926. /**
  35927. * Defines the number of iterations for the loop
  35928. */
  35929. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35930. /**
  35931. * Execute the next iteration. Must be called after the last iteration was finished.
  35932. */
  35933. executeNext(): void;
  35934. /**
  35935. * Break the loop and run the success callback.
  35936. */
  35937. breakLoop(): void;
  35938. /**
  35939. * Create and run an async loop.
  35940. * @param iterations the number of iterations.
  35941. * @param fn the function to run each iteration
  35942. * @param successCallback the callback that will be called upon succesful execution
  35943. * @param offset starting offset.
  35944. * @returns the created async loop object
  35945. */
  35946. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35947. /**
  35948. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35949. * @param iterations total number of iterations
  35950. * @param syncedIterations number of synchronous iterations in each async iteration.
  35951. * @param fn the function to call each iteration.
  35952. * @param callback a success call back that will be called when iterating stops.
  35953. * @param breakFunction a break condition (optional)
  35954. * @param timeout timeout settings for the setTimeout function. default - 0.
  35955. * @returns the created async loop object
  35956. */
  35957. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35958. }
  35959. }
  35960. interface HTMLCanvasElement {
  35961. /** Track wether a record is in progress */
  35962. isRecording: boolean;
  35963. /** Capture Stream method defined by some browsers */
  35964. captureStream(fps?: number): MediaStream;
  35965. }
  35966. interface MediaRecorder {
  35967. /** Starts recording */
  35968. start(timeSlice: number): void;
  35969. /** Stops recording */
  35970. stop(): void;
  35971. /** Event raised when an error arised. */
  35972. onerror: (event: ErrorEvent) => void;
  35973. /** Event raised when the recording stops. */
  35974. onstop: (event: Event) => void;
  35975. /** Event raised when a new chunk of data is available and should be tracked. */
  35976. ondataavailable: (event: Event) => void;
  35977. }
  35978. interface MediaRecorderOptions {
  35979. /** The mime type you want to use as the recording container for the new MediaRecorder */
  35980. mimeType?: string;
  35981. /** The chosen bitrate for the audio component of the media. */
  35982. audioBitsPerSecond?: number;
  35983. /** The chosen bitrate for the video component of the media. */
  35984. videoBitsPerSecond?: number;
  35985. /** 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. */
  35986. bitsPerSecond?: number;
  35987. }
  35988. interface MediaRecorderConstructor {
  35989. /**
  35990. * A reference to the prototype.
  35991. */
  35992. readonly prototype: MediaRecorder;
  35993. /**
  35994. * Creates a new MediaRecorder.
  35995. * @param stream Defines the stream to record.
  35996. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  35997. */
  35998. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  35999. }
  36000. /**
  36001. * MediaRecoreder object available in some browsers.
  36002. */
  36003. declare var MediaRecorder: MediaRecorderConstructor;
  36004. declare module BABYLON {
  36005. /**
  36006. * This represents the different options avilable for the video capture.
  36007. */
  36008. interface VideoRecorderOptions {
  36009. /** Defines the mime type of the video */
  36010. mimeType: string;
  36011. /** Defines the video the video should be recorded at */
  36012. fps: number;
  36013. /** Defines the chunk size for the recording data */
  36014. recordChunckSize: number;
  36015. }
  36016. /**
  36017. * This can helps recording videos from BabylonJS.
  36018. * This is based on the available WebRTC functionalities of the browser.
  36019. *
  36020. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  36021. */
  36022. class VideoRecorder {
  36023. private static readonly _defaultOptions;
  36024. /**
  36025. * Returns wehther or not the VideoRecorder is available in your browser.
  36026. * @param engine Defines the Babylon Engine to check the support for
  36027. * @returns true if supported otherwise false
  36028. */
  36029. static IsSupported(engine: Engine): boolean;
  36030. private readonly _options;
  36031. private _canvas;
  36032. private _mediaRecorder;
  36033. private _recordedChunks;
  36034. private _fileName;
  36035. private _resolve;
  36036. private _reject;
  36037. /**
  36038. * True wether a recording is already in progress.
  36039. */
  36040. readonly isRecording: boolean;
  36041. /**
  36042. * Create a new VideoCapture object which can help converting what you see in Babylon to
  36043. * a video file.
  36044. * @param engine Defines the BabylonJS Engine you wish to record
  36045. * @param options Defines options that can be used to customized the capture
  36046. */
  36047. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  36048. /**
  36049. * Stops the current recording before the default capture timeout passed in the startRecording
  36050. * functions.
  36051. */
  36052. stopRecording(): void;
  36053. /**
  36054. * Starts recording the canvas for a max duration specified in parameters.
  36055. * @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.
  36056. * @param maxDuration Defines the maximum recording time in seconds.
  36057. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  36058. * @return a promise callback at the end of the recording with the video data in Blob.
  36059. */
  36060. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  36061. /**
  36062. * Releases internal resources used during the recording.
  36063. */
  36064. dispose(): void;
  36065. private _handleDataAvailable;
  36066. private _handleError;
  36067. private _handleStop;
  36068. }
  36069. }
  36070. declare module BABYLON {
  36071. /**
  36072. * Defines the potential axis of a Joystick
  36073. */
  36074. enum JoystickAxis {
  36075. /** X axis */
  36076. X = 0,
  36077. /** Y axis */
  36078. Y = 1,
  36079. /** Z axis */
  36080. Z = 2
  36081. }
  36082. /**
  36083. * Class used to define virtual joystick (used in touch mode)
  36084. */
  36085. class VirtualJoystick {
  36086. /**
  36087. * Gets or sets a boolean indicating that left and right values must be inverted
  36088. */
  36089. reverseLeftRight: boolean;
  36090. /**
  36091. * Gets or sets a boolean indicating that up and down values must be inverted
  36092. */
  36093. reverseUpDown: boolean;
  36094. /**
  36095. * Gets the offset value for the position (ie. the change of the position value)
  36096. */
  36097. deltaPosition: Vector3;
  36098. /**
  36099. * Gets a boolean indicating if the virtual joystick was pressed
  36100. */
  36101. pressed: boolean;
  36102. private static _globalJoystickIndex;
  36103. private static vjCanvas;
  36104. private static vjCanvasContext;
  36105. private static vjCanvasWidth;
  36106. private static vjCanvasHeight;
  36107. private static halfWidth;
  36108. private _action;
  36109. private _axisTargetedByLeftAndRight;
  36110. private _axisTargetedByUpAndDown;
  36111. private _joystickSensibility;
  36112. private _inversedSensibility;
  36113. private _joystickPointerID;
  36114. private _joystickColor;
  36115. private _joystickPointerPos;
  36116. private _joystickPreviousPointerPos;
  36117. private _joystickPointerStartPos;
  36118. private _deltaJoystickVector;
  36119. private _leftJoystick;
  36120. private _touches;
  36121. private _onPointerDownHandlerRef;
  36122. private _onPointerMoveHandlerRef;
  36123. private _onPointerUpHandlerRef;
  36124. private _onResize;
  36125. /**
  36126. * Creates a new virtual joystick
  36127. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36128. */
  36129. constructor(leftJoystick?: boolean);
  36130. /**
  36131. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36132. * @param newJoystickSensibility defines the new sensibility
  36133. */
  36134. setJoystickSensibility(newJoystickSensibility: number): void;
  36135. private _onPointerDown;
  36136. private _onPointerMove;
  36137. private _onPointerUp;
  36138. /**
  36139. * Change the color of the virtual joystick
  36140. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36141. */
  36142. setJoystickColor(newColor: string): void;
  36143. /**
  36144. * Defines a callback to call when the joystick is touched
  36145. * @param action defines the callback
  36146. */
  36147. setActionOnTouch(action: () => any): void;
  36148. /**
  36149. * Defines which axis you'd like to control for left & right
  36150. * @param axis defines the axis to use
  36151. */
  36152. setAxisForLeftRight(axis: JoystickAxis): void;
  36153. /**
  36154. * Defines which axis you'd like to control for up & down
  36155. * @param axis defines the axis to use
  36156. */
  36157. setAxisForUpDown(axis: JoystickAxis): void;
  36158. private _drawVirtualJoystick;
  36159. /**
  36160. * Release internal HTML canvas
  36161. */
  36162. releaseCanvas(): void;
  36163. }
  36164. }
  36165. declare module BABYLON {
  36166. /**
  36167. * Helper class to push actions to a pool of workers.
  36168. */
  36169. class WorkerPool implements IDisposable {
  36170. private _workerInfos;
  36171. private _pendingActions;
  36172. /**
  36173. * Constructor
  36174. * @param workers Array of workers to use for actions
  36175. */
  36176. constructor(workers: Array<Worker>);
  36177. /**
  36178. * Terminates all workers and clears any pending actions.
  36179. */
  36180. dispose(): void;
  36181. /**
  36182. * Pushes an action to the worker pool. If all the workers are active, the action will be
  36183. * pended until a worker has completed its action.
  36184. * @param action The action to perform. Call onComplete when the action is complete.
  36185. */
  36186. push(action: (worker: Worker, onComplete: () => void) => void): void;
  36187. private _execute;
  36188. }
  36189. }
  36190. declare module BABYLON {
  36191. /**
  36192. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36193. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36194. */
  36195. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36196. /**
  36197. * Gets the name of the behavior.
  36198. */
  36199. readonly name: string;
  36200. private _zoomStopsAnimation;
  36201. private _idleRotationSpeed;
  36202. private _idleRotationWaitTime;
  36203. private _idleRotationSpinupTime;
  36204. /**
  36205. * Sets the flag that indicates if user zooming should stop animation.
  36206. */
  36207. /**
  36208. * Gets the flag that indicates if user zooming should stop animation.
  36209. */
  36210. zoomStopsAnimation: boolean;
  36211. /**
  36212. * Sets the default speed at which the camera rotates around the model.
  36213. */
  36214. /**
  36215. * Gets the default speed at which the camera rotates around the model.
  36216. */
  36217. idleRotationSpeed: number;
  36218. /**
  36219. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36220. */
  36221. /**
  36222. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36223. */
  36224. idleRotationWaitTime: number;
  36225. /**
  36226. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36227. */
  36228. /**
  36229. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36230. */
  36231. idleRotationSpinupTime: number;
  36232. /**
  36233. * Gets a value indicating if the camera is currently rotating because of this behavior
  36234. */
  36235. readonly rotationInProgress: boolean;
  36236. private _onPrePointerObservableObserver;
  36237. private _onAfterCheckInputsObserver;
  36238. private _attachedCamera;
  36239. private _isPointerDown;
  36240. private _lastFrameTime;
  36241. private _lastInteractionTime;
  36242. private _cameraRotationSpeed;
  36243. /**
  36244. * Initializes the behavior.
  36245. */
  36246. init(): void;
  36247. /**
  36248. * Attaches the behavior to its arc rotate camera.
  36249. * @param camera Defines the camera to attach the behavior to
  36250. */
  36251. attach(camera: ArcRotateCamera): void;
  36252. /**
  36253. * Detaches the behavior from its current arc rotate camera.
  36254. */
  36255. detach(): void;
  36256. /**
  36257. * Returns true if user is scrolling.
  36258. * @return true if user is scrolling.
  36259. */
  36260. private _userIsZooming;
  36261. private _lastFrameRadius;
  36262. private _shouldAnimationStopForInteraction;
  36263. /**
  36264. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36265. */
  36266. private _applyUserInteraction;
  36267. private _userIsMoving;
  36268. }
  36269. }
  36270. declare module BABYLON {
  36271. /**
  36272. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36274. */
  36275. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36276. /**
  36277. * Gets the name of the behavior.
  36278. */
  36279. readonly name: string;
  36280. /**
  36281. * The easing function used by animations
  36282. */
  36283. static EasingFunction: BackEase;
  36284. /**
  36285. * The easing mode used by animations
  36286. */
  36287. static EasingMode: number;
  36288. /**
  36289. * The duration of the animation, in milliseconds
  36290. */
  36291. transitionDuration: number;
  36292. /**
  36293. * Length of the distance animated by the transition when lower radius is reached
  36294. */
  36295. lowerRadiusTransitionRange: number;
  36296. /**
  36297. * Length of the distance animated by the transition when upper radius is reached
  36298. */
  36299. upperRadiusTransitionRange: number;
  36300. private _autoTransitionRange;
  36301. /**
  36302. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36303. */
  36304. /**
  36305. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36306. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36307. */
  36308. autoTransitionRange: boolean;
  36309. private _attachedCamera;
  36310. private _onAfterCheckInputsObserver;
  36311. private _onMeshTargetChangedObserver;
  36312. /**
  36313. * Initializes the behavior.
  36314. */
  36315. init(): void;
  36316. /**
  36317. * Attaches the behavior to its arc rotate camera.
  36318. * @param camera Defines the camera to attach the behavior to
  36319. */
  36320. attach(camera: ArcRotateCamera): void;
  36321. /**
  36322. * Detaches the behavior from its current arc rotate camera.
  36323. */
  36324. detach(): void;
  36325. private _radiusIsAnimating;
  36326. private _radiusBounceTransition;
  36327. private _animatables;
  36328. private _cachedWheelPrecision;
  36329. /**
  36330. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36331. * @param radiusLimit The limit to check against.
  36332. * @return Bool to indicate if at limit.
  36333. */
  36334. private _isRadiusAtLimit;
  36335. /**
  36336. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36337. * @param radiusDelta The delta by which to animate to. Can be negative.
  36338. */
  36339. private _applyBoundRadiusAnimation;
  36340. /**
  36341. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36342. */
  36343. protected _clearAnimationLocks(): void;
  36344. /**
  36345. * Stops and removes all animations that have been applied to the camera
  36346. */
  36347. stopAllAnimations(): void;
  36348. }
  36349. }
  36350. declare module BABYLON {
  36351. /**
  36352. * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  36353. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36354. */
  36355. class FramingBehavior implements Behavior<ArcRotateCamera> {
  36356. /**
  36357. * Gets the name of the behavior.
  36358. */
  36359. readonly name: string;
  36360. private _mode;
  36361. private _radiusScale;
  36362. private _positionScale;
  36363. private _defaultElevation;
  36364. private _elevationReturnTime;
  36365. private _elevationReturnWaitTime;
  36366. private _zoomStopsAnimation;
  36367. private _framingTime;
  36368. /**
  36369. * The easing function used by animations
  36370. */
  36371. static EasingFunction: ExponentialEase;
  36372. /**
  36373. * The easing mode used by animations
  36374. */
  36375. static EasingMode: number;
  36376. /**
  36377. * Sets the current mode used by the behavior
  36378. */
  36379. /**
  36380. * Gets current mode used by the behavior.
  36381. */
  36382. mode: number;
  36383. /**
  36384. * Sets the scale applied to the radius (1 by default)
  36385. */
  36386. /**
  36387. * Gets the scale applied to the radius
  36388. */
  36389. radiusScale: number;
  36390. /**
  36391. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36392. */
  36393. /**
  36394. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36395. */
  36396. positionScale: number;
  36397. /**
  36398. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36399. * behaviour is triggered, in radians.
  36400. */
  36401. /**
  36402. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36403. * behaviour is triggered, in radians.
  36404. */
  36405. defaultElevation: number;
  36406. /**
  36407. * Sets the time (in milliseconds) taken to return to the default beta position.
  36408. * Negative value indicates camera should not return to default.
  36409. */
  36410. /**
  36411. * Gets the time (in milliseconds) taken to return to the default beta position.
  36412. * Negative value indicates camera should not return to default.
  36413. */
  36414. elevationReturnTime: number;
  36415. /**
  36416. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36417. */
  36418. /**
  36419. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36420. */
  36421. elevationReturnWaitTime: number;
  36422. /**
  36423. * Sets the flag that indicates if user zooming should stop animation.
  36424. */
  36425. /**
  36426. * Gets the flag that indicates if user zooming should stop animation.
  36427. */
  36428. zoomStopsAnimation: boolean;
  36429. /**
  36430. * Sets the transition time when framing the mesh, in milliseconds
  36431. */
  36432. /**
  36433. * Gets the transition time when framing the mesh, in milliseconds
  36434. */
  36435. framingTime: number;
  36436. /**
  36437. * Define if the behavior should automatically change the configured
  36438. * camera limits and sensibilities.
  36439. */
  36440. autoCorrectCameraLimitsAndSensibility: boolean;
  36441. private _onPrePointerObservableObserver;
  36442. private _onAfterCheckInputsObserver;
  36443. private _onMeshTargetChangedObserver;
  36444. private _attachedCamera;
  36445. private _isPointerDown;
  36446. private _lastInteractionTime;
  36447. /**
  36448. * Initializes the behavior.
  36449. */
  36450. init(): void;
  36451. /**
  36452. * Attaches the behavior to its arc rotate camera.
  36453. * @param camera Defines the camera to attach the behavior to
  36454. */
  36455. attach(camera: ArcRotateCamera): void;
  36456. /**
  36457. * Detaches the behavior from its current arc rotate camera.
  36458. */
  36459. detach(): void;
  36460. private _animatables;
  36461. private _betaIsAnimating;
  36462. private _betaTransition;
  36463. private _radiusTransition;
  36464. private _vectorTransition;
  36465. /**
  36466. * Targets the given mesh and updates zoom level accordingly.
  36467. * @param mesh The mesh to target.
  36468. * @param radius Optional. If a cached radius position already exists, overrides default.
  36469. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36472. */
  36473. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36474. /**
  36475. * Targets the given mesh with its children and updates zoom level accordingly.
  36476. * @param mesh The mesh to target.
  36477. * @param radius Optional. If a cached radius position already exists, overrides default.
  36478. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36481. */
  36482. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36483. /**
  36484. * Targets the given meshes with their children and updates zoom level accordingly.
  36485. * @param meshes The mesh to target.
  36486. * @param radius Optional. If a cached radius position already exists, overrides default.
  36487. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36490. */
  36491. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36492. /**
  36493. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36494. * @param minimumWorld Determines the smaller position of the bounding box extend
  36495. * @param maximumWorld Determines the bigger position of the bounding box extend
  36496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36498. */
  36499. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36500. /**
  36501. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36502. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36503. * frustum width.
  36504. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36505. * to fully enclose the mesh in the viewing frustum.
  36506. */
  36507. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36508. /**
  36509. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36510. * is automatically returned to its default position (expected to be above ground plane).
  36511. */
  36512. private _maintainCameraAboveGround;
  36513. /**
  36514. * Returns the frustum slope based on the canvas ratio and camera FOV
  36515. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36516. */
  36517. private _getFrustumSlope;
  36518. /**
  36519. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36520. */
  36521. private _clearAnimationLocks;
  36522. /**
  36523. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36524. */
  36525. private _applyUserInteraction;
  36526. /**
  36527. * Stops and removes all animations that have been applied to the camera
  36528. */
  36529. stopAllAnimations(): void;
  36530. /**
  36531. * Gets a value indicating if the user is moving the camera
  36532. */
  36533. readonly isUserIsMoving: boolean;
  36534. /**
  36535. * The camera can move all the way towards the mesh.
  36536. */
  36537. static IgnoreBoundsSizeMode: number;
  36538. /**
  36539. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36540. */
  36541. static FitFrustumSidesMode: number;
  36542. }
  36543. }
  36544. declare module BABYLON {
  36545. /**
  36546. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36547. */
  36548. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  36549. private ui;
  36550. /**
  36551. * The name of the behavior
  36552. */
  36553. name: string;
  36554. /**
  36555. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36556. */
  36557. distanceAwayFromFace: number;
  36558. /**
  36559. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36560. */
  36561. distanceAwayFromBottomOfFace: number;
  36562. private _faceVectors;
  36563. private _target;
  36564. private _scene;
  36565. private _onRenderObserver;
  36566. private _tmpMatrix;
  36567. private _tmpVector;
  36568. /**
  36569. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36570. * @param ui The transform node that should be attched to the mesh
  36571. */
  36572. constructor(ui: BABYLON.TransformNode);
  36573. /**
  36574. * Initializes the behavior
  36575. */
  36576. init(): void;
  36577. private _closestFace;
  36578. private _zeroVector;
  36579. private _lookAtTmpMatrix;
  36580. private _lookAtToRef;
  36581. /**
  36582. * Attaches the AttachToBoxBehavior to the passed in mesh
  36583. * @param target The mesh that the specified node will be attached to
  36584. */
  36585. attach(target: BABYLON.Mesh): void;
  36586. /**
  36587. * Detaches the behavior from the mesh
  36588. */
  36589. detach(): void;
  36590. }
  36591. }
  36592. declare module BABYLON {
  36593. /**
  36594. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36595. */
  36596. class FadeInOutBehavior implements Behavior<Mesh> {
  36597. /**
  36598. * Time in milliseconds to delay before fading in (Default: 0)
  36599. */
  36600. delay: number;
  36601. /**
  36602. * Time in milliseconds for the mesh to fade in (Default: 300)
  36603. */
  36604. fadeInTime: number;
  36605. private _millisecondsPerFrame;
  36606. private _hovered;
  36607. private _hoverValue;
  36608. private _ownerNode;
  36609. /**
  36610. * Instatiates the FadeInOutBehavior
  36611. */
  36612. constructor();
  36613. /**
  36614. * The name of the behavior
  36615. */
  36616. readonly name: string;
  36617. /**
  36618. * Initializes the behavior
  36619. */
  36620. init(): void;
  36621. /**
  36622. * Attaches the fade behavior on the passed in mesh
  36623. * @param ownerNode The mesh that will be faded in/out once attached
  36624. */
  36625. attach(ownerNode: Mesh): void;
  36626. /**
  36627. * Detaches the behavior from the mesh
  36628. */
  36629. detach(): void;
  36630. /**
  36631. * Triggers the mesh to begin fading in or out
  36632. * @param value if the object should fade in or out (true to fade in)
  36633. */
  36634. fadeIn(value: boolean): void;
  36635. private _update;
  36636. private _setAllVisibility;
  36637. }
  36638. }
  36639. declare module BABYLON {
  36640. /**
  36641. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36642. */
  36643. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36644. private _dragBehaviorA;
  36645. private _dragBehaviorB;
  36646. private _startDistance;
  36647. private _initialScale;
  36648. private _targetScale;
  36649. private _ownerNode;
  36650. private _sceneRenderObserver;
  36651. /**
  36652. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36653. */
  36654. constructor();
  36655. /**
  36656. * The name of the behavior
  36657. */
  36658. readonly name: string;
  36659. /**
  36660. * Initializes the behavior
  36661. */
  36662. init(): void;
  36663. private _getCurrentDistance;
  36664. /**
  36665. * Attaches the scale behavior the passed in mesh
  36666. * @param ownerNode The mesh that will be scaled around once attached
  36667. */
  36668. attach(ownerNode: Mesh): void;
  36669. /**
  36670. * Detaches the behavior from the mesh
  36671. */
  36672. detach(): void;
  36673. }
  36674. }
  36675. declare module BABYLON {
  36676. /**
  36677. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36678. */
  36679. class PointerDragBehavior implements Behavior<Mesh> {
  36680. private static _AnyMouseID;
  36681. private _attachedNode;
  36682. private _dragPlane;
  36683. private _scene;
  36684. private _pointerObserver;
  36685. private _beforeRenderObserver;
  36686. private static _planeScene;
  36687. /**
  36688. * 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)
  36689. */
  36690. maxDragAngle: number;
  36691. /**
  36692. * @hidden
  36693. */
  36694. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36695. /**
  36696. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36697. */
  36698. currentDraggingPointerID: number;
  36699. /**
  36700. * The last position where the pointer hit the drag plane in world space
  36701. */
  36702. lastDragPosition: Vector3;
  36703. /**
  36704. * If the behavior is currently in a dragging state
  36705. */
  36706. dragging: boolean;
  36707. /**
  36708. * 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)
  36709. */
  36710. dragDeltaRatio: number;
  36711. /**
  36712. * If the drag plane orientation should be updated during the dragging (Default: true)
  36713. */
  36714. updateDragPlane: boolean;
  36715. private _debugMode;
  36716. private _moving;
  36717. /**
  36718. * Fires each time the attached mesh is dragged with the pointer
  36719. * * delta between last drag position and current drag position in world space
  36720. * * dragDistance along the drag axis
  36721. * * dragPlaneNormal normal of the current drag plane used during the drag
  36722. * * dragPlanePoint in world space where the drag intersects the drag plane
  36723. */
  36724. onDragObservable: Observable<{
  36725. delta: Vector3;
  36726. dragPlanePoint: Vector3;
  36727. dragPlaneNormal: Vector3;
  36728. dragDistance: number;
  36729. pointerId: number;
  36730. }>;
  36731. /**
  36732. * Fires each time a drag begins (eg. mouse down on mesh)
  36733. */
  36734. onDragStartObservable: Observable<{
  36735. dragPlanePoint: Vector3;
  36736. pointerId: number;
  36737. }>;
  36738. /**
  36739. * Fires each time a drag ends (eg. mouse release after drag)
  36740. */
  36741. onDragEndObservable: Observable<{
  36742. dragPlanePoint: Vector3;
  36743. pointerId: number;
  36744. }>;
  36745. /**
  36746. * If the attached mesh should be moved when dragged
  36747. */
  36748. moveAttached: boolean;
  36749. /**
  36750. * If the drag behavior will react to drag events (Default: true)
  36751. */
  36752. enabled: boolean;
  36753. /**
  36754. * If camera controls should be detached during the drag
  36755. */
  36756. detachCameraControls: boolean;
  36757. /**
  36758. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36759. */
  36760. useObjectOrienationForDragging: boolean;
  36761. private _options;
  36762. /**
  36763. * Creates a pointer drag behavior that can be attached to a mesh
  36764. * @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)
  36765. */
  36766. constructor(options?: {
  36767. dragAxis?: Vector3;
  36768. dragPlaneNormal?: Vector3;
  36769. });
  36770. /**
  36771. * The name of the behavior
  36772. */
  36773. readonly name: string;
  36774. /**
  36775. * Initializes the behavior
  36776. */
  36777. init(): void;
  36778. private _tmpVector;
  36779. private _alternatePickedPoint;
  36780. private _worldDragAxis;
  36781. private _targetPosition;
  36782. private _attachedElement;
  36783. /**
  36784. * Attaches the drag behavior the passed in mesh
  36785. * @param ownerNode The mesh that will be dragged around once attached
  36786. */
  36787. attach(ownerNode: Mesh): void;
  36788. /**
  36789. * Force relase the drag action by code.
  36790. */
  36791. releaseDrag(): void;
  36792. private _startDragRay;
  36793. private _lastPointerRay;
  36794. /**
  36795. * Simulates the start of a pointer drag event on the behavior
  36796. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36797. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36798. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36799. */
  36800. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36801. private _startDrag;
  36802. private _dragDelta;
  36803. private _moveDrag;
  36804. private _pickWithRayOnDragPlane;
  36805. private _pointA;
  36806. private _pointB;
  36807. private _pointC;
  36808. private _lineA;
  36809. private _lineB;
  36810. private _localAxis;
  36811. private _lookAt;
  36812. private _updateDragPlanePosition;
  36813. /**
  36814. * Detaches the behavior from the mesh
  36815. */
  36816. detach(): void;
  36817. }
  36818. }
  36819. declare module BABYLON {
  36820. /**
  36821. * 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
  36822. */
  36823. class SixDofDragBehavior implements Behavior<Mesh> {
  36824. private static _virtualScene;
  36825. private _ownerNode;
  36826. private _sceneRenderObserver;
  36827. private _scene;
  36828. private _targetPosition;
  36829. private _virtualOriginMesh;
  36830. private _virtualDragMesh;
  36831. private _pointerObserver;
  36832. private _moving;
  36833. private _startingOrientation;
  36834. /**
  36835. * 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)
  36836. */
  36837. private zDragFactor;
  36838. /**
  36839. * If the behavior is currently in a dragging state
  36840. */
  36841. dragging: boolean;
  36842. /**
  36843. * 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)
  36844. */
  36845. dragDeltaRatio: number;
  36846. /**
  36847. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36848. */
  36849. currentDraggingPointerID: number;
  36850. /**
  36851. * If camera controls should be detached during the drag
  36852. */
  36853. detachCameraControls: boolean;
  36854. /**
  36855. * Fires each time a drag starts
  36856. */
  36857. onDragStartObservable: Observable<{}>;
  36858. /**
  36859. * Fires each time a drag ends (eg. mouse release after drag)
  36860. */
  36861. onDragEndObservable: Observable<{}>;
  36862. /**
  36863. * Instantiates 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
  36864. */
  36865. constructor();
  36866. /**
  36867. * The name of the behavior
  36868. */
  36869. readonly name: string;
  36870. /**
  36871. * Initializes the behavior
  36872. */
  36873. init(): void;
  36874. /**
  36875. * Attaches the scale behavior the passed in mesh
  36876. * @param ownerNode The mesh that will be scaled around once attached
  36877. */
  36878. attach(ownerNode: Mesh): void;
  36879. /**
  36880. * Detaches the behavior from the mesh
  36881. */
  36882. detach(): void;
  36883. }
  36884. }
  36885. declare module BABYLON {
  36886. /**
  36887. * Manage the gamepad inputs to control an arc rotate camera.
  36888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36889. */
  36890. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36891. /**
  36892. * Defines the camera the input is attached to.
  36893. */
  36894. camera: ArcRotateCamera;
  36895. /**
  36896. * Defines the gamepad the input is gathering event from.
  36897. */
  36898. gamepad: Nullable<Gamepad>;
  36899. /**
  36900. * Defines the gamepad rotation sensiblity.
  36901. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36902. */
  36903. gamepadRotationSensibility: number;
  36904. /**
  36905. * Defines the gamepad move sensiblity.
  36906. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36907. */
  36908. gamepadMoveSensibility: number;
  36909. private _onGamepadConnectedObserver;
  36910. private _onGamepadDisconnectedObserver;
  36911. /**
  36912. * Attach the input controls to a specific dom element to get the input from.
  36913. * @param element Defines the element the controls should be listened from
  36914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36915. */
  36916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36917. /**
  36918. * Detach the current controls from the specified dom element.
  36919. * @param element Defines the element to stop listening the inputs from
  36920. */
  36921. detachControl(element: Nullable<HTMLElement>): void;
  36922. /**
  36923. * Update the current camera state depending on the inputs that have been used this frame.
  36924. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36925. */
  36926. checkInputs(): void;
  36927. /**
  36928. * Gets the class name of the current intput.
  36929. * @returns the class name
  36930. */
  36931. getClassName(): string;
  36932. /**
  36933. * Get the friendly name associated with the input class.
  36934. * @returns the input friendly name
  36935. */
  36936. getSimpleName(): string;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36943. */
  36944. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36945. /**
  36946. * Defines the camera the input is attached to.
  36947. */
  36948. camera: ArcRotateCamera;
  36949. /**
  36950. * Defines the list of key codes associated with the up action (increase alpha)
  36951. */
  36952. keysUp: number[];
  36953. /**
  36954. * Defines the list of key codes associated with the down action (decrease alpha)
  36955. */
  36956. keysDown: number[];
  36957. /**
  36958. * Defines the list of key codes associated with the left action (increase beta)
  36959. */
  36960. keysLeft: number[];
  36961. /**
  36962. * Defines the list of key codes associated with the right action (decrease beta)
  36963. */
  36964. keysRight: number[];
  36965. /**
  36966. * Defines the list of key codes associated with the reset action.
  36967. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36968. */
  36969. keysReset: number[];
  36970. /**
  36971. * Defines the panning sensibility of the inputs.
  36972. * (How fast is the camera paning)
  36973. */
  36974. panningSensibility: number;
  36975. /**
  36976. * Defines the zooming sensibility of the inputs.
  36977. * (How fast is the camera zooming)
  36978. */
  36979. zoomingSensibility: number;
  36980. /**
  36981. * Defines wether maintaining the alt key down switch the movement mode from
  36982. * orientation to zoom.
  36983. */
  36984. useAltToZoom: boolean;
  36985. private _keys;
  36986. private _ctrlPressed;
  36987. private _altPressed;
  36988. private _onCanvasBlurObserver;
  36989. private _onKeyboardObserver;
  36990. private _engine;
  36991. private _scene;
  36992. /**
  36993. * Attach the input controls to a specific dom element to get the input from.
  36994. * @param element Defines the element the controls should be listened from
  36995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36996. */
  36997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36998. /**
  36999. * Detach the current controls from the specified dom element.
  37000. * @param element Defines the element to stop listening the inputs from
  37001. */
  37002. detachControl(element: Nullable<HTMLElement>): void;
  37003. /**
  37004. * Update the current camera state depending on the inputs that have been used this frame.
  37005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37006. */
  37007. checkInputs(): void;
  37008. /**
  37009. * Gets the class name of the current intput.
  37010. * @returns the class name
  37011. */
  37012. getClassName(): string;
  37013. /**
  37014. * Get the friendly name associated with the input class.
  37015. * @returns the input friendly name
  37016. */
  37017. getSimpleName(): string;
  37018. }
  37019. }
  37020. declare module BABYLON {
  37021. /**
  37022. * Manage the mouse wheel inputs to control an arc rotate camera.
  37023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37024. */
  37025. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37026. /**
  37027. * Defines the camera the input is attached to.
  37028. */
  37029. camera: ArcRotateCamera;
  37030. /**
  37031. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37032. */
  37033. wheelPrecision: number;
  37034. /**
  37035. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37036. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37037. */
  37038. wheelDeltaPercentage: number;
  37039. private _wheel;
  37040. private _observer;
  37041. /**
  37042. * Attach the input controls to a specific dom element to get the input from.
  37043. * @param element Defines the element the controls should be listened from
  37044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37045. */
  37046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37047. /**
  37048. * Detach the current controls from the specified dom element.
  37049. * @param element Defines the element to stop listening the inputs from
  37050. */
  37051. detachControl(element: Nullable<HTMLElement>): void;
  37052. /**
  37053. * Gets the class name of the current intput.
  37054. * @returns the class name
  37055. */
  37056. getClassName(): string;
  37057. /**
  37058. * Get the friendly name associated with the input class.
  37059. * @returns the input friendly name
  37060. */
  37061. getSimpleName(): string;
  37062. }
  37063. }
  37064. declare module BABYLON {
  37065. /**
  37066. * Manage the pointers inputs to control an arc rotate camera.
  37067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37068. */
  37069. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  37070. /**
  37071. * Defines the camera the input is attached to.
  37072. */
  37073. camera: ArcRotateCamera;
  37074. /**
  37075. * Defines the buttons associated with the input to handle camera move.
  37076. */
  37077. buttons: number[];
  37078. /**
  37079. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37080. */
  37081. angularSensibilityX: number;
  37082. /**
  37083. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37084. */
  37085. angularSensibilityY: number;
  37086. /**
  37087. * Defines the pointer pinch precision or how fast is the camera zooming.
  37088. */
  37089. pinchPrecision: number;
  37090. /**
  37091. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  37092. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37093. */
  37094. pinchDeltaPercentage: number;
  37095. /**
  37096. * Defines the pointer panning sensibility or how fast is the camera moving.
  37097. */
  37098. panningSensibility: number;
  37099. /**
  37100. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37101. */
  37102. multiTouchPanning: boolean;
  37103. /**
  37104. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  37105. */
  37106. multiTouchPanAndZoom: boolean;
  37107. /**
  37108. * Revers pinch action direction.
  37109. */
  37110. pinchInwards: boolean;
  37111. private _isPanClick;
  37112. private _pointerInput;
  37113. private _observer;
  37114. private _onMouseMove;
  37115. private _onGestureStart;
  37116. private _onGesture;
  37117. private _MSGestureHandler;
  37118. private _onLostFocus;
  37119. private _onContextMenu;
  37120. /**
  37121. * Attach the input controls to a specific dom element to get the input from.
  37122. * @param element Defines the element the controls should be listened from
  37123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37124. */
  37125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37126. /**
  37127. * Detach the current controls from the specified dom element.
  37128. * @param element Defines the element to stop listening the inputs from
  37129. */
  37130. detachControl(element: Nullable<HTMLElement>): void;
  37131. /**
  37132. * Gets the class name of the current intput.
  37133. * @returns the class name
  37134. */
  37135. getClassName(): string;
  37136. /**
  37137. * Get the friendly name associated with the input class.
  37138. * @returns the input friendly name
  37139. */
  37140. getSimpleName(): string;
  37141. }
  37142. }
  37143. declare module BABYLON {
  37144. /**
  37145. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37147. */
  37148. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37149. /**
  37150. * Defines the camera the input is attached to.
  37151. */
  37152. camera: ArcRotateCamera;
  37153. /**
  37154. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37155. */
  37156. alphaCorrection: number;
  37157. /**
  37158. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  37159. */
  37160. betaCorrection: number;
  37161. /**
  37162. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37163. */
  37164. gammaCorrection: number;
  37165. private _alpha;
  37166. private _gamma;
  37167. private _dirty;
  37168. private _deviceOrientationHandler;
  37169. /**
  37170. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37171. */
  37172. constructor();
  37173. /**
  37174. * Attach the input controls to a specific dom element to get the input from.
  37175. * @param element Defines the element the controls should be listened from
  37176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37177. */
  37178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37179. /** @hidden */
  37180. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37181. /**
  37182. * Update the current camera state depending on the inputs that have been used this frame.
  37183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37184. */
  37185. checkInputs(): void;
  37186. /**
  37187. * Detach the current controls from the specified dom element.
  37188. * @param element Defines the element to stop listening the inputs from
  37189. */
  37190. detachControl(element: Nullable<HTMLElement>): void;
  37191. /**
  37192. * Gets the class name of the current intput.
  37193. * @returns the class name
  37194. */
  37195. getClassName(): string;
  37196. /**
  37197. * Get the friendly name associated with the input class.
  37198. * @returns the input friendly name
  37199. */
  37200. getSimpleName(): string;
  37201. }
  37202. }
  37203. declare module BABYLON {
  37204. /**
  37205. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37206. * Screen rotation is taken into account.
  37207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37208. */
  37209. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37210. private _camera;
  37211. private _screenOrientationAngle;
  37212. private _constantTranform;
  37213. private _screenQuaternion;
  37214. private _alpha;
  37215. private _beta;
  37216. private _gamma;
  37217. /**
  37218. * Instantiates a new input
  37219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37220. */
  37221. constructor();
  37222. /**
  37223. * Define the camera controlled by the input.
  37224. */
  37225. camera: FreeCamera;
  37226. /**
  37227. * Attach the input controls to a specific dom element to get the input from.
  37228. * @param element Defines the element the controls should be listened from
  37229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37230. */
  37231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37232. private _orientationChanged;
  37233. private _deviceOrientation;
  37234. /**
  37235. * Detach the current controls from the specified dom element.
  37236. * @param element Defines the element to stop listening the inputs from
  37237. */
  37238. detachControl(element: Nullable<HTMLElement>): void;
  37239. /**
  37240. * Update the current camera state depending on the inputs that have been used this frame.
  37241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37242. */
  37243. checkInputs(): void;
  37244. /**
  37245. * Gets the class name of the current intput.
  37246. * @returns the class name
  37247. */
  37248. getClassName(): string;
  37249. /**
  37250. * Get the friendly name associated with the input class.
  37251. * @returns the input friendly name
  37252. */
  37253. getSimpleName(): string;
  37254. }
  37255. }
  37256. declare module BABYLON {
  37257. /**
  37258. * Manage the gamepad inputs to control a free camera.
  37259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37260. */
  37261. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37262. /**
  37263. * Define the camera the input is attached to.
  37264. */
  37265. camera: FreeCamera;
  37266. /**
  37267. * Define the Gamepad controlling the input
  37268. */
  37269. gamepad: Nullable<Gamepad>;
  37270. /**
  37271. * Defines the gamepad rotation sensiblity.
  37272. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37273. */
  37274. gamepadAngularSensibility: number;
  37275. /**
  37276. * Defines the gamepad move sensiblity.
  37277. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37278. */
  37279. gamepadMoveSensibility: number;
  37280. private _onGamepadConnectedObserver;
  37281. private _onGamepadDisconnectedObserver;
  37282. private _cameraTransform;
  37283. private _deltaTransform;
  37284. private _vector3;
  37285. private _vector2;
  37286. /**
  37287. * Attach the input controls to a specific dom element to get the input from.
  37288. * @param element Defines the element the controls should be listened from
  37289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37290. */
  37291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37292. /**
  37293. * Detach the current controls from the specified dom element.
  37294. * @param element Defines the element to stop listening the inputs from
  37295. */
  37296. detachControl(element: Nullable<HTMLElement>): void;
  37297. /**
  37298. * Update the current camera state depending on the inputs that have been used this frame.
  37299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37300. */
  37301. checkInputs(): void;
  37302. /**
  37303. * Gets the class name of the current intput.
  37304. * @returns the class name
  37305. */
  37306. getClassName(): string;
  37307. /**
  37308. * Get the friendly name associated with the input class.
  37309. * @returns the input friendly name
  37310. */
  37311. getSimpleName(): string;
  37312. }
  37313. }
  37314. declare module BABYLON {
  37315. /**
  37316. * Manage the keyboard inputs to control the movement of a free camera.
  37317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37318. */
  37319. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  37320. /**
  37321. * Defines the camera the input is attached to.
  37322. */
  37323. camera: FreeCamera;
  37324. /**
  37325. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  37326. */
  37327. keysUp: number[];
  37328. /**
  37329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  37330. */
  37331. keysDown: number[];
  37332. /**
  37333. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  37334. */
  37335. keysLeft: number[];
  37336. /**
  37337. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  37338. */
  37339. keysRight: number[];
  37340. private _keys;
  37341. private _onCanvasBlurObserver;
  37342. private _onKeyboardObserver;
  37343. private _engine;
  37344. private _scene;
  37345. /**
  37346. * Attach the input controls to a specific dom element to get the input from.
  37347. * @param element Defines the element the controls should be listened from
  37348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37349. */
  37350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37351. /**
  37352. * Detach the current controls from the specified dom element.
  37353. * @param element Defines the element to stop listening the inputs from
  37354. */
  37355. detachControl(element: Nullable<HTMLElement>): void;
  37356. /**
  37357. * Update the current camera state depending on the inputs that have been used this frame.
  37358. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37359. */
  37360. checkInputs(): void;
  37361. /**
  37362. * Gets the class name of the current intput.
  37363. * @returns the class name
  37364. */
  37365. getClassName(): string;
  37366. /** @hidden */
  37367. _onLostFocus(e: FocusEvent): void;
  37368. /**
  37369. * Get the friendly name associated with the input class.
  37370. * @returns the input friendly name
  37371. */
  37372. getSimpleName(): string;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * Manage the mouse inputs to control the movement of a free camera.
  37378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37379. */
  37380. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  37381. /**
  37382. * Define if touch is enabled in the mouse input
  37383. */
  37384. touchEnabled: boolean;
  37385. /**
  37386. * Defines the camera the input is attached to.
  37387. */
  37388. camera: FreeCamera;
  37389. /**
  37390. * Defines the buttons associated with the input to handle camera move.
  37391. */
  37392. buttons: number[];
  37393. /**
  37394. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  37395. */
  37396. angularSensibility: number;
  37397. private _pointerInput;
  37398. private _onMouseMove;
  37399. private _observer;
  37400. private previousPosition;
  37401. /**
  37402. * Manage the mouse inputs to control the movement of a free camera.
  37403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37404. * @param touchEnabled Defines if touch is enabled or not
  37405. */
  37406. constructor(
  37407. /**
  37408. * Define if touch is enabled in the mouse input
  37409. */
  37410. touchEnabled?: boolean);
  37411. /**
  37412. * Attach the input controls to a specific dom element to get the input from.
  37413. * @param element Defines the element the controls should be listened from
  37414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37415. */
  37416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37417. /**
  37418. * Detach the current controls from the specified dom element.
  37419. * @param element Defines the element to stop listening the inputs from
  37420. */
  37421. detachControl(element: Nullable<HTMLElement>): void;
  37422. /**
  37423. * Gets the class name of the current intput.
  37424. * @returns the class name
  37425. */
  37426. getClassName(): string;
  37427. /**
  37428. * Get the friendly name associated with the input class.
  37429. * @returns the input friendly name
  37430. */
  37431. getSimpleName(): string;
  37432. }
  37433. }
  37434. declare module BABYLON {
  37435. /**
  37436. * Manage the touch inputs to control the movement of a free camera.
  37437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37438. */
  37439. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  37440. /**
  37441. * Defines the camera the input is attached to.
  37442. */
  37443. camera: FreeCamera;
  37444. /**
  37445. * Defines the touch sensibility for rotation.
  37446. * The higher the faster.
  37447. */
  37448. touchAngularSensibility: number;
  37449. /**
  37450. * Defines the touch sensibility for move.
  37451. * The higher the faster.
  37452. */
  37453. touchMoveSensibility: number;
  37454. private _offsetX;
  37455. private _offsetY;
  37456. private _pointerPressed;
  37457. private _pointerInput;
  37458. private _observer;
  37459. private _onLostFocus;
  37460. /**
  37461. * Attach the input controls to a specific dom element to get the input from.
  37462. * @param element Defines the element the controls should be listened from
  37463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37464. */
  37465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37466. /**
  37467. * Detach the current controls from the specified dom element.
  37468. * @param element Defines the element to stop listening the inputs from
  37469. */
  37470. detachControl(element: Nullable<HTMLElement>): void;
  37471. /**
  37472. * Update the current camera state depending on the inputs that have been used this frame.
  37473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37474. */
  37475. checkInputs(): void;
  37476. /**
  37477. * Gets the class name of the current intput.
  37478. * @returns the class name
  37479. */
  37480. getClassName(): string;
  37481. /**
  37482. * Get the friendly name associated with the input class.
  37483. * @returns the input friendly name
  37484. */
  37485. getSimpleName(): string;
  37486. }
  37487. }
  37488. declare module BABYLON {
  37489. /**
  37490. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37492. */
  37493. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37494. /**
  37495. * Defines the camera the input is attached to.
  37496. */
  37497. camera: FreeCamera;
  37498. private _leftjoystick;
  37499. private _rightjoystick;
  37500. /**
  37501. * Gets the left stick of the virtual joystick.
  37502. * @returns The virtual Joystick
  37503. */
  37504. getLeftJoystick(): VirtualJoystick;
  37505. /**
  37506. * Gets the right stick of the virtual joystick.
  37507. * @returns The virtual Joystick
  37508. */
  37509. getRightJoystick(): VirtualJoystick;
  37510. /**
  37511. * Update the current camera state depending on the inputs that have been used this frame.
  37512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37513. */
  37514. checkInputs(): void;
  37515. /**
  37516. * Attach the input controls to a specific dom element to get the input from.
  37517. * @param element Defines the element the controls should be listened from
  37518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37519. */
  37520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37521. /**
  37522. * Detach the current controls from the specified dom element.
  37523. * @param element Defines the element to stop listening the inputs from
  37524. */
  37525. detachControl(element: Nullable<HTMLElement>): void;
  37526. /**
  37527. * Gets the class name of the current intput.
  37528. * @returns the class name
  37529. */
  37530. getClassName(): string;
  37531. /**
  37532. * Get the friendly name associated with the input class.
  37533. * @returns the input friendly name
  37534. */
  37535. getSimpleName(): string;
  37536. }
  37537. }
  37538. declare module BABYLON {
  37539. /**
  37540. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37541. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37542. */
  37543. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37544. /**
  37545. * Creates a new AnaglyphArcRotateCamera
  37546. * @param name defines camera name
  37547. * @param alpha defines alpha angle (in radians)
  37548. * @param beta defines beta angle (in radians)
  37549. * @param radius defines radius
  37550. * @param target defines camera target
  37551. * @param interaxialDistance defines distance between each color axis
  37552. * @param scene defines the hosting scene
  37553. */
  37554. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37555. /**
  37556. * Gets camera class name
  37557. * @returns AnaglyphArcRotateCamera
  37558. */
  37559. getClassName(): string;
  37560. }
  37561. }
  37562. declare module BABYLON {
  37563. /**
  37564. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37565. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37566. */
  37567. class AnaglyphFreeCamera extends FreeCamera {
  37568. /**
  37569. * Creates a new AnaglyphFreeCamera
  37570. * @param name defines camera name
  37571. * @param position defines initial position
  37572. * @param interaxialDistance defines distance between each color axis
  37573. * @param scene defines the hosting scene
  37574. */
  37575. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37576. /**
  37577. * Gets camera class name
  37578. * @returns AnaglyphFreeCamera
  37579. */
  37580. getClassName(): string;
  37581. }
  37582. }
  37583. declare module BABYLON {
  37584. /**
  37585. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37586. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37587. */
  37588. class AnaglyphGamepadCamera extends GamepadCamera {
  37589. /**
  37590. * Creates a new AnaglyphGamepadCamera
  37591. * @param name defines camera name
  37592. * @param position defines initial position
  37593. * @param interaxialDistance defines distance between each color axis
  37594. * @param scene defines the hosting scene
  37595. */
  37596. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37597. /**
  37598. * Gets camera class name
  37599. * @returns AnaglyphGamepadCamera
  37600. */
  37601. getClassName(): string;
  37602. }
  37603. }
  37604. declare module BABYLON {
  37605. /**
  37606. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37607. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37608. */
  37609. class AnaglyphUniversalCamera extends UniversalCamera {
  37610. /**
  37611. * Creates a new AnaglyphUniversalCamera
  37612. * @param name defines camera name
  37613. * @param position defines initial position
  37614. * @param interaxialDistance defines distance between each color axis
  37615. * @param scene defines the hosting scene
  37616. */
  37617. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37618. /**
  37619. * Gets camera class name
  37620. * @returns AnaglyphUniversalCamera
  37621. */
  37622. getClassName(): string;
  37623. }
  37624. }
  37625. declare module BABYLON {
  37626. /**
  37627. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37628. * @see http://doc.babylonjs.com/features/cameras
  37629. */
  37630. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37631. /**
  37632. * Creates a new StereoscopicArcRotateCamera
  37633. * @param name defines camera name
  37634. * @param alpha defines alpha angle (in radians)
  37635. * @param beta defines beta angle (in radians)
  37636. * @param radius defines radius
  37637. * @param target defines camera target
  37638. * @param interaxialDistance defines distance between each color axis
  37639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37640. * @param scene defines the hosting scene
  37641. */
  37642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37643. /**
  37644. * Gets camera class name
  37645. * @returns StereoscopicArcRotateCamera
  37646. */
  37647. getClassName(): string;
  37648. }
  37649. }
  37650. declare module BABYLON {
  37651. /**
  37652. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37653. * @see http://doc.babylonjs.com/features/cameras
  37654. */
  37655. class StereoscopicFreeCamera extends FreeCamera {
  37656. /**
  37657. * Creates a new StereoscopicFreeCamera
  37658. * @param name defines camera name
  37659. * @param position defines initial position
  37660. * @param interaxialDistance defines distance between each color axis
  37661. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37662. * @param scene defines the hosting scene
  37663. */
  37664. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37665. /**
  37666. * Gets camera class name
  37667. * @returns StereoscopicFreeCamera
  37668. */
  37669. getClassName(): string;
  37670. }
  37671. }
  37672. declare module BABYLON {
  37673. /**
  37674. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37675. * @see http://doc.babylonjs.com/features/cameras
  37676. */
  37677. class StereoscopicGamepadCamera extends GamepadCamera {
  37678. /**
  37679. * Creates a new StereoscopicGamepadCamera
  37680. * @param name defines camera name
  37681. * @param position defines initial position
  37682. * @param interaxialDistance defines distance between each color axis
  37683. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37684. * @param scene defines the hosting scene
  37685. */
  37686. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37687. /**
  37688. * Gets camera class name
  37689. * @returns StereoscopicGamepadCamera
  37690. */
  37691. getClassName(): string;
  37692. }
  37693. }
  37694. declare module BABYLON {
  37695. /**
  37696. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37697. * @see http://doc.babylonjs.com/features/cameras
  37698. */
  37699. class StereoscopicUniversalCamera extends UniversalCamera {
  37700. /**
  37701. * Creates a new StereoscopicUniversalCamera
  37702. * @param name defines camera name
  37703. * @param position defines initial position
  37704. * @param interaxialDistance defines distance between each color axis
  37705. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37706. * @param scene defines the hosting scene
  37707. */
  37708. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37709. /**
  37710. * Gets camera class name
  37711. * @returns StereoscopicUniversalCamera
  37712. */
  37713. getClassName(): string;
  37714. }
  37715. }
  37716. declare module BABYLON {
  37717. /**
  37718. * This represents all the required metrics to create a VR camera.
  37719. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37720. */
  37721. class VRCameraMetrics {
  37722. /**
  37723. * Define the horizontal resolution off the screen.
  37724. */
  37725. hResolution: number;
  37726. /**
  37727. * Define the vertical resolution off the screen.
  37728. */
  37729. vResolution: number;
  37730. /**
  37731. * Define the horizontal screen size.
  37732. */
  37733. hScreenSize: number;
  37734. /**
  37735. * Define the vertical screen size.
  37736. */
  37737. vScreenSize: number;
  37738. /**
  37739. * Define the vertical screen center position.
  37740. */
  37741. vScreenCenter: number;
  37742. /**
  37743. * Define the distance of the eyes to the screen.
  37744. */
  37745. eyeToScreenDistance: number;
  37746. /**
  37747. * Define the distance between both lenses
  37748. */
  37749. lensSeparationDistance: number;
  37750. /**
  37751. * Define the distance between both viewer's eyes.
  37752. */
  37753. interpupillaryDistance: number;
  37754. /**
  37755. * Define the distortion factor of the VR postprocess.
  37756. * Please, touch with care.
  37757. */
  37758. distortionK: number[];
  37759. /**
  37760. * Define the chromatic aberration correction factors for the VR post process.
  37761. */
  37762. chromaAbCorrection: number[];
  37763. /**
  37764. * Define the scale factor of the post process.
  37765. * The smaller the better but the slower.
  37766. */
  37767. postProcessScaleFactor: number;
  37768. /**
  37769. * Define an offset for the lens center.
  37770. */
  37771. lensCenterOffset: number;
  37772. /**
  37773. * Define if the current vr camera should compensate the distortion of the lense or not.
  37774. */
  37775. compensateDistortion: boolean;
  37776. /**
  37777. * Gets the rendering aspect ratio based on the provided resolutions.
  37778. */
  37779. readonly aspectRatio: number;
  37780. /**
  37781. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37782. */
  37783. readonly aspectRatioFov: number;
  37784. /**
  37785. * @hidden
  37786. */
  37787. readonly leftHMatrix: Matrix;
  37788. /**
  37789. * @hidden
  37790. */
  37791. readonly rightHMatrix: Matrix;
  37792. /**
  37793. * @hidden
  37794. */
  37795. readonly leftPreViewMatrix: Matrix;
  37796. /**
  37797. * @hidden
  37798. */
  37799. readonly rightPreViewMatrix: Matrix;
  37800. /**
  37801. * Get the default VRMetrics based on the most generic setup.
  37802. * @returns the default vr metrics
  37803. */
  37804. static GetDefault(): VRCameraMetrics;
  37805. }
  37806. }
  37807. declare module BABYLON {
  37808. /**
  37809. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37810. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37811. */
  37812. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37813. /**
  37814. * Creates a new VRDeviceOrientationArcRotateCamera
  37815. * @param name defines camera name
  37816. * @param alpha defines the camera rotation along the logitudinal axis
  37817. * @param beta defines the camera rotation along the latitudinal axis
  37818. * @param radius defines the camera distance from its target
  37819. * @param target defines the camera target
  37820. * @param scene defines the scene the camera belongs to
  37821. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37822. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37823. */
  37824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37825. /**
  37826. * Gets camera class name
  37827. * @returns VRDeviceOrientationArcRotateCamera
  37828. */
  37829. getClassName(): string;
  37830. }
  37831. }
  37832. declare module BABYLON {
  37833. /**
  37834. * Camera used to simulate VR rendering (based on FreeCamera)
  37835. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37836. */
  37837. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37838. /**
  37839. * Creates a new VRDeviceOrientationFreeCamera
  37840. * @param name defines camera name
  37841. * @param position defines the start position of the camera
  37842. * @param scene defines the scene the camera belongs to
  37843. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37844. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37845. */
  37846. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37847. /**
  37848. * Gets camera class name
  37849. * @returns VRDeviceOrientationFreeCamera
  37850. */
  37851. getClassName(): string;
  37852. }
  37853. }
  37854. declare module BABYLON {
  37855. /**
  37856. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37857. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37858. */
  37859. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37860. /**
  37861. * Creates a new VRDeviceOrientationGamepadCamera
  37862. * @param name defines camera name
  37863. * @param position defines the start position of the camera
  37864. * @param scene defines the scene the camera belongs to
  37865. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37866. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37867. */
  37868. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37869. /**
  37870. * Gets camera class name
  37871. * @returns VRDeviceOrientationGamepadCamera
  37872. */
  37873. getClassName(): string;
  37874. }
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * Options to modify the vr teleportation behavior.
  37879. */
  37880. interface VRTeleportationOptions {
  37881. /**
  37882. * The name of the mesh which should be used as the teleportation floor. (default: null)
  37883. */
  37884. floorMeshName?: string;
  37885. /**
  37886. * A list of meshes to be used as the teleportation floor. (default: empty)
  37887. */
  37888. floorMeshes?: Mesh[];
  37889. }
  37890. /**
  37891. * Options to modify the vr experience helper's behavior.
  37892. */
  37893. interface VRExperienceHelperOptions extends WebVROptions {
  37894. /**
  37895. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  37896. */
  37897. createDeviceOrientationCamera?: boolean;
  37898. /**
  37899. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  37900. */
  37901. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  37902. /**
  37903. * Uses the main button on the controller to toggle the laser casted. (default: true)
  37904. */
  37905. laserToggle?: boolean;
  37906. /**
  37907. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  37908. */
  37909. floorMeshes?: Mesh[];
  37910. }
  37911. /**
  37912. * Helps to quickly add VR support to an existing scene.
  37913. * See http://doc.babylonjs.com/how_to/webvr_helper
  37914. */
  37915. class VRExperienceHelper {
  37916. /** Options to modify the vr experience helper's behavior. */
  37917. webVROptions: VRExperienceHelperOptions;
  37918. private _scene;
  37919. private _position;
  37920. private _btnVR;
  37921. private _btnVRDisplayed;
  37922. private _webVRsupported;
  37923. private _webVRready;
  37924. private _webVRrequesting;
  37925. private _webVRpresenting;
  37926. private _hasEnteredVR;
  37927. private _fullscreenVRpresenting;
  37928. private _canvas;
  37929. private _webVRCamera;
  37930. private _vrDeviceOrientationCamera;
  37931. private _deviceOrientationCamera;
  37932. private _existingCamera;
  37933. private _onKeyDown;
  37934. private _onVrDisplayPresentChange;
  37935. private _onVRDisplayChanged;
  37936. private _onVRRequestPresentStart;
  37937. private _onVRRequestPresentComplete;
  37938. /**
  37939. * Observable raised when entering VR.
  37940. */
  37941. onEnteringVRObservable: Observable<VRExperienceHelper>;
  37942. /**
  37943. * Observable raised when exiting VR.
  37944. */
  37945. onExitingVRObservable: Observable<VRExperienceHelper>;
  37946. /**
  37947. * Observable raised when controller mesh is loaded.
  37948. */
  37949. onControllerMeshLoadedObservable: Observable<WebVRController>;
  37950. /** Return this.onEnteringVRObservable
  37951. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  37952. */
  37953. readonly onEnteringVR: Observable<VRExperienceHelper>;
  37954. /** Return this.onExitingVRObservable
  37955. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  37956. */
  37957. readonly onExitingVR: Observable<VRExperienceHelper>;
  37958. /** Return this.onControllerMeshLoadedObservable
  37959. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  37960. */
  37961. readonly onControllerMeshLoaded: Observable<WebVRController>;
  37962. private _rayLength;
  37963. private _useCustomVRButton;
  37964. private _teleportationRequested;
  37965. private _teleportActive;
  37966. private _floorMeshName;
  37967. private _floorMeshesCollection;
  37968. private _rotationAllowed;
  37969. private _teleportBackwardsVector;
  37970. private _teleportationTarget;
  37971. private _isDefaultTeleportationTarget;
  37972. private _postProcessMove;
  37973. private _teleportationFillColor;
  37974. private _teleportationBorderColor;
  37975. private _rotationAngle;
  37976. private _haloCenter;
  37977. private _cameraGazer;
  37978. private _padSensibilityUp;
  37979. private _padSensibilityDown;
  37980. private _leftController;
  37981. private _rightController;
  37982. /**
  37983. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  37984. */
  37985. onNewMeshSelected: Observable<AbstractMesh>;
  37986. /**
  37987. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  37988. */
  37989. onNewMeshPicked: Observable<PickingInfo>;
  37990. private _circleEase;
  37991. /**
  37992. * Observable raised before camera teleportation
  37993. */
  37994. onBeforeCameraTeleport: Observable<Vector3>;
  37995. /**
  37996. * Observable raised after camera teleportation
  37997. */
  37998. onAfterCameraTeleport: Observable<Vector3>;
  37999. /**
  38000. * Observable raised when current selected mesh gets unselected
  38001. */
  38002. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38003. private _raySelectionPredicate;
  38004. /**
  38005. * To be optionaly changed by user to define custom ray selection
  38006. */
  38007. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38008. /**
  38009. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38010. */
  38011. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38012. /**
  38013. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38014. */
  38015. teleportationEnabled: boolean;
  38016. private _defaultHeight;
  38017. private _teleportationInitialized;
  38018. private _interactionsEnabled;
  38019. private _interactionsRequested;
  38020. private _displayGaze;
  38021. private _displayLaserPointer;
  38022. /**
  38023. * The mesh used to display where the user is going to teleport.
  38024. */
  38025. /**
  38026. * Sets the mesh to be used to display where the user is going to teleport.
  38027. */
  38028. teleportationTarget: Mesh;
  38029. /**
  38030. * 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
  38031. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38032. * See http://doc.babylonjs.com/resources/baking_transformations
  38033. */
  38034. gazeTrackerMesh: Mesh;
  38035. /**
  38036. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38037. */
  38038. updateGazeTrackerScale: boolean;
  38039. /**
  38040. * The gaze tracking mesh corresponding to the left controller
  38041. */
  38042. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38043. /**
  38044. * The gaze tracking mesh corresponding to the right controller
  38045. */
  38046. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38047. /**
  38048. * If the ray of the gaze should be displayed.
  38049. */
  38050. /**
  38051. * Sets if the ray of the gaze should be displayed.
  38052. */
  38053. displayGaze: boolean;
  38054. /**
  38055. * If the ray of the LaserPointer should be displayed.
  38056. */
  38057. /**
  38058. * Sets if the ray of the LaserPointer should be displayed.
  38059. */
  38060. displayLaserPointer: boolean;
  38061. /**
  38062. * The deviceOrientationCamera used as the camera when not in VR.
  38063. */
  38064. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38065. /**
  38066. * Based on the current WebVR support, returns the current VR camera used.
  38067. */
  38068. readonly currentVRCamera: Nullable<Camera>;
  38069. /**
  38070. * The webVRCamera which is used when in VR.
  38071. */
  38072. readonly webVRCamera: WebVRFreeCamera;
  38073. /**
  38074. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38075. */
  38076. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38077. private readonly _teleportationRequestInitiated;
  38078. /**
  38079. * Instantiates a VRExperienceHelper.
  38080. * Helps to quickly add VR support to an existing scene.
  38081. * @param scene The scene the VRExperienceHelper belongs to.
  38082. * @param webVROptions Options to modify the vr experience helper's behavior.
  38083. */
  38084. constructor(scene: Scene,
  38085. /** Options to modify the vr experience helper's behavior. */
  38086. webVROptions?: VRExperienceHelperOptions);
  38087. private _onDefaultMeshLoaded;
  38088. private _onResize;
  38089. private _onFullscreenChange;
  38090. /**
  38091. * Gets a value indicating if we are currently in VR mode.
  38092. */
  38093. readonly isInVRMode: boolean;
  38094. private onVrDisplayPresentChange;
  38095. private onVRDisplayChanged;
  38096. private moveButtonToBottomRight;
  38097. private displayVRButton;
  38098. private updateButtonVisibility;
  38099. /**
  38100. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  38101. * Otherwise, will use the fullscreen API.
  38102. */
  38103. enterVR(): void;
  38104. /**
  38105. * Attempt to exit VR, or fullscreen.
  38106. */
  38107. exitVR(): void;
  38108. /**
  38109. * The position of the vr experience helper.
  38110. */
  38111. /**
  38112. * Sets the position of the vr experience helper.
  38113. */
  38114. position: Vector3;
  38115. /**
  38116. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  38117. */
  38118. enableInteractions(): void;
  38119. private readonly _noControllerIsActive;
  38120. private beforeRender;
  38121. private _isTeleportationFloor;
  38122. /**
  38123. * Adds a floor mesh to be used for teleportation.
  38124. * @param floorMesh the mesh to be used for teleportation.
  38125. */
  38126. addFloorMesh(floorMesh: Mesh): void;
  38127. /**
  38128. * Removes a floor mesh from being used for teleportation.
  38129. * @param floorMesh the mesh to be removed.
  38130. */
  38131. removeFloorMesh(floorMesh: Mesh): void;
  38132. /**
  38133. * Enables interactions and teleportation using the VR controllers and gaze.
  38134. * @param vrTeleportationOptions options to modify teleportation behavior.
  38135. */
  38136. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38137. private _onNewGamepadConnected;
  38138. private _tryEnableInteractionOnController;
  38139. private _onNewGamepadDisconnected;
  38140. private _enableInteractionOnController;
  38141. private _checkTeleportWithRay;
  38142. private _checkRotate;
  38143. private _checkTeleportBackwards;
  38144. private _enableTeleportationOnController;
  38145. private _createTeleportationCircles;
  38146. private _displayTeleportationTarget;
  38147. private _hideTeleportationTarget;
  38148. private _rotateCamera;
  38149. private _moveTeleportationSelectorTo;
  38150. private _workingVector;
  38151. private _workingQuaternion;
  38152. private _workingMatrix;
  38153. /**
  38154. * Teleports the users feet to the desired location
  38155. * @param location The location where the user's feet should be placed
  38156. */
  38157. teleportCamera(location: Vector3): void;
  38158. private _convertNormalToDirectionOfRay;
  38159. private _castRayAndSelectObject;
  38160. private _notifySelectedMeshUnselected;
  38161. /**
  38162. * Sets the color of the laser ray from the vr controllers.
  38163. * @param color new color for the ray.
  38164. */
  38165. changeLaserColor(color: Color3): void;
  38166. /**
  38167. * Sets the color of the ray from the vr headsets gaze.
  38168. * @param color new color for the ray.
  38169. */
  38170. changeGazeColor(color: Color3): void;
  38171. /**
  38172. * Exits VR and disposes of the vr experience helper
  38173. */
  38174. dispose(): void;
  38175. /**
  38176. * Gets the name of the VRExperienceHelper class
  38177. * @returns "VRExperienceHelper"
  38178. */
  38179. getClassName(): string;
  38180. }
  38181. }
  38182. declare module BABYLON {
  38183. /**
  38184. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  38185. * IMPORTANT!! The data is right-hand data.
  38186. * @export
  38187. * @interface DevicePose
  38188. */
  38189. interface DevicePose {
  38190. /**
  38191. * The position of the device, values in array are [x,y,z].
  38192. */
  38193. readonly position: Nullable<Float32Array>;
  38194. /**
  38195. * The linearVelocity of the device, values in array are [x,y,z].
  38196. */
  38197. readonly linearVelocity: Nullable<Float32Array>;
  38198. /**
  38199. * The linearAcceleration of the device, values in array are [x,y,z].
  38200. */
  38201. readonly linearAcceleration: Nullable<Float32Array>;
  38202. /**
  38203. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  38204. */
  38205. readonly orientation: Nullable<Float32Array>;
  38206. /**
  38207. * The angularVelocity of the device, values in array are [x,y,z].
  38208. */
  38209. readonly angularVelocity: Nullable<Float32Array>;
  38210. /**
  38211. * The angularAcceleration of the device, values in array are [x,y,z].
  38212. */
  38213. readonly angularAcceleration: Nullable<Float32Array>;
  38214. }
  38215. /**
  38216. * Interface representing a pose controlled object in Babylon.
  38217. * A pose controlled object has both regular pose values as well as pose values
  38218. * from an external device such as a VR head mounted display
  38219. */
  38220. interface PoseControlled {
  38221. /**
  38222. * The position of the object in babylon space.
  38223. */
  38224. position: Vector3;
  38225. /**
  38226. * The rotation quaternion of the object in babylon space.
  38227. */
  38228. rotationQuaternion: Quaternion;
  38229. /**
  38230. * The position of the device in babylon space.
  38231. */
  38232. devicePosition?: Vector3;
  38233. /**
  38234. * The rotation quaternion of the device in babylon space.
  38235. */
  38236. deviceRotationQuaternion: Quaternion;
  38237. /**
  38238. * The raw pose coming from the device.
  38239. */
  38240. rawPose: Nullable<DevicePose>;
  38241. /**
  38242. * The scale of the device to be used when translating from device space to babylon space.
  38243. */
  38244. deviceScaleFactor: number;
  38245. /**
  38246. * Updates the poseControlled values based on the input device pose.
  38247. * @param poseData the pose data to update the object with
  38248. */
  38249. updateFromDevice(poseData: DevicePose): void;
  38250. }
  38251. /**
  38252. * Set of options to customize the webVRCamera
  38253. */
  38254. interface WebVROptions {
  38255. /**
  38256. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  38257. */
  38258. trackPosition?: boolean;
  38259. /**
  38260. * Sets the scale of the vrDevice in babylon space. (default: 1)
  38261. */
  38262. positionScale?: number;
  38263. /**
  38264. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  38265. */
  38266. displayName?: string;
  38267. /**
  38268. * Should the native controller meshes be initialized. (default: true)
  38269. */
  38270. controllerMeshes?: boolean;
  38271. /**
  38272. * Creating a default HemiLight only on controllers. (default: true)
  38273. */
  38274. defaultLightingOnControllers?: boolean;
  38275. /**
  38276. * If you don't want to use the default VR button of the helper. (default: false)
  38277. */
  38278. useCustomVRButton?: boolean;
  38279. /**
  38280. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  38281. */
  38282. customVRButton?: HTMLButtonElement;
  38283. /**
  38284. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  38285. */
  38286. rayLength?: number;
  38287. /**
  38288. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  38289. */
  38290. defaultHeight?: number;
  38291. }
  38292. /**
  38293. * This represents a WebVR camera.
  38294. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  38295. * @example http://doc.babylonjs.com/how_to/webvr_camera
  38296. */
  38297. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  38298. private webVROptions;
  38299. /**
  38300. * @hidden
  38301. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  38302. */
  38303. _vrDevice: any;
  38304. /**
  38305. * The rawPose of the vrDevice.
  38306. */
  38307. rawPose: Nullable<DevicePose>;
  38308. private _onVREnabled;
  38309. private _specsVersion;
  38310. private _attached;
  38311. private _frameData;
  38312. protected _descendants: Array<Node>;
  38313. private _deviceRoomPosition;
  38314. /** @hidden */
  38315. _deviceRoomRotationQuaternion: Quaternion;
  38316. private _standingMatrix;
  38317. /**
  38318. * Represents device position in babylon space.
  38319. */
  38320. devicePosition: Vector3;
  38321. /**
  38322. * Represents device rotation in babylon space.
  38323. */
  38324. deviceRotationQuaternion: Quaternion;
  38325. /**
  38326. * The scale of the device to be used when translating from device space to babylon space.
  38327. */
  38328. deviceScaleFactor: number;
  38329. private _deviceToWorld;
  38330. private _worldToDevice;
  38331. /**
  38332. * References to the webVR controllers for the vrDevice.
  38333. */
  38334. controllers: Array<WebVRController>;
  38335. /**
  38336. * Emits an event when a controller is attached.
  38337. */
  38338. onControllersAttachedObservable: Observable<WebVRController[]>;
  38339. /**
  38340. * Emits an event when a controller's mesh has been loaded;
  38341. */
  38342. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38343. /**
  38344. * Emits an event when the HMD's pose has been updated.
  38345. */
  38346. onPoseUpdatedFromDeviceObservable: Observable<any>;
  38347. private _poseSet;
  38348. /**
  38349. * If the rig cameras be used as parent instead of this camera.
  38350. */
  38351. rigParenting: boolean;
  38352. private _lightOnControllers;
  38353. private _defaultHeight?;
  38354. /**
  38355. * Instantiates a WebVRFreeCamera.
  38356. * @param name The name of the WebVRFreeCamera
  38357. * @param position The starting anchor position for the camera
  38358. * @param scene The scene the camera belongs to
  38359. * @param webVROptions a set of customizable options for the webVRCamera
  38360. */
  38361. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  38362. /**
  38363. * Gets the device distance from the ground in meters.
  38364. * @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.
  38365. */
  38366. deviceDistanceToRoomGround(): number;
  38367. /**
  38368. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  38369. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  38370. */
  38371. useStandingMatrix(callback?: (bool: boolean) => void): void;
  38372. /**
  38373. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  38374. * @returns A promise with a boolean set to if the standing matrix is supported.
  38375. */
  38376. useStandingMatrixAsync(): Promise<boolean>;
  38377. /**
  38378. * Disposes the camera
  38379. */
  38380. dispose(): void;
  38381. /**
  38382. * Gets a vrController by name.
  38383. * @param name The name of the controller to retreive
  38384. * @returns the controller matching the name specified or null if not found
  38385. */
  38386. getControllerByName(name: string): Nullable<WebVRController>;
  38387. private _leftController;
  38388. /**
  38389. * The controller corrisponding to the users left hand.
  38390. */
  38391. readonly leftController: Nullable<WebVRController>;
  38392. private _rightController;
  38393. /**
  38394. * The controller corrisponding to the users right hand.
  38395. */
  38396. readonly rightController: Nullable<WebVRController>;
  38397. /**
  38398. * Casts a ray forward from the vrCamera's gaze.
  38399. * @param length Length of the ray (default: 100)
  38400. * @returns the ray corrisponding to the gaze
  38401. */
  38402. getForwardRay(length?: number): Ray;
  38403. /**
  38404. * @hidden
  38405. * Updates the camera based on device's frame data
  38406. */
  38407. _checkInputs(): void;
  38408. /**
  38409. * Updates the poseControlled values based on the input device pose.
  38410. * @param poseData Pose coming from the device
  38411. */
  38412. updateFromDevice(poseData: DevicePose): void;
  38413. private _htmlElementAttached;
  38414. private _detachIfAttached;
  38415. /**
  38416. * WebVR's attach control will start broadcasting frames to the device.
  38417. * Note that in certain browsers (chrome for example) this function must be called
  38418. * within a user-interaction callback. Example:
  38419. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  38420. *
  38421. * @param element html element to attach the vrDevice to
  38422. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  38423. */
  38424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38425. /**
  38426. * Detaches the camera from the html element and disables VR
  38427. *
  38428. * @param element html element to detach from
  38429. */
  38430. detachControl(element: HTMLElement): void;
  38431. /**
  38432. * @returns the name of this class
  38433. */
  38434. getClassName(): string;
  38435. /**
  38436. * Calls resetPose on the vrDisplay
  38437. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  38438. */
  38439. resetToCurrentRotation(): void;
  38440. /**
  38441. * @hidden
  38442. * Updates the rig cameras (left and right eye)
  38443. */
  38444. _updateRigCameras(): void;
  38445. private _workingVector;
  38446. private _oneVector;
  38447. private _workingMatrix;
  38448. private updateCacheCalled;
  38449. private _correctPositionIfNotTrackPosition;
  38450. /**
  38451. * @hidden
  38452. * Updates the cached values of the camera
  38453. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  38454. */
  38455. _updateCache(ignoreParentClass?: boolean): void;
  38456. /**
  38457. * @hidden
  38458. * Get current device position in babylon world
  38459. */
  38460. _computeDevicePosition(): void;
  38461. /**
  38462. * Updates the current device position and rotation in the babylon world
  38463. */
  38464. update(): void;
  38465. /**
  38466. * @hidden
  38467. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  38468. * @returns an identity matrix
  38469. */
  38470. _getViewMatrix(): Matrix;
  38471. private _tmpMatrix;
  38472. /**
  38473. * This function is called by the two RIG cameras.
  38474. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  38475. */
  38476. protected _getWebVRViewMatrix(): Matrix;
  38477. protected _getWebVRProjectionMatrix(): Matrix;
  38478. private _onGamepadConnectedObserver;
  38479. private _onGamepadDisconnectedObserver;
  38480. private _updateCacheWhenTrackingDisabledObserver;
  38481. /**
  38482. * Initializes the controllers and their meshes
  38483. */
  38484. initControllers(): void;
  38485. }
  38486. }
  38487. declare module BABYLON {
  38488. interface Engine {
  38489. /**
  38490. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  38491. * @return the new query
  38492. */
  38493. createQuery(): WebGLQuery;
  38494. /**
  38495. * Delete and release a webGL query
  38496. * @param query defines the query to delete
  38497. * @return the current engine
  38498. */
  38499. deleteQuery(query: WebGLQuery): Engine;
  38500. /**
  38501. * Check if a given query has resolved and got its value
  38502. * @param query defines the query to check
  38503. * @returns true if the query got its value
  38504. */
  38505. isQueryResultAvailable(query: WebGLQuery): boolean;
  38506. /**
  38507. * Gets the value of a given query
  38508. * @param query defines the query to check
  38509. * @returns the value of the query
  38510. */
  38511. getQueryResult(query: WebGLQuery): number;
  38512. /**
  38513. * Initiates an occlusion query
  38514. * @param algorithmType defines the algorithm to use
  38515. * @param query defines the query to use
  38516. * @returns the current engine
  38517. * @see http://doc.babylonjs.com/features/occlusionquery
  38518. */
  38519. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  38520. /**
  38521. * Ends an occlusion query
  38522. * @see http://doc.babylonjs.com/features/occlusionquery
  38523. * @param algorithmType defines the algorithm to use
  38524. * @returns the current engine
  38525. */
  38526. endOcclusionQuery(algorithmType: number): Engine;
  38527. /**
  38528. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  38529. * Please note that only one query can be issued at a time
  38530. * @returns a time token used to track the time span
  38531. */
  38532. startTimeQuery(): Nullable<_TimeToken>;
  38533. /**
  38534. * Ends a time query
  38535. * @param token defines the token used to measure the time span
  38536. * @returns the time spent (in ns)
  38537. */
  38538. endTimeQuery(token: _TimeToken): int;
  38539. /** @hidden */
  38540. _currentNonTimestampToken: Nullable<_TimeToken>;
  38541. /** @hidden */
  38542. _createTimeQuery(): WebGLQuery;
  38543. /** @hidden */
  38544. _deleteTimeQuery(query: WebGLQuery): void;
  38545. /** @hidden */
  38546. _getGlAlgorithmType(algorithmType: number): number;
  38547. /** @hidden */
  38548. _getTimeQueryResult(query: WebGLQuery): any;
  38549. /** @hidden */
  38550. _getTimeQueryAvailability(query: WebGLQuery): any;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. interface Engine {
  38555. /**
  38556. * Creates a webGL transform feedback object
  38557. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  38558. * @returns the webGL transform feedback object
  38559. */
  38560. createTransformFeedback(): WebGLTransformFeedback;
  38561. /**
  38562. * Delete a webGL transform feedback object
  38563. * @param value defines the webGL transform feedback object to delete
  38564. */
  38565. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  38566. /**
  38567. * Bind a webGL transform feedback object to the webgl context
  38568. * @param value defines the webGL transform feedback object to bind
  38569. */
  38570. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  38571. /**
  38572. * Begins a transform feedback operation
  38573. * @param usePoints defines if points or triangles must be used
  38574. */
  38575. beginTransformFeedback(usePoints: boolean): void;
  38576. /**
  38577. * Ends a transform feedback operation
  38578. */
  38579. endTransformFeedback(): void;
  38580. /**
  38581. * Specify the varyings to use with transform feedback
  38582. * @param program defines the associated webGL program
  38583. * @param value defines the list of strings representing the varying names
  38584. */
  38585. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  38586. /**
  38587. * Bind a webGL buffer for a transform feedback operation
  38588. * @param value defines the webGL buffer to bind
  38589. */
  38590. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  38591. }
  38592. }
  38593. declare module BABYLON {
  38594. interface IOctreeContainer<T> {
  38595. blocks: Array<OctreeBlock<T>>;
  38596. }
  38597. class Octree<T> {
  38598. maxDepth: number;
  38599. blocks: Array<OctreeBlock<T>>;
  38600. dynamicContent: T[];
  38601. private _maxBlockCapacity;
  38602. private _selectionContent;
  38603. private _creationFunc;
  38604. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  38605. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  38606. addMesh(entry: T): void;
  38607. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  38608. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  38609. intersectsRay(ray: Ray): SmartArray<T>;
  38610. 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;
  38611. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  38612. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  38613. }
  38614. }
  38615. declare module BABYLON {
  38616. /**
  38617. * Class used to store a cell in an octree
  38618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38619. */
  38620. class OctreeBlock<T> {
  38621. /**
  38622. * Gets the content of the current block
  38623. */
  38624. entries: T[];
  38625. /**
  38626. * Gets the list of block children
  38627. */
  38628. blocks: Array<OctreeBlock<T>>;
  38629. private _depth;
  38630. private _maxDepth;
  38631. private _capacity;
  38632. private _minPoint;
  38633. private _maxPoint;
  38634. private _boundingVectors;
  38635. private _creationFunc;
  38636. /**
  38637. * Creates a new block
  38638. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  38639. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  38640. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38641. * @param depth defines the current depth of this block in the octree
  38642. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  38643. * @param creationFunc defines a callback to call when an element is added to the block
  38644. */
  38645. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  38646. /**
  38647. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38648. */
  38649. readonly capacity: number;
  38650. /**
  38651. * Gets the minimum vector (in world space) of the block's bounding box
  38652. */
  38653. readonly minPoint: Vector3;
  38654. /**
  38655. * Gets the maximum vector (in world space) of the block's bounding box
  38656. */
  38657. readonly maxPoint: Vector3;
  38658. /**
  38659. * Add a new element to this block
  38660. * @param entry defines the element to add
  38661. */
  38662. addEntry(entry: T): void;
  38663. /**
  38664. * Add an array of elements to this block
  38665. * @param entries defines the array of elements to add
  38666. */
  38667. addEntries(entries: T[]): void;
  38668. /**
  38669. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  38670. * @param frustumPlanes defines the frustum planes to test
  38671. * @param selection defines the array to store current content if selection is positive
  38672. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38673. */
  38674. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38675. /**
  38676. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  38677. * @param sphereCenter defines the bounding sphere center
  38678. * @param sphereRadius defines the bounding sphere radius
  38679. * @param selection defines the array to store current content if selection is positive
  38680. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38681. */
  38682. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38683. /**
  38684. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  38685. * @param ray defines the ray to test with
  38686. * @param selection defines the array to store current content if selection is positive
  38687. */
  38688. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  38689. /**
  38690. * Subdivide the content into child blocks (this block will then be empty)
  38691. */
  38692. createInnerBlocks(): void;
  38693. }
  38694. }
  38695. declare module BABYLON {
  38696. interface Scene {
  38697. /**
  38698. * @hidden
  38699. * Backing Filed
  38700. */
  38701. _selectionOctree: Octree<AbstractMesh>;
  38702. /**
  38703. * Gets the octree used to boost mesh selection (picking)
  38704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38705. */
  38706. selectionOctree: Octree<AbstractMesh>;
  38707. /**
  38708. * Creates or updates the octree used to boost selection (picking)
  38709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38710. * @param maxCapacity defines the maximum capacity per leaf
  38711. * @param maxDepth defines the maximum depth of the octree
  38712. * @returns an octree of AbstractMesh
  38713. */
  38714. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  38715. }
  38716. interface AbstractMesh {
  38717. /**
  38718. * @hidden
  38719. * Backing Field
  38720. */
  38721. _submeshesOctree: Octree<SubMesh>;
  38722. /**
  38723. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  38724. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  38725. * @param maxCapacity defines the maximum size of each block (64 by default)
  38726. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  38727. * @returns the new octree
  38728. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  38729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38730. */
  38731. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  38732. }
  38733. /**
  38734. * Defines the octree scene component responsible to manage any octrees
  38735. * in a given scene.
  38736. */
  38737. class OctreeSceneComponent {
  38738. /**
  38739. * The component name helpfull to identify the component in the list of scene components.
  38740. */
  38741. readonly name: string;
  38742. /**
  38743. * The scene the component belongs to.
  38744. */
  38745. scene: Scene;
  38746. /**
  38747. * Indicates if the meshes have been checked to make sure they are isEnabled()
  38748. */
  38749. readonly checksIsEnabled: boolean;
  38750. /**
  38751. * Creates a new instance of the component for the given scene
  38752. * @param scene Defines the scene to register the component in
  38753. */
  38754. constructor(scene: Scene);
  38755. /**
  38756. * Registers the component in a given scene
  38757. */
  38758. register(): void;
  38759. /**
  38760. * Return the list of active meshes
  38761. * @returns the list of active meshes
  38762. */
  38763. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38764. /**
  38765. * Return the list of active sub meshes
  38766. * @param mesh The mesh to get the candidates sub meshes from
  38767. * @returns the list of active sub meshes
  38768. */
  38769. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38770. private _tempRay;
  38771. /**
  38772. * Return the list of sub meshes intersecting with a given local ray
  38773. * @param mesh defines the mesh to find the submesh for
  38774. * @param localRay defines the ray in local space
  38775. * @returns the list of intersecting sub meshes
  38776. */
  38777. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  38778. /**
  38779. * Return the list of sub meshes colliding with a collider
  38780. * @param mesh defines the mesh to find the submesh for
  38781. * @param collider defines the collider to evaluate the collision against
  38782. * @returns the list of colliding sub meshes
  38783. */
  38784. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  38785. /**
  38786. * Rebuilds the elements related to this component in case of
  38787. * context lost for instance.
  38788. */
  38789. rebuild(): void;
  38790. /**
  38791. * Disposes the component and the associated ressources.
  38792. */
  38793. dispose(): void;
  38794. }
  38795. }
  38796. declare module BABYLON {
  38797. /**
  38798. * Google Daydream controller
  38799. */
  38800. class DaydreamController extends WebVRController {
  38801. /**
  38802. * Base Url for the controller model.
  38803. */
  38804. static MODEL_BASE_URL: string;
  38805. /**
  38806. * File name for the controller model.
  38807. */
  38808. static MODEL_FILENAME: string;
  38809. /**
  38810. * Gamepad Id prefix used to identify Daydream Controller.
  38811. */
  38812. static readonly GAMEPAD_ID_PREFIX: string;
  38813. /**
  38814. * Creates a new DaydreamController from a gamepad
  38815. * @param vrGamepad the gamepad that the controller should be created from
  38816. */
  38817. constructor(vrGamepad: any);
  38818. /**
  38819. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38820. * @param scene scene in which to add meshes
  38821. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38822. */
  38823. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38824. /**
  38825. * Called once for each button that changed state since the last frame
  38826. * @param buttonIdx Which button index changed
  38827. * @param state New state of the button
  38828. * @param changes Which properties on the state changed since last frame
  38829. */
  38830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38831. }
  38832. }
  38833. declare module BABYLON {
  38834. /**
  38835. * Gear VR Controller
  38836. */
  38837. class GearVRController extends WebVRController {
  38838. /**
  38839. * Base Url for the controller model.
  38840. */
  38841. static MODEL_BASE_URL: string;
  38842. /**
  38843. * File name for the controller model.
  38844. */
  38845. static MODEL_FILENAME: string;
  38846. /**
  38847. * Gamepad Id prefix used to identify this controller.
  38848. */
  38849. static readonly GAMEPAD_ID_PREFIX: string;
  38850. private readonly _buttonIndexToObservableNameMap;
  38851. /**
  38852. * Creates a new GearVRController from a gamepad
  38853. * @param vrGamepad the gamepad that the controller should be created from
  38854. */
  38855. constructor(vrGamepad: any);
  38856. /**
  38857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38858. * @param scene scene in which to add meshes
  38859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38860. */
  38861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38862. /**
  38863. * Called once for each button that changed state since the last frame
  38864. * @param buttonIdx Which button index changed
  38865. * @param state New state of the button
  38866. * @param changes Which properties on the state changed since last frame
  38867. */
  38868. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38869. }
  38870. }
  38871. declare module BABYLON {
  38872. /**
  38873. * Generic Controller
  38874. */
  38875. class GenericController extends WebVRController {
  38876. /**
  38877. * Base Url for the controller model.
  38878. */
  38879. static readonly MODEL_BASE_URL: string;
  38880. /**
  38881. * File name for the controller model.
  38882. */
  38883. static readonly MODEL_FILENAME: string;
  38884. /**
  38885. * Creates a new GenericController from a gamepad
  38886. * @param vrGamepad the gamepad that the controller should be created from
  38887. */
  38888. constructor(vrGamepad: any);
  38889. /**
  38890. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38891. * @param scene scene in which to add meshes
  38892. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38893. */
  38894. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38895. /**
  38896. * Called once for each button that changed state since the last frame
  38897. * @param buttonIdx Which button index changed
  38898. * @param state New state of the button
  38899. * @param changes Which properties on the state changed since last frame
  38900. */
  38901. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38902. }
  38903. }
  38904. declare module BABYLON {
  38905. /**
  38906. * Oculus Touch Controller
  38907. */
  38908. class OculusTouchController extends WebVRController {
  38909. /**
  38910. * Base Url for the controller model.
  38911. */
  38912. static MODEL_BASE_URL: string;
  38913. /**
  38914. * File name for the left controller model.
  38915. */
  38916. static MODEL_LEFT_FILENAME: string;
  38917. /**
  38918. * File name for the right controller model.
  38919. */
  38920. static MODEL_RIGHT_FILENAME: string;
  38921. /**
  38922. * Fired when the secondary trigger on this controller is modified
  38923. */
  38924. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  38925. /**
  38926. * Fired when the thumb rest on this controller is modified
  38927. */
  38928. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  38929. /**
  38930. * Creates a new OculusTouchController from a gamepad
  38931. * @param vrGamepad the gamepad that the controller should be created from
  38932. */
  38933. constructor(vrGamepad: any);
  38934. /**
  38935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38936. * @param scene scene in which to add meshes
  38937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38938. */
  38939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38940. /**
  38941. * Fired when the A button on this controller is modified
  38942. */
  38943. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38944. /**
  38945. * Fired when the B button on this controller is modified
  38946. */
  38947. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38948. /**
  38949. * Fired when the X button on this controller is modified
  38950. */
  38951. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38952. /**
  38953. * Fired when the Y button on this controller is modified
  38954. */
  38955. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38956. /**
  38957. * Called once for each button that changed state since the last frame
  38958. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  38959. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  38960. * 2) secondary trigger (same)
  38961. * 3) A (right) X (left), touch, pressed = value
  38962. * 4) B / Y
  38963. * 5) thumb rest
  38964. * @param buttonIdx Which button index changed
  38965. * @param state New state of the button
  38966. * @param changes Which properties on the state changed since last frame
  38967. */
  38968. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38969. }
  38970. }
  38971. declare module BABYLON {
  38972. /**
  38973. * Defines the types of pose enabled controllers that are supported
  38974. */
  38975. enum PoseEnabledControllerType {
  38976. /**
  38977. * HTC Vive
  38978. */
  38979. VIVE = 0,
  38980. /**
  38981. * Oculus Rift
  38982. */
  38983. OCULUS = 1,
  38984. /**
  38985. * Windows mixed reality
  38986. */
  38987. WINDOWS = 2,
  38988. /**
  38989. * Samsung gear VR
  38990. */
  38991. GEAR_VR = 3,
  38992. /**
  38993. * Google Daydream
  38994. */
  38995. DAYDREAM = 4,
  38996. /**
  38997. * Generic
  38998. */
  38999. GENERIC = 5
  39000. }
  39001. /**
  39002. * Defines the MutableGamepadButton interface for the state of a gamepad button
  39003. */
  39004. interface MutableGamepadButton {
  39005. /**
  39006. * Value of the button/trigger
  39007. */
  39008. value: number;
  39009. /**
  39010. * If the button/trigger is currently touched
  39011. */
  39012. touched: boolean;
  39013. /**
  39014. * If the button/trigger is currently pressed
  39015. */
  39016. pressed: boolean;
  39017. }
  39018. /**
  39019. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  39020. * @hidden
  39021. */
  39022. interface ExtendedGamepadButton extends GamepadButton {
  39023. /**
  39024. * If the button/trigger is currently pressed
  39025. */
  39026. readonly pressed: boolean;
  39027. /**
  39028. * If the button/trigger is currently touched
  39029. */
  39030. readonly touched: boolean;
  39031. /**
  39032. * Value of the button/trigger
  39033. */
  39034. readonly value: number;
  39035. }
  39036. /**
  39037. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  39038. */
  39039. class PoseEnabledControllerHelper {
  39040. /**
  39041. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  39042. * @param vrGamepad the gamepad to initialized
  39043. * @returns a vr controller of the type the gamepad identified as
  39044. */
  39045. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  39046. }
  39047. /**
  39048. * Defines the PoseEnabledController object that contains state of a vr capable controller
  39049. */
  39050. class PoseEnabledController extends Gamepad implements PoseControlled {
  39051. private _deviceRoomPosition;
  39052. private _deviceRoomRotationQuaternion;
  39053. /**
  39054. * The device position in babylon space
  39055. */
  39056. devicePosition: Vector3;
  39057. /**
  39058. * The device rotation in babylon space
  39059. */
  39060. deviceRotationQuaternion: Quaternion;
  39061. /**
  39062. * The scale factor of the device in babylon space
  39063. */
  39064. deviceScaleFactor: number;
  39065. /**
  39066. * (Likely devicePosition should be used instead) The device position in its room space
  39067. */
  39068. position: Vector3;
  39069. /**
  39070. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  39071. */
  39072. rotationQuaternion: Quaternion;
  39073. /**
  39074. * The type of controller (Eg. Windows mixed reality)
  39075. */
  39076. controllerType: PoseEnabledControllerType;
  39077. protected _calculatedPosition: Vector3;
  39078. private _calculatedRotation;
  39079. /**
  39080. * The raw pose from the device
  39081. */
  39082. rawPose: DevicePose;
  39083. private _trackPosition;
  39084. private _maxRotationDistFromHeadset;
  39085. private _draggedRoomRotation;
  39086. /**
  39087. * @hidden
  39088. */
  39089. _disableTrackPosition(fixedPosition: Vector3): void;
  39090. /**
  39091. * Internal, the mesh attached to the controller
  39092. * @hidden
  39093. */
  39094. _mesh: Nullable<AbstractMesh>;
  39095. private _poseControlledCamera;
  39096. private _leftHandSystemQuaternion;
  39097. /**
  39098. * Internal, matrix used to convert room space to babylon space
  39099. * @hidden
  39100. */
  39101. _deviceToWorld: Matrix;
  39102. /**
  39103. * Node to be used when casting a ray from the controller
  39104. * @hidden
  39105. */
  39106. _pointingPoseNode: Nullable<AbstractMesh>;
  39107. /**
  39108. * Name of the child mesh that can be used to cast a ray from the controller
  39109. */
  39110. static readonly POINTING_POSE: string;
  39111. /**
  39112. * Creates a new PoseEnabledController from a gamepad
  39113. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  39114. */
  39115. constructor(browserGamepad: any);
  39116. private _workingMatrix;
  39117. /**
  39118. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  39119. */
  39120. update(): void;
  39121. /**
  39122. * Updates only the pose device and mesh without doing any button event checking
  39123. */
  39124. protected _updatePoseAndMesh(): void;
  39125. /**
  39126. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  39127. * @param poseData raw pose fromthe device
  39128. */
  39129. updateFromDevice(poseData: DevicePose): void;
  39130. /**
  39131. * @hidden
  39132. */
  39133. _meshAttachedObservable: Observable<AbstractMesh>;
  39134. /**
  39135. * Attaches a mesh to the controller
  39136. * @param mesh the mesh to be attached
  39137. */
  39138. attachToMesh(mesh: AbstractMesh): void;
  39139. /**
  39140. * Attaches the controllers mesh to a camera
  39141. * @param camera the camera the mesh should be attached to
  39142. */
  39143. attachToPoseControlledCamera(camera: TargetCamera): void;
  39144. /**
  39145. * Disposes of the controller
  39146. */
  39147. dispose(): void;
  39148. /**
  39149. * The mesh that is attached to the controller
  39150. */
  39151. readonly mesh: Nullable<AbstractMesh>;
  39152. /**
  39153. * Gets the ray of the controller in the direction the controller is pointing
  39154. * @param length the length the resulting ray should be
  39155. * @returns a ray in the direction the controller is pointing
  39156. */
  39157. getForwardRay(length?: number): Ray;
  39158. }
  39159. }
  39160. declare module BABYLON {
  39161. /**
  39162. * Vive Controller
  39163. */
  39164. class ViveController extends WebVRController {
  39165. /**
  39166. * Base Url for the controller model.
  39167. */
  39168. static MODEL_BASE_URL: string;
  39169. /**
  39170. * File name for the controller model.
  39171. */
  39172. static MODEL_FILENAME: string;
  39173. /**
  39174. * Creates a new ViveController from a gamepad
  39175. * @param vrGamepad the gamepad that the controller should be created from
  39176. */
  39177. constructor(vrGamepad: any);
  39178. /**
  39179. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  39180. * @param scene scene in which to add meshes
  39181. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  39182. */
  39183. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  39184. /**
  39185. * Fired when the left button on this controller is modified
  39186. */
  39187. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39188. /**
  39189. * Fired when the right button on this controller is modified
  39190. */
  39191. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39192. /**
  39193. * Fired when the menu button on this controller is modified
  39194. */
  39195. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39196. /**
  39197. * Called once for each button that changed state since the last frame
  39198. * Vive mapping:
  39199. * 0: touchpad
  39200. * 1: trigger
  39201. * 2: left AND right buttons
  39202. * 3: menu button
  39203. * @param buttonIdx Which button index changed
  39204. * @param state New state of the button
  39205. * @param changes Which properties on the state changed since last frame
  39206. */
  39207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  39208. }
  39209. }
  39210. declare module BABYLON {
  39211. /**
  39212. * Defines the WebVRController object that represents controllers tracked in 3D space
  39213. */
  39214. abstract class WebVRController extends PoseEnabledController {
  39215. /**
  39216. * Internal, the default controller model for the controller
  39217. */
  39218. protected _defaultModel: AbstractMesh;
  39219. /**
  39220. * Fired when the trigger state has changed
  39221. */
  39222. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  39223. /**
  39224. * Fired when the main button state has changed
  39225. */
  39226. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39227. /**
  39228. * Fired when the secondary button state has changed
  39229. */
  39230. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39231. /**
  39232. * Fired when the pad state has changed
  39233. */
  39234. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  39235. /**
  39236. * Fired when controllers stick values have changed
  39237. */
  39238. onPadValuesChangedObservable: Observable<StickValues>;
  39239. /**
  39240. * Array of button availible on the controller
  39241. */
  39242. protected _buttons: Array<MutableGamepadButton>;
  39243. private _onButtonStateChange;
  39244. /**
  39245. * Fired when a controller button's state has changed
  39246. * @param callback the callback containing the button that was modified
  39247. */
  39248. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  39249. /**
  39250. * X and Y axis corrisponding to the controllers joystick
  39251. */
  39252. pad: StickValues;
  39253. /**
  39254. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  39255. */
  39256. hand: string;
  39257. /**
  39258. * The default controller model for the controller
  39259. */
  39260. readonly defaultModel: AbstractMesh;
  39261. /**
  39262. * Creates a new WebVRController from a gamepad
  39263. * @param vrGamepad the gamepad that the WebVRController should be created from
  39264. */
  39265. constructor(vrGamepad: any);
  39266. /**
  39267. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  39268. */
  39269. update(): void;
  39270. /**
  39271. * Function to be called when a button is modified
  39272. */
  39273. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  39274. /**
  39275. * Loads a mesh and attaches it to the controller
  39276. * @param scene the scene the mesh should be added to
  39277. * @param meshLoaded callback for when the mesh has been loaded
  39278. */
  39279. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  39280. private _setButtonValue;
  39281. private _changes;
  39282. private _checkChanges;
  39283. /**
  39284. * Disposes of th webVRCOntroller
  39285. */
  39286. dispose(): void;
  39287. }
  39288. }
  39289. declare module BABYLON {
  39290. /**
  39291. * Defines the WindowsMotionController object that the state of the windows motion controller
  39292. */
  39293. class WindowsMotionController extends WebVRController {
  39294. /**
  39295. * The base url used to load the left and right controller models
  39296. */
  39297. static MODEL_BASE_URL: string;
  39298. /**
  39299. * The name of the left controller model file
  39300. */
  39301. static MODEL_LEFT_FILENAME: string;
  39302. /**
  39303. * The name of the right controller model file
  39304. */
  39305. static MODEL_RIGHT_FILENAME: string;
  39306. /**
  39307. * The controller name prefix for this controller type
  39308. */
  39309. static readonly GAMEPAD_ID_PREFIX: string;
  39310. /**
  39311. * The controller id pattern for this controller type
  39312. */
  39313. private static readonly GAMEPAD_ID_PATTERN;
  39314. private _loadedMeshInfo;
  39315. private readonly _mapping;
  39316. /**
  39317. * Fired when the trackpad on this controller is clicked
  39318. */
  39319. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  39320. /**
  39321. * Fired when the trackpad on this controller is modified
  39322. */
  39323. onTrackpadValuesChangedObservable: Observable<StickValues>;
  39324. /**
  39325. * The current x and y values of this controller's trackpad
  39326. */
  39327. trackpad: StickValues;
  39328. /**
  39329. * Creates a new WindowsMotionController from a gamepad
  39330. * @param vrGamepad the gamepad that the controller should be created from
  39331. */
  39332. constructor(vrGamepad: any);
  39333. /**
  39334. * Fired when the trigger on this controller is modified
  39335. */
  39336. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39337. /**
  39338. * Fired when the menu button on this controller is modified
  39339. */
  39340. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39341. /**
  39342. * Fired when the grip button on this controller is modified
  39343. */
  39344. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39345. /**
  39346. * Fired when the thumbstick button on this controller is modified
  39347. */
  39348. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39349. /**
  39350. * Fired when the touchpad button on this controller is modified
  39351. */
  39352. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  39353. /**
  39354. * Fired when the touchpad values on this controller are modified
  39355. */
  39356. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  39357. private _updateTrackpad;
  39358. /**
  39359. * Called once per frame by the engine.
  39360. */
  39361. update(): void;
  39362. /**
  39363. * Called once for each button that changed state since the last frame
  39364. * @param buttonIdx Which button index changed
  39365. * @param state New state of the button
  39366. * @param changes Which properties on the state changed since last frame
  39367. */
  39368. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  39369. /**
  39370. * Moves the buttons on the controller mesh based on their current state
  39371. * @param buttonName the name of the button to move
  39372. * @param buttonValue the value of the button which determines the buttons new position
  39373. */
  39374. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  39375. /**
  39376. * Moves the axis on the controller mesh based on its current state
  39377. * @param axis the index of the axis
  39378. * @param axisValue the value of the axis which determines the meshes new position
  39379. * @hidden
  39380. */
  39381. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  39382. /**
  39383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  39384. * @param scene scene in which to add meshes
  39385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  39386. */
  39387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  39388. /**
  39389. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  39390. * can be transformed by button presses and axes values, based on this._mapping.
  39391. *
  39392. * @param scene scene in which the meshes exist
  39393. * @param meshes list of meshes that make up the controller model to process
  39394. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  39395. */
  39396. private processModel;
  39397. private createMeshInfo;
  39398. /**
  39399. * Gets the ray of the controller in the direction the controller is pointing
  39400. * @param length the length the resulting ray should be
  39401. * @returns a ray in the direction the controller is pointing
  39402. */
  39403. getForwardRay(length?: number): Ray;
  39404. /**
  39405. * Disposes of the controller
  39406. */
  39407. dispose(): void;
  39408. }
  39409. }
  39410. declare module BABYLON {
  39411. /**
  39412. * Interface to implement to create a shadow generator compatible with BJS.
  39413. */
  39414. interface IShadowGenerator {
  39415. /**
  39416. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  39417. * @returns The render target texture if present otherwise, null
  39418. */
  39419. getShadowMap(): Nullable<RenderTargetTexture>;
  39420. /**
  39421. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  39422. * @returns The render target texture if the shadow map is present otherwise, null
  39423. */
  39424. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  39425. /**
  39426. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  39427. * @param subMesh The submesh we want to render in the shadow map
  39428. * @param useInstances Defines wether will draw in the map using instances
  39429. * @returns true if ready otherwise, false
  39430. */
  39431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  39432. /**
  39433. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  39434. * @param defines Defines of the material we want to update
  39435. * @param lightIndex Index of the light in the enabled light list of the material
  39436. */
  39437. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  39438. /**
  39439. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  39440. * defined in the generator but impacting the effect).
  39441. * It implies the unifroms available on the materials are the standard BJS ones.
  39442. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  39443. * @param effect The effect we are binfing the information for
  39444. */
  39445. bindShadowLight(lightIndex: string, effect: Effect): void;
  39446. /**
  39447. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  39448. * (eq to shadow prjection matrix * light transform matrix)
  39449. * @returns The transform matrix used to create the shadow map
  39450. */
  39451. getTransformMatrix(): Matrix;
  39452. /**
  39453. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  39454. * Cube and 2D textures for instance.
  39455. */
  39456. recreateShadowMap(): void;
  39457. /**
  39458. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  39459. * @param onCompiled Callback triggered at the and of the effects compilation
  39460. * @param options Sets of optional options forcing the compilation with different modes
  39461. */
  39462. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  39463. useInstances: boolean;
  39464. }>): void;
  39465. /**
  39466. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  39467. * @param options Sets of optional options forcing the compilation with different modes
  39468. * @returns A promise that resolves when the compilation completes
  39469. */
  39470. forceCompilationAsync(options?: Partial<{
  39471. useInstances: boolean;
  39472. }>): Promise<void>;
  39473. /**
  39474. * Serializes the shadow generator setup to a json object.
  39475. * @returns The serialized JSON object
  39476. */
  39477. serialize(): any;
  39478. /**
  39479. * Disposes the Shadow map and related Textures and effects.
  39480. */
  39481. dispose(): void;
  39482. }
  39483. /**
  39484. * Default implementation IShadowGenerator.
  39485. * This is the main object responsible of generating shadows in the framework.
  39486. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  39487. */
  39488. class ShadowGenerator implements IShadowGenerator {
  39489. /**
  39490. * Shadow generator mode None: no filtering applied.
  39491. */
  39492. static readonly FILTER_NONE: number;
  39493. /**
  39494. * Shadow generator mode ESM: Exponential Shadow Mapping.
  39495. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  39496. */
  39497. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  39498. /**
  39499. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  39500. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  39501. */
  39502. static readonly FILTER_POISSONSAMPLING: number;
  39503. /**
  39504. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  39505. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  39506. */
  39507. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  39508. /**
  39509. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  39510. * edge artifacts on steep falloff.
  39511. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  39512. */
  39513. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  39514. /**
  39515. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  39516. * edge artifacts on steep falloff.
  39517. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  39518. */
  39519. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  39520. /**
  39521. * Shadow generator mode PCF: Percentage Closer Filtering
  39522. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  39523. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  39524. */
  39525. static readonly FILTER_PCF: number;
  39526. /**
  39527. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  39528. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  39529. * Contact Hardening
  39530. */
  39531. static readonly FILTER_PCSS: number;
  39532. /**
  39533. * Reserved for PCF and PCSS
  39534. * Highest Quality.
  39535. *
  39536. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  39537. *
  39538. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  39539. */
  39540. static readonly QUALITY_HIGH: number;
  39541. /**
  39542. * Reserved for PCF and PCSS
  39543. * Good tradeoff for quality/perf cross devices
  39544. *
  39545. * Execute PCF on a 3*3 kernel.
  39546. *
  39547. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  39548. */
  39549. static readonly QUALITY_MEDIUM: number;
  39550. /**
  39551. * Reserved for PCF and PCSS
  39552. * The lowest quality but the fastest.
  39553. *
  39554. * Execute PCF on a 1*1 kernel.
  39555. *
  39556. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  39557. */
  39558. static readonly QUALITY_LOW: number;
  39559. private _bias;
  39560. /**
  39561. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  39562. */
  39563. /**
  39564. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  39565. */
  39566. bias: number;
  39567. private _normalBias;
  39568. /**
  39569. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  39570. */
  39571. /**
  39572. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  39573. */
  39574. normalBias: number;
  39575. private _blurBoxOffset;
  39576. /**
  39577. * Gets the blur box offset: offset applied during the blur pass.
  39578. * Only usefull if useKernelBlur = false
  39579. */
  39580. /**
  39581. * Sets the blur box offset: offset applied during the blur pass.
  39582. * Only usefull if useKernelBlur = false
  39583. */
  39584. blurBoxOffset: number;
  39585. private _blurScale;
  39586. /**
  39587. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  39588. * 2 means half of the size.
  39589. */
  39590. /**
  39591. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  39592. * 2 means half of the size.
  39593. */
  39594. blurScale: number;
  39595. private _blurKernel;
  39596. /**
  39597. * Gets the blur kernel: kernel size of the blur pass.
  39598. * Only usefull if useKernelBlur = true
  39599. */
  39600. /**
  39601. * Sets the blur kernel: kernel size of the blur pass.
  39602. * Only usefull if useKernelBlur = true
  39603. */
  39604. blurKernel: number;
  39605. private _useKernelBlur;
  39606. /**
  39607. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  39608. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  39609. */
  39610. /**
  39611. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  39612. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  39613. */
  39614. useKernelBlur: boolean;
  39615. private _depthScale;
  39616. /**
  39617. * Gets the depth scale used in ESM mode.
  39618. */
  39619. /**
  39620. * Sets the depth scale used in ESM mode.
  39621. * This can override the scale stored on the light.
  39622. */
  39623. depthScale: number;
  39624. private _filter;
  39625. /**
  39626. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  39627. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  39628. */
  39629. /**
  39630. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  39631. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  39632. */
  39633. filter: number;
  39634. /**
  39635. * Gets if the current filter is set to Poisson Sampling.
  39636. */
  39637. /**
  39638. * Sets the current filter to Poisson Sampling.
  39639. */
  39640. usePoissonSampling: boolean;
  39641. /**
  39642. * Gets if the current filter is set to VSM.
  39643. * DEPRECATED. Should use useExponentialShadowMap instead.
  39644. */
  39645. /**
  39646. * Sets the current filter is to VSM.
  39647. * DEPRECATED. Should use useExponentialShadowMap instead.
  39648. */
  39649. useVarianceShadowMap: boolean;
  39650. /**
  39651. * Gets if the current filter is set to blurred VSM.
  39652. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  39653. */
  39654. /**
  39655. * Sets the current filter is to blurred VSM.
  39656. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  39657. */
  39658. useBlurVarianceShadowMap: boolean;
  39659. /**
  39660. * Gets if the current filter is set to ESM.
  39661. */
  39662. /**
  39663. * Sets the current filter is to ESM.
  39664. */
  39665. useExponentialShadowMap: boolean;
  39666. /**
  39667. * Gets if the current filter is set to filtered ESM.
  39668. */
  39669. /**
  39670. * Gets if the current filter is set to filtered ESM.
  39671. */
  39672. useBlurExponentialShadowMap: boolean;
  39673. /**
  39674. * Gets if the current filter is set to "close ESM" (using the inverse of the
  39675. * exponential to prevent steep falloff artifacts).
  39676. */
  39677. /**
  39678. * Sets the current filter to "close ESM" (using the inverse of the
  39679. * exponential to prevent steep falloff artifacts).
  39680. */
  39681. useCloseExponentialShadowMap: boolean;
  39682. /**
  39683. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  39684. * exponential to prevent steep falloff artifacts).
  39685. */
  39686. /**
  39687. * Sets the current filter to filtered "close ESM" (using the inverse of the
  39688. * exponential to prevent steep falloff artifacts).
  39689. */
  39690. useBlurCloseExponentialShadowMap: boolean;
  39691. /**
  39692. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  39693. */
  39694. /**
  39695. * Sets the current filter to "PCF" (percentage closer filtering).
  39696. */
  39697. usePercentageCloserFiltering: boolean;
  39698. private _filteringQuality;
  39699. /**
  39700. * Gets the PCF or PCSS Quality.
  39701. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  39702. */
  39703. /**
  39704. * Sets the PCF or PCSS Quality.
  39705. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  39706. */
  39707. filteringQuality: number;
  39708. /**
  39709. * Gets if the current filter is set to "PCSS" (contact hardening).
  39710. */
  39711. /**
  39712. * Sets the current filter to "PCSS" (contact hardening).
  39713. */
  39714. useContactHardeningShadow: boolean;
  39715. private _contactHardeningLightSizeUVRatio;
  39716. /**
  39717. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  39718. * Using a ratio helps keeping shape stability independently of the map size.
  39719. *
  39720. * It does not account for the light projection as it was having too much
  39721. * instability during the light setup or during light position changes.
  39722. *
  39723. * Only valid if useContactHardeningShadow is true.
  39724. */
  39725. /**
  39726. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  39727. * Using a ratio helps keeping shape stability independently of the map size.
  39728. *
  39729. * It does not account for the light projection as it was having too much
  39730. * instability during the light setup or during light position changes.
  39731. *
  39732. * Only valid if useContactHardeningShadow is true.
  39733. */
  39734. contactHardeningLightSizeUVRatio: number;
  39735. private _darkness;
  39736. /**
  39737. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  39738. * 0 means strongest and 1 would means no shadow.
  39739. * @returns the darkness.
  39740. */
  39741. getDarkness(): number;
  39742. /**
  39743. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  39744. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  39745. * @returns the shadow generator allowing fluent coding.
  39746. */
  39747. setDarkness(darkness: number): ShadowGenerator;
  39748. private _transparencyShadow;
  39749. /**
  39750. * Sets the ability to have transparent shadow (boolean).
  39751. * @param transparent True if transparent else False
  39752. * @returns the shadow generator allowing fluent coding
  39753. */
  39754. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  39755. private _shadowMap;
  39756. private _shadowMap2;
  39757. /**
  39758. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  39759. * @returns The render target texture if present otherwise, null
  39760. */
  39761. getShadowMap(): Nullable<RenderTargetTexture>;
  39762. /**
  39763. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  39764. * @returns The render target texture if the shadow map is present otherwise, null
  39765. */
  39766. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  39767. /**
  39768. * Helper function to add a mesh and its descendants to the list of shadow casters.
  39769. * @param mesh Mesh to add
  39770. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  39771. * @returns the Shadow Generator itself
  39772. */
  39773. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  39774. /**
  39775. * Helper function to remove a mesh and its descendants from the list of shadow casters
  39776. * @param mesh Mesh to remove
  39777. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  39778. * @returns the Shadow Generator itself
  39779. */
  39780. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  39781. /**
  39782. * Controls the extent to which the shadows fade out at the edge of the frustum
  39783. * Used only by directionals and spots
  39784. */
  39785. frustumEdgeFalloff: number;
  39786. private _light;
  39787. /**
  39788. * Returns the associated light object.
  39789. * @returns the light generating the shadow
  39790. */
  39791. getLight(): IShadowLight;
  39792. /**
  39793. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  39794. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  39795. * It might on the other hand introduce peter panning.
  39796. */
  39797. forceBackFacesOnly: boolean;
  39798. private _scene;
  39799. private _lightDirection;
  39800. private _effect;
  39801. private _viewMatrix;
  39802. private _projectionMatrix;
  39803. private _transformMatrix;
  39804. private _cachedPosition;
  39805. private _cachedDirection;
  39806. private _cachedDefines;
  39807. private _currentRenderID;
  39808. private _boxBlurPostprocess;
  39809. private _kernelBlurXPostprocess;
  39810. private _kernelBlurYPostprocess;
  39811. private _blurPostProcesses;
  39812. private _mapSize;
  39813. private _currentFaceIndex;
  39814. private _currentFaceIndexCache;
  39815. private _textureType;
  39816. private _defaultTextureMatrix;
  39817. /**
  39818. * Creates a ShadowGenerator object.
  39819. * A ShadowGenerator is the required tool to use the shadows.
  39820. * Each light casting shadows needs to use its own ShadowGenerator.
  39821. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  39822. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  39823. * @param light The light object generating the shadows.
  39824. * @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.
  39825. */
  39826. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  39827. private _initializeGenerator;
  39828. private _initializeShadowMap;
  39829. private _initializeBlurRTTAndPostProcesses;
  39830. private _renderForShadowMap;
  39831. private _renderSubMeshForShadowMap;
  39832. private _applyFilterValues;
  39833. /**
  39834. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  39835. * @param onCompiled Callback triggered at the and of the effects compilation
  39836. * @param options Sets of optional options forcing the compilation with different modes
  39837. */
  39838. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  39839. useInstances: boolean;
  39840. }>): void;
  39841. /**
  39842. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  39843. * @param options Sets of optional options forcing the compilation with different modes
  39844. * @returns A promise that resolves when the compilation completes
  39845. */
  39846. forceCompilationAsync(options?: Partial<{
  39847. useInstances: boolean;
  39848. }>): Promise<void>;
  39849. /**
  39850. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  39851. * @param subMesh The submesh we want to render in the shadow map
  39852. * @param useInstances Defines wether will draw in the map using instances
  39853. * @returns true if ready otherwise, false
  39854. */
  39855. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  39856. /**
  39857. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  39858. * @param defines Defines of the material we want to update
  39859. * @param lightIndex Index of the light in the enabled light list of the material
  39860. */
  39861. prepareDefines(defines: any, lightIndex: number): void;
  39862. /**
  39863. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  39864. * defined in the generator but impacting the effect).
  39865. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  39866. * @param effect The effect we are binfing the information for
  39867. */
  39868. bindShadowLight(lightIndex: string, effect: Effect): void;
  39869. /**
  39870. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  39871. * (eq to shadow prjection matrix * light transform matrix)
  39872. * @returns The transform matrix used to create the shadow map
  39873. */
  39874. getTransformMatrix(): Matrix;
  39875. /**
  39876. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  39877. * Cube and 2D textures for instance.
  39878. */
  39879. recreateShadowMap(): void;
  39880. private _disposeBlurPostProcesses;
  39881. private _disposeRTTandPostProcesses;
  39882. /**
  39883. * Disposes the ShadowGenerator.
  39884. * Returns nothing.
  39885. */
  39886. dispose(): void;
  39887. /**
  39888. * Serializes the shadow generator setup to a json object.
  39889. * @returns The serialized JSON object
  39890. */
  39891. serialize(): any;
  39892. /**
  39893. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  39894. * @param parsedShadowGenerator The JSON object to parse
  39895. * @param scene The scene to create the shadow map for
  39896. * @returns The parsed shadow generator
  39897. */
  39898. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  39899. }
  39900. }
  39901. declare module BABYLON {
  39902. /**
  39903. * Defines the shadow generator component responsible to manage any shadow generators
  39904. * in a given scene.
  39905. */
  39906. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  39907. /**
  39908. * The component name helpfull to identify the component in the list of scene components.
  39909. */
  39910. readonly name: string;
  39911. /**
  39912. * The scene the component belongs to.
  39913. */
  39914. scene: Scene;
  39915. /**
  39916. * Creates a new instance of the component for the given scene
  39917. * @param scene Defines the scene to register the component in
  39918. */
  39919. constructor(scene: Scene);
  39920. /**
  39921. * Registers the component in a given scene
  39922. */
  39923. register(): void;
  39924. /**
  39925. * Rebuilds the elements related to this component in case of
  39926. * context lost for instance.
  39927. */
  39928. rebuild(): void;
  39929. /**
  39930. * Serializes the component data to the specified json object
  39931. * @param serializationObject The object to serialize to
  39932. */
  39933. serialize(serializationObject: any): void;
  39934. /**
  39935. * Adds all the element from the container to the scene
  39936. * @param container the container holding the elements
  39937. */
  39938. addFromContainer(container: AbstractScene): void;
  39939. /**
  39940. * Removes all the elements in the container from the scene
  39941. * @param container contains the elements to remove
  39942. */
  39943. removeFromContainer(container: AbstractScene): void;
  39944. /**
  39945. * Rebuilds the elements related to this component in case of
  39946. * context lost for instance.
  39947. */
  39948. dispose(): void;
  39949. private _gatherRenderTargets;
  39950. }
  39951. }
  39952. declare module BABYLON {
  39953. }
  39954. declare module BABYLON {
  39955. /**
  39956. * Background material used to create an efficient environement around your scene.
  39957. */
  39958. class BackgroundMaterial extends PushMaterial {
  39959. /**
  39960. * Standard reflectance value at parallel view angle.
  39961. */
  39962. static StandardReflectance0: number;
  39963. /**
  39964. * Standard reflectance value at grazing angle.
  39965. */
  39966. static StandardReflectance90: number;
  39967. protected _primaryColor: Color3;
  39968. /**
  39969. * Key light Color (multiply against the environement texture)
  39970. */
  39971. primaryColor: Color3;
  39972. protected __perceptualColor: Nullable<Color3>;
  39973. /**
  39974. * Experimental Internal Use Only.
  39975. *
  39976. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  39977. * This acts as a helper to set the primary color to a more "human friendly" value.
  39978. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  39979. * output color as close as possible from the chosen value.
  39980. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  39981. * part of lighting setup.)
  39982. */
  39983. _perceptualColor: Nullable<Color3>;
  39984. protected _primaryColorShadowLevel: float;
  39985. /**
  39986. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  39987. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  39988. */
  39989. primaryColorShadowLevel: float;
  39990. protected _primaryColorHighlightLevel: float;
  39991. /**
  39992. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  39993. * The primary color is used at the level chosen to define what the white area would look.
  39994. */
  39995. primaryColorHighlightLevel: float;
  39996. protected _reflectionTexture: Nullable<BaseTexture>;
  39997. /**
  39998. * Reflection Texture used in the material.
  39999. * Should be author in a specific way for the best result (refer to the documentation).
  40000. */
  40001. reflectionTexture: Nullable<BaseTexture>;
  40002. protected _reflectionBlur: float;
  40003. /**
  40004. * Reflection Texture level of blur.
  40005. *
  40006. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  40007. * texture twice.
  40008. */
  40009. reflectionBlur: float;
  40010. protected _diffuseTexture: Nullable<BaseTexture>;
  40011. /**
  40012. * Diffuse Texture used in the material.
  40013. * Should be author in a specific way for the best result (refer to the documentation).
  40014. */
  40015. diffuseTexture: Nullable<BaseTexture>;
  40016. protected _shadowLights: Nullable<IShadowLight[]>;
  40017. /**
  40018. * Specify the list of lights casting shadow on the material.
  40019. * All scene shadow lights will be included if null.
  40020. */
  40021. shadowLights: Nullable<IShadowLight[]>;
  40022. protected _shadowLevel: float;
  40023. /**
  40024. * Helps adjusting the shadow to a softer level if required.
  40025. * 0 means black shadows and 1 means no shadows.
  40026. */
  40027. shadowLevel: float;
  40028. protected _sceneCenter: Vector3;
  40029. /**
  40030. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  40031. * It is usually zero but might be interesting to modify according to your setup.
  40032. */
  40033. sceneCenter: Vector3;
  40034. protected _opacityFresnel: boolean;
  40035. /**
  40036. * This helps specifying that the material is falling off to the sky box at grazing angle.
  40037. * This helps ensuring a nice transition when the camera goes under the ground.
  40038. */
  40039. opacityFresnel: boolean;
  40040. protected _reflectionFresnel: boolean;
  40041. /**
  40042. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  40043. * This helps adding a mirror texture on the ground.
  40044. */
  40045. reflectionFresnel: boolean;
  40046. protected _reflectionFalloffDistance: number;
  40047. /**
  40048. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  40049. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  40050. */
  40051. reflectionFalloffDistance: number;
  40052. protected _reflectionAmount: number;
  40053. /**
  40054. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  40055. */
  40056. reflectionAmount: number;
  40057. protected _reflectionReflectance0: number;
  40058. /**
  40059. * This specifies the weight of the reflection at grazing angle.
  40060. */
  40061. reflectionReflectance0: number;
  40062. protected _reflectionReflectance90: number;
  40063. /**
  40064. * This specifies the weight of the reflection at a perpendicular point of view.
  40065. */
  40066. reflectionReflectance90: number;
  40067. /**
  40068. * Sets the reflection reflectance fresnel values according to the default standard
  40069. * empirically know to work well :-)
  40070. */
  40071. reflectionStandardFresnelWeight: number;
  40072. protected _useRGBColor: boolean;
  40073. /**
  40074. * Helps to directly use the maps channels instead of their level.
  40075. */
  40076. useRGBColor: boolean;
  40077. protected _enableNoise: boolean;
  40078. /**
  40079. * This helps reducing the banding effect that could occur on the background.
  40080. */
  40081. enableNoise: boolean;
  40082. /**
  40083. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40084. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  40085. * Recommended to be keep at 1.0 except for special cases.
  40086. */
  40087. fovMultiplier: number;
  40088. private _fovMultiplier;
  40089. /**
  40090. * Enable the FOV adjustment feature controlled by fovMultiplier.
  40091. */
  40092. useEquirectangularFOV: boolean;
  40093. private _maxSimultaneousLights;
  40094. /**
  40095. * Number of Simultaneous lights allowed on the material.
  40096. */
  40097. maxSimultaneousLights: int;
  40098. /**
  40099. * Default configuration related to image processing available in the Background Material.
  40100. */
  40101. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40102. /**
  40103. * Keep track of the image processing observer to allow dispose and replace.
  40104. */
  40105. private _imageProcessingObserver;
  40106. /**
  40107. * Attaches a new image processing configuration to the PBR Material.
  40108. * @param configuration (if null the scene configuration will be use)
  40109. */
  40110. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40111. /**
  40112. * Gets the image processing configuration used either in this material.
  40113. */
  40114. /**
  40115. * Sets the Default image processing configuration used either in the this material.
  40116. *
  40117. * If sets to null, the scene one is in use.
  40118. */
  40119. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  40120. /**
  40121. * Gets wether the color curves effect is enabled.
  40122. */
  40123. /**
  40124. * Sets wether the color curves effect is enabled.
  40125. */
  40126. cameraColorCurvesEnabled: boolean;
  40127. /**
  40128. * Gets wether the color grading effect is enabled.
  40129. */
  40130. /**
  40131. * Gets wether the color grading effect is enabled.
  40132. */
  40133. cameraColorGradingEnabled: boolean;
  40134. /**
  40135. * Gets wether tonemapping is enabled or not.
  40136. */
  40137. /**
  40138. * Sets wether tonemapping is enabled or not
  40139. */
  40140. cameraToneMappingEnabled: boolean;
  40141. /**
  40142. * The camera exposure used on this material.
  40143. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40144. * This corresponds to a photographic exposure.
  40145. */
  40146. /**
  40147. * The camera exposure used on this material.
  40148. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40149. * This corresponds to a photographic exposure.
  40150. */
  40151. cameraExposure: float;
  40152. /**
  40153. * Gets The camera contrast used on this material.
  40154. */
  40155. /**
  40156. * Sets The camera contrast used on this material.
  40157. */
  40158. cameraContrast: float;
  40159. /**
  40160. * Gets the Color Grading 2D Lookup Texture.
  40161. */
  40162. /**
  40163. * Sets the Color Grading 2D Lookup Texture.
  40164. */
  40165. cameraColorGradingTexture: Nullable<BaseTexture>;
  40166. /**
  40167. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40168. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40169. * 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;
  40170. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40171. */
  40172. /**
  40173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40175. * 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;
  40176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40177. */
  40178. cameraColorCurves: Nullable<ColorCurves>;
  40179. /**
  40180. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  40181. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  40182. */
  40183. switchToBGR: boolean;
  40184. private _renderTargets;
  40185. private _reflectionControls;
  40186. private _white;
  40187. private _primaryShadowColor;
  40188. private _primaryHighlightColor;
  40189. /**
  40190. * Instantiates a Background Material in the given scene
  40191. * @param name The friendly name of the material
  40192. * @param scene The scene to add the material to
  40193. */
  40194. constructor(name: string, scene: Scene);
  40195. /**
  40196. * Gets a boolean indicating that current material needs to register RTT
  40197. */
  40198. readonly hasRenderTargetTextures: boolean;
  40199. /**
  40200. * The entire material has been created in order to prevent overdraw.
  40201. * @returns false
  40202. */
  40203. needAlphaTesting(): boolean;
  40204. /**
  40205. * The entire material has been created in order to prevent overdraw.
  40206. * @returns true if blending is enable
  40207. */
  40208. needAlphaBlending(): boolean;
  40209. /**
  40210. * Checks wether the material is ready to be rendered for a given mesh.
  40211. * @param mesh The mesh to render
  40212. * @param subMesh The submesh to check against
  40213. * @param useInstances Specify wether or not the material is used with instances
  40214. * @returns true if all the dependencies are ready (Textures, Effects...)
  40215. */
  40216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40217. /**
  40218. * Compute the primary color according to the chosen perceptual color.
  40219. */
  40220. private _computePrimaryColorFromPerceptualColor;
  40221. /**
  40222. * Compute the highlights and shadow colors according to their chosen levels.
  40223. */
  40224. private _computePrimaryColors;
  40225. /**
  40226. * Build the uniform buffer used in the material.
  40227. */
  40228. buildUniformLayout(): void;
  40229. /**
  40230. * Unbind the material.
  40231. */
  40232. unbind(): void;
  40233. /**
  40234. * Bind only the world matrix to the material.
  40235. * @param world The world matrix to bind.
  40236. */
  40237. bindOnlyWorldMatrix(world: Matrix): void;
  40238. /**
  40239. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  40240. * @param world The world matrix to bind.
  40241. * @param subMesh The submesh to bind for.
  40242. */
  40243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40244. /**
  40245. * Dispose the material.
  40246. * @param forceDisposeEffect Force disposal of the associated effect.
  40247. * @param forceDisposeTextures Force disposal of the associated textures.
  40248. */
  40249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40250. /**
  40251. * Clones the material.
  40252. * @param name The cloned name.
  40253. * @returns The cloned material.
  40254. */
  40255. clone(name: string): BackgroundMaterial;
  40256. /**
  40257. * Serializes the current material to its JSON representation.
  40258. * @returns The JSON representation.
  40259. */
  40260. serialize(): any;
  40261. /**
  40262. * Gets the class name of the material
  40263. * @returns "BackgroundMaterial"
  40264. */
  40265. getClassName(): string;
  40266. /**
  40267. * Parse a JSON input to create back a background material.
  40268. * @param source The JSON data to parse
  40269. * @param scene The scene to create the parsed material in
  40270. * @param rootUrl The root url of the assets the material depends upon
  40271. * @returns the instantiated BackgroundMaterial.
  40272. */
  40273. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  40274. }
  40275. }
  40276. declare module BABYLON {
  40277. /**
  40278. * The Physically based material base class of BJS.
  40279. *
  40280. * This offers the main features of a standard PBR material.
  40281. * For more information, please refer to the documentation :
  40282. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  40283. */
  40284. abstract class PBRBaseMaterial extends PushMaterial {
  40285. /**
  40286. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  40287. */
  40288. static readonly LIGHTFALLOFF_PHYSICAL: number;
  40289. /**
  40290. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  40291. * to enhance interoperability with other engines.
  40292. */
  40293. static readonly LIGHTFALLOFF_GLTF: number;
  40294. /**
  40295. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  40296. * to enhance interoperability with other materials.
  40297. */
  40298. static readonly LIGHTFALLOFF_STANDARD: number;
  40299. /**
  40300. * Intensity of the direct lights e.g. the four lights available in your scene.
  40301. * This impacts both the direct diffuse and specular highlights.
  40302. */
  40303. protected _directIntensity: number;
  40304. /**
  40305. * Intensity of the emissive part of the material.
  40306. * This helps controlling the emissive effect without modifying the emissive color.
  40307. */
  40308. protected _emissiveIntensity: number;
  40309. /**
  40310. * Intensity of the environment e.g. how much the environment will light the object
  40311. * either through harmonics for rough material or through the refelction for shiny ones.
  40312. */
  40313. protected _environmentIntensity: number;
  40314. /**
  40315. * This is a special control allowing the reduction of the specular highlights coming from the
  40316. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  40317. */
  40318. protected _specularIntensity: number;
  40319. /**
  40320. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  40321. */
  40322. private _lightingInfos;
  40323. /**
  40324. * Debug Control allowing disabling the bump map on this material.
  40325. */
  40326. protected _disableBumpMap: boolean;
  40327. /**
  40328. * AKA Diffuse Texture in standard nomenclature.
  40329. */
  40330. protected _albedoTexture: BaseTexture;
  40331. /**
  40332. * AKA Occlusion Texture in other nomenclature.
  40333. */
  40334. protected _ambientTexture: BaseTexture;
  40335. /**
  40336. * AKA Occlusion Texture Intensity in other nomenclature.
  40337. */
  40338. protected _ambientTextureStrength: number;
  40339. /**
  40340. * Defines how much the AO map is occluding the analytical lights (point spot...).
  40341. * 1 means it completely occludes it
  40342. * 0 mean it has no impact
  40343. */
  40344. protected _ambientTextureImpactOnAnalyticalLights: number;
  40345. /**
  40346. * Stores the alpha values in a texture.
  40347. */
  40348. protected _opacityTexture: BaseTexture;
  40349. /**
  40350. * Stores the reflection values in a texture.
  40351. */
  40352. protected _reflectionTexture: BaseTexture;
  40353. /**
  40354. * Stores the refraction values in a texture.
  40355. */
  40356. protected _refractionTexture: BaseTexture;
  40357. /**
  40358. * Stores the emissive values in a texture.
  40359. */
  40360. protected _emissiveTexture: BaseTexture;
  40361. /**
  40362. * AKA Specular texture in other nomenclature.
  40363. */
  40364. protected _reflectivityTexture: BaseTexture;
  40365. /**
  40366. * Used to switch from specular/glossiness to metallic/roughness workflow.
  40367. */
  40368. protected _metallicTexture: BaseTexture;
  40369. /**
  40370. * Specifies the metallic scalar of the metallic/roughness workflow.
  40371. * Can also be used to scale the metalness values of the metallic texture.
  40372. */
  40373. protected _metallic: Nullable<number>;
  40374. /**
  40375. * Specifies the roughness scalar of the metallic/roughness workflow.
  40376. * Can also be used to scale the roughness values of the metallic texture.
  40377. */
  40378. protected _roughness: Nullable<number>;
  40379. /**
  40380. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  40381. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  40382. */
  40383. protected _microSurfaceTexture: BaseTexture;
  40384. /**
  40385. * Stores surface normal data used to displace a mesh in a texture.
  40386. */
  40387. protected _bumpTexture: BaseTexture;
  40388. /**
  40389. * Stores the pre-calculated light information of a mesh in a texture.
  40390. */
  40391. protected _lightmapTexture: BaseTexture;
  40392. /**
  40393. * The color of a material in ambient lighting.
  40394. */
  40395. protected _ambientColor: Color3;
  40396. /**
  40397. * AKA Diffuse Color in other nomenclature.
  40398. */
  40399. protected _albedoColor: Color3;
  40400. /**
  40401. * AKA Specular Color in other nomenclature.
  40402. */
  40403. protected _reflectivityColor: Color3;
  40404. /**
  40405. * The color applied when light is reflected from a material.
  40406. */
  40407. protected _reflectionColor: Color3;
  40408. /**
  40409. * The color applied when light is emitted from a material.
  40410. */
  40411. protected _emissiveColor: Color3;
  40412. /**
  40413. * AKA Glossiness in other nomenclature.
  40414. */
  40415. protected _microSurface: number;
  40416. /**
  40417. * source material index of refraction (IOR)' / 'destination material IOR.
  40418. */
  40419. protected _indexOfRefraction: number;
  40420. /**
  40421. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  40422. */
  40423. protected _invertRefractionY: boolean;
  40424. /**
  40425. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  40426. * Materials half opaque for instance using refraction could benefit from this control.
  40427. */
  40428. protected _linkRefractionWithTransparency: boolean;
  40429. /**
  40430. * Specifies that the material will use the light map as a show map.
  40431. */
  40432. protected _useLightmapAsShadowmap: boolean;
  40433. /**
  40434. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  40435. * makes the reflect vector face the model (under horizon).
  40436. */
  40437. protected _useHorizonOcclusion: boolean;
  40438. /**
  40439. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  40440. * too much the area relying on ambient texture to define their ambient occlusion.
  40441. */
  40442. protected _useRadianceOcclusion: boolean;
  40443. /**
  40444. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  40445. */
  40446. protected _useAlphaFromAlbedoTexture: boolean;
  40447. /**
  40448. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  40449. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40450. */
  40451. protected _useSpecularOverAlpha: boolean;
  40452. /**
  40453. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  40454. */
  40455. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  40456. /**
  40457. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  40458. */
  40459. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  40460. /**
  40461. * Specifies if the metallic texture contains the roughness information in its green channel.
  40462. */
  40463. protected _useRoughnessFromMetallicTextureGreen: boolean;
  40464. /**
  40465. * Specifies if the metallic texture contains the metallness information in its blue channel.
  40466. */
  40467. protected _useMetallnessFromMetallicTextureBlue: boolean;
  40468. /**
  40469. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  40470. */
  40471. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  40472. /**
  40473. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  40474. */
  40475. protected _useAmbientInGrayScale: boolean;
  40476. /**
  40477. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  40478. * The material will try to infer what glossiness each pixel should be.
  40479. */
  40480. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  40481. /**
  40482. * Defines the falloff type used in this material.
  40483. * It by default is Physical.
  40484. */
  40485. protected _lightFalloff: number;
  40486. /**
  40487. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40488. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40489. */
  40490. protected _useRadianceOverAlpha: boolean;
  40491. /**
  40492. * Allows using an object space normal map (instead of tangent space).
  40493. */
  40494. protected _useObjectSpaceNormalMap: boolean;
  40495. /**
  40496. * Allows using the bump map in parallax mode.
  40497. */
  40498. protected _useParallax: boolean;
  40499. /**
  40500. * Allows using the bump map in parallax occlusion mode.
  40501. */
  40502. protected _useParallaxOcclusion: boolean;
  40503. /**
  40504. * Controls the scale bias of the parallax mode.
  40505. */
  40506. protected _parallaxScaleBias: number;
  40507. /**
  40508. * If sets to true, disables all the lights affecting the material.
  40509. */
  40510. protected _disableLighting: boolean;
  40511. /**
  40512. * Number of Simultaneous lights allowed on the material.
  40513. */
  40514. protected _maxSimultaneousLights: number;
  40515. /**
  40516. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  40517. */
  40518. protected _invertNormalMapX: boolean;
  40519. /**
  40520. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  40521. */
  40522. protected _invertNormalMapY: boolean;
  40523. /**
  40524. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40525. */
  40526. protected _twoSidedLighting: boolean;
  40527. /**
  40528. * Defines the alpha limits in alpha test mode.
  40529. */
  40530. protected _alphaCutOff: number;
  40531. /**
  40532. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  40533. */
  40534. protected _forceAlphaTest: boolean;
  40535. /**
  40536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  40537. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  40538. */
  40539. protected _useAlphaFresnel: boolean;
  40540. /**
  40541. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  40542. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  40543. */
  40544. protected _useLinearAlphaFresnel: boolean;
  40545. /**
  40546. * The transparency mode of the material.
  40547. */
  40548. protected _transparencyMode: Nullable<number>;
  40549. /**
  40550. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  40551. * from cos thetav and roughness:
  40552. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  40553. */
  40554. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  40555. /**
  40556. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  40557. */
  40558. protected _forceIrradianceInFragment: boolean;
  40559. /**
  40560. * Force normal to face away from face.
  40561. */
  40562. protected _forceNormalForward: boolean;
  40563. /**
  40564. * Enables specular anti aliasing in the PBR shader.
  40565. * It will both interacts on the Geometry for analytical and IBL lighting.
  40566. * It also prefilter the roughness map based on the bump values.
  40567. */
  40568. protected _enableSpecularAntiAliasing: boolean;
  40569. /**
  40570. * Default configuration related to image processing available in the PBR Material.
  40571. */
  40572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40573. /**
  40574. * Keep track of the image processing observer to allow dispose and replace.
  40575. */
  40576. private _imageProcessingObserver;
  40577. /**
  40578. * Attaches a new image processing configuration to the PBR Material.
  40579. * @param configuration
  40580. */
  40581. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40582. /**
  40583. * Stores the available render targets.
  40584. */
  40585. private _renderTargets;
  40586. /**
  40587. * Sets the global ambient color for the material used in lighting calculations.
  40588. */
  40589. private _globalAmbientColor;
  40590. /**
  40591. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  40592. */
  40593. private _useLogarithmicDepth;
  40594. /**
  40595. * If set to true, no lighting calculations will be applied.
  40596. */
  40597. private _unlit;
  40598. /**
  40599. * Instantiates a new PBRMaterial instance.
  40600. *
  40601. * @param name The material name
  40602. * @param scene The scene the material will be use in.
  40603. */
  40604. constructor(name: string, scene: Scene);
  40605. /**
  40606. * Gets a boolean indicating that current material needs to register RTT
  40607. */
  40608. readonly hasRenderTargetTextures: boolean;
  40609. /**
  40610. * Gets the name of the material class.
  40611. */
  40612. getClassName(): string;
  40613. /**
  40614. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  40615. */
  40616. /**
  40617. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  40618. */
  40619. useLogarithmicDepth: boolean;
  40620. /**
  40621. * Gets the current transparency mode.
  40622. */
  40623. /**
  40624. * Sets the transparency mode of the material.
  40625. *
  40626. * | Value | Type | Description |
  40627. * | ----- | ----------------------------------- | ----------- |
  40628. * | 0 | OPAQUE | |
  40629. * | 1 | ALPHATEST | |
  40630. * | 2 | ALPHABLEND | |
  40631. * | 3 | ALPHATESTANDBLEND | |
  40632. *
  40633. */
  40634. transparencyMode: Nullable<number>;
  40635. /**
  40636. * Returns true if alpha blending should be disabled.
  40637. */
  40638. private readonly _disableAlphaBlending;
  40639. /**
  40640. * Specifies whether or not this material should be rendered in alpha blend mode.
  40641. */
  40642. needAlphaBlending(): boolean;
  40643. /**
  40644. * Specifies if the mesh will require alpha blending.
  40645. * @param mesh - BJS mesh.
  40646. */
  40647. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  40648. /**
  40649. * Specifies whether or not this material should be rendered in alpha test mode.
  40650. */
  40651. needAlphaTesting(): boolean;
  40652. /**
  40653. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  40654. */
  40655. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  40656. /**
  40657. * Gets the texture used for the alpha test.
  40658. */
  40659. getAlphaTestTexture(): BaseTexture;
  40660. /**
  40661. * Stores the reflectivity values based on metallic roughness workflow.
  40662. */
  40663. private static _scaledReflectivity;
  40664. /**
  40665. * Specifies that the submesh is ready to be used.
  40666. * @param mesh - BJS mesh.
  40667. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  40668. * @param useInstances - Specifies that instances should be used.
  40669. * @returns - boolean indicating that the submesh is ready or not.
  40670. */
  40671. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40672. /**
  40673. * Specifies if the material uses metallic roughness workflow.
  40674. * @returns boolean specifiying if the material uses metallic roughness workflow.
  40675. */
  40676. isMetallicWorkflow(): boolean;
  40677. private _prepareEffect;
  40678. private _prepareDefines;
  40679. /**
  40680. * Force shader compilation
  40681. */
  40682. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  40683. clipPlane: boolean;
  40684. }>): void;
  40685. /**
  40686. * Initializes the uniform buffer layout for the shader.
  40687. */
  40688. buildUniformLayout(): void;
  40689. /**
  40690. * Unbinds the textures.
  40691. */
  40692. unbind(): void;
  40693. /**
  40694. * Binds the submesh data.
  40695. * @param world - The world matrix.
  40696. * @param mesh - The BJS mesh.
  40697. * @param subMesh - A submesh of the BJS mesh.
  40698. */
  40699. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40700. /**
  40701. * Returns the animatable textures.
  40702. * @returns - Array of animatable textures.
  40703. */
  40704. getAnimatables(): IAnimatable[];
  40705. /**
  40706. * Returns the texture used for reflections.
  40707. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  40708. */
  40709. private _getReflectionTexture;
  40710. /**
  40711. * Returns the texture used for refraction or null if none is used.
  40712. * @returns - Refection texture if present. If no refraction texture and refraction
  40713. * is linked with transparency, returns environment texture. Otherwise, returns null.
  40714. */
  40715. private _getRefractionTexture;
  40716. /**
  40717. * Disposes the resources of the material.
  40718. * @param forceDisposeEffect - Forces the disposal of effects.
  40719. * @param forceDisposeTextures - Forces the disposal of all textures.
  40720. */
  40721. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40722. }
  40723. }
  40724. declare module BABYLON {
  40725. /**
  40726. * The Physically based simple base material of BJS.
  40727. *
  40728. * This enables better naming and convention enforcements on top of the pbrMaterial.
  40729. * It is used as the base class for both the specGloss and metalRough conventions.
  40730. */
  40731. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  40732. /**
  40733. * Number of Simultaneous lights allowed on the material.
  40734. */
  40735. maxSimultaneousLights: number;
  40736. /**
  40737. * If sets to true, disables all the lights affecting the material.
  40738. */
  40739. disableLighting: boolean;
  40740. /**
  40741. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  40742. */
  40743. environmentTexture: BaseTexture;
  40744. /**
  40745. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40746. */
  40747. invertNormalMapX: boolean;
  40748. /**
  40749. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40750. */
  40751. invertNormalMapY: boolean;
  40752. /**
  40753. * Normal map used in the model.
  40754. */
  40755. normalTexture: BaseTexture;
  40756. /**
  40757. * Emissivie color used to self-illuminate the model.
  40758. */
  40759. emissiveColor: Color3;
  40760. /**
  40761. * Emissivie texture used to self-illuminate the model.
  40762. */
  40763. emissiveTexture: BaseTexture;
  40764. /**
  40765. * Occlusion Channel Strenght.
  40766. */
  40767. occlusionStrength: number;
  40768. /**
  40769. * Occlusion Texture of the material (adding extra occlusion effects).
  40770. */
  40771. occlusionTexture: BaseTexture;
  40772. /**
  40773. * Defines the alpha limits in alpha test mode.
  40774. */
  40775. alphaCutOff: number;
  40776. /**
  40777. * Gets the current double sided mode.
  40778. */
  40779. /**
  40780. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40781. */
  40782. doubleSided: boolean;
  40783. lightmapTexture: BaseTexture;
  40784. useLightmapAsShadowmap: boolean;
  40785. /**
  40786. * Return the active textures of the material.
  40787. */
  40788. getActiveTextures(): BaseTexture[];
  40789. hasTexture(texture: BaseTexture): boolean;
  40790. /**
  40791. * Instantiates a new PBRMaterial instance.
  40792. *
  40793. * @param name The material name
  40794. * @param scene The scene the material will be use in.
  40795. */
  40796. constructor(name: string, scene: Scene);
  40797. getClassName(): string;
  40798. }
  40799. }
  40800. declare module BABYLON {
  40801. /**
  40802. * The Physically based material of BJS.
  40803. *
  40804. * This offers the main features of a standard PBR material.
  40805. * For more information, please refer to the documentation :
  40806. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  40807. */
  40808. class PBRMaterial extends PBRBaseMaterial {
  40809. /**
  40810. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  40811. */
  40812. static readonly PBRMATERIAL_OPAQUE: number;
  40813. /**
  40814. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  40815. */
  40816. static readonly PBRMATERIAL_ALPHATEST: number;
  40817. /**
  40818. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  40819. */
  40820. static readonly PBRMATERIAL_ALPHABLEND: number;
  40821. /**
  40822. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  40823. * They are also discarded below the alpha cutoff threshold to improve performances.
  40824. */
  40825. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  40826. /**
  40827. * Defines the default value of how much AO map is occluding the analytical lights
  40828. * (point spot...).
  40829. */
  40830. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  40831. /**
  40832. * Intensity of the direct lights e.g. the four lights available in your scene.
  40833. * This impacts both the direct diffuse and specular highlights.
  40834. */
  40835. directIntensity: number;
  40836. /**
  40837. * Intensity of the emissive part of the material.
  40838. * This helps controlling the emissive effect without modifying the emissive color.
  40839. */
  40840. emissiveIntensity: number;
  40841. /**
  40842. * Intensity of the environment e.g. how much the environment will light the object
  40843. * either through harmonics for rough material or through the refelction for shiny ones.
  40844. */
  40845. environmentIntensity: number;
  40846. /**
  40847. * This is a special control allowing the reduction of the specular highlights coming from the
  40848. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  40849. */
  40850. specularIntensity: number;
  40851. /**
  40852. * Debug Control allowing disabling the bump map on this material.
  40853. */
  40854. disableBumpMap: boolean;
  40855. /**
  40856. * AKA Diffuse Texture in standard nomenclature.
  40857. */
  40858. albedoTexture: BaseTexture;
  40859. /**
  40860. * AKA Occlusion Texture in other nomenclature.
  40861. */
  40862. ambientTexture: BaseTexture;
  40863. /**
  40864. * AKA Occlusion Texture Intensity in other nomenclature.
  40865. */
  40866. ambientTextureStrength: number;
  40867. /**
  40868. * Defines how much the AO map is occluding the analytical lights (point spot...).
  40869. * 1 means it completely occludes it
  40870. * 0 mean it has no impact
  40871. */
  40872. ambientTextureImpactOnAnalyticalLights: number;
  40873. /**
  40874. * Stores the alpha values in a texture.
  40875. */
  40876. opacityTexture: BaseTexture;
  40877. /**
  40878. * Stores the reflection values in a texture.
  40879. */
  40880. reflectionTexture: Nullable<BaseTexture>;
  40881. /**
  40882. * Stores the emissive values in a texture.
  40883. */
  40884. emissiveTexture: BaseTexture;
  40885. /**
  40886. * AKA Specular texture in other nomenclature.
  40887. */
  40888. reflectivityTexture: BaseTexture;
  40889. /**
  40890. * Used to switch from specular/glossiness to metallic/roughness workflow.
  40891. */
  40892. metallicTexture: BaseTexture;
  40893. /**
  40894. * Specifies the metallic scalar of the metallic/roughness workflow.
  40895. * Can also be used to scale the metalness values of the metallic texture.
  40896. */
  40897. metallic: Nullable<number>;
  40898. /**
  40899. * Specifies the roughness scalar of the metallic/roughness workflow.
  40900. * Can also be used to scale the roughness values of the metallic texture.
  40901. */
  40902. roughness: Nullable<number>;
  40903. /**
  40904. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  40905. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  40906. */
  40907. microSurfaceTexture: BaseTexture;
  40908. /**
  40909. * Stores surface normal data used to displace a mesh in a texture.
  40910. */
  40911. bumpTexture: BaseTexture;
  40912. /**
  40913. * Stores the pre-calculated light information of a mesh in a texture.
  40914. */
  40915. lightmapTexture: BaseTexture;
  40916. /**
  40917. * Stores the refracted light information in a texture.
  40918. */
  40919. refractionTexture: BaseTexture;
  40920. /**
  40921. * The color of a material in ambient lighting.
  40922. */
  40923. ambientColor: Color3;
  40924. /**
  40925. * AKA Diffuse Color in other nomenclature.
  40926. */
  40927. albedoColor: Color3;
  40928. /**
  40929. * AKA Specular Color in other nomenclature.
  40930. */
  40931. reflectivityColor: Color3;
  40932. /**
  40933. * The color reflected from the material.
  40934. */
  40935. reflectionColor: Color3;
  40936. /**
  40937. * The color emitted from the material.
  40938. */
  40939. emissiveColor: Color3;
  40940. /**
  40941. * AKA Glossiness in other nomenclature.
  40942. */
  40943. microSurface: number;
  40944. /**
  40945. * source material index of refraction (IOR)' / 'destination material IOR.
  40946. */
  40947. indexOfRefraction: number;
  40948. /**
  40949. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  40950. */
  40951. invertRefractionY: boolean;
  40952. /**
  40953. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  40954. * Materials half opaque for instance using refraction could benefit from this control.
  40955. */
  40956. linkRefractionWithTransparency: boolean;
  40957. useLightmapAsShadowmap: boolean;
  40958. /**
  40959. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  40960. */
  40961. useAlphaFromAlbedoTexture: boolean;
  40962. /**
  40963. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  40964. */
  40965. forceAlphaTest: boolean;
  40966. /**
  40967. * Defines the alpha limits in alpha test mode.
  40968. */
  40969. alphaCutOff: number;
  40970. /**
  40971. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  40972. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40973. */
  40974. useSpecularOverAlpha: boolean;
  40975. /**
  40976. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  40977. */
  40978. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  40979. /**
  40980. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  40981. */
  40982. useRoughnessFromMetallicTextureAlpha: boolean;
  40983. /**
  40984. * Specifies if the metallic texture contains the roughness information in its green channel.
  40985. */
  40986. useRoughnessFromMetallicTextureGreen: boolean;
  40987. /**
  40988. * Specifies if the metallic texture contains the metallness information in its blue channel.
  40989. */
  40990. useMetallnessFromMetallicTextureBlue: boolean;
  40991. /**
  40992. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  40993. */
  40994. useAmbientOcclusionFromMetallicTextureRed: boolean;
  40995. /**
  40996. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  40997. */
  40998. useAmbientInGrayScale: boolean;
  40999. /**
  41000. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  41001. * The material will try to infer what glossiness each pixel should be.
  41002. */
  41003. useAutoMicroSurfaceFromReflectivityMap: boolean;
  41004. /**
  41005. * BJS is using an harcoded light falloff based on a manually sets up range.
  41006. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  41007. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  41008. */
  41009. /**
  41010. * BJS is using an harcoded light falloff based on a manually sets up range.
  41011. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  41012. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  41013. */
  41014. usePhysicalLightFalloff: boolean;
  41015. /**
  41016. * In order to support the falloff compatibility with gltf, a special mode has been added
  41017. * to reproduce the gltf light falloff.
  41018. */
  41019. /**
  41020. * In order to support the falloff compatibility with gltf, a special mode has been added
  41021. * to reproduce the gltf light falloff.
  41022. */
  41023. useGLTFLightFalloff: boolean;
  41024. /**
  41025. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41026. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41027. */
  41028. useRadianceOverAlpha: boolean;
  41029. /**
  41030. * Allows using an object space normal map (instead of tangent space).
  41031. */
  41032. useObjectSpaceNormalMap: boolean;
  41033. /**
  41034. * Allows using the bump map in parallax mode.
  41035. */
  41036. useParallax: boolean;
  41037. /**
  41038. * Allows using the bump map in parallax occlusion mode.
  41039. */
  41040. useParallaxOcclusion: boolean;
  41041. /**
  41042. * Controls the scale bias of the parallax mode.
  41043. */
  41044. parallaxScaleBias: number;
  41045. /**
  41046. * If sets to true, disables all the lights affecting the material.
  41047. */
  41048. disableLighting: boolean;
  41049. /**
  41050. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  41051. */
  41052. forceIrradianceInFragment: boolean;
  41053. /**
  41054. * Number of Simultaneous lights allowed on the material.
  41055. */
  41056. maxSimultaneousLights: number;
  41057. /**
  41058. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41059. */
  41060. invertNormalMapX: boolean;
  41061. /**
  41062. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41063. */
  41064. invertNormalMapY: boolean;
  41065. /**
  41066. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41067. */
  41068. twoSidedLighting: boolean;
  41069. /**
  41070. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41071. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  41072. */
  41073. useAlphaFresnel: boolean;
  41074. /**
  41075. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41076. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  41077. */
  41078. useLinearAlphaFresnel: boolean;
  41079. /**
  41080. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41081. * And/Or occlude the blended part.
  41082. */
  41083. environmentBRDFTexture: Nullable<BaseTexture>;
  41084. /**
  41085. * Force normal to face away from face.
  41086. */
  41087. forceNormalForward: boolean;
  41088. /**
  41089. * Enables specular anti aliasing in the PBR shader.
  41090. * It will both interacts on the Geometry for analytical and IBL lighting.
  41091. * It also prefilter the roughness map based on the bump values.
  41092. */
  41093. enableSpecularAntiAliasing: boolean;
  41094. /**
  41095. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  41096. * makes the reflect vector face the model (under horizon).
  41097. */
  41098. useHorizonOcclusion: boolean;
  41099. /**
  41100. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  41101. * too much the area relying on ambient texture to define their ambient occlusion.
  41102. */
  41103. useRadianceOcclusion: boolean;
  41104. /**
  41105. * If set to true, no lighting calculations will be applied.
  41106. */
  41107. unlit: boolean;
  41108. /**
  41109. * Gets the image processing configuration used either in this material.
  41110. */
  41111. /**
  41112. * Sets the Default image processing configuration used either in the this material.
  41113. *
  41114. * If sets to null, the scene one is in use.
  41115. */
  41116. imageProcessingConfiguration: ImageProcessingConfiguration;
  41117. /**
  41118. * Gets wether the color curves effect is enabled.
  41119. */
  41120. /**
  41121. * Sets wether the color curves effect is enabled.
  41122. */
  41123. cameraColorCurvesEnabled: boolean;
  41124. /**
  41125. * Gets wether the color grading effect is enabled.
  41126. */
  41127. /**
  41128. * Gets wether the color grading effect is enabled.
  41129. */
  41130. cameraColorGradingEnabled: boolean;
  41131. /**
  41132. * Gets wether tonemapping is enabled or not.
  41133. */
  41134. /**
  41135. * Sets wether tonemapping is enabled or not
  41136. */
  41137. cameraToneMappingEnabled: boolean;
  41138. /**
  41139. * The camera exposure used on this material.
  41140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41141. * This corresponds to a photographic exposure.
  41142. */
  41143. /**
  41144. * The camera exposure used on this material.
  41145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41146. * This corresponds to a photographic exposure.
  41147. */
  41148. cameraExposure: number;
  41149. /**
  41150. * Gets The camera contrast used on this material.
  41151. */
  41152. /**
  41153. * Sets The camera contrast used on this material.
  41154. */
  41155. cameraContrast: number;
  41156. /**
  41157. * Gets the Color Grading 2D Lookup Texture.
  41158. */
  41159. /**
  41160. * Sets the Color Grading 2D Lookup Texture.
  41161. */
  41162. cameraColorGradingTexture: Nullable<BaseTexture>;
  41163. /**
  41164. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41165. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41166. * 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;
  41167. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41168. */
  41169. /**
  41170. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41171. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41172. * 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;
  41173. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41174. */
  41175. cameraColorCurves: Nullable<ColorCurves>;
  41176. /**
  41177. * Instantiates a new PBRMaterial instance.
  41178. *
  41179. * @param name The material name
  41180. * @param scene The scene the material will be use in.
  41181. */
  41182. constructor(name: string, scene: Scene);
  41183. /**
  41184. * Returns the name of this material class.
  41185. */
  41186. getClassName(): string;
  41187. /**
  41188. * Returns an array of the actively used textures.
  41189. * @returns - Array of BaseTextures
  41190. */
  41191. getActiveTextures(): BaseTexture[];
  41192. /**
  41193. * Checks to see if a texture is used in the material.
  41194. * @param texture - Base texture to use.
  41195. * @returns - Boolean specifying if a texture is used in the material.
  41196. */
  41197. hasTexture(texture: BaseTexture): boolean;
  41198. /**
  41199. * Makes a duplicate of the current material.
  41200. * @param name - name to use for the new material.
  41201. */
  41202. clone(name: string): PBRMaterial;
  41203. /**
  41204. * Serializes this PBR Material.
  41205. * @returns - An object with the serialized material.
  41206. */
  41207. serialize(): any;
  41208. /**
  41209. * Parses a PBR Material from a serialized object.
  41210. * @param source - Serialized object.
  41211. * @param scene - BJS scene instance.
  41212. * @param rootUrl - url for the scene object
  41213. * @returns - PBRMaterial
  41214. */
  41215. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  41216. }
  41217. }
  41218. declare module BABYLON {
  41219. /**
  41220. * The PBR material of BJS following the metal roughness convention.
  41221. *
  41222. * This fits to the PBR convention in the GLTF definition:
  41223. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  41224. */
  41225. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  41226. /**
  41227. * The base color has two different interpretations depending on the value of metalness.
  41228. * When the material is a metal, the base color is the specific measured reflectance value
  41229. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  41230. * of the material.
  41231. */
  41232. baseColor: Color3;
  41233. /**
  41234. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  41235. * well as opacity information in the alpha channel.
  41236. */
  41237. baseTexture: BaseTexture;
  41238. /**
  41239. * Specifies the metallic scalar value of the material.
  41240. * Can also be used to scale the metalness values of the metallic texture.
  41241. */
  41242. metallic: number;
  41243. /**
  41244. * Specifies the roughness scalar value of the material.
  41245. * Can also be used to scale the roughness values of the metallic texture.
  41246. */
  41247. roughness: number;
  41248. /**
  41249. * Texture containing both the metallic value in the B channel and the
  41250. * roughness value in the G channel to keep better precision.
  41251. */
  41252. metallicRoughnessTexture: BaseTexture;
  41253. /**
  41254. * Instantiates a new PBRMetalRoughnessMaterial instance.
  41255. *
  41256. * @param name The material name
  41257. * @param scene The scene the material will be use in.
  41258. */
  41259. constructor(name: string, scene: Scene);
  41260. /**
  41261. * Return the currrent class name of the material.
  41262. */
  41263. getClassName(): string;
  41264. /**
  41265. * Return the active textures of the material.
  41266. */
  41267. getActiveTextures(): BaseTexture[];
  41268. /**
  41269. * Checks to see if a texture is used in the material.
  41270. * @param texture - Base texture to use.
  41271. * @returns - Boolean specifying if a texture is used in the material.
  41272. */
  41273. hasTexture(texture: BaseTexture): boolean;
  41274. /**
  41275. * Makes a duplicate of the current material.
  41276. * @param name - name to use for the new material.
  41277. */
  41278. clone(name: string): PBRMetallicRoughnessMaterial;
  41279. /**
  41280. * Serialize the material to a parsable JSON object.
  41281. */
  41282. serialize(): any;
  41283. /**
  41284. * Parses a JSON object correponding to the serialize function.
  41285. */
  41286. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  41287. }
  41288. }
  41289. declare module BABYLON {
  41290. /**
  41291. * The PBR material of BJS following the specular glossiness convention.
  41292. *
  41293. * This fits to the PBR convention in the GLTF definition:
  41294. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  41295. */
  41296. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  41297. /**
  41298. * Specifies the diffuse color of the material.
  41299. */
  41300. diffuseColor: Color3;
  41301. /**
  41302. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  41303. * channel.
  41304. */
  41305. diffuseTexture: BaseTexture;
  41306. /**
  41307. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  41308. */
  41309. specularColor: Color3;
  41310. /**
  41311. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  41312. */
  41313. glossiness: number;
  41314. /**
  41315. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  41316. */
  41317. specularGlossinessTexture: BaseTexture;
  41318. /**
  41319. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  41320. *
  41321. * @param name The material name
  41322. * @param scene The scene the material will be use in.
  41323. */
  41324. constructor(name: string, scene: Scene);
  41325. /**
  41326. * Return the currrent class name of the material.
  41327. */
  41328. getClassName(): string;
  41329. /**
  41330. * Return the active textures of the material.
  41331. */
  41332. getActiveTextures(): BaseTexture[];
  41333. /**
  41334. * Checks to see if a texture is used in the material.
  41335. * @param texture - Base texture to use.
  41336. * @returns - Boolean specifying if a texture is used in the material.
  41337. */
  41338. hasTexture(texture: BaseTexture): boolean;
  41339. /**
  41340. * Makes a duplicate of the current material.
  41341. * @param name - name to use for the new material.
  41342. */
  41343. clone(name: string): PBRSpecularGlossinessMaterial;
  41344. /**
  41345. * Serialize the material to a parsable JSON object.
  41346. */
  41347. serialize(): any;
  41348. /**
  41349. * Parses a JSON object correponding to the serialize function.
  41350. */
  41351. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  41352. }
  41353. }
  41354. declare module BABYLON {
  41355. class BaseTexture {
  41356. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  41357. name: string;
  41358. private _hasAlpha;
  41359. hasAlpha: boolean;
  41360. getAlphaFromRGB: boolean;
  41361. level: number;
  41362. coordinatesIndex: number;
  41363. private _coordinatesMode;
  41364. /**
  41365. * How a texture is mapped.
  41366. *
  41367. * | Value | Type | Description |
  41368. * | ----- | ----------------------------------- | ----------- |
  41369. * | 0 | EXPLICIT_MODE | |
  41370. * | 1 | SPHERICAL_MODE | |
  41371. * | 2 | PLANAR_MODE | |
  41372. * | 3 | CUBIC_MODE | |
  41373. * | 4 | PROJECTION_MODE | |
  41374. * | 5 | SKYBOX_MODE | |
  41375. * | 6 | INVCUBIC_MODE | |
  41376. * | 7 | EQUIRECTANGULAR_MODE | |
  41377. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  41378. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  41379. */
  41380. coordinatesMode: number;
  41381. /**
  41382. * | Value | Type | Description |
  41383. * | ----- | ------------------ | ----------- |
  41384. * | 0 | CLAMP_ADDRESSMODE | |
  41385. * | 1 | WRAP_ADDRESSMODE | |
  41386. * | 2 | MIRROR_ADDRESSMODE | |
  41387. */
  41388. wrapU: number;
  41389. /**
  41390. * | Value | Type | Description |
  41391. * | ----- | ------------------ | ----------- |
  41392. * | 0 | CLAMP_ADDRESSMODE | |
  41393. * | 1 | WRAP_ADDRESSMODE | |
  41394. * | 2 | MIRROR_ADDRESSMODE | |
  41395. */
  41396. wrapV: number;
  41397. /**
  41398. * | Value | Type | Description |
  41399. * | ----- | ------------------ | ----------- |
  41400. * | 0 | CLAMP_ADDRESSMODE | |
  41401. * | 1 | WRAP_ADDRESSMODE | |
  41402. * | 2 | MIRROR_ADDRESSMODE | |
  41403. */
  41404. wrapR: number;
  41405. anisotropicFilteringLevel: number;
  41406. isCube: boolean;
  41407. is3D: boolean;
  41408. gammaSpace: boolean;
  41409. /**
  41410. * Gets whether or not the texture contains RGBD data.
  41411. */
  41412. readonly isRGBD: boolean;
  41413. invertZ: boolean;
  41414. lodLevelInAlpha: boolean;
  41415. lodGenerationOffset: number;
  41416. lodGenerationScale: number;
  41417. isRenderTarget: boolean;
  41418. readonly uid: string;
  41419. toString(): string;
  41420. getClassName(): string;
  41421. animations: Animation[];
  41422. /**
  41423. * An event triggered when the texture is disposed.
  41424. */
  41425. onDisposeObservable: Observable<BaseTexture>;
  41426. private _onDisposeObserver;
  41427. onDispose: () => void;
  41428. delayLoadState: number;
  41429. private _scene;
  41430. /** @hidden */
  41431. _texture: Nullable<InternalTexture>;
  41432. private _uid;
  41433. readonly isBlocking: boolean;
  41434. constructor(scene: Nullable<Scene>);
  41435. getScene(): Nullable<Scene>;
  41436. getTextureMatrix(): Matrix;
  41437. getReflectionTextureMatrix(): Matrix;
  41438. getInternalTexture(): Nullable<InternalTexture>;
  41439. isReadyOrNotBlocking(): boolean;
  41440. isReady(): boolean;
  41441. private _cachedSize;
  41442. getSize(): ISize;
  41443. getBaseSize(): ISize;
  41444. scale(ratio: number): void;
  41445. readonly canRescale: boolean;
  41446. /** @hidden */
  41447. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  41448. /** @hidden */
  41449. _rebuild(): void;
  41450. delayLoad(): void;
  41451. clone(): Nullable<BaseTexture>;
  41452. readonly textureType: number;
  41453. readonly textureFormat: number;
  41454. /**
  41455. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  41456. * This will returns an RGBA array buffer containing either in values (0-255) or
  41457. * float values (0-1) depending of the underlying buffer type.
  41458. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  41459. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  41460. * @param buffer defines a user defined buffer to fill with data (can be null)
  41461. * @returns The Array buffer containing the pixels data.
  41462. */
  41463. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  41464. releaseInternalTexture(): void;
  41465. sphericalPolynomial: Nullable<SphericalPolynomial>;
  41466. readonly _lodTextureHigh: Nullable<BaseTexture>;
  41467. readonly _lodTextureMid: Nullable<BaseTexture>;
  41468. readonly _lodTextureLow: Nullable<BaseTexture>;
  41469. dispose(): void;
  41470. serialize(): any;
  41471. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  41472. }
  41473. }
  41474. declare module BABYLON {
  41475. /**
  41476. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  41477. * It can help converting any input color in a desired output one. This can then be used to create effects
  41478. * from sepia, black and white to sixties or futuristic rendering...
  41479. *
  41480. * The only supported format is currently 3dl.
  41481. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  41482. */
  41483. class ColorGradingTexture extends BaseTexture {
  41484. /**
  41485. * The current texture matrix. (will always be identity in color grading texture)
  41486. */
  41487. private _textureMatrix;
  41488. /**
  41489. * The texture URL.
  41490. */
  41491. url: string;
  41492. /**
  41493. * Empty line regex stored for GC.
  41494. */
  41495. private static _noneEmptyLineRegex;
  41496. private _engine;
  41497. /**
  41498. * Instantiates a ColorGradingTexture from the following parameters.
  41499. *
  41500. * @param url The location of the color gradind data (currently only supporting 3dl)
  41501. * @param scene The scene the texture will be used in
  41502. */
  41503. constructor(url: string, scene: Scene);
  41504. /**
  41505. * Returns the texture matrix used in most of the material.
  41506. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  41507. */
  41508. getTextureMatrix(): Matrix;
  41509. /**
  41510. * Occurs when the file being loaded is a .3dl LUT file.
  41511. */
  41512. private load3dlTexture;
  41513. /**
  41514. * Starts the loading process of the texture.
  41515. */
  41516. private loadTexture;
  41517. /**
  41518. * Clones the color gradind texture.
  41519. */
  41520. clone(): ColorGradingTexture;
  41521. /**
  41522. * Called during delayed load for textures.
  41523. */
  41524. delayLoad(): void;
  41525. /**
  41526. * Parses a color grading texture serialized by Babylon.
  41527. * @param parsedTexture The texture information being parsedTexture
  41528. * @param scene The scene to load the texture in
  41529. * @param rootUrl The root url of the data assets to load
  41530. * @return A color gradind texture
  41531. */
  41532. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  41533. /**
  41534. * Serializes the LUT texture to json format.
  41535. */
  41536. serialize(): any;
  41537. }
  41538. }
  41539. declare module BABYLON {
  41540. class CubeTexture extends BaseTexture {
  41541. url: string;
  41542. /**
  41543. * Gets or sets the center of the bounding box associated with the cube texture
  41544. * It must define where the camera used to render the texture was set
  41545. */
  41546. boundingBoxPosition: Vector3;
  41547. private _boundingBoxSize;
  41548. /**
  41549. * Gets or sets the size of the bounding box associated with the cube texture
  41550. * When defined, the cubemap will switch to local mode
  41551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  41552. * @example https://www.babylonjs-playground.com/#RNASML
  41553. */
  41554. boundingBoxSize: Vector3;
  41555. protected _rotationY: number;
  41556. /**
  41557. * Sets texture matrix rotation angle around Y axis in radians.
  41558. */
  41559. /**
  41560. * Gets texture matrix rotation angle around Y axis radians.
  41561. */
  41562. rotationY: number;
  41563. private _noMipmap;
  41564. private _files;
  41565. private _extensions;
  41566. private _textureMatrix;
  41567. private _format;
  41568. private _createPolynomials;
  41569. /** @hidden */
  41570. readonly _prefiltered: boolean;
  41571. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  41572. /**
  41573. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  41574. * @param url defines the url of the prefiltered texture
  41575. * @param scene defines the scene the texture is attached to
  41576. * @param forcedExtension defines the extension of the file if different from the url
  41577. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  41578. * @return the prefiltered texture
  41579. */
  41580. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  41581. /**
  41582. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  41583. * as prefiltered data.
  41584. * @param rootUrl defines the url of the texture or the root name of the six images
  41585. * @param scene defines the scene the texture is attached to
  41586. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  41587. * @param noMipmap defines if mipmaps should be created or not
  41588. * @param files defines the six files to load for the different faces
  41589. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  41590. * @param onError defines a callback triggered in case of error during load
  41591. * @param format defines the internal format to use for the texture once loaded
  41592. * @param prefiltered defines whether or not the texture is created from prefiltered data
  41593. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  41594. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  41595. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  41596. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  41597. * @return the cube texture
  41598. */
  41599. 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);
  41600. delayLoad(): void;
  41601. getReflectionTextureMatrix(): Matrix;
  41602. setReflectionTextureMatrix(value: Matrix): void;
  41603. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  41604. clone(): CubeTexture;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * A class extending {BABYLON.Texture} allowing drawing on a texture
  41610. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41611. */
  41612. class DynamicTexture extends Texture {
  41613. private _generateMipMaps;
  41614. private _canvas;
  41615. private _context;
  41616. private _engine;
  41617. /**
  41618. * Creates a {BABYLON.DynamicTexture}
  41619. * @param name defines the name of the texture
  41620. * @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
  41621. * @param scene defines the scene where you want the texture
  41622. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41623. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  41624. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  41625. */
  41626. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41627. /**
  41628. * Gets the current state of canRescale
  41629. */
  41630. readonly canRescale: boolean;
  41631. private _recreate;
  41632. /**
  41633. * Scales the texture
  41634. * @param ratio the scale factor to apply to both width and height
  41635. */
  41636. scale(ratio: number): void;
  41637. /**
  41638. * Resizes the texture
  41639. * @param width the new width
  41640. * @param height the new height
  41641. */
  41642. scaleTo(width: number, height: number): void;
  41643. /**
  41644. * Gets the context of the canvas used by the texture
  41645. * @returns the canvas context of the dynamic texture
  41646. */
  41647. getContext(): CanvasRenderingContext2D;
  41648. /**
  41649. * Clears the texture
  41650. */
  41651. clear(): void;
  41652. /**
  41653. * Updates the texture
  41654. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41655. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41656. */
  41657. update(invertY?: boolean, premulAlpha?: boolean): void;
  41658. /**
  41659. * Draws text onto the texture
  41660. * @param text defines the text to be drawn
  41661. * @param x defines the placement of the text from the left
  41662. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41663. * @param font defines the font to be used with font-style, font-size, font-name
  41664. * @param color defines the color used for the text
  41665. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41666. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41667. * @param update defines whether texture is immediately update (default is true)
  41668. */
  41669. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41670. /**
  41671. * Clones the texture
  41672. * @returns the clone of the texture.
  41673. */
  41674. clone(): DynamicTexture;
  41675. /**
  41676. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41677. * @returns a serialized dynamic texture object
  41678. */
  41679. serialize(): any;
  41680. /** @hidden */
  41681. _rebuild(): void;
  41682. }
  41683. }
  41684. declare module BABYLON {
  41685. /**
  41686. * This represents a texture coming from an HDR input.
  41687. *
  41688. * The only supported format is currently panorama picture stored in RGBE format.
  41689. * Example of such files can be found on HDRLib: http://hdrlib.com/
  41690. */
  41691. class HDRCubeTexture extends BaseTexture {
  41692. private static _facesMapping;
  41693. private _generateHarmonics;
  41694. private _noMipmap;
  41695. private _textureMatrix;
  41696. private _size;
  41697. private _onLoad;
  41698. private _onError;
  41699. /**
  41700. * The texture URL.
  41701. */
  41702. url: string;
  41703. /**
  41704. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  41705. */
  41706. coordinatesMode: number;
  41707. protected _isBlocking: boolean;
  41708. /**
  41709. * Sets wether or not the texture is blocking during loading.
  41710. */
  41711. /**
  41712. * Gets wether or not the texture is blocking during loading.
  41713. */
  41714. isBlocking: boolean;
  41715. protected _rotationY: number;
  41716. /**
  41717. * Sets texture matrix rotation angle around Y axis in radians.
  41718. */
  41719. /**
  41720. * Gets texture matrix rotation angle around Y axis radians.
  41721. */
  41722. rotationY: number;
  41723. /**
  41724. * Gets or sets the center of the bounding box associated with the cube texture
  41725. * It must define where the camera used to render the texture was set
  41726. */
  41727. boundingBoxPosition: Vector3;
  41728. private _boundingBoxSize;
  41729. /**
  41730. * Gets or sets the size of the bounding box associated with the cube texture
  41731. * When defined, the cubemap will switch to local mode
  41732. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  41733. * @example https://www.babylonjs-playground.com/#RNASML
  41734. */
  41735. boundingBoxSize: Vector3;
  41736. /**
  41737. * Instantiates an HDRTexture from the following parameters.
  41738. *
  41739. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  41740. * @param scene The scene the texture will be used in
  41741. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  41742. * @param noMipmap Forces to not generate the mipmap if true
  41743. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  41744. * @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)
  41745. * @param reserved Reserved flag for internal use.
  41746. */
  41747. 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>);
  41748. /**
  41749. * Occurs when the file is raw .hdr file.
  41750. */
  41751. private loadTexture;
  41752. clone(): HDRCubeTexture;
  41753. delayLoad(): void;
  41754. getReflectionTextureMatrix(): Matrix;
  41755. setReflectionTextureMatrix(value: Matrix): void;
  41756. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  41757. serialize(): any;
  41758. }
  41759. }
  41760. declare module BABYLON {
  41761. /**
  41762. * Class used to store data associated with WebGL texture data for the engine
  41763. * This class should not be used directly
  41764. */
  41765. class InternalTexture implements IInternalTextureTracker {
  41766. /**
  41767. * The source of the texture data is unknown
  41768. */
  41769. static DATASOURCE_UNKNOWN: number;
  41770. /**
  41771. * Texture data comes from an URL
  41772. */
  41773. static DATASOURCE_URL: number;
  41774. /**
  41775. * Texture data is only used for temporary storage
  41776. */
  41777. static DATASOURCE_TEMP: number;
  41778. /**
  41779. * Texture data comes from raw data (ArrayBuffer)
  41780. */
  41781. static DATASOURCE_RAW: number;
  41782. /**
  41783. * Texture content is dynamic (video or dynamic texture)
  41784. */
  41785. static DATASOURCE_DYNAMIC: number;
  41786. /**
  41787. * Texture content is generated by rendering to it
  41788. */
  41789. static DATASOURCE_RENDERTARGET: number;
  41790. /**
  41791. * Texture content is part of a multi render target process
  41792. */
  41793. static DATASOURCE_MULTIRENDERTARGET: number;
  41794. /**
  41795. * Texture data comes from a cube data file
  41796. */
  41797. static DATASOURCE_CUBE: number;
  41798. /**
  41799. * Texture data comes from a raw cube data
  41800. */
  41801. static DATASOURCE_CUBERAW: number;
  41802. /**
  41803. * Texture data come from a prefiltered cube data file
  41804. */
  41805. static DATASOURCE_CUBEPREFILTERED: number;
  41806. /**
  41807. * Texture content is raw 3D data
  41808. */
  41809. static DATASOURCE_RAW3D: number;
  41810. /**
  41811. * Texture content is a depth texture
  41812. */
  41813. static DATASOURCE_DEPTHTEXTURE: number;
  41814. /**
  41815. * Texture data comes from a raw cube data encoded with RGBD
  41816. */
  41817. static DATASOURCE_CUBERAW_RGBD: number;
  41818. /**
  41819. * Defines if the texture is ready
  41820. */
  41821. isReady: boolean;
  41822. /**
  41823. * Defines if the texture is a cube texture
  41824. */
  41825. isCube: boolean;
  41826. /**
  41827. * Defines if the texture contains 3D data
  41828. */
  41829. is3D: boolean;
  41830. /**
  41831. * Gets the URL used to load this texture
  41832. */
  41833. url: string;
  41834. /**
  41835. * Gets the sampling mode of the texture
  41836. */
  41837. samplingMode: number;
  41838. /**
  41839. * Gets a boolean indicating if the texture needs mipmaps generation
  41840. */
  41841. generateMipMaps: boolean;
  41842. /**
  41843. * Gets the number of samples used by the texture (WebGL2+ only)
  41844. */
  41845. samples: number;
  41846. /**
  41847. * Gets the type of the texture
  41848. */
  41849. type: number;
  41850. /**
  41851. * Gets the format of the texture
  41852. */
  41853. format: number;
  41854. /**
  41855. * Observable called when the texture is loaded
  41856. */
  41857. onLoadedObservable: Observable<InternalTexture>;
  41858. /**
  41859. * Gets the width of the texture
  41860. */
  41861. width: number;
  41862. /**
  41863. * Gets the height of the texture
  41864. */
  41865. height: number;
  41866. /**
  41867. * Gets the depth of the texture
  41868. */
  41869. depth: number;
  41870. /**
  41871. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41872. */
  41873. baseWidth: number;
  41874. /**
  41875. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41876. */
  41877. baseHeight: number;
  41878. /**
  41879. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41880. */
  41881. baseDepth: number;
  41882. /**
  41883. * Gets a boolean indicating if the texture is inverted on Y axis
  41884. */
  41885. invertY: boolean;
  41886. /**
  41887. * Gets or set the previous tracker in the list
  41888. */
  41889. previous: Nullable<IInternalTextureTracker>;
  41890. /**
  41891. * Gets or set the next tracker in the list
  41892. */
  41893. next: Nullable<IInternalTextureTracker>;
  41894. /** @hidden */
  41895. _initialSlot: number;
  41896. /** @hidden */
  41897. _designatedSlot: number;
  41898. /** @hidden */
  41899. _dataSource: number;
  41900. /** @hidden */
  41901. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  41902. /** @hidden */
  41903. _bufferView: Nullable<ArrayBufferView>;
  41904. /** @hidden */
  41905. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41906. /** @hidden */
  41907. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41908. /** @hidden */
  41909. _size: number;
  41910. /** @hidden */
  41911. _extension: string;
  41912. /** @hidden */
  41913. _files: Nullable<string[]>;
  41914. /** @hidden */
  41915. _workingCanvas: HTMLCanvasElement;
  41916. /** @hidden */
  41917. _workingContext: CanvasRenderingContext2D;
  41918. /** @hidden */
  41919. _framebuffer: Nullable<WebGLFramebuffer>;
  41920. /** @hidden */
  41921. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41922. /** @hidden */
  41923. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41924. /** @hidden */
  41925. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41926. /** @hidden */
  41927. _attachments: Nullable<number[]>;
  41928. /** @hidden */
  41929. _cachedCoordinatesMode: Nullable<number>;
  41930. /** @hidden */
  41931. _cachedWrapU: Nullable<number>;
  41932. /** @hidden */
  41933. _cachedWrapV: Nullable<number>;
  41934. /** @hidden */
  41935. _cachedWrapR: Nullable<number>;
  41936. /** @hidden */
  41937. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41938. /** @hidden */
  41939. _isDisabled: boolean;
  41940. /** @hidden */
  41941. _compression: Nullable<string>;
  41942. /** @hidden */
  41943. _generateStencilBuffer: boolean;
  41944. /** @hidden */
  41945. _generateDepthBuffer: boolean;
  41946. /** @hidden */
  41947. _comparisonFunction: number;
  41948. /** @hidden */
  41949. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41950. /** @hidden */
  41951. _lodGenerationScale: number;
  41952. /** @hidden */
  41953. _lodGenerationOffset: number;
  41954. /** @hidden */
  41955. _lodTextureHigh: BaseTexture;
  41956. /** @hidden */
  41957. _lodTextureMid: BaseTexture;
  41958. /** @hidden */
  41959. _lodTextureLow: BaseTexture;
  41960. /** @hidden */
  41961. _isRGBD: boolean;
  41962. /** @hidden */
  41963. _webGLTexture: Nullable<WebGLTexture>;
  41964. /** @hidden */
  41965. _references: number;
  41966. private _engine;
  41967. /**
  41968. * Gets the Engine the texture belongs to.
  41969. * @returns The babylon engine
  41970. */
  41971. getEngine(): Engine;
  41972. /**
  41973. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  41974. */
  41975. readonly dataSource: number;
  41976. /**
  41977. * Creates a new InternalTexture
  41978. * @param engine defines the engine to use
  41979. * @param dataSource defines the type of data that will be used
  41980. */
  41981. constructor(engine: Engine, dataSource: number);
  41982. /**
  41983. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  41984. */
  41985. incrementReferences(): void;
  41986. /**
  41987. * Change the size of the texture (not the size of the content)
  41988. * @param width defines the new width
  41989. * @param height defines the new height
  41990. * @param depth defines the new depth (1 by default)
  41991. */
  41992. updateSize(width: int, height: int, depth?: int): void;
  41993. /** @hidden */
  41994. _rebuild(): void;
  41995. /** @hidden */
  41996. _swapAndDie(target: InternalTexture): void;
  41997. /**
  41998. * Dispose the current allocated resources
  41999. */
  42000. dispose(): void;
  42001. }
  42002. }
  42003. declare module BABYLON {
  42004. /**
  42005. * This represents the required contract to create a new type of texture loader.
  42006. */
  42007. interface IInternalTextureLoader {
  42008. /**
  42009. * Defines wether the loader supports cascade loading the different faces.
  42010. */
  42011. supportCascades: boolean;
  42012. /**
  42013. * This returns if the loader support the current file information.
  42014. * @param extension defines the file extension of the file being loaded
  42015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  42016. * @param fallback defines the fallback internal texture if any
  42017. * @param isBase64 defines whether the texture is encoded as a base64
  42018. * @param isBuffer defines whether the texture data are stored as a buffer
  42019. * @returns true if the loader can load the specified file
  42020. */
  42021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  42022. /**
  42023. * Transform the url before loading if required.
  42024. * @param rootUrl the url of the texture
  42025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  42026. * @returns the transformed texture
  42027. */
  42028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  42029. /**
  42030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  42031. * @param rootUrl the url of the texture
  42032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  42033. * @returns the fallback texture
  42034. */
  42035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  42036. /**
  42037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  42038. * @param data contains the texture data
  42039. * @param texture defines the BabylonJS internal texture
  42040. * @param createPolynomials will be true if polynomials have been requested
  42041. * @param onLoad defines the callback to trigger once the texture is ready
  42042. * @param onError defines the callback to trigger in case of error
  42043. */
  42044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  42045. /**
  42046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  42047. * @param data contains the texture data
  42048. * @param texture defines the BabylonJS internal texture
  42049. * @param callback defines the method to call once ready to upload
  42050. */
  42051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  42052. }
  42053. }
  42054. declare module BABYLON {
  42055. /**
  42056. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  42057. */
  42058. interface IInternalTextureTracker {
  42059. /**
  42060. * Gets or set the previous tracker in the list
  42061. */
  42062. previous: Nullable<IInternalTextureTracker>;
  42063. /**
  42064. * Gets or set the next tracker in the list
  42065. */
  42066. next: Nullable<IInternalTextureTracker>;
  42067. }
  42068. /**
  42069. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  42070. */
  42071. class DummyInternalTextureTracker {
  42072. /**
  42073. * Gets or set the previous tracker in the list
  42074. */
  42075. previous: Nullable<IInternalTextureTracker>;
  42076. /**
  42077. * Gets or set the next tracker in the list
  42078. */
  42079. next: Nullable<IInternalTextureTracker>;
  42080. }
  42081. }
  42082. declare module BABYLON {
  42083. class MirrorTexture extends RenderTargetTexture {
  42084. private scene;
  42085. mirrorPlane: Plane;
  42086. private _transformMatrix;
  42087. private _mirrorMatrix;
  42088. private _savedViewMatrix;
  42089. private _blurX;
  42090. private _blurY;
  42091. private _adaptiveBlurKernel;
  42092. private _blurKernelX;
  42093. private _blurKernelY;
  42094. private _blurRatio;
  42095. blurRatio: number;
  42096. adaptiveBlurKernel: number;
  42097. blurKernel: number;
  42098. blurKernelX: number;
  42099. blurKernelY: number;
  42100. private _autoComputeBlurKernel;
  42101. protected _onRatioRescale(): void;
  42102. private _updateGammaSpace;
  42103. private _imageProcessingConfigChangeObserver;
  42104. constructor(name: string, size: number | {
  42105. width: number;
  42106. height: number;
  42107. } | {
  42108. ratio: number;
  42109. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  42110. private _preparePostProcesses;
  42111. clone(): MirrorTexture;
  42112. serialize(): any;
  42113. dispose(): void;
  42114. }
  42115. }
  42116. declare module BABYLON {
  42117. interface IMultiRenderTargetOptions {
  42118. generateMipMaps?: boolean;
  42119. types?: number[];
  42120. samplingModes?: number[];
  42121. generateDepthBuffer?: boolean;
  42122. generateStencilBuffer?: boolean;
  42123. generateDepthTexture?: boolean;
  42124. textureCount?: number;
  42125. doNotChangeAspectRatio?: boolean;
  42126. defaultType?: number;
  42127. }
  42128. class MultiRenderTarget extends RenderTargetTexture {
  42129. private _internalTextures;
  42130. private _textures;
  42131. readonly isSupported: boolean;
  42132. private _multiRenderTargetOptions;
  42133. readonly textures: Texture[];
  42134. readonly depthTexture: Texture;
  42135. wrapU: number;
  42136. wrapV: number;
  42137. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42138. /** @hidden */
  42139. _rebuild(): void;
  42140. private _createInternalTextures;
  42141. private _createTextures;
  42142. samples: number;
  42143. resize(size: any): void;
  42144. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42145. dispose(): void;
  42146. releaseInternalTextures(): void;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /**
  42151. * Raw cube texture where the raw buffers are passed in
  42152. */
  42153. class RawCubeTexture extends CubeTexture {
  42154. /**
  42155. * Creates a cube texture where the raw buffers are passed in.
  42156. * @param scene defines the scene the texture is attached to
  42157. * @param data defines the array of data to use to create each face
  42158. * @param size defines the size of the textures
  42159. * @param format defines the format of the data
  42160. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  42161. * @param generateMipMaps defines if the engine should generate the mip levels
  42162. * @param invertY defines if data must be stored with Y axis inverted
  42163. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  42164. * @param compression defines the compression used (null by default)
  42165. */
  42166. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  42167. /**
  42168. * Updates the raw cube texture.
  42169. * @param data defines the data to store
  42170. * @param format defines the data format
  42171. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  42172. * @param invertY defines if data must be stored with Y axis inverted
  42173. * @param compression defines the compression used (null by default)
  42174. * @param level defines which level of the texture to update
  42175. */
  42176. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  42177. /**
  42178. * Updates a raw cube texture with RGBD encoded data.
  42179. * @param data defines the array of data [mipmap][face] to use to create each face
  42180. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  42181. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  42182. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  42183. * @returns a promsie that resolves when the operation is complete
  42184. */
  42185. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  42186. /**
  42187. * Clones the raw cube texture.
  42188. * @return a new cube texture
  42189. */
  42190. clone(): CubeTexture;
  42191. /** @hidden */
  42192. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. class RawTexture extends Texture {
  42197. format: number;
  42198. private _engine;
  42199. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  42200. update(data: ArrayBufferView): void;
  42201. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  42202. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  42203. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  42204. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  42205. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  42206. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  42207. }
  42208. }
  42209. declare module BABYLON {
  42210. /**
  42211. * Class used to store 3D textures containing user data
  42212. */
  42213. class RawTexture3D extends Texture {
  42214. /** Gets or sets the texture format to use */
  42215. format: number;
  42216. private _engine;
  42217. /**
  42218. * Create a new RawTexture3D
  42219. * @param data defines the data of the texture
  42220. * @param width defines the width of the texture
  42221. * @param height defines the height of the texture
  42222. * @param depth defines the depth of the texture
  42223. * @param format defines the texture format to use
  42224. * @param scene defines the hosting scene
  42225. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  42226. * @param invertY defines if texture must be stored with Y axis inverted
  42227. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  42228. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  42229. */
  42230. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  42231. /** Gets or sets the texture format to use */
  42232. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  42233. /**
  42234. * Update the texture with new data
  42235. * @param data defines the data to store in the texture
  42236. */
  42237. update(data: ArrayBufferView): void;
  42238. }
  42239. }
  42240. declare module BABYLON {
  42241. /**
  42242. * Creates a refraction texture used by refraction channel of the standard material.
  42243. * @param name the texture name
  42244. * @param size size of the underlying texture
  42245. * @param scene root scene
  42246. */
  42247. class RefractionTexture extends RenderTargetTexture {
  42248. refractionPlane: Plane;
  42249. depth: number;
  42250. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  42251. clone(): RefractionTexture;
  42252. serialize(): any;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. class RenderTargetTexture extends Texture {
  42257. isCube: boolean;
  42258. static _REFRESHRATE_RENDER_ONCE: number;
  42259. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  42260. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  42261. static readonly REFRESHRATE_RENDER_ONCE: number;
  42262. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  42263. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  42264. /**
  42265. * Use this predicate to dynamically define the list of mesh you want to render.
  42266. * If set, the renderList property will be overwritten.
  42267. */
  42268. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  42269. private _renderList;
  42270. /**
  42271. * Use this list to define the list of mesh you want to render.
  42272. */
  42273. renderList: Nullable<Array<AbstractMesh>>;
  42274. private _hookArray;
  42275. renderParticles: boolean;
  42276. renderSprites: boolean;
  42277. coordinatesMode: number;
  42278. activeCamera: Nullable<Camera>;
  42279. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  42280. useCameraPostProcesses: boolean;
  42281. ignoreCameraViewport: boolean;
  42282. private _postProcessManager;
  42283. private _postProcesses;
  42284. private _resizeObserver;
  42285. /**
  42286. * An event triggered when the texture is unbind.
  42287. */
  42288. onBeforeBindObservable: Observable<RenderTargetTexture>;
  42289. /**
  42290. * An event triggered when the texture is unbind.
  42291. */
  42292. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  42293. private _onAfterUnbindObserver;
  42294. onAfterUnbind: () => void;
  42295. /**
  42296. * An event triggered before rendering the texture
  42297. */
  42298. onBeforeRenderObservable: Observable<number>;
  42299. private _onBeforeRenderObserver;
  42300. onBeforeRender: (faceIndex: number) => void;
  42301. /**
  42302. * An event triggered after rendering the texture
  42303. */
  42304. onAfterRenderObservable: Observable<number>;
  42305. private _onAfterRenderObserver;
  42306. onAfterRender: (faceIndex: number) => void;
  42307. /**
  42308. * An event triggered after the texture clear
  42309. */
  42310. onClearObservable: Observable<Engine>;
  42311. private _onClearObserver;
  42312. onClear: (Engine: Engine) => void;
  42313. clearColor: Color4;
  42314. protected _size: number | {
  42315. width: number;
  42316. height: number;
  42317. };
  42318. protected _initialSizeParameter: number | {
  42319. width: number;
  42320. height: number;
  42321. } | {
  42322. ratio: number;
  42323. };
  42324. protected _sizeRatio: Nullable<number>;
  42325. /** @hidden */
  42326. _generateMipMaps: boolean;
  42327. protected _renderingManager: RenderingManager;
  42328. /** @hidden */
  42329. _waitingRenderList: string[];
  42330. protected _doNotChangeAspectRatio: boolean;
  42331. protected _currentRefreshId: number;
  42332. protected _refreshRate: number;
  42333. protected _textureMatrix: Matrix;
  42334. protected _samples: number;
  42335. protected _renderTargetOptions: RenderTargetCreationOptions;
  42336. readonly renderTargetOptions: RenderTargetCreationOptions;
  42337. protected _engine: Engine;
  42338. protected _onRatioRescale(): void;
  42339. /**
  42340. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  42341. * It must define where the camera used to render the texture is set
  42342. */
  42343. boundingBoxPosition: Vector3;
  42344. private _boundingBoxSize;
  42345. /**
  42346. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  42347. * When defined, the cubemap will switch to local mode
  42348. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  42349. * @example https://www.babylonjs-playground.com/#RNASML
  42350. */
  42351. boundingBoxSize: Vector3;
  42352. /**
  42353. * In case the RTT has been created with a depth texture, get the associated
  42354. * depth texture.
  42355. * Otherwise, return null.
  42356. */
  42357. depthStencilTexture: Nullable<InternalTexture>;
  42358. /**
  42359. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  42360. * or used a shadow, depth texture...
  42361. * @param name The friendly name of the texture
  42362. * @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)
  42363. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  42364. * @param generateMipMaps True if mip maps need to be generated after render.
  42365. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  42366. * @param type The type of the buffer in the RTT (int, half float, float...)
  42367. * @param isCube True if a cube texture needs to be created
  42368. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  42369. * @param generateDepthBuffer True to generate a depth buffer
  42370. * @param generateStencilBuffer True to generate a stencil buffer
  42371. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  42372. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  42373. */
  42374. constructor(name: string, size: number | {
  42375. width: number;
  42376. height: number;
  42377. } | {
  42378. ratio: number;
  42379. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  42380. /**
  42381. * Creates a depth stencil texture.
  42382. * This is only available in WebGL 2 or with the depth texture extension available.
  42383. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  42384. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  42385. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  42386. */
  42387. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  42388. private _processSizeParameter;
  42389. samples: number;
  42390. resetRefreshCounter(): void;
  42391. refreshRate: number;
  42392. addPostProcess(postProcess: PostProcess): void;
  42393. clearPostProcesses(dispose?: boolean): void;
  42394. removePostProcess(postProcess: PostProcess): void;
  42395. /** @hidden */
  42396. _shouldRender(): boolean;
  42397. getRenderSize(): number;
  42398. getRenderWidth(): number;
  42399. getRenderHeight(): number;
  42400. readonly canRescale: boolean;
  42401. scale(ratio: number): void;
  42402. getReflectionTextureMatrix(): Matrix;
  42403. resize(size: number | {
  42404. width: number;
  42405. height: number;
  42406. } | {
  42407. ratio: number;
  42408. }): void;
  42409. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  42410. private _bestReflectionRenderTargetDimension;
  42411. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42412. private renderToTarget;
  42413. /**
  42414. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42415. * This allowed control for front to back rendering or reversly depending of the special needs.
  42416. *
  42417. * @param renderingGroupId The rendering group id corresponding to its index
  42418. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42419. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42420. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42421. */
  42422. 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;
  42423. /**
  42424. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42425. *
  42426. * @param renderingGroupId The rendering group id corresponding to its index
  42427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42428. */
  42429. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  42430. clone(): RenderTargetTexture;
  42431. serialize(): any;
  42432. disposeFramebufferObjects(): void;
  42433. dispose(): void;
  42434. /** @hidden */
  42435. _rebuild(): void;
  42436. /**
  42437. * Clear the info related to rendering groups preventing retention point in material dispose.
  42438. */
  42439. freeRenderingGroups(): void;
  42440. }
  42441. }
  42442. declare module BABYLON {
  42443. class Texture extends BaseTexture {
  42444. static NEAREST_SAMPLINGMODE: number;
  42445. static NEAREST_NEAREST_MIPLINEAR: number;
  42446. static BILINEAR_SAMPLINGMODE: number;
  42447. static LINEAR_LINEAR_MIPNEAREST: number;
  42448. static TRILINEAR_SAMPLINGMODE: number;
  42449. static LINEAR_LINEAR_MIPLINEAR: number;
  42450. static NEAREST_NEAREST_MIPNEAREST: number;
  42451. static NEAREST_LINEAR_MIPNEAREST: number;
  42452. static NEAREST_LINEAR_MIPLINEAR: number;
  42453. static NEAREST_LINEAR: number;
  42454. static NEAREST_NEAREST: number;
  42455. static LINEAR_NEAREST_MIPNEAREST: number;
  42456. static LINEAR_NEAREST_MIPLINEAR: number;
  42457. static LINEAR_LINEAR: number;
  42458. static LINEAR_NEAREST: number;
  42459. static EXPLICIT_MODE: number;
  42460. static SPHERICAL_MODE: number;
  42461. static PLANAR_MODE: number;
  42462. static CUBIC_MODE: number;
  42463. static PROJECTION_MODE: number;
  42464. static SKYBOX_MODE: number;
  42465. static INVCUBIC_MODE: number;
  42466. static EQUIRECTANGULAR_MODE: number;
  42467. static FIXED_EQUIRECTANGULAR_MODE: number;
  42468. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42469. static readonly CLAMP_ADDRESSMODE: number;
  42470. static readonly WRAP_ADDRESSMODE: number;
  42471. static readonly MIRROR_ADDRESSMODE: number;
  42472. /**
  42473. * 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
  42474. */
  42475. static UseSerializedUrlIfAny: boolean;
  42476. url: Nullable<string>;
  42477. uOffset: number;
  42478. vOffset: number;
  42479. uScale: number;
  42480. vScale: number;
  42481. uAng: number;
  42482. vAng: number;
  42483. wAng: number;
  42484. /**
  42485. * Defines the center of rotation (U)
  42486. */
  42487. uRotationCenter: number;
  42488. /**
  42489. * Defines the center of rotation (V)
  42490. */
  42491. vRotationCenter: number;
  42492. /**
  42493. * Defines the center of rotation (W)
  42494. */
  42495. wRotationCenter: number;
  42496. readonly noMipmap: boolean;
  42497. private _noMipmap;
  42498. /** @hidden */
  42499. _invertY: boolean;
  42500. private _rowGenerationMatrix;
  42501. private _cachedTextureMatrix;
  42502. private _projectionModeMatrix;
  42503. private _t0;
  42504. private _t1;
  42505. private _t2;
  42506. private _cachedUOffset;
  42507. private _cachedVOffset;
  42508. private _cachedUScale;
  42509. private _cachedVScale;
  42510. private _cachedUAng;
  42511. private _cachedVAng;
  42512. private _cachedWAng;
  42513. private _cachedProjectionMatrixId;
  42514. private _cachedCoordinatesMode;
  42515. /** @hidden */
  42516. _samplingMode: number;
  42517. /** @hidden */
  42518. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  42519. private _deleteBuffer;
  42520. protected _format: Nullable<number>;
  42521. private _delayedOnLoad;
  42522. private _delayedOnError;
  42523. protected _onLoadObservable: Nullable<Observable<Texture>>;
  42524. protected _isBlocking: boolean;
  42525. isBlocking: boolean;
  42526. readonly samplingMode: number;
  42527. 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);
  42528. /**
  42529. * Update the url (and optional buffer) of this texture if url was null during construction.
  42530. * @param url the url of the texture
  42531. * @param buffer the buffer of the texture (defaults to null)
  42532. */
  42533. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  42534. delayLoad(): void;
  42535. /**
  42536. * Default is Trilinear mode.
  42537. *
  42538. * | Value | Type | Description |
  42539. * | ----- | ------------------ | ----------- |
  42540. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  42541. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  42542. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  42543. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  42544. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  42545. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  42546. * | 7 | NEAREST_LINEAR | |
  42547. * | 8 | NEAREST_NEAREST | |
  42548. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  42549. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  42550. * | 11 | LINEAR_LINEAR | |
  42551. * | 12 | LINEAR_NEAREST | |
  42552. *
  42553. * > _mag_: magnification filter (close to the viewer)
  42554. * > _min_: minification filter (far from the viewer)
  42555. * > _mip_: filter used between mip map levels
  42556. *
  42557. */
  42558. updateSamplingMode(samplingMode: number): void;
  42559. private _prepareRowForTextureGeneration;
  42560. getTextureMatrix(): Matrix;
  42561. getReflectionTextureMatrix(): Matrix;
  42562. clone(): Texture;
  42563. readonly onLoadObservable: Observable<Texture>;
  42564. serialize(): any;
  42565. getClassName(): string;
  42566. dispose(): void;
  42567. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  42568. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  42569. 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;
  42570. }
  42571. }
  42572. declare module BABYLON {
  42573. /**
  42574. * Settings for finer control over video usage
  42575. */
  42576. interface VideoTextureSettings {
  42577. /**
  42578. * Applies `autoplay` to video, if specified
  42579. */
  42580. autoPlay?: boolean;
  42581. /**
  42582. * Applies `loop` to video, if specified
  42583. */
  42584. loop?: boolean;
  42585. /**
  42586. * Automatically updates internal texture from video at every frame in the render loop
  42587. */
  42588. autoUpdateTexture: boolean;
  42589. /**
  42590. * Image src displayed during the video loading or until the user interacts with the video.
  42591. */
  42592. poster?: string;
  42593. }
  42594. class VideoTexture extends Texture {
  42595. /**
  42596. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  42597. */
  42598. readonly autoUpdateTexture: boolean;
  42599. /**
  42600. * The video instance used by the texture internally
  42601. */
  42602. readonly video: HTMLVideoElement;
  42603. private _onUserActionRequestedObservable;
  42604. readonly onUserActionRequestedObservable: Observable<Texture>;
  42605. private _generateMipMaps;
  42606. private _engine;
  42607. private _stillImageCaptured;
  42608. private _poster;
  42609. /**
  42610. * Creates a video texture.
  42611. * Sample : https://doc.babylonjs.com/how_to/video_texture
  42612. * @param {string | null} name optional name, will detect from video source, if not defined
  42613. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  42614. * @param {BABYLON.Scene} scene is obviously the current scene.
  42615. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  42616. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  42617. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  42618. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  42619. */
  42620. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  42621. private _getName;
  42622. private _getVideo;
  42623. private _createInternalTexture;
  42624. private reset;
  42625. /**
  42626. * @hidden Internal method to initiate `update`.
  42627. */
  42628. _rebuild(): void;
  42629. /**
  42630. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  42631. */
  42632. update(): void;
  42633. /**
  42634. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  42635. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  42636. */
  42637. updateTexture(isVisible: boolean): void;
  42638. protected _updateInternalTexture: (e?: Event | undefined) => void;
  42639. /**
  42640. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  42641. * @param url New url.
  42642. */
  42643. updateURL(url: string): void;
  42644. dispose(): void;
  42645. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  42646. minWidth: number;
  42647. maxWidth: number;
  42648. minHeight: number;
  42649. maxHeight: number;
  42650. deviceId: string;
  42651. }): void;
  42652. }
  42653. }
  42654. declare var DracoDecoderModule: any;
  42655. declare var WebAssembly: any;
  42656. declare module BABYLON {
  42657. /**
  42658. * Configuration for Draco compression
  42659. */
  42660. interface IDracoCompressionConfiguration {
  42661. /**
  42662. * Configuration for the decoder.
  42663. */
  42664. decoder?: {
  42665. /**
  42666. * The url to the WebAssembly module.
  42667. */
  42668. wasmUrl?: string;
  42669. /**
  42670. * The url to the WebAssembly binary.
  42671. */
  42672. wasmBinaryUrl?: string;
  42673. /**
  42674. * The url to the fallback JavaScript module.
  42675. */
  42676. fallbackUrl?: string;
  42677. };
  42678. }
  42679. /**
  42680. * Draco compression (https://google.github.io/draco/)
  42681. *
  42682. * This class wraps the Draco module.
  42683. *
  42684. * **Encoder**
  42685. *
  42686. * The encoder is not currently implemented.
  42687. *
  42688. * **Decoder**
  42689. *
  42690. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  42691. *
  42692. * To update the configuration, use the following code:
  42693. * ```javascript
  42694. * BABYLON.DracoCompression.Configuration = {
  42695. * decoder: {
  42696. * wasmUrl: "<url to the WebAssembly library>",
  42697. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  42698. * fallbackUrl: "<url to the fallback JavaScript library>",
  42699. * }
  42700. * };
  42701. * ```
  42702. *
  42703. * 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.
  42704. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  42705. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  42706. *
  42707. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  42708. * ```javascript
  42709. * var dracoCompression = new BABYLON.DracoCompression();
  42710. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  42711. * [BABYLON.VertexBuffer.PositionKind]: 0
  42712. * });
  42713. * ```
  42714. *
  42715. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  42716. */
  42717. class DracoCompression implements IDisposable {
  42718. private static _DecoderModulePromise;
  42719. /**
  42720. * The configuration. Defaults to the following urls:
  42721. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  42722. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  42723. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  42724. */
  42725. static Configuration: IDracoCompressionConfiguration;
  42726. /**
  42727. * Returns true if the decoder is available.
  42728. */
  42729. static readonly DecoderAvailable: boolean;
  42730. /**
  42731. * Constructor
  42732. */
  42733. constructor();
  42734. /**
  42735. * Stop all async operations and release resources.
  42736. */
  42737. dispose(): void;
  42738. /**
  42739. * Decode Draco compressed mesh data to vertex data.
  42740. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  42741. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  42742. * @returns A promise that resolves with the decoded vertex data
  42743. */
  42744. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  42745. [kind: string]: number;
  42746. }): Promise<VertexData>;
  42747. private static _GetDecoderModule;
  42748. private static _LoadScriptAsync;
  42749. private static _LoadFileAsync;
  42750. }
  42751. }
  42752. declare module BABYLON {
  42753. /**
  42754. * Particle emitter emitting particles from the inside of a box.
  42755. * It emits the particles randomly between 2 given directions.
  42756. */
  42757. class BoxParticleEmitter implements IParticleEmitterType {
  42758. /**
  42759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  42760. */
  42761. direction1: Vector3;
  42762. /**
  42763. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  42764. */
  42765. direction2: Vector3;
  42766. /**
  42767. * 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.
  42768. */
  42769. minEmitBox: Vector3;
  42770. /**
  42771. * 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.
  42772. */
  42773. maxEmitBox: Vector3;
  42774. /**
  42775. * Creates a new instance BoxParticleEmitter
  42776. */
  42777. constructor();
  42778. /**
  42779. * Called by the particle System when the direction is computed for the created particle.
  42780. * @param worldMatrix is the world matrix of the particle system
  42781. * @param directionToUpdate is the direction vector to update with the result
  42782. * @param particle is the particle we are computed the direction for
  42783. */
  42784. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42785. /**
  42786. * Called by the particle System when the position is computed for the created particle.
  42787. * @param worldMatrix is the world matrix of the particle system
  42788. * @param positionToUpdate is the position vector to update with the result
  42789. * @param particle is the particle we are computed the position for
  42790. */
  42791. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42792. /**
  42793. * Clones the current emitter and returns a copy of it
  42794. * @returns the new emitter
  42795. */
  42796. clone(): BoxParticleEmitter;
  42797. /**
  42798. * Called by the GPUParticleSystem to setup the update shader
  42799. * @param effect defines the update shader
  42800. */
  42801. applyToShader(effect: Effect): void;
  42802. /**
  42803. * Returns a string to use to update the GPU particles update shader
  42804. * @returns a string containng the defines string
  42805. */
  42806. getEffectDefines(): string;
  42807. /**
  42808. * Returns the string "BoxParticleEmitter"
  42809. * @returns a string containing the class name
  42810. */
  42811. getClassName(): string;
  42812. /**
  42813. * Serializes the particle system to a JSON object.
  42814. * @returns the JSON object
  42815. */
  42816. serialize(): any;
  42817. /**
  42818. * Parse properties from a JSON object
  42819. * @param serializationObject defines the JSON object
  42820. */
  42821. parse(serializationObject: any): void;
  42822. }
  42823. }
  42824. declare module BABYLON {
  42825. /**
  42826. * Particle emitter emitting particles from the inside of a cone.
  42827. * It emits the particles alongside the cone volume from the base to the particle.
  42828. * The emission direction might be randomized.
  42829. */
  42830. class ConeParticleEmitter implements IParticleEmitterType {
  42831. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  42832. directionRandomizer: number;
  42833. private _radius;
  42834. private _angle;
  42835. private _height;
  42836. /**
  42837. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  42838. */
  42839. radiusRange: number;
  42840. /**
  42841. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  42842. */
  42843. heightRange: number;
  42844. /**
  42845. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  42846. */
  42847. emitFromSpawnPointOnly: boolean;
  42848. /**
  42849. * Gets or sets the radius of the emission cone
  42850. */
  42851. radius: number;
  42852. /**
  42853. * Gets or sets the angle of the emission cone
  42854. */
  42855. angle: number;
  42856. private _buildHeight;
  42857. /**
  42858. * Creates a new instance ConeParticleEmitter
  42859. * @param radius the radius of the emission cone (1 by default)
  42860. * @param angles the cone base angle (PI by default)
  42861. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  42862. */
  42863. constructor(radius?: number, angle?: number,
  42864. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  42865. directionRandomizer?: number);
  42866. /**
  42867. * Called by the particle System when the direction is computed for the created particle.
  42868. * @param worldMatrix is the world matrix of the particle system
  42869. * @param directionToUpdate is the direction vector to update with the result
  42870. * @param particle is the particle we are computed the direction for
  42871. */
  42872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42873. /**
  42874. * Called by the particle System when the position is computed for the created particle.
  42875. * @param worldMatrix is the world matrix of the particle system
  42876. * @param positionToUpdate is the position vector to update with the result
  42877. * @param particle is the particle we are computed the position for
  42878. */
  42879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42880. /**
  42881. * Clones the current emitter and returns a copy of it
  42882. * @returns the new emitter
  42883. */
  42884. clone(): ConeParticleEmitter;
  42885. /**
  42886. * Called by the GPUParticleSystem to setup the update shader
  42887. * @param effect defines the update shader
  42888. */
  42889. applyToShader(effect: Effect): void;
  42890. /**
  42891. * Returns a string to use to update the GPU particles update shader
  42892. * @returns a string containng the defines string
  42893. */
  42894. getEffectDefines(): string;
  42895. /**
  42896. * Returns the string "ConeParticleEmitter"
  42897. * @returns a string containing the class name
  42898. */
  42899. getClassName(): string;
  42900. /**
  42901. * Serializes the particle system to a JSON object.
  42902. * @returns the JSON object
  42903. */
  42904. serialize(): any;
  42905. /**
  42906. * Parse properties from a JSON object
  42907. * @param serializationObject defines the JSON object
  42908. */
  42909. parse(serializationObject: any): void;
  42910. }
  42911. }
  42912. declare module BABYLON {
  42913. /**
  42914. * Particle emitter emitting particles from the inside of a cylinder.
  42915. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  42916. */
  42917. class CylinderParticleEmitter implements IParticleEmitterType {
  42918. /**
  42919. * The radius of the emission cylinder.
  42920. */
  42921. radius: number;
  42922. /**
  42923. * The height of the emission cylinder.
  42924. */
  42925. height: number;
  42926. /**
  42927. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42928. */
  42929. radiusRange: number;
  42930. /**
  42931. * How much to randomize the particle direction [0-1].
  42932. */
  42933. directionRandomizer: number;
  42934. /**
  42935. * Creates a new instance CylinderParticleEmitter
  42936. * @param radius the radius of the emission cylinder (1 by default)
  42937. * @param height the height of the emission cylinder (1 by default)
  42938. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  42939. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  42940. */
  42941. constructor(
  42942. /**
  42943. * The radius of the emission cylinder.
  42944. */
  42945. radius?: number,
  42946. /**
  42947. * The height of the emission cylinder.
  42948. */
  42949. height?: number,
  42950. /**
  42951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42952. */
  42953. radiusRange?: number,
  42954. /**
  42955. * How much to randomize the particle direction [0-1].
  42956. */
  42957. directionRandomizer?: number);
  42958. /**
  42959. * Called by the particle System when the direction is computed for the created particle.
  42960. * @param worldMatrix is the world matrix of the particle system
  42961. * @param directionToUpdate is the direction vector to update with the result
  42962. * @param particle is the particle we are computed the direction for
  42963. */
  42964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42965. /**
  42966. * Called by the particle System when the position is computed for the created particle.
  42967. * @param worldMatrix is the world matrix of the particle system
  42968. * @param positionToUpdate is the position vector to update with the result
  42969. * @param particle is the particle we are computed the position for
  42970. */
  42971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42972. /**
  42973. * Clones the current emitter and returns a copy of it
  42974. * @returns the new emitter
  42975. */
  42976. clone(): CylinderParticleEmitter;
  42977. /**
  42978. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  42979. * @param effect defines the update shader
  42980. */
  42981. applyToShader(effect: Effect): void;
  42982. /**
  42983. * Returns a string to use to update the GPU particles update shader
  42984. * @returns a string containng the defines string
  42985. */
  42986. getEffectDefines(): string;
  42987. /**
  42988. * Returns the string "CylinderParticleEmitter"
  42989. * @returns a string containing the class name
  42990. */
  42991. getClassName(): string;
  42992. /**
  42993. * Serializes the particle system to a JSON object.
  42994. * @returns the JSON object
  42995. */
  42996. serialize(): any;
  42997. /**
  42998. * Parse properties from a JSON object
  42999. * @param serializationObject defines the JSON object
  43000. */
  43001. parse(serializationObject: any): void;
  43002. }
  43003. /**
  43004. * Particle emitter emitting particles from the inside of a cylinder.
  43005. * It emits the particles randomly between two vectors.
  43006. */
  43007. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  43008. /**
  43009. * The min limit of the emission direction.
  43010. */
  43011. direction1: Vector3;
  43012. /**
  43013. * The max limit of the emission direction.
  43014. */
  43015. direction2: Vector3;
  43016. /**
  43017. * Creates a new instance CylinderDirectedParticleEmitter
  43018. * @param radius the radius of the emission cylinder (1 by default)
  43019. * @param height the height of the emission cylinder (1 by default)
  43020. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  43021. * @param direction1 the min limit of the emission direction (up vector by default)
  43022. * @param direction2 the max limit of the emission direction (up vector by default)
  43023. */
  43024. constructor(radius?: number, height?: number, radiusRange?: number,
  43025. /**
  43026. * The min limit of the emission direction.
  43027. */
  43028. direction1?: Vector3,
  43029. /**
  43030. * The max limit of the emission direction.
  43031. */
  43032. direction2?: Vector3);
  43033. /**
  43034. * Called by the particle System when the direction is computed for the created particle.
  43035. * @param worldMatrix is the world matrix of the particle system
  43036. * @param directionToUpdate is the direction vector to update with the result
  43037. * @param particle is the particle we are computed the direction for
  43038. */
  43039. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  43040. /**
  43041. * Clones the current emitter and returns a copy of it
  43042. * @returns the new emitter
  43043. */
  43044. clone(): CylinderDirectedParticleEmitter;
  43045. /**
  43046. * Called by the GPUParticleSystem to setup the update shader
  43047. * @param effect defines the update shader
  43048. */
  43049. applyToShader(effect: Effect): void;
  43050. /**
  43051. * Returns a string to use to update the GPU particles update shader
  43052. * @returns a string containng the defines string
  43053. */
  43054. getEffectDefines(): string;
  43055. /**
  43056. * Returns the string "CylinderDirectedParticleEmitter"
  43057. * @returns a string containing the class name
  43058. */
  43059. getClassName(): string;
  43060. /**
  43061. * Serializes the particle system to a JSON object.
  43062. * @returns the JSON object
  43063. */
  43064. serialize(): any;
  43065. /**
  43066. * Parse properties from a JSON object
  43067. * @param serializationObject defines the JSON object
  43068. */
  43069. parse(serializationObject: any): void;
  43070. }
  43071. }
  43072. declare module BABYLON {
  43073. /**
  43074. * Particle emitter emitting particles from the inside of a hemisphere.
  43075. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  43076. */
  43077. class HemisphericParticleEmitter implements IParticleEmitterType {
  43078. /**
  43079. * The radius of the emission hemisphere.
  43080. */
  43081. radius: number;
  43082. /**
  43083. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  43084. */
  43085. radiusRange: number;
  43086. /**
  43087. * How much to randomize the particle direction [0-1].
  43088. */
  43089. directionRandomizer: number;
  43090. /**
  43091. * Creates a new instance HemisphericParticleEmitter
  43092. * @param radius the radius of the emission hemisphere (1 by default)
  43093. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  43094. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  43095. */
  43096. constructor(
  43097. /**
  43098. * The radius of the emission hemisphere.
  43099. */
  43100. radius?: number,
  43101. /**
  43102. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  43103. */
  43104. radiusRange?: number,
  43105. /**
  43106. * How much to randomize the particle direction [0-1].
  43107. */
  43108. directionRandomizer?: number);
  43109. /**
  43110. * Called by the particle System when the direction is computed for the created particle.
  43111. * @param worldMatrix is the world matrix of the particle system
  43112. * @param directionToUpdate is the direction vector to update with the result
  43113. * @param particle is the particle we are computed the direction for
  43114. */
  43115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  43116. /**
  43117. * Called by the particle System when the position is computed for the created particle.
  43118. * @param worldMatrix is the world matrix of the particle system
  43119. * @param positionToUpdate is the position vector to update with the result
  43120. * @param particle is the particle we are computed the position for
  43121. */
  43122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  43123. /**
  43124. * Clones the current emitter and returns a copy of it
  43125. * @returns the new emitter
  43126. */
  43127. clone(): HemisphericParticleEmitter;
  43128. /**
  43129. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  43130. * @param effect defines the update shader
  43131. */
  43132. applyToShader(effect: Effect): void;
  43133. /**
  43134. * Returns a string to use to update the GPU particles update shader
  43135. * @returns a string containng the defines string
  43136. */
  43137. getEffectDefines(): string;
  43138. /**
  43139. * Returns the string "HemisphericParticleEmitter"
  43140. * @returns a string containing the class name
  43141. */
  43142. getClassName(): string;
  43143. /**
  43144. * Serializes the particle system to a JSON object.
  43145. * @returns the JSON object
  43146. */
  43147. serialize(): any;
  43148. /**
  43149. * Parse properties from a JSON object
  43150. * @param serializationObject defines the JSON object
  43151. */
  43152. parse(serializationObject: any): void;
  43153. }
  43154. }
  43155. declare module BABYLON {
  43156. /**
  43157. * Particle emitter represents a volume emitting particles.
  43158. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  43159. */
  43160. interface IParticleEmitterType {
  43161. /**
  43162. * Called by the particle System when the direction is computed for the created particle.
  43163. * @param worldMatrix is the world matrix of the particle system
  43164. * @param directionToUpdate is the direction vector to update with the result
  43165. * @param particle is the particle we are computed the direction for
  43166. */
  43167. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  43168. /**
  43169. * Called by the particle System when the position is computed for the created particle.
  43170. * @param worldMatrix is the world matrix of the particle system
  43171. * @param positionToUpdate is the position vector to update with the result
  43172. * @param particle is the particle we are computed the position for
  43173. */
  43174. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  43175. /**
  43176. * Clones the current emitter and returns a copy of it
  43177. * @returns the new emitter
  43178. */
  43179. clone(): IParticleEmitterType;
  43180. /**
  43181. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  43182. * @param effect defines the update shader
  43183. */
  43184. applyToShader(effect: Effect): void;
  43185. /**
  43186. * Returns a string to use to update the GPU particles update shader
  43187. * @returns the effect defines string
  43188. */
  43189. getEffectDefines(): string;
  43190. /**
  43191. * Returns a string representing the class name
  43192. * @returns a string containing the class name
  43193. */
  43194. getClassName(): string;
  43195. /**
  43196. * Serializes the particle system to a JSON object.
  43197. * @returns the JSON object
  43198. */
  43199. serialize(): any;
  43200. /**
  43201. * Parse properties from a JSON object
  43202. * @param serializationObject defines the JSON object
  43203. */
  43204. parse(serializationObject: any): void;
  43205. }
  43206. }
  43207. declare module BABYLON {
  43208. /**
  43209. * Particle emitter emitting particles from a point.
  43210. * It emits the particles randomly between 2 given directions.
  43211. */
  43212. class PointParticleEmitter implements IParticleEmitterType {
  43213. /**
  43214. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  43215. */
  43216. direction1: Vector3;
  43217. /**
  43218. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  43219. */
  43220. direction2: Vector3;
  43221. /**
  43222. * Creates a new instance PointParticleEmitter
  43223. */
  43224. constructor();
  43225. /**
  43226. * Called by the particle System when the direction is computed for the created particle.
  43227. * @param worldMatrix is the world matrix of the particle system
  43228. * @param directionToUpdate is the direction vector to update with the result
  43229. * @param particle is the particle we are computed the direction for
  43230. */
  43231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  43232. /**
  43233. * Called by the particle System when the position is computed for the created particle.
  43234. * @param worldMatrix is the world matrix of the particle system
  43235. * @param positionToUpdate is the position vector to update with the result
  43236. * @param particle is the particle we are computed the position for
  43237. */
  43238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  43239. /**
  43240. * Clones the current emitter and returns a copy of it
  43241. * @returns the new emitter
  43242. */
  43243. clone(): PointParticleEmitter;
  43244. /**
  43245. * Called by the GPUParticleSystem to setup the update shader
  43246. * @param effect defines the update shader
  43247. */
  43248. applyToShader(effect: Effect): void;
  43249. /**
  43250. * Returns a string to use to update the GPU particles update shader
  43251. * @returns a string containng the defines string
  43252. */
  43253. getEffectDefines(): string;
  43254. /**
  43255. * Returns the string "PointParticleEmitter"
  43256. * @returns a string containing the class name
  43257. */
  43258. getClassName(): string;
  43259. /**
  43260. * Serializes the particle system to a JSON object.
  43261. * @returns the JSON object
  43262. */
  43263. serialize(): any;
  43264. /**
  43265. * Parse properties from a JSON object
  43266. * @param serializationObject defines the JSON object
  43267. */
  43268. parse(serializationObject: any): void;
  43269. }
  43270. }
  43271. declare module BABYLON {
  43272. /**
  43273. * Particle emitter emitting particles from the inside of a sphere.
  43274. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  43275. */
  43276. class SphereParticleEmitter implements IParticleEmitterType {
  43277. /**
  43278. * The radius of the emission sphere.
  43279. */
  43280. radius: number;
  43281. /**
  43282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  43283. */
  43284. radiusRange: number;
  43285. /**
  43286. * How much to randomize the particle direction [0-1].
  43287. */
  43288. directionRandomizer: number;
  43289. /**
  43290. * Creates a new instance SphereParticleEmitter
  43291. * @param radius the radius of the emission sphere (1 by default)
  43292. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  43293. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  43294. */
  43295. constructor(
  43296. /**
  43297. * The radius of the emission sphere.
  43298. */
  43299. radius?: number,
  43300. /**
  43301. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  43302. */
  43303. radiusRange?: number,
  43304. /**
  43305. * How much to randomize the particle direction [0-1].
  43306. */
  43307. directionRandomizer?: number);
  43308. /**
  43309. * Called by the particle System when the direction is computed for the created particle.
  43310. * @param worldMatrix is the world matrix of the particle system
  43311. * @param directionToUpdate is the direction vector to update with the result
  43312. * @param particle is the particle we are computed the direction for
  43313. */
  43314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  43315. /**
  43316. * Called by the particle System when the position is computed for the created particle.
  43317. * @param worldMatrix is the world matrix of the particle system
  43318. * @param positionToUpdate is the position vector to update with the result
  43319. * @param particle is the particle we are computed the position for
  43320. */
  43321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  43322. /**
  43323. * Clones the current emitter and returns a copy of it
  43324. * @returns the new emitter
  43325. */
  43326. clone(): SphereParticleEmitter;
  43327. /**
  43328. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  43329. * @param effect defines the update shader
  43330. */
  43331. applyToShader(effect: Effect): void;
  43332. /**
  43333. * Returns a string to use to update the GPU particles update shader
  43334. * @returns a string containng the defines string
  43335. */
  43336. getEffectDefines(): string;
  43337. /**
  43338. * Returns the string "SphereParticleEmitter"
  43339. * @returns a string containing the class name
  43340. */
  43341. getClassName(): string;
  43342. /**
  43343. * Serializes the particle system to a JSON object.
  43344. * @returns the JSON object
  43345. */
  43346. serialize(): any;
  43347. /**
  43348. * Parse properties from a JSON object
  43349. * @param serializationObject defines the JSON object
  43350. */
  43351. parse(serializationObject: any): void;
  43352. }
  43353. /**
  43354. * Particle emitter emitting particles from the inside of a sphere.
  43355. * It emits the particles randomly between two vectors.
  43356. */
  43357. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  43358. /**
  43359. * The min limit of the emission direction.
  43360. */
  43361. direction1: Vector3;
  43362. /**
  43363. * The max limit of the emission direction.
  43364. */
  43365. direction2: Vector3;
  43366. /**
  43367. * Creates a new instance SphereDirectedParticleEmitter
  43368. * @param radius the radius of the emission sphere (1 by default)
  43369. * @param direction1 the min limit of the emission direction (up vector by default)
  43370. * @param direction2 the max limit of the emission direction (up vector by default)
  43371. */
  43372. constructor(radius?: number,
  43373. /**
  43374. * The min limit of the emission direction.
  43375. */
  43376. direction1?: Vector3,
  43377. /**
  43378. * The max limit of the emission direction.
  43379. */
  43380. direction2?: Vector3);
  43381. /**
  43382. * Called by the particle System when the direction is computed for the created particle.
  43383. * @param worldMatrix is the world matrix of the particle system
  43384. * @param directionToUpdate is the direction vector to update with the result
  43385. * @param particle is the particle we are computed the direction for
  43386. */
  43387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  43388. /**
  43389. * Clones the current emitter and returns a copy of it
  43390. * @returns the new emitter
  43391. */
  43392. clone(): SphereDirectedParticleEmitter;
  43393. /**
  43394. * Called by the GPUParticleSystem to setup the update shader
  43395. * @param effect defines the update shader
  43396. */
  43397. applyToShader(effect: Effect): void;
  43398. /**
  43399. * Returns a string to use to update the GPU particles update shader
  43400. * @returns a string containng the defines string
  43401. */
  43402. getEffectDefines(): string;
  43403. /**
  43404. * Returns the string "SphereDirectedParticleEmitter"
  43405. * @returns a string containing the class name
  43406. */
  43407. getClassName(): string;
  43408. /**
  43409. * Serializes the particle system to a JSON object.
  43410. * @returns the JSON object
  43411. */
  43412. serialize(): any;
  43413. /**
  43414. * Parse properties from a JSON object
  43415. * @param serializationObject defines the JSON object
  43416. */
  43417. parse(serializationObject: any): void;
  43418. }
  43419. }
  43420. declare module BABYLON {
  43421. /** @hidden */
  43422. class CannonJSPlugin implements IPhysicsEnginePlugin {
  43423. private _useDeltaForWorldStep;
  43424. world: any;
  43425. name: string;
  43426. private _physicsMaterials;
  43427. private _fixedTimeStep;
  43428. BJSCANNON: any;
  43429. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  43430. setGravity(gravity: Vector3): void;
  43431. setTimeStep(timeStep: number): void;
  43432. getTimeStep(): number;
  43433. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  43434. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  43435. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  43436. generatePhysicsBody(impostor: PhysicsImpostor): void;
  43437. private _processChildMeshes;
  43438. removePhysicsBody(impostor: PhysicsImpostor): void;
  43439. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  43440. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  43441. private _addMaterial;
  43442. private _checkWithEpsilon;
  43443. private _createShape;
  43444. private _createHeightmap;
  43445. private _minus90X;
  43446. private _plus90X;
  43447. private _tmpPosition;
  43448. private _tmpDeltaPosition;
  43449. private _tmpUnityRotation;
  43450. private _updatePhysicsBodyTransformation;
  43451. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  43452. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  43453. isSupported(): boolean;
  43454. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  43455. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  43456. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  43457. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  43458. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  43459. getBodyMass(impostor: PhysicsImpostor): number;
  43460. getBodyFriction(impostor: PhysicsImpostor): number;
  43461. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  43462. getBodyRestitution(impostor: PhysicsImpostor): number;
  43463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  43464. sleepBody(impostor: PhysicsImpostor): void;
  43465. wakeUpBody(impostor: PhysicsImpostor): void;
  43466. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  43467. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  43468. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  43469. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  43470. getRadius(impostor: PhysicsImpostor): number;
  43471. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  43472. dispose(): void;
  43473. private _extendNamespace;
  43474. }
  43475. }
  43476. declare module BABYLON {
  43477. /** @hidden */
  43478. class OimoJSPlugin implements IPhysicsEnginePlugin {
  43479. world: any;
  43480. name: string;
  43481. BJSOIMO: any;
  43482. constructor(iterations?: number);
  43483. setGravity(gravity: Vector3): void;
  43484. setTimeStep(timeStep: number): void;
  43485. getTimeStep(): number;
  43486. private _tmpImpostorsArray;
  43487. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  43488. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  43489. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  43490. generatePhysicsBody(impostor: PhysicsImpostor): void;
  43491. private _tmpPositionVector;
  43492. removePhysicsBody(impostor: PhysicsImpostor): void;
  43493. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  43494. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  43495. isSupported(): boolean;
  43496. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  43497. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  43498. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  43499. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  43500. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  43501. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  43502. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  43503. getBodyMass(impostor: PhysicsImpostor): number;
  43504. getBodyFriction(impostor: PhysicsImpostor): number;
  43505. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  43506. getBodyRestitution(impostor: PhysicsImpostor): number;
  43507. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  43508. sleepBody(impostor: PhysicsImpostor): void;
  43509. wakeUpBody(impostor: PhysicsImpostor): void;
  43510. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  43511. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  43512. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  43513. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  43514. getRadius(impostor: PhysicsImpostor): number;
  43515. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  43516. dispose(): void;
  43517. }
  43518. }
  43519. declare module BABYLON {
  43520. /**
  43521. * This represents a set of one or more post processes in Babylon.
  43522. * A post process can be used to apply a shader to a texture after it is rendered.
  43523. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  43524. */
  43525. class PostProcessRenderEffect {
  43526. private _postProcesses;
  43527. private _getPostProcesses;
  43528. private _singleInstance;
  43529. private _cameras;
  43530. private _indicesForCamera;
  43531. /**
  43532. * Name of the effect
  43533. * @hidden
  43534. */
  43535. _name: string;
  43536. /**
  43537. * Instantiates a post process render effect.
  43538. * A post process can be used to apply a shader to a texture after it is rendered.
  43539. * @param engine The engine the effect is tied to
  43540. * @param name The name of the effect
  43541. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  43542. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  43543. */
  43544. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  43545. /**
  43546. * Checks if all the post processes in the effect are supported.
  43547. */
  43548. readonly isSupported: boolean;
  43549. /**
  43550. * Updates the current state of the effect
  43551. * @hidden
  43552. */
  43553. _update(): void;
  43554. /**
  43555. * Attaches the effect on cameras
  43556. * @param cameras The camera to attach to.
  43557. * @hidden
  43558. */
  43559. _attachCameras(cameras: Camera): void;
  43560. /**
  43561. * Attaches the effect on cameras
  43562. * @param cameras The camera to attach to.
  43563. * @hidden
  43564. */
  43565. _attachCameras(cameras: Camera[]): void;
  43566. /**
  43567. * Detatches the effect on cameras
  43568. * @param cameras The camera to detatch from.
  43569. * @hidden
  43570. */
  43571. _detachCameras(cameras: Camera): void;
  43572. /**
  43573. * Detatches the effect on cameras
  43574. * @param cameras The camera to detatch from.
  43575. * @hidden
  43576. */
  43577. _detachCameras(cameras: Camera[]): void;
  43578. /**
  43579. * Enables the effect on given cameras
  43580. * @param cameras The camera to enable.
  43581. * @hidden
  43582. */
  43583. _enable(cameras: Camera): void;
  43584. /**
  43585. * Enables the effect on given cameras
  43586. * @param cameras The camera to enable.
  43587. * @hidden
  43588. */
  43589. _enable(cameras: Nullable<Camera[]>): void;
  43590. /**
  43591. * Disables the effect on the given cameras
  43592. * @param cameras The camera to disable.
  43593. * @hidden
  43594. */
  43595. _disable(cameras: Camera): void;
  43596. /**
  43597. * Disables the effect on the given cameras
  43598. * @param cameras The camera to disable.
  43599. * @hidden
  43600. */
  43601. _disable(cameras: Nullable<Camera[]>): void;
  43602. /**
  43603. * Gets a list of the post processes contained in the effect.
  43604. * @param camera The camera to get the post processes on.
  43605. * @returns The list of the post processes in the effect.
  43606. */
  43607. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  43608. }
  43609. }
  43610. declare module BABYLON {
  43611. class PostProcessRenderPipeline {
  43612. private engine;
  43613. private _renderEffects;
  43614. private _renderEffectsForIsolatedPass;
  43615. protected _cameras: Camera[];
  43616. /** @hidden */
  43617. _name: string;
  43618. constructor(engine: Engine, name: string);
  43619. getClassName(): string;
  43620. readonly isSupported: boolean;
  43621. addEffect(renderEffect: PostProcessRenderEffect): void;
  43622. /** @hidden */
  43623. _rebuild(): void;
  43624. /** @hidden */
  43625. _enableEffect(renderEffectName: string, cameras: Camera): void;
  43626. /** @hidden */
  43627. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  43628. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  43629. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  43630. /** @hidden */
  43631. _attachCameras(cameras: Camera, unique: boolean): void;
  43632. /** @hidden */
  43633. _attachCameras(cameras: Camera[], unique: boolean): void;
  43634. /** @hidden */
  43635. _detachCameras(cameras: Camera): void;
  43636. /** @hidden */
  43637. _detachCameras(cameras: Nullable<Camera[]>): void;
  43638. /** @hidden */
  43639. _update(): void;
  43640. /** @hidden */
  43641. _reset(): void;
  43642. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  43643. dispose(): void;
  43644. }
  43645. }
  43646. declare module BABYLON {
  43647. class PostProcessRenderPipelineManager {
  43648. private _renderPipelines;
  43649. constructor();
  43650. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  43651. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  43652. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  43653. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  43654. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  43655. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  43656. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  43657. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  43658. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  43659. update(): void;
  43660. /** @hidden */
  43661. _rebuild(): void;
  43662. dispose(): void;
  43663. }
  43664. }
  43665. declare module BABYLON {
  43666. interface Scene {
  43667. /** @hidden (Backing field) */
  43668. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  43669. /**
  43670. * Gets the postprocess render pipeline manager
  43671. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  43672. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  43673. */
  43674. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  43675. }
  43676. /**
  43677. * Defines the Render Pipeline scene component responsible to rendering pipelines
  43678. */
  43679. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  43680. /**
  43681. * The component name helpfull to identify the component in the list of scene components.
  43682. */
  43683. readonly name: string;
  43684. /**
  43685. * The scene the component belongs to.
  43686. */
  43687. scene: Scene;
  43688. /**
  43689. * Creates a new instance of the component for the given scene
  43690. * @param scene Defines the scene to register the component in
  43691. */
  43692. constructor(scene: Scene);
  43693. /**
  43694. * Registers the component in a given scene
  43695. */
  43696. register(): void;
  43697. /**
  43698. * Rebuilds the elements related to this component in case of
  43699. * context lost for instance.
  43700. */
  43701. rebuild(): void;
  43702. /**
  43703. * Disposes the component and the associated ressources
  43704. */
  43705. dispose(): void;
  43706. private _gatherRenderTargets;
  43707. }
  43708. }
  43709. declare module BABYLON {
  43710. /**
  43711. * Helper class dealing with the extraction of spherical polynomial dataArray
  43712. * from a cube map.
  43713. */
  43714. class CubeMapToSphericalPolynomialTools {
  43715. private static FileFaces;
  43716. /**
  43717. * Converts a texture to the according Spherical Polynomial data.
  43718. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43719. *
  43720. * @param texture The texture to extract the information from.
  43721. * @return The Spherical Polynomial data.
  43722. */
  43723. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  43724. /**
  43725. * Converts a cubemap to the according Spherical Polynomial data.
  43726. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43727. *
  43728. * @param cubeInfo The Cube map to extract the information from.
  43729. * @return The Spherical Polynomial data.
  43730. */
  43731. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  43732. }
  43733. }
  43734. declare module BABYLON {
  43735. /**
  43736. * Header information of HDR texture files.
  43737. */
  43738. interface HDRInfo {
  43739. /**
  43740. * The height of the texture in pixels.
  43741. */
  43742. height: number;
  43743. /**
  43744. * The width of the texture in pixels.
  43745. */
  43746. width: number;
  43747. /**
  43748. * The index of the beginning of the data in the binary file.
  43749. */
  43750. dataPosition: number;
  43751. }
  43752. /**
  43753. * This groups tools to convert HDR texture to native colors array.
  43754. */
  43755. class HDRTools {
  43756. private static Ldexp;
  43757. private static Rgbe2float;
  43758. private static readStringLine;
  43759. /**
  43760. * Reads header information from an RGBE texture stored in a native array.
  43761. * More information on this format are available here:
  43762. * https://en.wikipedia.org/wiki/RGBE_image_format
  43763. *
  43764. * @param uint8array The binary file stored in native array.
  43765. * @return The header information.
  43766. */
  43767. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  43768. /**
  43769. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  43770. * This RGBE texture needs to store the information as a panorama.
  43771. *
  43772. * More information on this format are available here:
  43773. * https://en.wikipedia.org/wiki/RGBE_image_format
  43774. *
  43775. * @param buffer The binary file stored in an array buffer.
  43776. * @param size The expected size of the extracted cubemap.
  43777. * @return The Cube Map information.
  43778. */
  43779. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  43780. /**
  43781. * Returns the pixels data extracted from an RGBE texture.
  43782. * This pixels will be stored left to right up to down in the R G B order in one array.
  43783. *
  43784. * More information on this format are available here:
  43785. * https://en.wikipedia.org/wiki/RGBE_image_format
  43786. *
  43787. * @param uint8array The binary file stored in an array buffer.
  43788. * @param hdrInfo The header information of the file.
  43789. * @return The pixels data in RGB right to left up to down order.
  43790. */
  43791. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  43792. private static RGBE_ReadPixels_RLE;
  43793. }
  43794. }
  43795. declare module BABYLON {
  43796. /**
  43797. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  43798. */
  43799. interface CubeMapInfo {
  43800. /**
  43801. * The pixel array for the front face.
  43802. * This is stored in format, left to right, up to down format.
  43803. */
  43804. front: Nullable<ArrayBufferView>;
  43805. /**
  43806. * The pixel array for the back face.
  43807. * This is stored in format, left to right, up to down format.
  43808. */
  43809. back: Nullable<ArrayBufferView>;
  43810. /**
  43811. * The pixel array for the left face.
  43812. * This is stored in format, left to right, up to down format.
  43813. */
  43814. left: Nullable<ArrayBufferView>;
  43815. /**
  43816. * The pixel array for the right face.
  43817. * This is stored in format, left to right, up to down format.
  43818. */
  43819. right: Nullable<ArrayBufferView>;
  43820. /**
  43821. * The pixel array for the up face.
  43822. * This is stored in format, left to right, up to down format.
  43823. */
  43824. up: Nullable<ArrayBufferView>;
  43825. /**
  43826. * The pixel array for the down face.
  43827. * This is stored in format, left to right, up to down format.
  43828. */
  43829. down: Nullable<ArrayBufferView>;
  43830. /**
  43831. * The size of the cubemap stored.
  43832. *
  43833. * Each faces will be size * size pixels.
  43834. */
  43835. size: number;
  43836. /**
  43837. * The format of the texture.
  43838. *
  43839. * RGBA, RGB.
  43840. */
  43841. format: number;
  43842. /**
  43843. * The type of the texture data.
  43844. *
  43845. * UNSIGNED_INT, FLOAT.
  43846. */
  43847. type: number;
  43848. /**
  43849. * Specifies whether the texture is in gamma space.
  43850. */
  43851. gammaSpace: boolean;
  43852. }
  43853. /**
  43854. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  43855. */
  43856. class PanoramaToCubeMapTools {
  43857. private static FACE_FRONT;
  43858. private static FACE_BACK;
  43859. private static FACE_RIGHT;
  43860. private static FACE_LEFT;
  43861. private static FACE_DOWN;
  43862. private static FACE_UP;
  43863. /**
  43864. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  43865. *
  43866. * @param float32Array The source data.
  43867. * @param inputWidth The width of the input panorama.
  43868. * @param inputhHeight The height of the input panorama.
  43869. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  43870. * @return The cubemap data
  43871. */
  43872. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  43873. private static CreateCubemapTexture;
  43874. private static CalcProjectionSpherical;
  43875. }
  43876. }
  43877. declare module BABYLON {
  43878. }
  43879. declare module BABYLON {
  43880. }
  43881. declare module BABYLON {
  43882. }
  43883. declare module BABYLON {
  43884. }
  43885. declare module BABYLON {
  43886. class CustomProceduralTexture extends ProceduralTexture {
  43887. private _animate;
  43888. private _time;
  43889. private _config;
  43890. private _texturePath;
  43891. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  43892. private loadJson;
  43893. isReady(): boolean;
  43894. render(useCameraPostProcess?: boolean): void;
  43895. updateTextures(): void;
  43896. updateShaderUniforms(): void;
  43897. animate: boolean;
  43898. }
  43899. }
  43900. declare module BABYLON {
  43901. /**
  43902. * Class used to generate noise procedural textures
  43903. */
  43904. class NoiseProceduralTexture extends ProceduralTexture {
  43905. private _time;
  43906. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  43907. brightness: number;
  43908. /** Defines the number of octaves to process */
  43909. octaves: number;
  43910. /** Defines the level of persistence (0.8 by default) */
  43911. persistence: number;
  43912. /** Gets or sets animation speed factor (default is 1) */
  43913. animationSpeedFactor: number;
  43914. /**
  43915. * Creates a new NoiseProceduralTexture
  43916. * @param name defines the name fo the texture
  43917. * @param size defines the size of the texture (default is 256)
  43918. * @param scene defines the hosting scene
  43919. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  43920. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  43921. */
  43922. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  43923. private _updateShaderUniforms;
  43924. protected _getDefines(): string;
  43925. /** Generate the current state of the procedural texture */
  43926. render(useCameraPostProcess?: boolean): void;
  43927. /**
  43928. * Serializes this noise procedural texture
  43929. * @returns a serialized noise procedural texture object
  43930. */
  43931. serialize(): any;
  43932. /**
  43933. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  43934. * @param parsedTexture defines parsed texture data
  43935. * @param scene defines the current scene
  43936. * @param rootUrl defines the root URL containing noise procedural texture information
  43937. * @returns a parsed NoiseProceduralTexture
  43938. */
  43939. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  43940. }
  43941. }
  43942. declare module BABYLON {
  43943. class ProceduralTexture extends Texture {
  43944. isCube: boolean;
  43945. private _size;
  43946. /** @hidden */
  43947. _generateMipMaps: boolean;
  43948. isEnabled: boolean;
  43949. private _currentRefreshId;
  43950. private _refreshRate;
  43951. /**
  43952. * Callback called when the texture is generated
  43953. */
  43954. onGenerated: () => void;
  43955. /**
  43956. * Event raised when the texture is generated
  43957. */
  43958. onGeneratedObservable: Observable<ProceduralTexture>;
  43959. private _vertexBuffers;
  43960. private _indexBuffer;
  43961. /** get the internal effect */
  43962. _effect: Effect;
  43963. private _uniforms;
  43964. private _samplers;
  43965. private _fragment;
  43966. /** @hidden */
  43967. _textures: {
  43968. [key: string]: Texture;
  43969. };
  43970. private _floats;
  43971. private _ints;
  43972. private _floatsArrays;
  43973. private _colors3;
  43974. private _colors4;
  43975. private _vectors2;
  43976. private _vectors3;
  43977. private _matrices;
  43978. private _fallbackTexture;
  43979. private _fallbackTextureUsed;
  43980. private _engine;
  43981. private _cachedDefines;
  43982. private _contentUpdateId;
  43983. private _contentData;
  43984. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  43985. /**
  43986. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  43987. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  43988. */
  43989. getContent(): Nullable<ArrayBufferView>;
  43990. private _createIndexBuffer;
  43991. /** @hidden */
  43992. _rebuild(): void;
  43993. reset(): void;
  43994. protected _getDefines(): string;
  43995. isReady(): boolean;
  43996. resetRefreshCounter(): void;
  43997. setFragment(fragment: any): void;
  43998. refreshRate: number;
  43999. /** @hidden */
  44000. _shouldRender(): boolean;
  44001. getRenderSize(): number;
  44002. resize(size: number, generateMipMaps: boolean): void;
  44003. private _checkUniform;
  44004. setTexture(name: string, texture: Texture): ProceduralTexture;
  44005. setFloat(name: string, value: number): ProceduralTexture;
  44006. /**
  44007. * Set the value of an uniform to an integer value
  44008. * @param name defines the name of the uniform
  44009. * @param value defines the value to set
  44010. * @returns the current procedural texture
  44011. */
  44012. setInt(name: string, value: number): ProceduralTexture;
  44013. setFloats(name: string, value: number[]): ProceduralTexture;
  44014. setColor3(name: string, value: Color3): ProceduralTexture;
  44015. setColor4(name: string, value: Color4): ProceduralTexture;
  44016. setVector2(name: string, value: Vector2): ProceduralTexture;
  44017. setVector3(name: string, value: Vector3): ProceduralTexture;
  44018. setMatrix(name: string, value: Matrix): ProceduralTexture;
  44019. render(useCameraPostProcess?: boolean): void;
  44020. clone(): ProceduralTexture;
  44021. dispose(): void;
  44022. }
  44023. }
  44024. declare module BABYLON {
  44025. interface AbstractScene {
  44026. /**
  44027. * The list of procedural textures added to the scene
  44028. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  44029. */
  44030. proceduralTextures: Array<ProceduralTexture>;
  44031. }
  44032. /**
  44033. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  44034. * in a given scene.
  44035. */
  44036. class ProceduralTextureSceneComponent implements ISceneComponent {
  44037. /**
  44038. * The component name helpfull to identify the component in the list of scene components.
  44039. */
  44040. readonly name: string;
  44041. /**
  44042. * The scene the component belongs to.
  44043. */
  44044. scene: Scene;
  44045. /**
  44046. * Creates a new instance of the component for the given scene
  44047. * @param scene Defines the scene to register the component in
  44048. */
  44049. constructor(scene: Scene);
  44050. /**
  44051. * Registers the component in a given scene
  44052. */
  44053. register(): void;
  44054. /**
  44055. * Rebuilds the elements related to this component in case of
  44056. * context lost for instance.
  44057. */
  44058. rebuild(): void;
  44059. /**
  44060. * Disposes the component and the associated ressources.
  44061. */
  44062. dispose(): void;
  44063. private _beforeClear;
  44064. }
  44065. }
  44066. declare module BABYLON {
  44067. /**
  44068. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  44069. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  44070. */
  44071. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  44072. private _scene;
  44073. private _camerasToBeAttached;
  44074. /**
  44075. * ID of the sharpen post process,
  44076. */
  44077. private readonly SharpenPostProcessId;
  44078. /**
  44079. * ID of the image processing post process;
  44080. */
  44081. readonly ImageProcessingPostProcessId: string;
  44082. /**
  44083. * ID of the Fast Approximate Anti-Aliasing post process;
  44084. */
  44085. readonly FxaaPostProcessId: string;
  44086. /**
  44087. * ID of the chromatic aberration post process,
  44088. */
  44089. private readonly ChromaticAberrationPostProcessId;
  44090. /**
  44091. * ID of the grain post process
  44092. */
  44093. private readonly GrainPostProcessId;
  44094. /**
  44095. * Sharpen post process which will apply a sharpen convolution to enhance edges
  44096. */
  44097. sharpen: SharpenPostProcess;
  44098. private _sharpenEffect;
  44099. private bloom;
  44100. /**
  44101. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  44102. */
  44103. depthOfField: DepthOfFieldEffect;
  44104. /**
  44105. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  44106. */
  44107. fxaa: FxaaPostProcess;
  44108. /**
  44109. * Image post processing pass used to perform operations such as tone mapping or color grading.
  44110. */
  44111. imageProcessing: ImageProcessingPostProcess;
  44112. /**
  44113. * Chromatic aberration post process which will shift rgb colors in the image
  44114. */
  44115. chromaticAberration: ChromaticAberrationPostProcess;
  44116. private _chromaticAberrationEffect;
  44117. /**
  44118. * Grain post process which add noise to the image
  44119. */
  44120. grain: GrainPostProcess;
  44121. private _grainEffect;
  44122. /**
  44123. * Glow post process which adds a glow to emmisive areas of the image
  44124. */
  44125. private _glowLayer;
  44126. /**
  44127. * Animations which can be used to tweak settings over a period of time
  44128. */
  44129. animations: Animation[];
  44130. private _imageProcessingConfigurationObserver;
  44131. private _sharpenEnabled;
  44132. private _bloomEnabled;
  44133. private _depthOfFieldEnabled;
  44134. private _depthOfFieldBlurLevel;
  44135. private _fxaaEnabled;
  44136. private _imageProcessingEnabled;
  44137. private _defaultPipelineTextureType;
  44138. private _bloomScale;
  44139. private _chromaticAberrationEnabled;
  44140. private _grainEnabled;
  44141. private _buildAllowed;
  44142. /**
  44143. * Enable or disable the sharpen process from the pipeline
  44144. */
  44145. sharpenEnabled: boolean;
  44146. private _resizeObserver;
  44147. private _hardwareScaleLevel;
  44148. private _bloomKernel;
  44149. /**
  44150. * Specifies the size of the bloom blur kernel, relative to the final output size
  44151. */
  44152. bloomKernel: number;
  44153. /**
  44154. * Specifies the weight of the bloom in the final rendering
  44155. */
  44156. private _bloomWeight;
  44157. /**
  44158. * Specifies the luma threshold for the area that will be blurred by the bloom
  44159. */
  44160. private _bloomThreshold;
  44161. private _hdr;
  44162. /**
  44163. * The strength of the bloom.
  44164. */
  44165. bloomWeight: number;
  44166. /**
  44167. * The strength of the bloom.
  44168. */
  44169. bloomThreshold: number;
  44170. /**
  44171. * The scale of the bloom, lower value will provide better performance.
  44172. */
  44173. bloomScale: number;
  44174. /**
  44175. * Enable or disable the bloom from the pipeline
  44176. */
  44177. bloomEnabled: boolean;
  44178. private _rebuildBloom;
  44179. /**
  44180. * If the depth of field is enabled.
  44181. */
  44182. depthOfFieldEnabled: boolean;
  44183. /**
  44184. * Blur level of the depth of field effect. (Higher blur will effect performance)
  44185. */
  44186. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  44187. /**
  44188. * If the anti aliasing is enabled.
  44189. */
  44190. fxaaEnabled: boolean;
  44191. private _samples;
  44192. /**
  44193. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  44194. */
  44195. samples: number;
  44196. /**
  44197. * If image processing is enabled.
  44198. */
  44199. imageProcessingEnabled: boolean;
  44200. /**
  44201. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  44202. */
  44203. glowLayerEnabled: boolean;
  44204. /**
  44205. * Enable or disable the chromaticAberration process from the pipeline
  44206. */
  44207. chromaticAberrationEnabled: boolean;
  44208. /**
  44209. * Enable or disable the grain process from the pipeline
  44210. */
  44211. grainEnabled: boolean;
  44212. /**
  44213. * @constructor
  44214. * @param {string} name - The rendering pipeline name (default: "")
  44215. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  44216. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  44217. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  44218. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  44219. */
  44220. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  44221. /**
  44222. * Force the compilation of the entire pipeline.
  44223. */
  44224. prepare(): void;
  44225. private _hasCleared;
  44226. private _prevPostProcess;
  44227. private _prevPrevPostProcess;
  44228. private _setAutoClearAndTextureSharing;
  44229. private _depthOfFieldSceneObserver;
  44230. private _buildPipeline;
  44231. private _disposePostProcesses;
  44232. /**
  44233. * Adds a camera to the pipeline
  44234. * @param camera the camera to be added
  44235. */
  44236. addCamera(camera: Camera): void;
  44237. /**
  44238. * Removes a camera from the pipeline
  44239. * @param camera the camera to remove
  44240. */
  44241. removeCamera(camera: Camera): void;
  44242. /**
  44243. * Dispose of the pipeline and stop all post processes
  44244. */
  44245. dispose(): void;
  44246. /**
  44247. * Serialize the rendering pipeline (Used when exporting)
  44248. * @returns the serialized object
  44249. */
  44250. serialize(): any;
  44251. /**
  44252. * Parse the serialized pipeline
  44253. * @param source Source pipeline.
  44254. * @param scene The scene to load the pipeline to.
  44255. * @param rootUrl The URL of the serialized pipeline.
  44256. * @returns An instantiated pipeline from the serialized object.
  44257. */
  44258. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  44259. }
  44260. }
  44261. declare module BABYLON {
  44262. class LensRenderingPipeline extends PostProcessRenderPipeline {
  44263. /**
  44264. * The chromatic aberration PostProcess id in the pipeline
  44265. */
  44266. LensChromaticAberrationEffect: string;
  44267. /**
  44268. * The highlights enhancing PostProcess id in the pipeline
  44269. */
  44270. HighlightsEnhancingEffect: string;
  44271. /**
  44272. * The depth-of-field PostProcess id in the pipeline
  44273. */
  44274. LensDepthOfFieldEffect: string;
  44275. private _scene;
  44276. private _depthTexture;
  44277. private _grainTexture;
  44278. private _chromaticAberrationPostProcess;
  44279. private _highlightsPostProcess;
  44280. private _depthOfFieldPostProcess;
  44281. private _edgeBlur;
  44282. private _grainAmount;
  44283. private _chromaticAberration;
  44284. private _distortion;
  44285. private _highlightsGain;
  44286. private _highlightsThreshold;
  44287. private _dofDistance;
  44288. private _dofAperture;
  44289. private _dofDarken;
  44290. private _dofPentagon;
  44291. private _blurNoise;
  44292. /**
  44293. * @constructor
  44294. *
  44295. * Effect parameters are as follow:
  44296. * {
  44297. * chromatic_aberration: number; // from 0 to x (1 for realism)
  44298. * edge_blur: number; // from 0 to x (1 for realism)
  44299. * distortion: number; // from 0 to x (1 for realism)
  44300. * grain_amount: number; // from 0 to 1
  44301. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  44302. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  44303. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  44304. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  44305. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  44306. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  44307. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  44308. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  44309. * }
  44310. * Note: if an effect parameter is unset, effect is disabled
  44311. *
  44312. * @param {string} name - The rendering pipeline name
  44313. * @param {object} parameters - An object containing all parameters (see above)
  44314. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  44315. * @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)
  44316. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  44317. */
  44318. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  44319. setEdgeBlur(amount: number): void;
  44320. disableEdgeBlur(): void;
  44321. setGrainAmount(amount: number): void;
  44322. disableGrain(): void;
  44323. setChromaticAberration(amount: number): void;
  44324. disableChromaticAberration(): void;
  44325. setEdgeDistortion(amount: number): void;
  44326. disableEdgeDistortion(): void;
  44327. setFocusDistance(amount: number): void;
  44328. disableDepthOfField(): void;
  44329. setAperture(amount: number): void;
  44330. setDarkenOutOfFocus(amount: number): void;
  44331. enablePentagonBokeh(): void;
  44332. disablePentagonBokeh(): void;
  44333. enableNoiseBlur(): void;
  44334. disableNoiseBlur(): void;
  44335. setHighlightsGain(amount: number): void;
  44336. setHighlightsThreshold(amount: number): void;
  44337. disableHighlights(): void;
  44338. /**
  44339. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  44340. */
  44341. dispose(disableDepthRender?: boolean): void;
  44342. private _createChromaticAberrationPostProcess;
  44343. private _createHighlightsPostProcess;
  44344. private _createDepthOfFieldPostProcess;
  44345. private _createGrainTexture;
  44346. }
  44347. }
  44348. declare module BABYLON {
  44349. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  44350. /**
  44351. * The PassPostProcess id in the pipeline that contains the original scene color
  44352. */
  44353. SSAOOriginalSceneColorEffect: string;
  44354. /**
  44355. * The SSAO PostProcess id in the pipeline
  44356. */
  44357. SSAORenderEffect: string;
  44358. /**
  44359. * The horizontal blur PostProcess id in the pipeline
  44360. */
  44361. SSAOBlurHRenderEffect: string;
  44362. /**
  44363. * The vertical blur PostProcess id in the pipeline
  44364. */
  44365. SSAOBlurVRenderEffect: string;
  44366. /**
  44367. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  44368. */
  44369. SSAOCombineRenderEffect: string;
  44370. /**
  44371. * The output strength of the SSAO post-process. Default value is 1.0.
  44372. */
  44373. totalStrength: number;
  44374. /**
  44375. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  44376. */
  44377. maxZ: number;
  44378. /**
  44379. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  44380. */
  44381. minZAspect: number;
  44382. private _samples;
  44383. /**
  44384. * Number of samples used for the SSAO calculations. Default value is 8
  44385. */
  44386. samples: number;
  44387. private _textureSamples;
  44388. /**
  44389. * Number of samples to use for antialiasing
  44390. */
  44391. textureSamples: number;
  44392. /**
  44393. * Ratio object used for SSAO ratio and blur ratio
  44394. */
  44395. private _ratio;
  44396. /**
  44397. * Dynamically generated sphere sampler.
  44398. */
  44399. private _sampleSphere;
  44400. /**
  44401. * Blur filter offsets
  44402. */
  44403. private _samplerOffsets;
  44404. /**
  44405. * Are we using bilateral blur ?
  44406. */
  44407. private _expensiveBlur;
  44408. expensiveBlur: boolean;
  44409. /**
  44410. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  44411. */
  44412. radius: number;
  44413. /**
  44414. * The base color of the SSAO post-process
  44415. * The final result is "base + ssao" between [0, 1]
  44416. */
  44417. base: number;
  44418. /**
  44419. * Support test.
  44420. */
  44421. static readonly IsSupported: boolean;
  44422. private _scene;
  44423. private _depthTexture;
  44424. private _normalTexture;
  44425. private _randomTexture;
  44426. private _originalColorPostProcess;
  44427. private _ssaoPostProcess;
  44428. private _blurHPostProcess;
  44429. private _blurVPostProcess;
  44430. private _ssaoCombinePostProcess;
  44431. private _firstUpdate;
  44432. /**
  44433. * @constructor
  44434. * @param {string} name - The rendering pipeline name
  44435. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  44436. * @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 }
  44437. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  44438. */
  44439. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  44440. /**
  44441. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  44442. */
  44443. dispose(disableGeometryBufferRenderer?: boolean): void;
  44444. private _createBlurPostProcess;
  44445. /** @hidden */
  44446. _rebuild(): void;
  44447. private _bits;
  44448. private _radicalInverse_VdC;
  44449. private _hammersley;
  44450. private _hemisphereSample_uniform;
  44451. private _generateHemisphere;
  44452. private _createSSAOPostProcess;
  44453. private _createSSAOCombinePostProcess;
  44454. private _createRandomTexture;
  44455. /**
  44456. * Serialize the rendering pipeline (Used when exporting)
  44457. * @returns the serialized object
  44458. */
  44459. serialize(): any;
  44460. /**
  44461. * Parse the serialized pipeline
  44462. * @param source Source pipeline.
  44463. * @param scene The scene to load the pipeline to.
  44464. * @param rootUrl The URL of the serialized pipeline.
  44465. * @returns An instantiated pipeline from the serialized object.
  44466. */
  44467. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  44468. }
  44469. }
  44470. declare module BABYLON {
  44471. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  44472. /**
  44473. * The PassPostProcess id in the pipeline that contains the original scene color
  44474. */
  44475. SSAOOriginalSceneColorEffect: string;
  44476. /**
  44477. * The SSAO PostProcess id in the pipeline
  44478. */
  44479. SSAORenderEffect: string;
  44480. /**
  44481. * The horizontal blur PostProcess id in the pipeline
  44482. */
  44483. SSAOBlurHRenderEffect: string;
  44484. /**
  44485. * The vertical blur PostProcess id in the pipeline
  44486. */
  44487. SSAOBlurVRenderEffect: string;
  44488. /**
  44489. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  44490. */
  44491. SSAOCombineRenderEffect: string;
  44492. /**
  44493. * The output strength of the SSAO post-process. Default value is 1.0.
  44494. */
  44495. totalStrength: number;
  44496. /**
  44497. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  44498. */
  44499. radius: number;
  44500. /**
  44501. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  44502. * Must not be equal to fallOff and superior to fallOff.
  44503. * Default value is 0.975
  44504. */
  44505. area: number;
  44506. /**
  44507. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  44508. * Must not be equal to area and inferior to area.
  44509. * Default value is 0.0
  44510. */
  44511. fallOff: number;
  44512. /**
  44513. * The base color of the SSAO post-process
  44514. * The final result is "base + ssao" between [0, 1]
  44515. */
  44516. base: number;
  44517. private _scene;
  44518. private _depthTexture;
  44519. private _randomTexture;
  44520. private _originalColorPostProcess;
  44521. private _ssaoPostProcess;
  44522. private _blurHPostProcess;
  44523. private _blurVPostProcess;
  44524. private _ssaoCombinePostProcess;
  44525. private _firstUpdate;
  44526. /**
  44527. * @constructor
  44528. * @param {string} name - The rendering pipeline name
  44529. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  44530. * @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 }
  44531. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  44532. */
  44533. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  44534. /**
  44535. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  44536. */
  44537. dispose(disableDepthRender?: boolean): void;
  44538. private _createBlurPostProcess;
  44539. /** @hidden */
  44540. _rebuild(): void;
  44541. private _createSSAOPostProcess;
  44542. private _createSSAOCombinePostProcess;
  44543. private _createRandomTexture;
  44544. }
  44545. }
  44546. declare module BABYLON {
  44547. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  44548. /**
  44549. * Public members
  44550. */
  44551. /**
  44552. * Post-process which contains the original scene color before the pipeline applies all the effects
  44553. */
  44554. originalPostProcess: Nullable<PostProcess>;
  44555. /**
  44556. * Post-process used to down scale an image x4
  44557. */
  44558. downSampleX4PostProcess: Nullable<PostProcess>;
  44559. /**
  44560. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  44561. */
  44562. brightPassPostProcess: Nullable<PostProcess>;
  44563. /**
  44564. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  44565. */
  44566. blurHPostProcesses: PostProcess[];
  44567. /**
  44568. * Post-process array storing all the vertical blur post-processes used by the pipeline
  44569. */
  44570. blurVPostProcesses: PostProcess[];
  44571. /**
  44572. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  44573. */
  44574. textureAdderPostProcess: Nullable<PostProcess>;
  44575. /**
  44576. * Post-process used to create volumetric lighting effect
  44577. */
  44578. volumetricLightPostProcess: Nullable<PostProcess>;
  44579. /**
  44580. * Post-process used to smooth the previous volumetric light post-process on the X axis
  44581. */
  44582. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  44583. /**
  44584. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  44585. */
  44586. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  44587. /**
  44588. * Post-process used to merge the volumetric light effect and the real scene color
  44589. */
  44590. volumetricLightMergePostProces: Nullable<PostProcess>;
  44591. /**
  44592. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  44593. */
  44594. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  44595. /**
  44596. * Base post-process used to calculate the average luminance of the final image for HDR
  44597. */
  44598. luminancePostProcess: Nullable<PostProcess>;
  44599. /**
  44600. * Post-processes used to create down sample post-processes in order to get
  44601. * the average luminance of the final image for HDR
  44602. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  44603. */
  44604. luminanceDownSamplePostProcesses: PostProcess[];
  44605. /**
  44606. * Post-process used to create a HDR effect (light adaptation)
  44607. */
  44608. hdrPostProcess: Nullable<PostProcess>;
  44609. /**
  44610. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  44611. */
  44612. textureAdderFinalPostProcess: Nullable<PostProcess>;
  44613. /**
  44614. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  44615. */
  44616. lensFlareFinalPostProcess: Nullable<PostProcess>;
  44617. /**
  44618. * Post-process used to merge the final HDR post-process and the real scene color
  44619. */
  44620. hdrFinalPostProcess: Nullable<PostProcess>;
  44621. /**
  44622. * Post-process used to create a lens flare effect
  44623. */
  44624. lensFlarePostProcess: Nullable<PostProcess>;
  44625. /**
  44626. * Post-process that merges the result of the lens flare post-process and the real scene color
  44627. */
  44628. lensFlareComposePostProcess: Nullable<PostProcess>;
  44629. /**
  44630. * Post-process used to create a motion blur effect
  44631. */
  44632. motionBlurPostProcess: Nullable<PostProcess>;
  44633. /**
  44634. * Post-process used to create a depth of field effect
  44635. */
  44636. depthOfFieldPostProcess: Nullable<PostProcess>;
  44637. /**
  44638. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  44639. */
  44640. fxaaPostProcess: Nullable<FxaaPostProcess>;
  44641. /**
  44642. * Represents the brightness threshold in order to configure the illuminated surfaces
  44643. */
  44644. brightThreshold: number;
  44645. /**
  44646. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  44647. */
  44648. blurWidth: number;
  44649. /**
  44650. * Sets if the blur for highlighted surfaces must be only horizontal
  44651. */
  44652. horizontalBlur: boolean;
  44653. /**
  44654. * Sets the overall exposure used by the pipeline
  44655. */
  44656. exposure: number;
  44657. /**
  44658. * Texture used typically to simulate "dirty" on camera lens
  44659. */
  44660. lensTexture: Nullable<Texture>;
  44661. /**
  44662. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  44663. */
  44664. volumetricLightCoefficient: number;
  44665. /**
  44666. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  44667. */
  44668. volumetricLightPower: number;
  44669. /**
  44670. * Used the set the blur intensity to smooth the volumetric lights
  44671. */
  44672. volumetricLightBlurScale: number;
  44673. /**
  44674. * Light (spot or directional) used to generate the volumetric lights rays
  44675. * The source light must have a shadow generate so the pipeline can get its
  44676. * depth map
  44677. */
  44678. sourceLight: Nullable<SpotLight | DirectionalLight>;
  44679. /**
  44680. * For eye adaptation, represents the minimum luminance the eye can see
  44681. */
  44682. hdrMinimumLuminance: number;
  44683. /**
  44684. * For eye adaptation, represents the decrease luminance speed
  44685. */
  44686. hdrDecreaseRate: number;
  44687. /**
  44688. * For eye adaptation, represents the increase luminance speed
  44689. */
  44690. hdrIncreaseRate: number;
  44691. /**
  44692. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  44693. */
  44694. lensColorTexture: Nullable<Texture>;
  44695. /**
  44696. * The overall strengh for the lens flare effect
  44697. */
  44698. lensFlareStrength: number;
  44699. /**
  44700. * Dispersion coefficient for lens flare ghosts
  44701. */
  44702. lensFlareGhostDispersal: number;
  44703. /**
  44704. * Main lens flare halo width
  44705. */
  44706. lensFlareHaloWidth: number;
  44707. /**
  44708. * Based on the lens distortion effect, defines how much the lens flare result
  44709. * is distorted
  44710. */
  44711. lensFlareDistortionStrength: number;
  44712. /**
  44713. * Lens star texture must be used to simulate rays on the flares and is available
  44714. * in the documentation
  44715. */
  44716. lensStarTexture: Nullable<Texture>;
  44717. /**
  44718. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  44719. * flare effect by taking account of the dirt texture
  44720. */
  44721. lensFlareDirtTexture: Nullable<Texture>;
  44722. /**
  44723. * Represents the focal length for the depth of field effect
  44724. */
  44725. depthOfFieldDistance: number;
  44726. /**
  44727. * Represents the blur intensity for the blurred part of the depth of field effect
  44728. */
  44729. depthOfFieldBlurWidth: number;
  44730. /**
  44731. * For motion blur, defines how much the image is blurred by the movement
  44732. */
  44733. motionStrength: number;
  44734. /**
  44735. * List of animations for the pipeline (IAnimatable implementation)
  44736. */
  44737. animations: Animation[];
  44738. /**
  44739. * Private members
  44740. */
  44741. private _scene;
  44742. private _currentDepthOfFieldSource;
  44743. private _basePostProcess;
  44744. private _hdrCurrentLuminance;
  44745. private _floatTextureType;
  44746. private _ratio;
  44747. private _bloomEnabled;
  44748. private _depthOfFieldEnabled;
  44749. private _vlsEnabled;
  44750. private _lensFlareEnabled;
  44751. private _hdrEnabled;
  44752. private _motionBlurEnabled;
  44753. private _fxaaEnabled;
  44754. private _motionBlurSamples;
  44755. private _volumetricLightStepsCount;
  44756. private _samples;
  44757. /**
  44758. * Specifies if the bloom pipeline is enabled
  44759. */
  44760. BloomEnabled: boolean;
  44761. /**
  44762. * Specifies if the depth of field pipeline is enabed
  44763. */
  44764. DepthOfFieldEnabled: boolean;
  44765. /**
  44766. * Specifies if the lens flare pipeline is enabed
  44767. */
  44768. LensFlareEnabled: boolean;
  44769. /**
  44770. * Specifies if the HDR pipeline is enabled
  44771. */
  44772. HDREnabled: boolean;
  44773. /**
  44774. * Specifies if the volumetric lights scattering effect is enabled
  44775. */
  44776. VLSEnabled: boolean;
  44777. /**
  44778. * Specifies if the motion blur effect is enabled
  44779. */
  44780. MotionBlurEnabled: boolean;
  44781. /**
  44782. * Specifies if anti-aliasing is enabled
  44783. */
  44784. fxaaEnabled: boolean;
  44785. /**
  44786. * Specifies the number of steps used to calculate the volumetric lights
  44787. * Typically in interval [50, 200]
  44788. */
  44789. volumetricLightStepsCount: number;
  44790. /**
  44791. * Specifies the number of samples used for the motion blur effect
  44792. * Typically in interval [16, 64]
  44793. */
  44794. motionBlurSamples: number;
  44795. /**
  44796. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  44797. */
  44798. samples: number;
  44799. /**
  44800. * @constructor
  44801. * @param {string} name - The rendering pipeline name
  44802. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  44803. * @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)
  44804. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  44805. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  44806. */
  44807. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  44808. private _buildPipeline;
  44809. private _createDownSampleX4PostProcess;
  44810. private _createBrightPassPostProcess;
  44811. private _createBlurPostProcesses;
  44812. private _createTextureAdderPostProcess;
  44813. private _createVolumetricLightPostProcess;
  44814. private _createLuminancePostProcesses;
  44815. private _createHdrPostProcess;
  44816. private _createLensFlarePostProcess;
  44817. private _createDepthOfFieldPostProcess;
  44818. private _createMotionBlurPostProcess;
  44819. private _getDepthTexture;
  44820. private _disposePostProcesses;
  44821. /**
  44822. * Dispose of the pipeline and stop all post processes
  44823. */
  44824. dispose(): void;
  44825. /**
  44826. * Serialize the rendering pipeline (Used when exporting)
  44827. * @returns the serialized object
  44828. */
  44829. serialize(): any;
  44830. /**
  44831. * Parse the serialized pipeline
  44832. * @param source Source pipeline.
  44833. * @param scene The scene to load the pipeline to.
  44834. * @param rootUrl The URL of the serialized pipeline.
  44835. * @returns An instantiated pipeline from the serialized object.
  44836. */
  44837. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  44838. static LuminanceSteps: number;
  44839. }
  44840. }