babylon.d.ts 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  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. private _ranges;
  369. /**
  370. * Callback raised when the node is ready to be used
  371. */
  372. onReady: (node: Node) => void;
  373. private _isEnabled;
  374. private _isReady;
  375. /** @hidden */
  376. _currentRenderId: number;
  377. private _parentRenderId;
  378. protected _childRenderId: number;
  379. /** @hidden */
  380. _waitingParentId: Nullable<string>;
  381. private _scene;
  382. /** @hidden */
  383. _cache: any;
  384. private _parentNode;
  385. private _children;
  386. /**
  387. * Gets a boolean indicating if the node has been disposed
  388. * @returns true if the node was disposed
  389. */
  390. isDisposed(): boolean;
  391. /**
  392. * Gets or sets the parent of the node
  393. */
  394. parent: Nullable<Node>;
  395. private _animationPropertiesOverride;
  396. /**
  397. * Gets or sets the animation properties override
  398. */
  399. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  400. /**
  401. * Gets a string idenfifying the name of the class
  402. * @returns "Node" string
  403. */
  404. getClassName(): string;
  405. /**
  406. * An event triggered when the mesh is disposed
  407. */
  408. onDisposeObservable: Observable<Node>;
  409. private _onDisposeObserver;
  410. /**
  411. * Sets a callback that will be raised when the node will be disposed
  412. */
  413. onDispose: () => void;
  414. /**
  415. * Creates a new Node
  416. * @param {string} name - the name and id to be given to this node
  417. * @param {BABYLON.Scene} the scene this node will be added to
  418. */
  419. constructor(name: string, scene?: Nullable<Scene>);
  420. /**
  421. * Gets the scene of the node
  422. * @returns a {BABYLON.Scene}
  423. */
  424. getScene(): Scene;
  425. /**
  426. * Gets the engine of the node
  427. * @returns a {BABYLON.Engine}
  428. */
  429. getEngine(): Engine;
  430. private _behaviors;
  431. /**
  432. * Attach a behavior to the node
  433. * @see http://doc.babylonjs.com/features/behaviour
  434. * @param behavior defines the behavior to attach
  435. * @returns the current Node
  436. */
  437. addBehavior(behavior: Behavior<Node>): Node;
  438. /**
  439. * Remove an attached behavior
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @param behavior defines the behavior to attach
  442. * @returns the current Node
  443. */
  444. removeBehavior(behavior: Behavior<Node>): Node;
  445. /**
  446. * Gets the list of attached behaviors
  447. * @see http://doc.babylonjs.com/features/behaviour
  448. */
  449. readonly behaviors: Behavior<Node>[];
  450. /**
  451. * Gets an attached behavior by name
  452. * @param name defines the name of the behavior to look for
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @returns null if behavior was not found else the requested behavior
  455. */
  456. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  457. /**
  458. * Returns the world matrix of the node
  459. * @returns a matrix containing the node's world matrix
  460. */
  461. getWorldMatrix(): Matrix;
  462. /** @hidden */
  463. _getWorldMatrixDeterminant(): number;
  464. /** @hidden */
  465. _initCache(): void;
  466. /** @hidden */
  467. updateCache(force?: boolean): void;
  468. /** @hidden */
  469. _updateCache(ignoreParentClass?: boolean): void;
  470. /** @hidden */
  471. _isSynchronized(): boolean;
  472. /** @hidden */
  473. _markSyncedWithParent(): void;
  474. /** @hidden */
  475. isSynchronizedWithParent(): boolean;
  476. /** @hidden */
  477. isSynchronized(updateCache?: boolean): boolean;
  478. /** @hidden */
  479. hasNewParent(update?: boolean): boolean;
  480. /**
  481. * Is this node ready to be used/rendered
  482. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  483. * @return true if the node is ready
  484. */
  485. isReady(completeCheck?: boolean): boolean;
  486. /**
  487. * Is this node enabled?
  488. * 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
  489. * @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
  490. * @return whether this node (and its parent) is enabled
  491. */
  492. isEnabled(checkAncestors?: boolean): boolean;
  493. /**
  494. * Set the enabled state of this node
  495. * @param value defines the new enabled state
  496. */
  497. setEnabled(value: boolean): void;
  498. /**
  499. * Is this node a descendant of the given node?
  500. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  501. * @param ancestor defines the parent node to inspect
  502. * @returns a boolean indicating if this node is a descendant of the given node
  503. */
  504. isDescendantOf(ancestor: Node): boolean;
  505. /** @hidden */
  506. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  507. /**
  508. * Will return all nodes that have this node as ascendant
  509. * @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
  510. * @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
  511. * @return all children nodes of all types
  512. */
  513. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  514. /**
  515. * Get all child-meshes of this node
  516. * @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
  517. * @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
  518. * @returns an array of {BABYLON.AbstractMesh}
  519. */
  520. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  521. /**
  522. * Get all child-transformNodes of this node
  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. * @returns an array of {BABYLON.TransformNode}
  526. */
  527. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  528. /**
  529. * Get all direct children of this node
  530. * @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
  531. * @returns an array of {BABYLON.Node}
  532. */
  533. getChildren(predicate?: (node: Node) => boolean): Node[];
  534. /** @hidden */
  535. _setReady(state: boolean): void;
  536. /**
  537. * Get an animation by name
  538. * @param name defines the name of the animation to look for
  539. * @returns null if not found else the requested animation
  540. */
  541. getAnimationByName(name: string): Nullable<Animation>;
  542. /**
  543. * Creates an animation range for this node
  544. * @param name defines the name of the range
  545. * @param from defines the starting key
  546. * @param to defines the end key
  547. */
  548. createAnimationRange(name: string, from: number, to: number): void;
  549. /**
  550. * Delete a specific animation range
  551. * @param name defines the name of the range to delete
  552. * @param deleteFrames defines if animation frames from the range must be deleted as well
  553. */
  554. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  555. /**
  556. * Get an animation range by name
  557. * @param name defines the name of the animation range to look for
  558. * @returns null if not found else the requested animation range
  559. */
  560. getAnimationRange(name: string): Nullable<AnimationRange>;
  561. /**
  562. * Will start the animation sequence
  563. * @param name defines the range frames for animation sequence
  564. * @param loop defines if the animation should loop (false by default)
  565. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  566. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  567. * @returns the object created for this animation. If range does not exist, it will return null
  568. */
  569. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  570. /**
  571. * Serialize animation ranges into a JSON compatible object
  572. * @returns serialization object
  573. */
  574. serializeAnimationRanges(): any;
  575. /**
  576. * Computes the world matrix of the node
  577. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  578. * @returns the world matrix
  579. */
  580. computeWorldMatrix(force?: boolean): Matrix;
  581. /**
  582. * Releases resources associated with this node.
  583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  585. */
  586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  587. /**
  588. * Parse animation range data from a serialization object and store them into a given node
  589. * @param node defines where to store the animation ranges
  590. * @param parsedNode defines the serialization object to read data from
  591. * @param scene defines the hosting scene
  592. */
  593. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  594. }
  595. }
  596. declare module BABYLON {
  597. /**
  598. * Define an interface for all classes that will hold resources
  599. */
  600. interface IDisposable {
  601. /**
  602. * Releases all held resources
  603. */
  604. dispose(): void;
  605. }
  606. /**
  607. * Interface used to let developers provide their own mesh selection mechanism
  608. */
  609. interface IActiveMeshCandidateProvider {
  610. /**
  611. * Return the list of active meshes
  612. * @param scene defines the current scene
  613. * @returns the list of active meshes
  614. */
  615. getMeshes(scene: Scene): AbstractMesh[];
  616. /**
  617. * Indicates if the meshes have been checked to make sure they are isEnabled()
  618. */
  619. readonly checksIsEnabled: boolean;
  620. }
  621. /**
  622. * This class is used by the onRenderingGroupObservable
  623. */
  624. class RenderingGroupInfo {
  625. /**
  626. * The Scene that being rendered
  627. */
  628. scene: Scene;
  629. /**
  630. * The camera currently used for the rendering pass
  631. */
  632. camera: Nullable<Camera>;
  633. /**
  634. * The ID of the renderingGroup being processed
  635. */
  636. renderingGroupId: number;
  637. /**
  638. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  639. */
  640. renderStage: number;
  641. /**
  642. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  643. * This stage will be fired no matter what
  644. */
  645. static STAGE_PRECLEAR: number;
  646. /**
  647. * Called before opaque object are rendered.
  648. * This stage will be fired only if there's 3D Opaque content to render
  649. */
  650. static STAGE_PREOPAQUE: number;
  651. /**
  652. * Called after the opaque objects are rendered and before the transparent ones
  653. * This stage will be fired only if there's 3D transparent content to render
  654. */
  655. static STAGE_PRETRANSPARENT: number;
  656. /**
  657. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  658. * This stage will be fired no matter what
  659. */
  660. static STAGE_POSTTRANSPARENT: number;
  661. }
  662. /**
  663. * Represents a scene to be rendered by the engine.
  664. * @see http://doc.babylonjs.com/features/scene
  665. */
  666. class Scene extends AbstractScene implements IAnimatable {
  667. private static _FOGMODE_NONE;
  668. private static _FOGMODE_EXP;
  669. private static _FOGMODE_EXP2;
  670. private static _FOGMODE_LINEAR;
  671. private static _uniqueIdCounter;
  672. /**
  673. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  674. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  675. */
  676. static MinDeltaTime: number;
  677. /**
  678. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  679. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  680. */
  681. static MaxDeltaTime: number;
  682. /** The fog is deactivated */
  683. static readonly FOGMODE_NONE: number;
  684. /** The fog density is following an exponential function */
  685. static readonly FOGMODE_EXP: number;
  686. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  687. static readonly FOGMODE_EXP2: number;
  688. /** The fog density is following a linear function. */
  689. static readonly FOGMODE_LINEAR: number;
  690. /**
  691. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  692. */
  693. autoClear: boolean;
  694. /**
  695. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  696. */
  697. autoClearDepthAndStencil: boolean;
  698. /**
  699. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  700. */
  701. clearColor: Color4;
  702. /**
  703. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  704. */
  705. ambientColor: Color3;
  706. /** @hidden */
  707. _environmentBRDFTexture: BaseTexture;
  708. /** @hidden */
  709. protected _environmentTexture: BaseTexture;
  710. /**
  711. * Texture used in all pbr material as the reflection texture.
  712. * As in the majority of the scene they are the same (exception for multi room and so on),
  713. * this is easier to reference from here than from all the materials.
  714. */
  715. /**
  716. * Texture used in all pbr material as the reflection texture.
  717. * As in the majority of the scene they are the same (exception for multi room and so on),
  718. * this is easier to set here than in all the materials.
  719. */
  720. environmentTexture: BaseTexture;
  721. /** @hidden */
  722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  723. /**
  724. * Default image processing configuration used either in the rendering
  725. * Forward main pass or through the imageProcessingPostProcess if present.
  726. * As in the majority of the scene they are the same (exception for multi camera),
  727. * this is easier to reference from here than from all the materials and post process.
  728. *
  729. * No setter as we it is a shared configuration, you can set the values instead.
  730. */
  731. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  732. private _forceWireframe;
  733. /**
  734. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  735. */
  736. forceWireframe: boolean;
  737. private _forcePointsCloud;
  738. /**
  739. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  740. */
  741. forcePointsCloud: boolean;
  742. /**
  743. * Gets or sets the active clipplane
  744. */
  745. clipPlane: Nullable<Plane>;
  746. /**
  747. * Gets or sets a boolean indicating if animations are enabled
  748. */
  749. animationsEnabled: boolean;
  750. private _animationPropertiesOverride;
  751. /**
  752. * Gets or sets the animation properties override
  753. */
  754. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  755. /**
  756. * Gets or sets a boolean indicating if a constant deltatime has to be used
  757. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  758. */
  759. useConstantAnimationDeltaTime: boolean;
  760. /**
  761. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  762. * Please note that it requires to run a ray cast through the scene on every frame
  763. */
  764. constantlyUpdateMeshUnderPointer: boolean;
  765. /**
  766. * Defines the HTML cursor to use when hovering over interactive elements
  767. */
  768. hoverCursor: string;
  769. /**
  770. * Defines the HTML default cursor to use (empty by default)
  771. */
  772. defaultCursor: string;
  773. /**
  774. * This is used to call preventDefault() on pointer down
  775. * in order to block unwanted artifacts like system double clicks
  776. */
  777. preventDefaultOnPointerDown: boolean;
  778. /**
  779. * Gets or sets user defined metadata
  780. */
  781. metadata: any;
  782. /**
  783. * Gets the name of the plugin used to load this scene (null by default)
  784. */
  785. loadingPluginName: string;
  786. /**
  787. * Use this array to add regular expressions used to disable offline support for specific urls
  788. */
  789. disableOfflineSupportExceptionRules: RegExp[];
  790. private _spritePredicate;
  791. /**
  792. * An event triggered when the scene is disposed.
  793. */
  794. onDisposeObservable: Observable<Scene>;
  795. private _onDisposeObserver;
  796. /** Sets a function to be executed when this scene is disposed. */
  797. onDispose: () => void;
  798. /**
  799. * An event triggered before rendering the scene (right after animations and physics)
  800. */
  801. onBeforeRenderObservable: Observable<Scene>;
  802. private _onBeforeRenderObserver;
  803. /** Sets a function to be executed before rendering this scene */
  804. beforeRender: Nullable<() => void>;
  805. /**
  806. * An event triggered after rendering the scene
  807. */
  808. onAfterRenderObservable: Observable<Scene>;
  809. private _onAfterRenderObserver;
  810. /** Sets a function to be executed after rendering this scene */
  811. afterRender: Nullable<() => void>;
  812. /**
  813. * An event triggered before animating the scene
  814. */
  815. onBeforeAnimationsObservable: Observable<Scene>;
  816. /**
  817. * An event triggered after animations processing
  818. */
  819. onAfterAnimationsObservable: Observable<Scene>;
  820. /**
  821. * An event triggered before draw calls are ready to be sent
  822. */
  823. onBeforeDrawPhaseObservable: Observable<Scene>;
  824. /**
  825. * An event triggered after draw calls have been sent
  826. */
  827. onAfterDrawPhaseObservable: Observable<Scene>;
  828. /**
  829. * An event triggered when physic simulation is about to be run
  830. */
  831. onBeforePhysicsObservable: Observable<Scene>;
  832. /**
  833. * An event triggered when physic simulation has been done
  834. */
  835. onAfterPhysicsObservable: Observable<Scene>;
  836. /**
  837. * An event triggered when the scene is ready
  838. */
  839. onReadyObservable: Observable<Scene>;
  840. /**
  841. * An event triggered before rendering a camera
  842. */
  843. onBeforeCameraRenderObservable: Observable<Camera>;
  844. private _onBeforeCameraRenderObserver;
  845. /** Sets a function to be executed before rendering a camera*/
  846. beforeCameraRender: () => void;
  847. /**
  848. * An event triggered after rendering a camera
  849. */
  850. onAfterCameraRenderObservable: Observable<Camera>;
  851. private _onAfterCameraRenderObserver;
  852. /** Sets a function to be executed after rendering a camera*/
  853. afterCameraRender: () => void;
  854. /**
  855. * An event triggered when active meshes evaluation is about to start
  856. */
  857. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when active meshes evaluation is done
  860. */
  861. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  862. /**
  863. * An event triggered when particles rendering is about to start
  864. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  865. */
  866. onBeforeParticlesRenderingObservable: Observable<Scene>;
  867. /**
  868. * An event triggered when particles rendering is done
  869. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  870. */
  871. onAfterParticlesRenderingObservable: Observable<Scene>;
  872. /**
  873. * An event triggered when sprites rendering is about to start
  874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  875. */
  876. onBeforeSpritesRenderingObservable: Observable<Scene>;
  877. /**
  878. * An event triggered when sprites rendering is done
  879. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  880. */
  881. onAfterSpritesRenderingObservable: Observable<Scene>;
  882. /**
  883. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  884. */
  885. onDataLoadedObservable: Observable<Scene>;
  886. /**
  887. * An event triggered when a camera is created
  888. */
  889. onNewCameraAddedObservable: Observable<Camera>;
  890. /**
  891. * An event triggered when a camera is removed
  892. */
  893. onCameraRemovedObservable: Observable<Camera>;
  894. /**
  895. * An event triggered when a light is created
  896. */
  897. onNewLightAddedObservable: Observable<Light>;
  898. /**
  899. * An event triggered when a light is removed
  900. */
  901. onLightRemovedObservable: Observable<Light>;
  902. /**
  903. * An event triggered when a geometry is created
  904. */
  905. onNewGeometryAddedObservable: Observable<Geometry>;
  906. /**
  907. * An event triggered when a geometry is removed
  908. */
  909. onGeometryRemovedObservable: Observable<Geometry>;
  910. /**
  911. * An event triggered when a transform node is created
  912. */
  913. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  914. /**
  915. * An event triggered when a transform node is removed
  916. */
  917. onTransformNodeRemovedObservable: Observable<TransformNode>;
  918. /**
  919. * An event triggered when a mesh is created
  920. */
  921. onNewMeshAddedObservable: Observable<AbstractMesh>;
  922. /**
  923. * An event triggered when a mesh is removed
  924. */
  925. onMeshRemovedObservable: Observable<AbstractMesh>;
  926. /**
  927. * An event triggered when render targets are about to be rendered
  928. * Can happen multiple times per frame.
  929. */
  930. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  931. /**
  932. * An event triggered when render targets were rendered.
  933. * Can happen multiple times per frame.
  934. */
  935. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  936. /**
  937. * An event triggered before calculating deterministic simulation step
  938. */
  939. onBeforeStepObservable: Observable<Scene>;
  940. /**
  941. * An event triggered after calculating deterministic simulation step
  942. */
  943. onAfterStepObservable: Observable<Scene>;
  944. /**
  945. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  946. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  947. * 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)
  948. */
  949. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  950. private _registeredForLateAnimationBindings;
  951. /**
  952. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  953. */
  954. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  955. /**
  956. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  957. */
  958. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  959. /**
  960. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  961. */
  962. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  963. private _onPointerMove;
  964. private _onPointerDown;
  965. private _onPointerUp;
  966. /** Deprecated. Use onPointerObservable instead */
  967. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  968. /** Deprecated. Use onPointerObservable instead */
  969. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  970. /** Deprecated. Use onPointerObservable instead */
  971. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  972. /** Deprecated. Use onPointerObservable instead */
  973. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  974. /**
  975. * 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).
  976. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  977. */
  978. onPrePointerObservable: Observable<PointerInfoPre>;
  979. /**
  980. * Observable event triggered each time an input event is received from the rendering canvas
  981. */
  982. onPointerObservable: Observable<PointerInfo>;
  983. /**
  984. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  985. */
  986. readonly unTranslatedPointer: Vector2;
  987. /** The distance in pixel that you have to move to prevent some events */
  988. static DragMovementThreshold: number;
  989. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  990. static LongPressDelay: number;
  991. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  992. static DoubleClickDelay: number;
  993. /** If you need to check double click without raising a single click at first click, enable this flag */
  994. static ExclusiveDoubleClickMode: boolean;
  995. private _initClickEvent;
  996. private _initActionManager;
  997. private _delayedSimpleClick;
  998. private _delayedSimpleClickTimeout;
  999. private _previousDelayedSimpleClickTimeout;
  1000. private _meshPickProceed;
  1001. private _previousButtonPressed;
  1002. private _currentPickResult;
  1003. private _previousPickResult;
  1004. private _totalPointersPressed;
  1005. private _doubleClickOccured;
  1006. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1007. cameraToUseForPointers: Nullable<Camera>;
  1008. private _pointerX;
  1009. private _pointerY;
  1010. private _unTranslatedPointerX;
  1011. private _unTranslatedPointerY;
  1012. private _startingPointerPosition;
  1013. private _previousStartingPointerPosition;
  1014. private _startingPointerTime;
  1015. private _previousStartingPointerTime;
  1016. private _pointerCaptures;
  1017. private _timeAccumulator;
  1018. private _currentStepId;
  1019. private _currentInternalStep;
  1020. /** @hidden */
  1021. _mirroredCameraPosition: Nullable<Vector3>;
  1022. /**
  1023. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1024. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1025. */
  1026. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1027. /**
  1028. * Observable event triggered each time an keyboard event is received from the hosting window
  1029. */
  1030. onKeyboardObservable: Observable<KeyboardInfo>;
  1031. private _onKeyDown;
  1032. private _onKeyUp;
  1033. private _onCanvasFocusObserver;
  1034. private _onCanvasBlurObserver;
  1035. private _useRightHandedSystem;
  1036. /**
  1037. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1038. */
  1039. useRightHandedSystem: boolean;
  1040. /**
  1041. * Sets the step Id used by deterministic lock step
  1042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1043. * @param newStepId defines the step Id
  1044. */
  1045. setStepId(newStepId: number): void;
  1046. /**
  1047. * Gets the step Id used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @returns the step Id
  1050. */
  1051. getStepId(): number;
  1052. /**
  1053. * Gets the internal step used by deterministic lock step
  1054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1055. * @returns the internal step
  1056. */
  1057. getInternalStep(): number;
  1058. private _fogEnabled;
  1059. /**
  1060. * Gets or sets a boolean indicating if fog is enabled on this scene
  1061. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1062. */
  1063. fogEnabled: boolean;
  1064. private _fogMode;
  1065. /**
  1066. * Gets or sets the fog mode to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogMode: number;
  1070. /**
  1071. * Gets or sets the fog color to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogColor: Color3;
  1075. /**
  1076. * Gets or sets the fog density to use
  1077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1078. */
  1079. fogDensity: number;
  1080. /**
  1081. * Gets or sets the fog start distance to use
  1082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1083. */
  1084. fogStart: number;
  1085. /**
  1086. * Gets or sets the fog end distance to use
  1087. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1088. */
  1089. fogEnd: number;
  1090. private _shadowsEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1093. */
  1094. shadowsEnabled: boolean;
  1095. private _lightsEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if lights are enabled on this scene
  1098. */
  1099. lightsEnabled: boolean;
  1100. /** All of the active cameras added to this scene. */
  1101. activeCameras: Camera[];
  1102. /** The current active camera */
  1103. activeCamera: Nullable<Camera>;
  1104. private _defaultMaterial;
  1105. /** The default material used on meshes when no material is affected */
  1106. /** The default material used on meshes when no material is affected */
  1107. defaultMaterial: Material;
  1108. private _texturesEnabled;
  1109. /**
  1110. * Gets or sets a boolean indicating if textures are enabled on this scene
  1111. */
  1112. texturesEnabled: boolean;
  1113. /**
  1114. * Gets or sets a boolean indicating if particles are enabled on this scene
  1115. */
  1116. particlesEnabled: boolean;
  1117. /**
  1118. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1119. */
  1120. spritesEnabled: boolean;
  1121. /**
  1122. * All of the sprite managers added to this scene
  1123. * @see http://doc.babylonjs.com/babylon101/sprites
  1124. */
  1125. spriteManagers: SpriteManager[];
  1126. private _skeletonsEnabled;
  1127. /**
  1128. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1129. */
  1130. skeletonsEnabled: boolean;
  1131. /**
  1132. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1133. */
  1134. lensFlaresEnabled: boolean;
  1135. /**
  1136. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1138. */
  1139. collisionsEnabled: boolean;
  1140. private _workerCollisions;
  1141. /** @hidden */
  1142. collisionCoordinator: ICollisionCoordinator;
  1143. /**
  1144. * Defines the gravity applied to this scene (used only for collisions)
  1145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1146. */
  1147. gravity: Vector3;
  1148. /**
  1149. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1150. */
  1151. postProcessesEnabled: boolean;
  1152. /**
  1153. * The list of postprocesses added to the scene
  1154. */
  1155. postProcesses: PostProcess[];
  1156. /**
  1157. * Gets the current postprocess manager
  1158. */
  1159. postProcessManager: PostProcessManager;
  1160. private _postProcessRenderPipelineManager;
  1161. /**
  1162. * Gets the postprocess render pipeline manager
  1163. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1164. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1165. */
  1166. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1167. /**
  1168. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1169. */
  1170. renderTargetsEnabled: boolean;
  1171. /**
  1172. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1173. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1174. */
  1175. dumpNextRenderTargets: boolean;
  1176. /**
  1177. * The list of user defined render targets added to the scene
  1178. */
  1179. customRenderTargets: RenderTargetTexture[];
  1180. /**
  1181. * Defines if texture loading must be delayed
  1182. * If true, textures will only be loaded when they need to be rendered
  1183. */
  1184. useDelayedTextureLoading: boolean;
  1185. /**
  1186. * Gets the list of meshes imported to the scene through SceneLoader
  1187. */
  1188. importedMeshesFiles: String[];
  1189. /**
  1190. * Gets or sets a boolean indicating if probes are enabled on this scene
  1191. */
  1192. probesEnabled: boolean;
  1193. /**
  1194. * The list of reflection probes added to the scene
  1195. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1196. */
  1197. reflectionProbes: ReflectionProbe[];
  1198. /**
  1199. * @hidden
  1200. */
  1201. database: Database;
  1202. /**
  1203. * Gets or sets the action manager associated with the scene
  1204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1205. */
  1206. actionManager: ActionManager;
  1207. private _meshesForIntersections;
  1208. /**
  1209. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1210. */
  1211. proceduralTexturesEnabled: boolean;
  1212. /**
  1213. * The list of procedural textures added to the scene
  1214. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1215. */
  1216. proceduralTextures: ProceduralTexture[];
  1217. private _mainSoundTrack;
  1218. /**
  1219. * The list of sound tracks added to the scene
  1220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1221. */
  1222. soundTracks: SoundTrack[];
  1223. private _audioEnabled;
  1224. private _headphone;
  1225. /**
  1226. * Gets the main soundtrack associated with the scene
  1227. */
  1228. readonly mainSoundTrack: SoundTrack;
  1229. /**
  1230. * Gets or sets the VRExperienceHelper attached to the scene
  1231. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1232. * @ignorenaming
  1233. */
  1234. VRHelper: VRExperienceHelper;
  1235. /**
  1236. * Gets or sets the simplification queue attached to the scene
  1237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1238. */
  1239. simplificationQueue: SimplificationQueue;
  1240. private _engine;
  1241. private _totalVertices;
  1242. /** @hidden */
  1243. _activeIndices: PerfCounter;
  1244. /** @hidden */
  1245. _activeParticles: PerfCounter;
  1246. /** @hidden */
  1247. _activeBones: PerfCounter;
  1248. private _animationRatio;
  1249. private _animationTimeLast;
  1250. private _animationTime;
  1251. /**
  1252. * Gets or sets a general scale for animation speed
  1253. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1254. */
  1255. animationTimeScale: number;
  1256. /** @hidden */
  1257. _cachedMaterial: Nullable<Material>;
  1258. /** @hidden */
  1259. _cachedEffect: Nullable<Effect>;
  1260. /** @hidden */
  1261. _cachedVisibility: Nullable<number>;
  1262. private _renderId;
  1263. private _executeWhenReadyTimeoutId;
  1264. private _intermediateRendering;
  1265. private _viewUpdateFlag;
  1266. private _projectionUpdateFlag;
  1267. private _alternateViewUpdateFlag;
  1268. private _alternateProjectionUpdateFlag;
  1269. /** @hidden */
  1270. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1271. private _activeRequests;
  1272. private _pendingData;
  1273. private _isDisposed;
  1274. /**
  1275. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1276. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1277. */
  1278. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1279. private _activeMeshes;
  1280. private _processedMaterials;
  1281. private _renderTargets;
  1282. /** @hidden */
  1283. _activeParticleSystems: SmartArray<IParticleSystem>;
  1284. private _activeSkeletons;
  1285. private _softwareSkinnedMeshes;
  1286. private _renderingManager;
  1287. private _physicsEngine;
  1288. /** @hidden */
  1289. _activeAnimatables: Animatable[];
  1290. private _transformMatrix;
  1291. private _sceneUbo;
  1292. private _alternateSceneUbo;
  1293. private _pickWithRayInverseMatrix;
  1294. private _outlineRenderer;
  1295. private _viewMatrix;
  1296. private _projectionMatrix;
  1297. private _alternateViewMatrix;
  1298. private _alternateProjectionMatrix;
  1299. private _alternateTransformMatrix;
  1300. private _useAlternateCameraConfiguration;
  1301. private _alternateRendering;
  1302. /** @hidden */
  1303. _forcedViewPosition: Nullable<Vector3>;
  1304. /** @hidden */
  1305. readonly _isAlternateRenderingEnabled: boolean;
  1306. private _frustumPlanes;
  1307. /**
  1308. * Gets the list of frustum planes (built from the active camera)
  1309. */
  1310. readonly frustumPlanes: Plane[];
  1311. /**
  1312. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1313. * This is useful if there are more lights that the maximum simulteanous authorized
  1314. */
  1315. requireLightSorting: boolean;
  1316. private _selectionOctree;
  1317. private _pointerOverMesh;
  1318. private _pointerOverSprite;
  1319. private _debugLayer;
  1320. private _depthRenderer;
  1321. private _geometryBufferRenderer;
  1322. /**
  1323. * Gets the current geometry buffer associated to the scene.
  1324. */
  1325. /**
  1326. * Sets the current geometry buffer for the scene.
  1327. */
  1328. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1329. private _pickedDownMesh;
  1330. private _pickedUpMesh;
  1331. private _pickedDownSprite;
  1332. private _externalData;
  1333. private _uid;
  1334. /**
  1335. * Backing store of defined scene components.
  1336. */
  1337. _components: ISceneComponent[];
  1338. /**
  1339. * Backing store of defined scene components.
  1340. */
  1341. _serializableComponents: ISceneSerializableComponent[];
  1342. /**
  1343. * List of components to register on the next registration step.
  1344. */
  1345. private _transientComponents;
  1346. /**
  1347. * Registers the transient components if needed.
  1348. */
  1349. private _registerTransientComponents();
  1350. /**
  1351. * Add a component to the scene.
  1352. * Note that the ccomponent could be registered on th next frame if this is called after
  1353. * the register component stage.
  1354. * @param component Defines the component to add to the scene
  1355. */
  1356. _addComponent(component: ISceneComponent): void;
  1357. /**
  1358. * Gets a component from the scene.
  1359. * @param name defines the name of the component to retrieve
  1360. * @returns the component or null if not present
  1361. */
  1362. _getComponent(name: string): Nullable<ISceneComponent>;
  1363. /**
  1364. * Defines the actions happening before camera updates.
  1365. */
  1366. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1367. /**
  1368. * Defines the actions happening during the per mesh ready checks.
  1369. */
  1370. _isReadyForMeshStage: Stage<MeshStageAction>;
  1371. /**
  1372. * Defines the actions happening before evaluate active mesh checks.
  1373. */
  1374. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1375. /**
  1376. * Defines the actions happening during the evaluate sub mesh checks.
  1377. */
  1378. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1379. /**
  1380. * Defines the actions happening during the active mesh stage.
  1381. */
  1382. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1383. /**
  1384. * Defines the actions happening during the per camera render target step.
  1385. */
  1386. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1387. /**
  1388. * Defines the actions happening just before the active camera is drawing.
  1389. */
  1390. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1391. /**
  1392. * Defines the actions happening just before a rendering group is drawing.
  1393. */
  1394. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1395. /**
  1396. * Defines the actions happening just after a rendering group has been drawn.
  1397. */
  1398. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1399. /**
  1400. * Defines the actions happening just after the active camera has been drawn.
  1401. */
  1402. _afterCameraDrawStage: Stage<CameraStageAction>;
  1403. /**
  1404. * Creates a new Scene
  1405. * @param engine defines the engine to use to render this scene
  1406. */
  1407. constructor(engine: Engine);
  1408. /**
  1409. * Gets the debug layer (aka Inspector) associated with the scene
  1410. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1411. */
  1412. readonly debugLayer: DebugLayer;
  1413. /**
  1414. * Gets a boolean indicating if collisions are processed on a web worker
  1415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1416. */
  1417. workerCollisions: boolean;
  1418. /**
  1419. * Gets the octree used to boost mesh selection (picking)
  1420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1421. */
  1422. readonly selectionOctree: Octree<AbstractMesh>;
  1423. /**
  1424. * Gets the mesh that is currently under the pointer
  1425. */
  1426. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1427. /**
  1428. * Gets the current on-screen X position of the pointer
  1429. */
  1430. readonly pointerX: number;
  1431. /**
  1432. * Gets the current on-screen Y position of the pointer
  1433. */
  1434. readonly pointerY: number;
  1435. /**
  1436. * Gets the cached material (ie. the latest rendered one)
  1437. * @returns the cached material
  1438. */
  1439. getCachedMaterial(): Nullable<Material>;
  1440. /**
  1441. * Gets the cached effect (ie. the latest rendered one)
  1442. * @returns the cached effect
  1443. */
  1444. getCachedEffect(): Nullable<Effect>;
  1445. /**
  1446. * Gets the cached visibility state (ie. the latest rendered one)
  1447. * @returns the cached visibility state
  1448. */
  1449. getCachedVisibility(): Nullable<number>;
  1450. /**
  1451. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1452. * @param material defines the current material
  1453. * @param effect defines the current effect
  1454. * @param visibility defines the current visibility state
  1455. * @returns true if one parameter is not cached
  1456. */
  1457. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1458. /**
  1459. * Gets the outline renderer associated with the scene
  1460. * @returns a OutlineRenderer
  1461. */
  1462. getOutlineRenderer(): OutlineRenderer;
  1463. /**
  1464. * Gets the engine associated with the scene
  1465. * @returns an Engine
  1466. */
  1467. getEngine(): Engine;
  1468. /**
  1469. * Gets the total number of vertices rendered per frame
  1470. * @returns the total number of vertices rendered per frame
  1471. */
  1472. getTotalVertices(): number;
  1473. /**
  1474. * Gets the performance counter for total vertices
  1475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1476. */
  1477. readonly totalVerticesPerfCounter: PerfCounter;
  1478. /**
  1479. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1480. * @returns the total number of active indices rendered per frame
  1481. */
  1482. getActiveIndices(): number;
  1483. /**
  1484. * Gets the performance counter for active indices
  1485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1486. */
  1487. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1488. /**
  1489. * Gets the total number of active particles rendered per frame
  1490. * @returns the total number of active particles rendered per frame
  1491. */
  1492. getActiveParticles(): number;
  1493. /**
  1494. * Gets the performance counter for active particles
  1495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1496. */
  1497. readonly activeParticlesPerfCounter: PerfCounter;
  1498. /**
  1499. * Gets the total number of active bones rendered per frame
  1500. * @returns the total number of active bones rendered per frame
  1501. */
  1502. getActiveBones(): number;
  1503. /**
  1504. * Gets the performance counter for active bones
  1505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1506. */
  1507. readonly activeBonesPerfCounter: PerfCounter;
  1508. /** @hidden */
  1509. getInterFramePerfCounter(): number;
  1510. /** @hidden */
  1511. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1512. /** @hidden */
  1513. getLastFrameDuration(): number;
  1514. /** @hidden */
  1515. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1516. /** @hidden */
  1517. getEvaluateActiveMeshesDuration(): number;
  1518. /** @hidden */
  1519. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1520. /**
  1521. * Gets the array of active meshes
  1522. * @returns an array of AbstractMesh
  1523. */
  1524. getActiveMeshes(): SmartArray<AbstractMesh>;
  1525. /** @hidden */
  1526. getRenderTargetsDuration(): number;
  1527. /** @hidden */
  1528. getRenderDuration(): number;
  1529. /** @hidden */
  1530. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1531. /** @hidden */
  1532. getParticlesDuration(): number;
  1533. /** @hidden */
  1534. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1535. /** @hidden */
  1536. getSpritesDuration(): number;
  1537. /** @hidden */
  1538. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1539. /**
  1540. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1541. * @returns a number
  1542. */
  1543. getAnimationRatio(): number;
  1544. /**
  1545. * Gets an unique Id for the current frame
  1546. * @returns a number
  1547. */
  1548. getRenderId(): number;
  1549. /** Call this function if you want to manually increment the render Id*/
  1550. incrementRenderId(): void;
  1551. private _updatePointerPosition(evt);
  1552. private _createUbo();
  1553. private _createAlternateUbo();
  1554. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1555. private _setRayOnPointerInfo(pointerInfo);
  1556. /**
  1557. * Use this method to simulate a pointer move on a mesh
  1558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1561. * @returns the current scene
  1562. */
  1563. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1564. private _processPointerMove(pickResult, evt);
  1565. private _checkPrePointerObservable(pickResult, evt, type);
  1566. /**
  1567. * Use this method to simulate a pointer down on a mesh
  1568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1571. * @returns the current scene
  1572. */
  1573. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1574. private _processPointerDown(pickResult, evt);
  1575. /**
  1576. * Use this method to simulate a pointer up on a mesh
  1577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1580. * @returns the current scene
  1581. */
  1582. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1583. private _processPointerUp(pickResult, evt, clickInfo);
  1584. /**
  1585. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1586. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1587. * @returns true if the pointer was captured
  1588. */
  1589. isPointerCaptured(pointerId?: number): boolean;
  1590. /**
  1591. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1592. * @param attachUp defines if you want to attach events to pointerup
  1593. * @param attachDown defines if you want to attach events to pointerdown
  1594. * @param attachMove defines if you want to attach events to pointermove
  1595. */
  1596. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1597. /** Detaches all event handlers*/
  1598. detachControl(): void;
  1599. /**
  1600. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1601. * Delay loaded resources are not taking in account
  1602. * @return true if all required resources are ready
  1603. */
  1604. isReady(): boolean;
  1605. /** Resets all cached information relative to material (including effect and visibility) */
  1606. resetCachedMaterial(): void;
  1607. /**
  1608. * Registers a function to be called before every frame render
  1609. * @param func defines the function to register
  1610. */
  1611. registerBeforeRender(func: () => void): void;
  1612. /**
  1613. * Unregisters a function called before every frame render
  1614. * @param func defines the function to unregister
  1615. */
  1616. unregisterBeforeRender(func: () => void): void;
  1617. /**
  1618. * Registers a function to be called after every frame render
  1619. * @param func defines the function to register
  1620. */
  1621. registerAfterRender(func: () => void): void;
  1622. /**
  1623. * Unregisters a function called after every frame render
  1624. * @param func defines the function to unregister
  1625. */
  1626. unregisterAfterRender(func: () => void): void;
  1627. private _executeOnceBeforeRender(func);
  1628. /**
  1629. * The provided function will run before render once and will be disposed afterwards.
  1630. * A timeout delay can be provided so that the function will be executed in N ms.
  1631. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1632. * @param func The function to be executed.
  1633. * @param timeout optional delay in ms
  1634. */
  1635. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1636. /** @hidden */
  1637. _addPendingData(data: any): void;
  1638. /** @hidden */
  1639. _removePendingData(data: any): void;
  1640. /**
  1641. * Returns the number of items waiting to be loaded
  1642. * @returns the number of items waiting to be loaded
  1643. */
  1644. getWaitingItemsCount(): number;
  1645. /**
  1646. * Returns a boolean indicating if the scene is still loading data
  1647. */
  1648. readonly isLoading: boolean;
  1649. /**
  1650. * Registers a function to be executed when the scene is ready
  1651. * @param {Function} func - the function to be executed
  1652. */
  1653. executeWhenReady(func: () => void): void;
  1654. /**
  1655. * Returns a promise that resolves when the scene is ready
  1656. * @returns A promise that resolves when the scene is ready
  1657. */
  1658. whenReadyAsync(): Promise<void>;
  1659. /** @hidden */
  1660. _checkIsReady(): void;
  1661. /**
  1662. * Will start the animation sequence of a given target
  1663. * @param target defines the target
  1664. * @param from defines from which frame should animation start
  1665. * @param to defines until which frame should animation run.
  1666. * @param weight defines the weight to apply to the animation (1.0 by default)
  1667. * @param loop defines if the animation loops
  1668. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1669. * @param onAnimationEnd defines the function to be executed when the animation ends
  1670. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1671. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1672. * @returns the animatable object created for this animation
  1673. */
  1674. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1675. /**
  1676. * Will start the animation sequence of a given target
  1677. * @param target defines the target
  1678. * @param from defines from which frame should animation start
  1679. * @param to defines until which frame should animation run.
  1680. * @param loop defines if the animation loops
  1681. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1682. * @param onAnimationEnd defines the function to be executed when the animation ends
  1683. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1684. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1685. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1686. * @returns the animatable object created for this animation
  1687. */
  1688. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1689. /**
  1690. * Begin a new animation on a given node
  1691. * @param target defines the target where the animation will take place
  1692. * @param animations defines the list of animations to start
  1693. * @param from defines the initial value
  1694. * @param to defines the final value
  1695. * @param loop defines if you want animation to loop (off by default)
  1696. * @param speedRatio defines the speed ratio to apply to all animations
  1697. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1698. * @returns the list of created animatables
  1699. */
  1700. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1701. /**
  1702. * Begin a new animation on a given node and its hierarchy
  1703. * @param target defines the root node where the animation will take place
  1704. * @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.
  1705. * @param animations defines the list of animations to start
  1706. * @param from defines the initial value
  1707. * @param to defines the final value
  1708. * @param loop defines if you want animation to loop (off by default)
  1709. * @param speedRatio defines the speed ratio to apply to all animations
  1710. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1711. * @returns the list of animatables created for all nodes
  1712. */
  1713. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1714. /**
  1715. * Gets the animatable associated with a specific target
  1716. * @param target defines the target of the animatable
  1717. * @returns the required animatable if found
  1718. */
  1719. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1720. /**
  1721. * Gets all animatables associated with a given target
  1722. * @param target defines the target to look animatables for
  1723. * @returns an array of Animatables
  1724. */
  1725. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1726. /**
  1727. * Gets all animatable attached to the scene
  1728. */
  1729. readonly animatables: Animatable[];
  1730. /**
  1731. * Will stop the animation of the given target
  1732. * @param target - the target
  1733. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1734. * @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)
  1735. */
  1736. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1737. /**
  1738. * Stops and removes all animations that have been applied to the scene
  1739. */
  1740. stopAllAnimations(): void;
  1741. private _animate();
  1742. /** @hidden */
  1743. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1744. private _processLateAnimationBindingsForMatrices(holder);
  1745. private _processLateAnimationBindingsForQuaternions(holder);
  1746. private _processLateAnimationBindings();
  1747. /** @hidden */
  1748. _switchToAlternateCameraConfiguration(active: boolean): void;
  1749. /**
  1750. * Gets the current view matrix
  1751. * @returns a Matrix
  1752. */
  1753. getViewMatrix(): Matrix;
  1754. /**
  1755. * Gets the current projection matrix
  1756. * @returns a Matrix
  1757. */
  1758. getProjectionMatrix(): Matrix;
  1759. /**
  1760. * Gets the current transform matrix
  1761. * @returns a Matrix made of View * Projection
  1762. */
  1763. getTransformMatrix(): Matrix;
  1764. /**
  1765. * Sets the current transform matrix
  1766. * @param view defines the View matrix to use
  1767. * @param projection defines the Projection matrix to use
  1768. */
  1769. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1770. /** @hidden */
  1771. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1772. /**
  1773. * Gets the uniform buffer used to store scene data
  1774. * @returns a UniformBuffer
  1775. */
  1776. getSceneUniformBuffer(): UniformBuffer;
  1777. /**
  1778. * Gets an unique (relatively to the current scene) Id
  1779. * @returns an unique number for the scene
  1780. */
  1781. getUniqueId(): number;
  1782. /**
  1783. * Add a mesh to the list of scene's meshes
  1784. * @param newMesh defines the mesh to add
  1785. * @param recursive if all child meshes should also be added to the scene
  1786. */
  1787. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1788. /**
  1789. * Remove a mesh for the list of scene's meshes
  1790. * @param toRemove defines the mesh to remove
  1791. * @param recursive if all child meshes should also be removed from the scene
  1792. * @returns the index where the mesh was in the mesh list
  1793. */
  1794. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1795. /**
  1796. * Add a transform node to the list of scene's transform nodes
  1797. * @param newTransformNode defines the transform node to add
  1798. */
  1799. addTransformNode(newTransformNode: TransformNode): void;
  1800. /**
  1801. * Remove a transform node for the list of scene's transform nodes
  1802. * @param toRemove defines the transform node to remove
  1803. * @returns the index where the transform node was in the transform node list
  1804. */
  1805. removeTransformNode(toRemove: TransformNode): number;
  1806. /**
  1807. * Remove a skeleton for the list of scene's skeletons
  1808. * @param toRemove defines the skeleton to remove
  1809. * @returns the index where the skeleton was in the skeleton list
  1810. */
  1811. removeSkeleton(toRemove: Skeleton): number;
  1812. /**
  1813. * Remove a morph target for the list of scene's morph targets
  1814. * @param toRemove defines the morph target to remove
  1815. * @returns the index where the morph target was in the morph target list
  1816. */
  1817. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1818. /**
  1819. * Remove a light for the list of scene's lights
  1820. * @param toRemove defines the light to remove
  1821. * @returns the index where the light was in the light list
  1822. */
  1823. removeLight(toRemove: Light): number;
  1824. /**
  1825. * Remove a camera for the list of scene's cameras
  1826. * @param toRemove defines the camera to remove
  1827. * @returns the index where the camera was in the camera list
  1828. */
  1829. removeCamera(toRemove: Camera): number;
  1830. /**
  1831. * Remove a particle system for the list of scene's particle systems
  1832. * @param toRemove defines the particle system to remove
  1833. * @returns the index where the particle system was in the particle system list
  1834. */
  1835. removeParticleSystem(toRemove: IParticleSystem): number;
  1836. /**
  1837. * Remove a animation for the list of scene's animations
  1838. * @param toRemove defines the animation to remove
  1839. * @returns the index where the animation was in the animation list
  1840. */
  1841. removeAnimation(toRemove: Animation): number;
  1842. /**
  1843. * Removes the given animation group from this scene.
  1844. * @param toRemove The animation group to remove
  1845. * @returns The index of the removed animation group
  1846. */
  1847. removeAnimationGroup(toRemove: AnimationGroup): number;
  1848. /**
  1849. * Removes the given multi-material from this scene.
  1850. * @param toRemove The multi-material to remove
  1851. * @returns The index of the removed multi-material
  1852. */
  1853. removeMultiMaterial(toRemove: MultiMaterial): number;
  1854. /**
  1855. * Removes the given material from this scene.
  1856. * @param toRemove The material to remove
  1857. * @returns The index of the removed material
  1858. */
  1859. removeMaterial(toRemove: Material): number;
  1860. /**
  1861. * Removes the given action manager from this scene.
  1862. * @param toRemove The action manager to remove
  1863. * @returns The index of the removed action manager
  1864. */
  1865. removeActionManager(toRemove: ActionManager): number;
  1866. /**
  1867. * Removes the given texture from this scene.
  1868. * @param toRemove The texture to remove
  1869. * @returns The index of the removed texture
  1870. */
  1871. removeTexture(toRemove: BaseTexture): number;
  1872. /**
  1873. * Adds the given light to this scene
  1874. * @param newLight The light to add
  1875. */
  1876. addLight(newLight: Light): void;
  1877. /**
  1878. * Sorts the list list based on light priorities
  1879. */
  1880. sortLightsByPriority(): void;
  1881. /**
  1882. * Adds the given camera to this scene
  1883. * @param newCamera The camera to add
  1884. */
  1885. addCamera(newCamera: Camera): void;
  1886. /**
  1887. * Adds the given skeleton to this scene
  1888. * @param newSkeleton The skeleton to add
  1889. */
  1890. addSkeleton(newSkeleton: Skeleton): void;
  1891. /**
  1892. * Adds the given particle system to this scene
  1893. * @param newParticleSystem The particle system to add
  1894. */
  1895. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1896. /**
  1897. * Adds the given animation to this scene
  1898. * @param newAnimation The animation to add
  1899. */
  1900. addAnimation(newAnimation: Animation): void;
  1901. /**
  1902. * Adds the given animation group to this scene.
  1903. * @param newAnimationGroup The animation group to add
  1904. */
  1905. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1906. /**
  1907. * Adds the given multi-material to this scene
  1908. * @param newMultiMaterial The multi-material to add
  1909. */
  1910. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1911. /**
  1912. * Adds the given material to this scene
  1913. * @param newMaterial The material to add
  1914. */
  1915. addMaterial(newMaterial: Material): void;
  1916. /**
  1917. * Adds the given morph target to this scene
  1918. * @param newMorphTargetManager The morph target to add
  1919. */
  1920. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1921. /**
  1922. * Adds the given geometry to this scene
  1923. * @param newGeometry The geometry to add
  1924. */
  1925. addGeometry(newGeometry: Geometry): void;
  1926. /**
  1927. * Adds the given action manager to this scene
  1928. * @param newActionManager The action manager to add
  1929. */
  1930. addActionManager(newActionManager: ActionManager): void;
  1931. /**
  1932. * Adds the given texture to this scene.
  1933. * @param newTexture The texture to add
  1934. */
  1935. addTexture(newTexture: BaseTexture): void;
  1936. /**
  1937. * Switch active camera
  1938. * @param newCamera defines the new active camera
  1939. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1940. */
  1941. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1942. /**
  1943. * sets the active camera of the scene using its ID
  1944. * @param id defines the camera's ID
  1945. * @return the new active camera or null if none found.
  1946. */
  1947. setActiveCameraByID(id: string): Nullable<Camera>;
  1948. /**
  1949. * sets the active camera of the scene using its name
  1950. * @param name defines the camera's name
  1951. * @returns the new active camera or null if none found.
  1952. */
  1953. setActiveCameraByName(name: string): Nullable<Camera>;
  1954. /**
  1955. * get an animation group using its name
  1956. * @param name defines the material's name
  1957. * @return the animation group or null if none found.
  1958. */
  1959. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1960. /**
  1961. * get a material using its id
  1962. * @param id defines the material's ID
  1963. * @return the material or null if none found.
  1964. */
  1965. getMaterialByID(id: string): Nullable<Material>;
  1966. /**
  1967. * Gets a material using its name
  1968. * @param name defines the material's name
  1969. * @return the material or null if none found.
  1970. */
  1971. getMaterialByName(name: string): Nullable<Material>;
  1972. /**
  1973. * Gets a camera using its id
  1974. * @param id defines the id to look for
  1975. * @returns the camera or null if not found
  1976. */
  1977. getCameraByID(id: string): Nullable<Camera>;
  1978. /**
  1979. * Gets a camera using its unique id
  1980. * @param uniqueId defines the unique id to look for
  1981. * @returns the camera or null if not found
  1982. */
  1983. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1984. /**
  1985. * Gets a camera using its name
  1986. * @param name defines the camera's name
  1987. * @return the camera or null if none found.
  1988. */
  1989. getCameraByName(name: string): Nullable<Camera>;
  1990. /**
  1991. * Gets a bone using its id
  1992. * @param id defines the bone's id
  1993. * @return the bone or null if not found
  1994. */
  1995. getBoneByID(id: string): Nullable<Bone>;
  1996. /**
  1997. * Gets a bone using its id
  1998. * @param name defines the bone's name
  1999. * @return the bone or null if not found
  2000. */
  2001. getBoneByName(name: string): Nullable<Bone>;
  2002. /**
  2003. * Gets a light node using its name
  2004. * @param name defines the the light's name
  2005. * @return the light or null if none found.
  2006. */
  2007. getLightByName(name: string): Nullable<Light>;
  2008. /**
  2009. * Gets a light node using its id
  2010. * @param id defines the light's id
  2011. * @return the light or null if none found.
  2012. */
  2013. getLightByID(id: string): Nullable<Light>;
  2014. /**
  2015. * Gets a light node using its scene-generated unique ID
  2016. * @param uniqueId defines the light's unique id
  2017. * @return the light or null if none found.
  2018. */
  2019. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2020. /**
  2021. * Gets a particle system by id
  2022. * @param id defines the particle system id
  2023. * @return the corresponding system or null if none found
  2024. */
  2025. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2026. /**
  2027. * Gets a geometry using its ID
  2028. * @param id defines the geometry's id
  2029. * @return the geometry or null if none found.
  2030. */
  2031. getGeometryByID(id: string): Nullable<Geometry>;
  2032. /**
  2033. * Add a new geometry to this scene
  2034. * @param geometry defines the geometry to be added to the scene.
  2035. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2036. * @return a boolean defining if the geometry was added or not
  2037. */
  2038. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2039. /**
  2040. * Removes an existing geometry
  2041. * @param geometry defines the geometry to be removed from the scene
  2042. * @return a boolean defining if the geometry was removed or not
  2043. */
  2044. removeGeometry(geometry: Geometry): boolean;
  2045. /**
  2046. * Gets the list of geometries attached to the scene
  2047. * @returns an array of Geometry
  2048. */
  2049. getGeometries(): Geometry[];
  2050. /**
  2051. * Gets the first added mesh found of a given ID
  2052. * @param id defines the id to search for
  2053. * @return the mesh found or null if not found at all
  2054. */
  2055. getMeshByID(id: string): Nullable<AbstractMesh>;
  2056. /**
  2057. * Gets a list of meshes using their id
  2058. * @param id defines the id to search for
  2059. * @returns a list of meshes
  2060. */
  2061. getMeshesByID(id: string): Array<AbstractMesh>;
  2062. /**
  2063. * Gets the first added transform node found of a given ID
  2064. * @param id defines the id to search for
  2065. * @return the found transform node or null if not found at all.
  2066. */
  2067. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2068. /**
  2069. * Gets a list of transform nodes using their id
  2070. * @param id defines the id to search for
  2071. * @returns a list of transform nodes
  2072. */
  2073. getTransformNodesByID(id: string): Array<TransformNode>;
  2074. /**
  2075. * Gets a mesh with its auto-generated unique id
  2076. * @param uniqueId defines the unique id to search for
  2077. * @return the found mesh or null if not found at all.
  2078. */
  2079. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2080. /**
  2081. * Gets a the last added mesh using a given id
  2082. * @param id defines the id to search for
  2083. * @return the found mesh or null if not found at all.
  2084. */
  2085. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2086. /**
  2087. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2088. * @param id defines the id to search for
  2089. * @return the found node or null if not found at all
  2090. */
  2091. getLastEntryByID(id: string): Nullable<Node>;
  2092. /**
  2093. * Gets a node (Mesh, Camera, Light) using a given id
  2094. * @param id defines the id to search for
  2095. * @return the found node or null if not found at all
  2096. */
  2097. getNodeByID(id: string): Nullable<Node>;
  2098. /**
  2099. * Gets a node (Mesh, Camera, Light) using a given name
  2100. * @param name defines the name to search for
  2101. * @return the found node or null if not found at all.
  2102. */
  2103. getNodeByName(name: string): Nullable<Node>;
  2104. /**
  2105. * Gets a mesh using a given name
  2106. * @param name defines the name to search for
  2107. * @return the found mesh or null if not found at all.
  2108. */
  2109. getMeshByName(name: string): Nullable<AbstractMesh>;
  2110. /**
  2111. * Gets a transform node using a given name
  2112. * @param name defines the name to search for
  2113. * @return the found transform node or null if not found at all.
  2114. */
  2115. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2116. /**
  2117. * Gets a sound using a given name
  2118. * @param name defines the name to search for
  2119. * @return the found sound or null if not found at all.
  2120. */
  2121. getSoundByName(name: string): Nullable<Sound>;
  2122. /**
  2123. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2124. * @param id defines the id to search for
  2125. * @return the found skeleton or null if not found at all.
  2126. */
  2127. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2128. /**
  2129. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2130. * @param id defines the id to search for
  2131. * @return the found skeleton or null if not found at all.
  2132. */
  2133. getSkeletonById(id: string): Nullable<Skeleton>;
  2134. /**
  2135. * Gets a skeleton using a given name
  2136. * @param name defines the name to search for
  2137. * @return the found skeleton or null if not found at all.
  2138. */
  2139. getSkeletonByName(name: string): Nullable<Skeleton>;
  2140. /**
  2141. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2142. * @param id defines the id to search for
  2143. * @return the found morph target manager or null if not found at all.
  2144. */
  2145. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2146. /**
  2147. * Gets a boolean indicating if the given mesh is active
  2148. * @param mesh defines the mesh to look for
  2149. * @returns true if the mesh is in the active list
  2150. */
  2151. isActiveMesh(mesh: AbstractMesh): boolean;
  2152. /**
  2153. * Return a unique id as a string which can serve as an identifier for the scene
  2154. */
  2155. readonly uid: string;
  2156. /**
  2157. * Add an externaly attached data from its key.
  2158. * This method call will fail and return false, if such key already exists.
  2159. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2160. * @param key the unique key that identifies the data
  2161. * @param data the data object to associate to the key for this Engine instance
  2162. * @return true if no such key were already present and the data was added successfully, false otherwise
  2163. */
  2164. addExternalData<T>(key: string, data: T): boolean;
  2165. /**
  2166. * Get an externaly attached data from its key
  2167. * @param key the unique key that identifies the data
  2168. * @return the associated data, if present (can be null), or undefined if not present
  2169. */
  2170. getExternalData<T>(key: string): Nullable<T>;
  2171. /**
  2172. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2173. * @param key the unique key that identifies the data
  2174. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2175. * @return the associated data, can be null if the factory returned null.
  2176. */
  2177. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2178. /**
  2179. * Remove an externaly attached data from the Engine instance
  2180. * @param key the unique key that identifies the data
  2181. * @return true if the data was successfully removed, false if it doesn't exist
  2182. */
  2183. removeExternalData(key: string): boolean;
  2184. private _evaluateSubMesh(subMesh, mesh);
  2185. /**
  2186. * Clear the processed materials smart array preventing retention point in material dispose.
  2187. */
  2188. freeProcessedMaterials(): void;
  2189. /**
  2190. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2191. */
  2192. freeActiveMeshes(): void;
  2193. /**
  2194. * Clear the info related to rendering groups preventing retention points during dispose.
  2195. */
  2196. freeRenderingGroups(): void;
  2197. /** @hidden */
  2198. _isInIntermediateRendering(): boolean;
  2199. private _activeMeshCandidateProvider;
  2200. /**
  2201. * Defines the current active mesh candidate provider
  2202. * @param provider defines the provider to use
  2203. */
  2204. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2205. /**
  2206. * Gets the current active mesh candidate provider
  2207. * @returns the current active mesh candidate provider
  2208. */
  2209. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2210. private _activeMeshesFrozen;
  2211. /**
  2212. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2213. * @returns the current scene
  2214. */
  2215. freezeActiveMeshes(): Scene;
  2216. /**
  2217. * Use this function to restart evaluating active meshes on every frame
  2218. * @returns the current scene
  2219. */
  2220. unfreezeActiveMeshes(): Scene;
  2221. private _evaluateActiveMeshes();
  2222. private _activeMesh(sourceMesh, mesh);
  2223. /**
  2224. * Update the transform matrix to update from the current active camera
  2225. * @param force defines a boolean used to force the update even if cache is up to date
  2226. */
  2227. updateTransformMatrix(force?: boolean): void;
  2228. /**
  2229. * 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)
  2230. * @param alternateCamera defines the camera to use
  2231. */
  2232. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2233. private _renderForCamera(camera, rigParent?);
  2234. private _processSubCameras(camera);
  2235. private _checkIntersections();
  2236. /**
  2237. * Render the scene
  2238. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2239. */
  2240. render(updateCameras?: boolean): void;
  2241. private _updateAudioParameters();
  2242. /**
  2243. * Gets or sets if audio support is enabled
  2244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2245. */
  2246. audioEnabled: boolean;
  2247. private _disableAudio();
  2248. private _enableAudio();
  2249. /**
  2250. * Gets or sets if audio will be output to headphones
  2251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2252. */
  2253. headphone: boolean;
  2254. private _switchAudioModeForHeadphones();
  2255. private _switchAudioModeForNormalSpeakers();
  2256. /**
  2257. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2258. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2259. * @returns the created depth renderer
  2260. */
  2261. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2262. /**
  2263. * Disables a depth renderer for a given camera
  2264. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2265. */
  2266. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2267. /**
  2268. * Enables a GeometryBufferRender and associates it with the scene
  2269. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2270. * @returns the GeometryBufferRenderer
  2271. */
  2272. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2273. /**
  2274. * Disables the GeometryBufferRender associated with the scene
  2275. */
  2276. disableGeometryBufferRenderer(): void;
  2277. /**
  2278. * Freeze all materials
  2279. * A frozen material will not be updatable but should be faster to render
  2280. */
  2281. freezeMaterials(): void;
  2282. /**
  2283. * Unfreeze all materials
  2284. * A frozen material will not be updatable but should be faster to render
  2285. */
  2286. unfreezeMaterials(): void;
  2287. /**
  2288. * Releases all held ressources
  2289. */
  2290. dispose(): void;
  2291. /**
  2292. * Gets if the scene is already disposed
  2293. */
  2294. readonly isDisposed: boolean;
  2295. /**
  2296. * Releases sounds & soundtracks
  2297. */
  2298. disposeSounds(): void;
  2299. /**
  2300. * Call this function to reduce memory footprint of the scene.
  2301. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2302. */
  2303. clearCachedVertexData(): void;
  2304. /**
  2305. * This function will remove the local cached buffer data from texture.
  2306. * It will save memory but will prevent the texture from being rebuilt
  2307. */
  2308. cleanCachedTextureBuffer(): void;
  2309. /**
  2310. * Get the world extend vectors with an optional filter
  2311. *
  2312. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2313. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2314. */
  2315. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2316. min: Vector3;
  2317. max: Vector3;
  2318. };
  2319. /**
  2320. * Creates or updates the octree used to boost selection (picking)
  2321. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2322. * @param maxCapacity defines the maximum capacity per leaf
  2323. * @param maxDepth defines the maximum depth of the octree
  2324. * @returns an octree of AbstractMesh
  2325. */
  2326. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2327. /**
  2328. * Creates a ray that can be used to pick in the scene
  2329. * @param x defines the x coordinate of the origin (on-screen)
  2330. * @param y defines the y coordinate of the origin (on-screen)
  2331. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2332. * @param camera defines the camera to use for the picking
  2333. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2334. * @returns a Ray
  2335. */
  2336. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2337. /**
  2338. * Creates a ray that can be used to pick in the scene
  2339. * @param x defines the x coordinate of the origin (on-screen)
  2340. * @param y defines the y coordinate of the origin (on-screen)
  2341. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2342. * @param result defines the ray where to store the picking ray
  2343. * @param camera defines the camera to use for the picking
  2344. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2345. * @returns the current scene
  2346. */
  2347. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2348. /**
  2349. * Creates a ray that can be used to pick in the scene
  2350. * @param x defines the x coordinate of the origin (on-screen)
  2351. * @param y defines the y coordinate of the origin (on-screen)
  2352. * @param camera defines the camera to use for the picking
  2353. * @returns a Ray
  2354. */
  2355. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2356. /**
  2357. * Creates a ray that can be used to pick in the scene
  2358. * @param x defines the x coordinate of the origin (on-screen)
  2359. * @param y defines the y coordinate of the origin (on-screen)
  2360. * @param result defines the ray where to store the picking ray
  2361. * @param camera defines the camera to use for the picking
  2362. * @returns the current scene
  2363. */
  2364. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2365. private _internalPick(rayFunction, predicate?, fastCheck?);
  2366. private _internalMultiPick(rayFunction, predicate?);
  2367. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2368. private _tempPickingRay;
  2369. /** Launch a ray to try to pick a mesh in the scene
  2370. * @param x position on screen
  2371. * @param y position on screen
  2372. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2373. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2374. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2375. * @returns a PickingInfo
  2376. */
  2377. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2378. /** Launch a ray to try to pick a sprite in the scene
  2379. * @param x position on screen
  2380. * @param y position on screen
  2381. * @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
  2382. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2383. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2384. * @returns a PickingInfo
  2385. */
  2386. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2387. private _cachedRayForTransform;
  2388. /** Use the given ray to pick a mesh in the scene
  2389. * @param ray The ray to use to pick meshes
  2390. * @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
  2391. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2392. * @returns a PickingInfo
  2393. */
  2394. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2395. /**
  2396. * Launch a ray to try to pick a mesh in the scene
  2397. * @param x X position on screen
  2398. * @param y Y position on screen
  2399. * @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
  2400. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2401. * @returns an array of PickingInfo
  2402. */
  2403. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2404. /**
  2405. * Launch a ray to try to pick a mesh in the scene
  2406. * @param ray Ray to use
  2407. * @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
  2408. * @returns an array of PickingInfo
  2409. */
  2410. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2411. /**
  2412. * Force the value of meshUnderPointer
  2413. * @param mesh defines the mesh to use
  2414. */
  2415. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2416. /**
  2417. * Gets the mesh under the pointer
  2418. * @returns a Mesh or null if no mesh is under the pointer
  2419. */
  2420. getPointerOverMesh(): Nullable<AbstractMesh>;
  2421. /**
  2422. * Force the sprite under the pointer
  2423. * @param sprite defines the sprite to use
  2424. */
  2425. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2426. /**
  2427. * Gets the sprite under the pointer
  2428. * @returns a Sprite or null if no sprite is under the pointer
  2429. */
  2430. getPointerOverSprite(): Nullable<Sprite>;
  2431. /**
  2432. * Gets the current physics engine
  2433. * @returns a PhysicsEngine or null if none attached
  2434. */
  2435. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2436. /**
  2437. * Enables physics to the current scene
  2438. * @param gravity defines the scene's gravity for the physics engine
  2439. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2440. * @return a boolean indicating if the physics engine was initialized
  2441. */
  2442. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2443. /**
  2444. * Disables and disposes the physics engine associated with the scene
  2445. */
  2446. disablePhysicsEngine(): void;
  2447. /**
  2448. * Gets a boolean indicating if there is an active physics engine
  2449. * @returns a boolean indicating if there is an active physics engine
  2450. */
  2451. isPhysicsEnabled(): boolean;
  2452. /**
  2453. * Deletes a physics compound impostor
  2454. * @param compound defines the compound to delete
  2455. */
  2456. deleteCompoundImpostor(compound: any): void;
  2457. /** @hidden */
  2458. _rebuildGeometries(): void;
  2459. /** @hidden */
  2460. _rebuildTextures(): void;
  2461. /**
  2462. * Creates a default light for the scene.
  2463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2464. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2465. */
  2466. createDefaultLight(replace?: boolean): void;
  2467. /**
  2468. * Creates a default camera for the scene.
  2469. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2470. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2471. * @param replace has default false, when true replaces the active camera in the scene
  2472. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2473. */
  2474. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2475. /**
  2476. * Creates a default camera and a default light.
  2477. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2478. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2479. * @param replace has the default false, when true replaces the active camera/light in the scene
  2480. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2481. */
  2482. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2483. /**
  2484. * Creates a new sky box
  2485. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2486. * @param environmentTexture defines the texture to use as environment texture
  2487. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2488. * @param scale defines the overall scale of the skybox
  2489. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2490. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2491. * @returns a new mesh holding the sky box
  2492. */
  2493. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2494. /**
  2495. * Creates a new environment
  2496. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2497. * @param options defines the options you can use to configure the environment
  2498. * @returns the new EnvironmentHelper
  2499. */
  2500. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2501. /**
  2502. * Creates a new VREXperienceHelper
  2503. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2504. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2505. * @returns a new VREXperienceHelper
  2506. */
  2507. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2508. private _getByTags(list, tagsQuery, forEach?);
  2509. /**
  2510. * Get a list of meshes by tags
  2511. * @param tagsQuery defines the tags query to use
  2512. * @param forEach defines a predicate used to filter results
  2513. * @returns an array of Mesh
  2514. */
  2515. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2516. /**
  2517. * Get a list of cameras by tags
  2518. * @param tagsQuery defines the tags query to use
  2519. * @param forEach defines a predicate used to filter results
  2520. * @returns an array of Camera
  2521. */
  2522. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2523. /**
  2524. * Get a list of lights by tags
  2525. * @param tagsQuery defines the tags query to use
  2526. * @param forEach defines a predicate used to filter results
  2527. * @returns an array of Light
  2528. */
  2529. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2530. /**
  2531. * Get a list of materials by tags
  2532. * @param tagsQuery defines the tags query to use
  2533. * @param forEach defines a predicate used to filter results
  2534. * @returns an array of Material
  2535. */
  2536. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2537. /**
  2538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2539. * This allowed control for front to back rendering or reversly depending of the special needs.
  2540. *
  2541. * @param renderingGroupId The rendering group id corresponding to its index
  2542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2545. */
  2546. 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;
  2547. /**
  2548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2549. *
  2550. * @param renderingGroupId The rendering group id corresponding to its index
  2551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2554. */
  2555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2556. /**
  2557. * Will flag all materials as dirty to trigger new shader compilation
  2558. * @param flag defines the flag used to specify which material part must be marked as dirty
  2559. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2560. */
  2561. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2562. /** @hidden */
  2563. _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;
  2564. /** @hidden */
  2565. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2566. }
  2567. }
  2568. declare module BABYLON {
  2569. /**
  2570. * Groups all the scene component constants in one place to ease maintenance.
  2571. * @hidden
  2572. */
  2573. class SceneComponentConstants {
  2574. static readonly NAME_EFFECTLAYER: string;
  2575. static readonly NAME_LAYER: string;
  2576. static readonly NAME_LENSFLARESYSTEM: string;
  2577. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2578. static readonly NAME_PARTICLESYSTEM: string;
  2579. static readonly NAME_GAMEPAD: string;
  2580. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2581. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2582. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2583. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2584. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2585. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2586. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2587. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2588. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2590. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2591. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2592. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2593. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2594. }
  2595. /**
  2596. * This represents a scene component.
  2597. *
  2598. * This is used to decouple the dependency the scene is having on the different workloads like
  2599. * layers, post processes...
  2600. */
  2601. interface ISceneComponent {
  2602. /**
  2603. * The name of the component. Each component must have a unique name.
  2604. */
  2605. name: string;
  2606. /**
  2607. * The scene the component belongs to.
  2608. */
  2609. scene: Scene;
  2610. /**
  2611. * Register the component to one instance of a scene.
  2612. */
  2613. register(): void;
  2614. /**
  2615. * Rebuilds the elements related to this component in case of
  2616. * context lost for instance.
  2617. */
  2618. rebuild(): void;
  2619. /**
  2620. * Disposes the component and the associated ressources.
  2621. */
  2622. dispose(): void;
  2623. }
  2624. /**
  2625. * This represents a SERIALIZABLE scene component.
  2626. *
  2627. * This extends Scene Component to add Serialization methods on top.
  2628. */
  2629. interface ISceneSerializableComponent extends ISceneComponent {
  2630. /**
  2631. * Adds all the element from the container to the scene
  2632. * @param container the container holding the elements
  2633. */
  2634. addFromContainer(container: AbstractScene): void;
  2635. /**
  2636. * Removes all the elements in the container from the scene
  2637. * @param container contains the elements to remove
  2638. */
  2639. removeFromContainer(container: AbstractScene): void;
  2640. /**
  2641. * Serializes the component data to the specified json object
  2642. * @param serializationObject The object to serialize to
  2643. */
  2644. serialize(serializationObject: any): void;
  2645. }
  2646. /**
  2647. * Strong typing of a Mesh related stage step action
  2648. */
  2649. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2650. /**
  2651. * Strong typing of a Evaluate Sub Mesh related stage step action
  2652. */
  2653. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2654. /**
  2655. * Strong typing of a Active Mesh related stage step action
  2656. */
  2657. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2658. /**
  2659. * Strong typing of a Camera related stage step action
  2660. */
  2661. type CameraStageAction = (camera: Camera) => void;
  2662. /**
  2663. * Strong typing of a RenderingGroup related stage step action
  2664. */
  2665. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2666. /**
  2667. * Strong typing of a simple stage step action
  2668. */
  2669. type SimpleStageAction = () => void;
  2670. /**
  2671. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2672. * @hidden
  2673. */
  2674. class Stage<T extends Function> extends Array<{
  2675. index: number;
  2676. component: ISceneComponent;
  2677. action: T;
  2678. }> {
  2679. /**
  2680. * Hide ctor from the rest of the world.
  2681. * @param items The items to add.
  2682. */
  2683. private constructor();
  2684. /**
  2685. * Creates a new Stage.
  2686. * @returns A new instance of a Stage
  2687. */
  2688. static Create<T extends Function>(): Stage<T>;
  2689. /**
  2690. * Registers a step in an ordered way in the targeted stage.
  2691. * @param index Defines the position to register the step in
  2692. * @param component Defines the component attached to the step
  2693. * @param action Defines the action to launch during the step
  2694. */
  2695. registerStep(index: number, component: ISceneComponent, action: T): void;
  2696. /**
  2697. * Clears all the steps from the stage.
  2698. */
  2699. clear(): void;
  2700. }
  2701. }
  2702. declare module BABYLON {
  2703. type Nullable<T> = T | null;
  2704. type float = number;
  2705. type double = number;
  2706. type int = number;
  2707. type FloatArray = number[] | Float32Array;
  2708. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2709. /**
  2710. * Alias for types that can be used by a Buffer or VertexBuffer.
  2711. */
  2712. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2713. }
  2714. declare module BABYLON {
  2715. /**
  2716. * The action to be carried out following a trigger
  2717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2718. */
  2719. class Action {
  2720. /** the trigger, with or without parameters, for the action */
  2721. triggerOptions: any;
  2722. /**
  2723. * Trigger for the action
  2724. */
  2725. trigger: number;
  2726. /**
  2727. * Internal only - manager for action
  2728. * @hidden
  2729. */
  2730. _actionManager: ActionManager;
  2731. private _nextActiveAction;
  2732. private _child;
  2733. private _condition?;
  2734. private _triggerParameter;
  2735. /**
  2736. * An event triggered prior to action being executed.
  2737. */
  2738. onBeforeExecuteObservable: Observable<Action>;
  2739. /**
  2740. * Creates a new Action
  2741. * @param triggerOptions the trigger, with or without parameters, for the action
  2742. * @param condition an optional determinant of action
  2743. */
  2744. constructor(
  2745. /** the trigger, with or without parameters, for the action */
  2746. triggerOptions: any, condition?: Condition);
  2747. /**
  2748. * Internal only
  2749. * @hidden
  2750. */
  2751. _prepare(): void;
  2752. /**
  2753. * Gets the trigger parameters
  2754. * @returns the trigger parameters
  2755. */
  2756. getTriggerParameter(): any;
  2757. /**
  2758. * Internal only - executes current action event
  2759. * @hidden
  2760. */
  2761. _executeCurrent(evt?: ActionEvent): void;
  2762. /**
  2763. * Execute placeholder for child classes
  2764. * @param evt optional action event
  2765. */
  2766. execute(evt?: ActionEvent): void;
  2767. /**
  2768. * Skips to next active action
  2769. */
  2770. skipToNextActiveAction(): void;
  2771. /**
  2772. * Adds action to chain of actions, may be a DoNothingAction
  2773. * @param action defines the next action to execute
  2774. * @returns The action passed in
  2775. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2776. */
  2777. then(action: Action): Action;
  2778. /**
  2779. * Internal only
  2780. * @hidden
  2781. */
  2782. _getProperty(propertyPath: string): string;
  2783. /**
  2784. * Internal only
  2785. * @hidden
  2786. */
  2787. _getEffectiveTarget(target: any, propertyPath: string): any;
  2788. /**
  2789. * Serialize placeholder for child classes
  2790. * @param parent of child
  2791. * @returns the serialized object
  2792. */
  2793. serialize(parent: any): any;
  2794. /**
  2795. * Internal only called by serialize
  2796. * @hidden
  2797. */
  2798. protected _serialize(serializedAction: any, parent?: any): any;
  2799. /**
  2800. * Internal only
  2801. * @hidden
  2802. */
  2803. static _SerializeValueAsString: (value: any) => string;
  2804. /**
  2805. * Internal only
  2806. * @hidden
  2807. */
  2808. static _GetTargetProperty: (target: Scene | Node) => {
  2809. name: string;
  2810. targetType: string;
  2811. value: string;
  2812. };
  2813. }
  2814. }
  2815. declare module BABYLON {
  2816. /**
  2817. * ActionEvent is the event being sent when an action is triggered.
  2818. */
  2819. class ActionEvent {
  2820. /** The mesh or sprite that triggered the action */
  2821. source: any;
  2822. /** The X mouse cursor position at the time of the event */
  2823. pointerX: number;
  2824. /** The Y mouse cursor position at the time of the event */
  2825. pointerY: number;
  2826. /** The mesh that is currently pointed at (can be null) */
  2827. meshUnderPointer: Nullable<AbstractMesh>;
  2828. /** the original (browser) event that triggered the ActionEvent */
  2829. sourceEvent: any;
  2830. /** additional data for the event */
  2831. additionalData: any;
  2832. /**
  2833. * Creates a new ActionEvent
  2834. * @param source The mesh or sprite that triggered the action
  2835. * @param pointerX The X mouse cursor position at the time of the event
  2836. * @param pointerY The Y mouse cursor position at the time of the event
  2837. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2838. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2839. * @param additionalData additional data for the event
  2840. */
  2841. constructor(
  2842. /** The mesh or sprite that triggered the action */
  2843. source: any,
  2844. /** The X mouse cursor position at the time of the event */
  2845. pointerX: number,
  2846. /** The Y mouse cursor position at the time of the event */
  2847. pointerY: number,
  2848. /** The mesh that is currently pointed at (can be null) */
  2849. meshUnderPointer: Nullable<AbstractMesh>,
  2850. /** the original (browser) event that triggered the ActionEvent */
  2851. sourceEvent?: any,
  2852. /** additional data for the event */
  2853. additionalData?: any);
  2854. /**
  2855. * Helper function to auto-create an ActionEvent from a source mesh.
  2856. * @param source The source mesh that triggered the event
  2857. * @param evt The original (browser) event
  2858. * @param additionalData additional data for the event
  2859. * @returns the new ActionEvent
  2860. */
  2861. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2862. /**
  2863. * Helper function to auto-create an ActionEvent from a source sprite
  2864. * @param source The source sprite that triggered the event
  2865. * @param scene Scene associated with the sprite
  2866. * @param evt The original (browser) event
  2867. * @param additionalData additional data for the event
  2868. * @returns the new ActionEvent
  2869. */
  2870. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2871. /**
  2872. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2873. * @param scene the scene where the event occurred
  2874. * @param evt The original (browser) event
  2875. * @returns the new ActionEvent
  2876. */
  2877. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2878. /**
  2879. * Helper function to auto-create an ActionEvent from a primitive
  2880. * @param prim defines the target primitive
  2881. * @param pointerPos defines the pointer position
  2882. * @param evt The original (browser) event
  2883. * @param additionalData additional data for the event
  2884. * @returns the new ActionEvent
  2885. */
  2886. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2887. }
  2888. /**
  2889. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2890. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2892. */
  2893. class ActionManager {
  2894. private static _NothingTrigger;
  2895. private static _OnPickTrigger;
  2896. private static _OnLeftPickTrigger;
  2897. private static _OnRightPickTrigger;
  2898. private static _OnCenterPickTrigger;
  2899. private static _OnPickDownTrigger;
  2900. private static _OnDoublePickTrigger;
  2901. private static _OnPickUpTrigger;
  2902. private static _OnLongPressTrigger;
  2903. private static _OnPointerOverTrigger;
  2904. private static _OnPointerOutTrigger;
  2905. private static _OnEveryFrameTrigger;
  2906. private static _OnIntersectionEnterTrigger;
  2907. private static _OnIntersectionExitTrigger;
  2908. private static _OnKeyDownTrigger;
  2909. private static _OnKeyUpTrigger;
  2910. private static _OnPickOutTrigger;
  2911. /**
  2912. * Nothing
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly NothingTrigger: number;
  2916. /**
  2917. * On pick
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnPickTrigger: number;
  2921. /**
  2922. * On left pick
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnLeftPickTrigger: number;
  2926. /**
  2927. * On right pick
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnRightPickTrigger: number;
  2931. /**
  2932. * On center pick
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnCenterPickTrigger: number;
  2936. /**
  2937. * On pick down
  2938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2939. */
  2940. static readonly OnPickDownTrigger: number;
  2941. /**
  2942. * On double pick
  2943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2944. */
  2945. static readonly OnDoublePickTrigger: number;
  2946. /**
  2947. * On pick up
  2948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2949. */
  2950. static readonly OnPickUpTrigger: number;
  2951. /**
  2952. * On pick out.
  2953. * This trigger will only be raised if you also declared a OnPickDown
  2954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2955. */
  2956. static readonly OnPickOutTrigger: number;
  2957. /**
  2958. * On long press
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly OnLongPressTrigger: number;
  2962. /**
  2963. * On pointer over
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnPointerOverTrigger: number;
  2967. /**
  2968. * On pointer out
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnPointerOutTrigger: number;
  2972. /**
  2973. * On every frame
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2975. */
  2976. static readonly OnEveryFrameTrigger: number;
  2977. /**
  2978. * On intersection enter
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly OnIntersectionEnterTrigger: number;
  2982. /**
  2983. * On intersection exit
  2984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2985. */
  2986. static readonly OnIntersectionExitTrigger: number;
  2987. /**
  2988. * On key down
  2989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2990. */
  2991. static readonly OnKeyDownTrigger: number;
  2992. /**
  2993. * On key up
  2994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2995. */
  2996. static readonly OnKeyUpTrigger: number;
  2997. /** Gets the list of active triggers */
  2998. static Triggers: {
  2999. [key: string]: number;
  3000. };
  3001. /** Gets the list of actions */
  3002. actions: Action[];
  3003. /** Gets the cursor to use when hovering items */
  3004. hoverCursor: string;
  3005. private _scene;
  3006. /**
  3007. * Creates a new action manager
  3008. * @param scene defines the hosting scene
  3009. */
  3010. constructor(scene: Scene);
  3011. /**
  3012. * Releases all associated resources
  3013. */
  3014. dispose(): void;
  3015. /**
  3016. * Gets hosting scene
  3017. * @returns the hosting scene
  3018. */
  3019. getScene(): Scene;
  3020. /**
  3021. * Does this action manager handles actions of any of the given triggers
  3022. * @param triggers defines the triggers to be tested
  3023. * @return a boolean indicating whether one (or more) of the triggers is handled
  3024. */
  3025. hasSpecificTriggers(triggers: number[]): boolean;
  3026. /**
  3027. * Does this action manager handles actions of a given trigger
  3028. * @param trigger defines the trigger to be tested
  3029. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3030. * @return whether the trigger is handled
  3031. */
  3032. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3033. /**
  3034. * Does this action manager has pointer triggers
  3035. */
  3036. readonly hasPointerTriggers: boolean;
  3037. /**
  3038. * Does this action manager has pick triggers
  3039. */
  3040. readonly hasPickTriggers: boolean;
  3041. /**
  3042. * Does exist one action manager with at least one trigger
  3043. **/
  3044. static readonly HasTriggers: boolean;
  3045. /**
  3046. * Does exist one action manager with at least one pick trigger
  3047. **/
  3048. static readonly HasPickTriggers: boolean;
  3049. /**
  3050. * Does exist one action manager that handles actions of a given trigger
  3051. * @param trigger defines the trigger to be tested
  3052. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3053. **/
  3054. static HasSpecificTrigger(trigger: number): boolean;
  3055. /**
  3056. * Registers an action to this action manager
  3057. * @param action defines the action to be registered
  3058. * @return the action amended (prepared) after registration
  3059. */
  3060. registerAction(action: Action): Nullable<Action>;
  3061. /**
  3062. * Unregisters an action to this action manager
  3063. * @param action defines the action to be unregistered
  3064. * @return a boolean indicating whether the action has been unregistered
  3065. */
  3066. unregisterAction(action: Action): Boolean;
  3067. /**
  3068. * Process a specific trigger
  3069. * @param trigger defines the trigger to process
  3070. * @param evt defines the event details to be processed
  3071. */
  3072. processTrigger(trigger: number, evt?: ActionEvent): void;
  3073. /** @hidden */
  3074. _getEffectiveTarget(target: any, propertyPath: string): any;
  3075. /** @hidden */
  3076. _getProperty(propertyPath: string): string;
  3077. /**
  3078. * Serialize this manager to a JSON object
  3079. * @param name defines the property name to store this manager
  3080. * @returns a JSON representation of this manager
  3081. */
  3082. serialize(name: string): any;
  3083. /**
  3084. * Creates a new ActionManager from a JSON data
  3085. * @param parsedActions defines the JSON data to read from
  3086. * @param object defines the hosting mesh
  3087. * @param scene defines the hosting scene
  3088. */
  3089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3090. /**
  3091. * Get a trigger name by index
  3092. * @param trigger defines the trigger index
  3093. * @returns a trigger name
  3094. */
  3095. static GetTriggerName(trigger: number): string;
  3096. }
  3097. }
  3098. declare module BABYLON {
  3099. /**
  3100. * A Condition applied to an Action
  3101. */
  3102. class Condition {
  3103. /**
  3104. * Internal only - manager for action
  3105. * @hidden
  3106. */
  3107. _actionManager: ActionManager;
  3108. /**
  3109. * Internal only
  3110. * @hidden
  3111. */
  3112. _evaluationId: number;
  3113. /**
  3114. * Internal only
  3115. * @hidden
  3116. */
  3117. _currentResult: boolean;
  3118. /**
  3119. * Creates a new Condition
  3120. * @param actionManager the manager of the action the condition is applied to
  3121. */
  3122. constructor(actionManager: ActionManager);
  3123. /**
  3124. * Check if the current condition is valid
  3125. * @returns a boolean
  3126. */
  3127. isValid(): boolean;
  3128. /**
  3129. * Internal only
  3130. * @hidden
  3131. */
  3132. _getProperty(propertyPath: string): string;
  3133. /**
  3134. * Internal only
  3135. * @hidden
  3136. */
  3137. _getEffectiveTarget(target: any, propertyPath: string): any;
  3138. /**
  3139. * Serialize placeholder for child classes
  3140. * @returns the serialized object
  3141. */
  3142. serialize(): any;
  3143. /**
  3144. * Internal only
  3145. * @hidden
  3146. */
  3147. protected _serialize(serializedCondition: any): any;
  3148. }
  3149. /**
  3150. * Defines specific conditional operators as extensions of Condition
  3151. */
  3152. class ValueCondition extends Condition {
  3153. /** path to specify the property of the target the conditional operator uses */
  3154. propertyPath: string;
  3155. /** the value compared by the conditional operator against the current value of the property */
  3156. value: any;
  3157. /** the conditional operator, default ValueCondition.IsEqual */
  3158. operator: number;
  3159. /**
  3160. * Internal only
  3161. * @hidden
  3162. */
  3163. private static _IsEqual;
  3164. /**
  3165. * Internal only
  3166. * @hidden
  3167. */
  3168. private static _IsDifferent;
  3169. /**
  3170. * Internal only
  3171. * @hidden
  3172. */
  3173. private static _IsGreater;
  3174. /**
  3175. * Internal only
  3176. * @hidden
  3177. */
  3178. private static _IsLesser;
  3179. /**
  3180. * returns the number for IsEqual
  3181. */
  3182. static readonly IsEqual: number;
  3183. /**
  3184. * Returns the number for IsDifferent
  3185. */
  3186. static readonly IsDifferent: number;
  3187. /**
  3188. * Returns the number for IsGreater
  3189. */
  3190. static readonly IsGreater: number;
  3191. /**
  3192. * Returns the number for IsLesser
  3193. */
  3194. static readonly IsLesser: number;
  3195. /**
  3196. * Internal only The action manager for the condition
  3197. * @hidden
  3198. */
  3199. _actionManager: ActionManager;
  3200. /**
  3201. * Internal only
  3202. * @hidden
  3203. */
  3204. private _target;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _effectiveTarget;
  3210. /**
  3211. * Internal only
  3212. * @hidden
  3213. */
  3214. private _property;
  3215. /**
  3216. * Creates a new ValueCondition
  3217. * @param actionManager manager for the action the condition applies to
  3218. * @param target for the action
  3219. * @param propertyPath path to specify the property of the target the conditional operator uses
  3220. * @param value the value compared by the conditional operator against the current value of the property
  3221. * @param operator the conditional operator, default ValueCondition.IsEqual
  3222. */
  3223. constructor(actionManager: ActionManager, target: any,
  3224. /** path to specify the property of the target the conditional operator uses */
  3225. propertyPath: string,
  3226. /** the value compared by the conditional operator against the current value of the property */
  3227. value: any,
  3228. /** the conditional operator, default ValueCondition.IsEqual */
  3229. operator?: number);
  3230. /**
  3231. * Compares the given value with the property value for the specified conditional operator
  3232. * @returns the result of the comparison
  3233. */
  3234. isValid(): boolean;
  3235. /**
  3236. * Serialize the ValueCondition into a JSON compatible object
  3237. * @returns serialization object
  3238. */
  3239. serialize(): any;
  3240. /**
  3241. * Gets the name of the conditional operator for the ValueCondition
  3242. * @param operator the conditional operator
  3243. * @returns the name
  3244. */
  3245. static GetOperatorName(operator: number): string;
  3246. }
  3247. /**
  3248. * Defines a predicate condition as an extension of Condition
  3249. */
  3250. class PredicateCondition extends Condition {
  3251. /** defines the predicate function used to validate the condition */
  3252. predicate: () => boolean;
  3253. /**
  3254. * Internal only - manager for action
  3255. * @hidden
  3256. */
  3257. _actionManager: ActionManager;
  3258. /**
  3259. * Creates a new PredicateCondition
  3260. * @param actionManager manager for the action the condition applies to
  3261. * @param predicate defines the predicate function used to validate the condition
  3262. */
  3263. constructor(actionManager: ActionManager,
  3264. /** defines the predicate function used to validate the condition */
  3265. predicate: () => boolean);
  3266. /**
  3267. * @returns the validity of the predicate condition
  3268. */
  3269. isValid(): boolean;
  3270. }
  3271. /**
  3272. * Defines a state condition as an extension of Condition
  3273. */
  3274. class StateCondition extends Condition {
  3275. value: string;
  3276. /**
  3277. * Internal only - manager for action
  3278. * @hidden
  3279. */
  3280. _actionManager: ActionManager;
  3281. /**
  3282. * Internal only
  3283. * @hidden
  3284. */
  3285. private _target;
  3286. /**
  3287. * Creates a new StateCondition
  3288. * @param actionManager manager for the action the condition applies to
  3289. * @param target of the condition
  3290. * @param value to compare with target state
  3291. */
  3292. constructor(actionManager: ActionManager, target: any, value: string);
  3293. /**
  3294. * @returns the validity of the state
  3295. */
  3296. isValid(): boolean;
  3297. /**
  3298. * Serialize the StateCondition into a JSON compatible object
  3299. * @returns serialization object
  3300. */
  3301. serialize(): any;
  3302. }
  3303. }
  3304. declare module BABYLON {
  3305. class SwitchBooleanAction extends Action {
  3306. propertyPath: string;
  3307. private _target;
  3308. private _effectiveTarget;
  3309. private _property;
  3310. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3311. _prepare(): void;
  3312. execute(): void;
  3313. serialize(parent: any): any;
  3314. }
  3315. class SetStateAction extends Action {
  3316. value: string;
  3317. private _target;
  3318. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3319. execute(): void;
  3320. serialize(parent: any): any;
  3321. }
  3322. class SetValueAction extends Action {
  3323. propertyPath: string;
  3324. value: any;
  3325. private _target;
  3326. private _effectiveTarget;
  3327. private _property;
  3328. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3329. _prepare(): void;
  3330. execute(): void;
  3331. serialize(parent: any): any;
  3332. }
  3333. class IncrementValueAction extends Action {
  3334. propertyPath: string;
  3335. value: any;
  3336. private _target;
  3337. private _effectiveTarget;
  3338. private _property;
  3339. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3340. _prepare(): void;
  3341. execute(): void;
  3342. serialize(parent: any): any;
  3343. }
  3344. class PlayAnimationAction extends Action {
  3345. from: number;
  3346. to: number;
  3347. loop: boolean | undefined;
  3348. private _target;
  3349. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3350. _prepare(): void;
  3351. execute(): void;
  3352. serialize(parent: any): any;
  3353. }
  3354. class StopAnimationAction extends Action {
  3355. private _target;
  3356. constructor(triggerOptions: any, target: any, condition?: Condition);
  3357. _prepare(): void;
  3358. execute(): void;
  3359. serialize(parent: any): any;
  3360. }
  3361. class DoNothingAction extends Action {
  3362. constructor(triggerOptions?: any, condition?: Condition);
  3363. execute(): void;
  3364. serialize(parent: any): any;
  3365. }
  3366. class CombineAction extends Action {
  3367. children: Action[];
  3368. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3369. _prepare(): void;
  3370. execute(evt: ActionEvent): void;
  3371. serialize(parent: any): any;
  3372. }
  3373. class ExecuteCodeAction extends Action {
  3374. func: (evt: ActionEvent) => void;
  3375. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3376. execute(evt: ActionEvent): void;
  3377. }
  3378. class SetParentAction extends Action {
  3379. private _parent;
  3380. private _target;
  3381. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3382. _prepare(): void;
  3383. execute(): void;
  3384. serialize(parent: any): any;
  3385. }
  3386. class PlaySoundAction extends Action {
  3387. private _sound;
  3388. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3389. _prepare(): void;
  3390. execute(): void;
  3391. serialize(parent: any): any;
  3392. }
  3393. class StopSoundAction extends Action {
  3394. private _sound;
  3395. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3396. _prepare(): void;
  3397. execute(): void;
  3398. serialize(parent: any): any;
  3399. }
  3400. }
  3401. declare module BABYLON {
  3402. class InterpolateValueAction extends Action {
  3403. propertyPath: string;
  3404. value: any;
  3405. duration: number;
  3406. stopOtherAnimations: boolean | undefined;
  3407. onInterpolationDone: (() => void) | undefined;
  3408. private _target;
  3409. private _effectiveTarget;
  3410. private _property;
  3411. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3413. _prepare(): void;
  3414. execute(): void;
  3415. serialize(parent: any): any;
  3416. }
  3417. }
  3418. declare module BABYLON {
  3419. /**
  3420. * Class used to store an actual running animation
  3421. */
  3422. class Animatable {
  3423. /** defines the target object */
  3424. target: any;
  3425. /** defines the starting frame number (default is 0) */
  3426. fromFrame: number;
  3427. /** defines the ending frame number (default is 100) */
  3428. toFrame: number;
  3429. /** defines if the animation must loop (default is false) */
  3430. loopAnimation: boolean;
  3431. /** defines a callback to call when animation ends if it is not looping */
  3432. onAnimationEnd: (() => void) | null | undefined;
  3433. private _localDelayOffset;
  3434. private _pausedDelay;
  3435. private _runtimeAnimations;
  3436. private _paused;
  3437. private _scene;
  3438. private _speedRatio;
  3439. private _weight;
  3440. private _syncRoot;
  3441. /**
  3442. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3443. * This will only apply for non looping animation (default is true)
  3444. */
  3445. disposeOnEnd: boolean;
  3446. /**
  3447. * Gets a boolean indicating if the animation has started
  3448. */
  3449. animationStarted: boolean;
  3450. /**
  3451. * Observer raised when the animation ends
  3452. */
  3453. onAnimationEndObservable: Observable<Animatable>;
  3454. /**
  3455. * Gets the root Animatable used to synchronize and normalize animations
  3456. */
  3457. readonly syncRoot: Animatable;
  3458. /**
  3459. * Gets the current frame of the first RuntimeAnimation
  3460. * Used to synchronize Animatables
  3461. */
  3462. readonly masterFrame: number;
  3463. /**
  3464. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3465. */
  3466. weight: number;
  3467. /**
  3468. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3469. */
  3470. speedRatio: number;
  3471. /**
  3472. * Creates a new Animatable
  3473. * @param scene defines the hosting scene
  3474. * @param target defines the target object
  3475. * @param fromFrame defines the starting frame number (default is 0)
  3476. * @param toFrame defines the ending frame number (default is 100)
  3477. * @param loopAnimation defines if the animation must loop (default is false)
  3478. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3479. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3480. * @param animations defines a group of animation to add to the new Animatable
  3481. */
  3482. constructor(scene: Scene,
  3483. /** defines the target object */
  3484. target: any,
  3485. /** defines the starting frame number (default is 0) */
  3486. fromFrame?: number,
  3487. /** defines the ending frame number (default is 100) */
  3488. toFrame?: number,
  3489. /** defines if the animation must loop (default is false) */
  3490. loopAnimation?: boolean, speedRatio?: number,
  3491. /** defines a callback to call when animation ends if it is not looping */
  3492. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3493. /**
  3494. * Synchronize and normalize current Animatable with a source Animatable
  3495. * This is useful when using animation weights and when animations are not of the same length
  3496. * @param root defines the root Animatable to synchronize with
  3497. * @returns the current Animatable
  3498. */
  3499. syncWith(root: Animatable): Animatable;
  3500. /**
  3501. * Gets the list of runtime animations
  3502. * @returns an array of RuntimeAnimation
  3503. */
  3504. getAnimations(): RuntimeAnimation[];
  3505. /**
  3506. * Adds more animations to the current animatable
  3507. * @param target defines the target of the animations
  3508. * @param animations defines the new animations to add
  3509. */
  3510. appendAnimations(target: any, animations: Animation[]): void;
  3511. /**
  3512. * Gets the source animation for a specific property
  3513. * @param property defines the propertyu to look for
  3514. * @returns null or the source animation for the given property
  3515. */
  3516. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3517. /**
  3518. * Gets the runtime animation for a specific property
  3519. * @param property defines the propertyu to look for
  3520. * @returns null or the runtime animation for the given property
  3521. */
  3522. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3523. /**
  3524. * Resets the animatable to its original state
  3525. */
  3526. reset(): void;
  3527. /**
  3528. * Allows the animatable to blend with current running animations
  3529. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3530. * @param blendingSpeed defines the blending speed to use
  3531. */
  3532. enableBlending(blendingSpeed: number): void;
  3533. /**
  3534. * Disable animation blending
  3535. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3536. */
  3537. disableBlending(): void;
  3538. /**
  3539. * Jump directly to a given frame
  3540. * @param frame defines the frame to jump to
  3541. */
  3542. goToFrame(frame: number): void;
  3543. /**
  3544. * Pause the animation
  3545. */
  3546. pause(): void;
  3547. /**
  3548. * Restart the animation
  3549. */
  3550. restart(): void;
  3551. private _raiseOnAnimationEnd();
  3552. /**
  3553. * Stop and delete the current animation
  3554. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3555. * @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)
  3556. */
  3557. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3558. /**
  3559. * Wait asynchronously for the animation to end
  3560. * @returns a promise which will be fullfilled when the animation ends
  3561. */
  3562. waitAsync(): Promise<Animatable>;
  3563. /** @hidden */
  3564. _animate(delay: number): boolean;
  3565. }
  3566. }
  3567. declare module BABYLON {
  3568. /**
  3569. * Represents the range of an animation
  3570. */
  3571. class AnimationRange {
  3572. /**The name of the animation range**/
  3573. name: string;
  3574. /**The starting frame of the animation */
  3575. from: number;
  3576. /**The ending frame of the animation*/
  3577. to: number;
  3578. /**
  3579. * Initializes the range of an animation
  3580. * @param name The name of the animation range
  3581. * @param from The starting frame of the animation
  3582. * @param to The ending frame of the animation
  3583. */
  3584. constructor(
  3585. /**The name of the animation range**/
  3586. name: string,
  3587. /**The starting frame of the animation */
  3588. from: number,
  3589. /**The ending frame of the animation*/
  3590. to: number);
  3591. /**
  3592. * Makes a copy of the animation range
  3593. * @returns A copy of the animation range
  3594. */
  3595. clone(): AnimationRange;
  3596. }
  3597. /**
  3598. * Composed of a frame, and an action function
  3599. */
  3600. class AnimationEvent {
  3601. /** The frame for which the event is triggered **/
  3602. frame: number;
  3603. /** The event to perform when triggered **/
  3604. action: () => void;
  3605. /** Specifies if the event should be triggered only once**/
  3606. onlyOnce: boolean | undefined;
  3607. /**
  3608. * Specifies if the animation event is done
  3609. */
  3610. isDone: boolean;
  3611. /**
  3612. * Initializes the animation event
  3613. * @param frame The frame for which the event is triggered
  3614. * @param action The event to perform when triggered
  3615. * @param onlyOnce Specifies if the event should be triggered only once
  3616. */
  3617. constructor(
  3618. /** The frame for which the event is triggered **/
  3619. frame: number,
  3620. /** The event to perform when triggered **/
  3621. action: () => void,
  3622. /** Specifies if the event should be triggered only once**/
  3623. onlyOnce?: boolean | undefined);
  3624. /** @hidden */
  3625. _clone(): AnimationEvent;
  3626. }
  3627. /**
  3628. * A cursor which tracks a point on a path
  3629. */
  3630. class PathCursor {
  3631. private path;
  3632. /**
  3633. * Stores path cursor callbacks for when an onchange event is triggered
  3634. */
  3635. private _onchange;
  3636. /**
  3637. * The value of the path cursor
  3638. */
  3639. value: number;
  3640. /**
  3641. * The animation array of the path cursor
  3642. */
  3643. animations: Animation[];
  3644. /**
  3645. * Initializes the path cursor
  3646. * @param path The path to track
  3647. */
  3648. constructor(path: Path2);
  3649. /**
  3650. * Gets the cursor point on the path
  3651. * @returns A point on the path cursor at the cursor location
  3652. */
  3653. getPoint(): Vector3;
  3654. /**
  3655. * Moves the cursor ahead by the step amount
  3656. * @param step The amount to move the cursor forward
  3657. * @returns This path cursor
  3658. */
  3659. moveAhead(step?: number): PathCursor;
  3660. /**
  3661. * Moves the cursor behind by the step amount
  3662. * @param step The amount to move the cursor back
  3663. * @returns This path cursor
  3664. */
  3665. moveBack(step?: number): PathCursor;
  3666. /**
  3667. * Moves the cursor by the step amount
  3668. * If the step amount is greater than one, an exception is thrown
  3669. * @param step The amount to move the cursor
  3670. * @returns This path cursor
  3671. */
  3672. move(step: number): PathCursor;
  3673. /**
  3674. * Ensures that the value is limited between zero and one
  3675. * @returns This path cursor
  3676. */
  3677. private ensureLimits();
  3678. /**
  3679. * Runs onchange callbacks on change (used by the animation engine)
  3680. * @returns This path cursor
  3681. */
  3682. private raiseOnChange();
  3683. /**
  3684. * Executes a function on change
  3685. * @param f A path cursor onchange callback
  3686. * @returns This path cursor
  3687. */
  3688. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3689. }
  3690. /**
  3691. * Defines an interface which represents an animation key frame
  3692. */
  3693. interface IAnimationKey {
  3694. /**
  3695. * Frame of the key frame
  3696. */
  3697. frame: number;
  3698. /**
  3699. * Value at the specifies key frame
  3700. */
  3701. value: any;
  3702. /**
  3703. * The input tangent for the cubic hermite spline
  3704. */
  3705. inTangent?: any;
  3706. /**
  3707. * The output tangent for the cubic hermite spline
  3708. */
  3709. outTangent?: any;
  3710. /**
  3711. * The animation interpolation type
  3712. */
  3713. interpolation?: AnimationKeyInterpolation;
  3714. }
  3715. /**
  3716. * Enum for the animation key frame interpolation type
  3717. */
  3718. enum AnimationKeyInterpolation {
  3719. /**
  3720. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3721. */
  3722. STEP = 1,
  3723. }
  3724. /**
  3725. * Class used to store any kind of animation
  3726. */
  3727. class Animation {
  3728. /**Name of the animation */
  3729. name: string;
  3730. /**Property to animate */
  3731. targetProperty: string;
  3732. /**The frames per second of the animation */
  3733. framePerSecond: number;
  3734. /**The data type of the animation */
  3735. dataType: number;
  3736. /**The loop mode of the animation */
  3737. loopMode: number | undefined;
  3738. /**Specifies if blending should be enabled */
  3739. enableBlending: boolean | undefined;
  3740. /**
  3741. * Use matrix interpolation instead of using direct key value when animating matrices
  3742. */
  3743. static AllowMatricesInterpolation: boolean;
  3744. /**
  3745. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3746. */
  3747. static AllowMatrixDecomposeForInterpolation: boolean;
  3748. /**
  3749. * Stores the key frames of the animation
  3750. */
  3751. private _keys;
  3752. /**
  3753. * Stores the easing function of the animation
  3754. */
  3755. private _easingFunction;
  3756. /**
  3757. * @hidden Internal use only
  3758. */
  3759. _runtimeAnimations: RuntimeAnimation[];
  3760. /**
  3761. * The set of event that will be linked to this animation
  3762. */
  3763. private _events;
  3764. /**
  3765. * Stores an array of target property paths
  3766. */
  3767. targetPropertyPath: string[];
  3768. /**
  3769. * Stores the blending speed of the animation
  3770. */
  3771. blendingSpeed: number;
  3772. /**
  3773. * Stores the animation ranges for the animation
  3774. */
  3775. private _ranges;
  3776. /**
  3777. * @hidden Internal use
  3778. */
  3779. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3780. /**
  3781. * Sets up an animation
  3782. * @param property The property to animate
  3783. * @param animationType The animation type to apply
  3784. * @param framePerSecond The frames per second of the animation
  3785. * @param easingFunction The easing function used in the animation
  3786. * @returns The created animation
  3787. */
  3788. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3789. /**
  3790. * Create and start an animation on a node
  3791. * @param name defines the name of the global animation that will be run on all nodes
  3792. * @param node defines the root node where the animation will take place
  3793. * @param targetProperty defines property to animate
  3794. * @param framePerSecond defines the number of frame per second yo use
  3795. * @param totalFrame defines the number of frames in total
  3796. * @param from defines the initial value
  3797. * @param to defines the final value
  3798. * @param loopMode defines which loop mode you want to use (off by default)
  3799. * @param easingFunction defines the easing function to use (linear by default)
  3800. * @param onAnimationEnd defines the callback to call when animation end
  3801. * @returns the animatable created for this animation
  3802. */
  3803. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3804. /**
  3805. * Create and start an animation on a node and its descendants
  3806. * @param name defines the name of the global animation that will be run on all nodes
  3807. * @param node defines the root node where the animation will take place
  3808. * @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
  3809. * @param targetProperty defines property to animate
  3810. * @param framePerSecond defines the number of frame per second to use
  3811. * @param totalFrame defines the number of frames in total
  3812. * @param from defines the initial value
  3813. * @param to defines the final value
  3814. * @param loopMode defines which loop mode you want to use (off by default)
  3815. * @param easingFunction defines the easing function to use (linear by default)
  3816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3817. * @returns the list of animatables created for all nodes
  3818. * @example https://www.babylonjs-playground.com/#MH0VLI
  3819. */
  3820. 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[]>;
  3821. /**
  3822. * Creates a new animation, merges it with the existing animations and starts it
  3823. * @param name Name of the animation
  3824. * @param node Node which contains the scene that begins the animations
  3825. * @param targetProperty Specifies which property to animate
  3826. * @param framePerSecond The frames per second of the animation
  3827. * @param totalFrame The total number of frames
  3828. * @param from The frame at the beginning of the animation
  3829. * @param to The frame at the end of the animation
  3830. * @param loopMode Specifies the loop mode of the animation
  3831. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3832. * @param onAnimationEnd Callback to run once the animation is complete
  3833. * @returns Nullable animation
  3834. */
  3835. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3836. /**
  3837. * Transition property of an host to the target Value
  3838. * @param property The property to transition
  3839. * @param targetValue The target Value of the property
  3840. * @param host The object where the property to animate belongs
  3841. * @param scene Scene used to run the animation
  3842. * @param frameRate Framerate (in frame/s) to use
  3843. * @param transition The transition type we want to use
  3844. * @param duration The duration of the animation, in milliseconds
  3845. * @param onAnimationEnd Callback trigger at the end of the animation
  3846. * @returns Nullable animation
  3847. */
  3848. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3849. /**
  3850. * Return the array of runtime animations currently using this animation
  3851. */
  3852. readonly runtimeAnimations: RuntimeAnimation[];
  3853. /**
  3854. * Specifies if any of the runtime animations are currently running
  3855. */
  3856. readonly hasRunningRuntimeAnimations: boolean;
  3857. /**
  3858. * Initializes the animation
  3859. * @param name Name of the animation
  3860. * @param targetProperty Property to animate
  3861. * @param framePerSecond The frames per second of the animation
  3862. * @param dataType The data type of the animation
  3863. * @param loopMode The loop mode of the animation
  3864. * @param enableBlendings Specifies if blending should be enabled
  3865. */
  3866. constructor(
  3867. /**Name of the animation */
  3868. name: string,
  3869. /**Property to animate */
  3870. targetProperty: string,
  3871. /**The frames per second of the animation */
  3872. framePerSecond: number,
  3873. /**The data type of the animation */
  3874. dataType: number,
  3875. /**The loop mode of the animation */
  3876. loopMode?: number | undefined,
  3877. /**Specifies if blending should be enabled */
  3878. enableBlending?: boolean | undefined);
  3879. /**
  3880. * Converts the animation to a string
  3881. * @param fullDetails support for multiple levels of logging within scene loading
  3882. * @returns String form of the animation
  3883. */
  3884. toString(fullDetails?: boolean): string;
  3885. /**
  3886. * Add an event to this animation
  3887. * @param event Event to add
  3888. */
  3889. addEvent(event: AnimationEvent): void;
  3890. /**
  3891. * Remove all events found at the given frame
  3892. * @param frame The frame to remove events from
  3893. */
  3894. removeEvents(frame: number): void;
  3895. /**
  3896. * Retrieves all the events from the animation
  3897. * @returns Events from the animation
  3898. */
  3899. getEvents(): AnimationEvent[];
  3900. /**
  3901. * Creates an animation range
  3902. * @param name Name of the animation range
  3903. * @param from Starting frame of the animation range
  3904. * @param to Ending frame of the animation
  3905. */
  3906. createRange(name: string, from: number, to: number): void;
  3907. /**
  3908. * Deletes an animation range by name
  3909. * @param name Name of the animation range to delete
  3910. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3911. */
  3912. deleteRange(name: string, deleteFrames?: boolean): void;
  3913. /**
  3914. * Gets the animation range by name, or null if not defined
  3915. * @param name Name of the animation range
  3916. * @returns Nullable animation range
  3917. */
  3918. getRange(name: string): Nullable<AnimationRange>;
  3919. /**
  3920. * Gets the key frames from the animation
  3921. * @returns The key frames of the animation
  3922. */
  3923. getKeys(): Array<IAnimationKey>;
  3924. /**
  3925. * Gets the highest frame rate of the animation
  3926. * @returns Highest frame rate of the animation
  3927. */
  3928. getHighestFrame(): number;
  3929. /**
  3930. * Gets the easing function of the animation
  3931. * @returns Easing function of the animation
  3932. */
  3933. getEasingFunction(): IEasingFunction;
  3934. /**
  3935. * Sets the easing function of the animation
  3936. * @param easingFunction A custom mathematical formula for animation
  3937. */
  3938. setEasingFunction(easingFunction: EasingFunction): void;
  3939. /**
  3940. * Interpolates a scalar linearly
  3941. * @param startValue Start value of the animation curve
  3942. * @param endValue End value of the animation curve
  3943. * @param gradient Scalar amount to interpolate
  3944. * @returns Interpolated scalar value
  3945. */
  3946. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3947. /**
  3948. * Interpolates a scalar cubically
  3949. * @param startValue Start value of the animation curve
  3950. * @param outTangent End tangent of the animation
  3951. * @param endValue End value of the animation curve
  3952. * @param inTangent Start tangent of the animation curve
  3953. * @param gradient Scalar amount to interpolate
  3954. * @returns Interpolated scalar value
  3955. */
  3956. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3957. /**
  3958. * Interpolates a quaternion using a spherical linear interpolation
  3959. * @param startValue Start value of the animation curve
  3960. * @param endValue End value of the animation curve
  3961. * @param gradient Scalar amount to interpolate
  3962. * @returns Interpolated quaternion value
  3963. */
  3964. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3965. /**
  3966. * Interpolates a quaternion cubically
  3967. * @param startValue Start value of the animation curve
  3968. * @param outTangent End tangent of the animation curve
  3969. * @param endValue End value of the animation curve
  3970. * @param inTangent Start tangent of the animation curve
  3971. * @param gradient Scalar amount to interpolate
  3972. * @returns Interpolated quaternion value
  3973. */
  3974. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3975. /**
  3976. * Interpolates a Vector3 linearl
  3977. * @param startValue Start value of the animation curve
  3978. * @param endValue End value of the animation curve
  3979. * @param gradient Scalar amount to interpolate
  3980. * @returns Interpolated scalar value
  3981. */
  3982. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3983. /**
  3984. * Interpolates a Vector3 cubically
  3985. * @param startValue Start value of the animation curve
  3986. * @param outTangent End tangent of the animation
  3987. * @param endValue End value of the animation curve
  3988. * @param inTangent Start tangent of the animation curve
  3989. * @param gradient Scalar amount to interpolate
  3990. * @returns InterpolatedVector3 value
  3991. */
  3992. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3993. /**
  3994. * Interpolates a Vector2 linearly
  3995. * @param startValue Start value of the animation curve
  3996. * @param endValue End value of the animation curve
  3997. * @param gradient Scalar amount to interpolate
  3998. * @returns Interpolated Vector2 value
  3999. */
  4000. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4001. /**
  4002. * Interpolates a Vector2 cubically
  4003. * @param startValue Start value of the animation curve
  4004. * @param outTangent End tangent of the animation
  4005. * @param endValue End value of the animation curve
  4006. * @param inTangent Start tangent of the animation curve
  4007. * @param gradient Scalar amount to interpolate
  4008. * @returns Interpolated Vector2 value
  4009. */
  4010. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4011. /**
  4012. * Interpolates a size linearly
  4013. * @param startValue Start value of the animation curve
  4014. * @param endValue End value of the animation curve
  4015. * @param gradient Scalar amount to interpolate
  4016. * @returns Interpolated Size value
  4017. */
  4018. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4019. /**
  4020. * Interpolates a Color3 linearly
  4021. * @param startValue Start value of the animation curve
  4022. * @param endValue End value of the animation curve
  4023. * @param gradient Scalar amount to interpolate
  4024. * @returns Interpolated Color3 value
  4025. */
  4026. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4027. /**
  4028. * @hidden Internal use only
  4029. */
  4030. _getKeyValue(value: any): any;
  4031. /**
  4032. * @hidden Internal use only
  4033. */
  4034. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4035. /**
  4036. * Defines the function to use to interpolate matrices
  4037. * @param startValue defines the start matrix
  4038. * @param endValue defines the end matrix
  4039. * @param gradient defines the gradient between both matrices
  4040. * @param result defines an optional target matrix where to store the interpolation
  4041. * @returns the interpolated matrix
  4042. */
  4043. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4044. /**
  4045. * Makes a copy of the animation
  4046. * @returns Cloned animation
  4047. */
  4048. clone(): Animation;
  4049. /**
  4050. * Sets the key frames of the animation
  4051. * @param values The animation key frames to set
  4052. */
  4053. setKeys(values: Array<IAnimationKey>): void;
  4054. /**
  4055. * Serializes the animation to an object
  4056. * @returns Serialized object
  4057. */
  4058. serialize(): any;
  4059. /**
  4060. * Float animation type
  4061. */
  4062. private static _ANIMATIONTYPE_FLOAT;
  4063. /**
  4064. * Vector3 animation type
  4065. */
  4066. private static _ANIMATIONTYPE_VECTOR3;
  4067. /**
  4068. * Quaternion animation type
  4069. */
  4070. private static _ANIMATIONTYPE_QUATERNION;
  4071. /**
  4072. * Matrix animation type
  4073. */
  4074. private static _ANIMATIONTYPE_MATRIX;
  4075. /**
  4076. * Color3 animation type
  4077. */
  4078. private static _ANIMATIONTYPE_COLOR3;
  4079. /**
  4080. * Vector2 animation type
  4081. */
  4082. private static _ANIMATIONTYPE_VECTOR2;
  4083. /**
  4084. * Size animation type
  4085. */
  4086. private static _ANIMATIONTYPE_SIZE;
  4087. /**
  4088. * Relative Loop Mode
  4089. */
  4090. private static _ANIMATIONLOOPMODE_RELATIVE;
  4091. /**
  4092. * Cycle Loop Mode
  4093. */
  4094. private static _ANIMATIONLOOPMODE_CYCLE;
  4095. /**
  4096. * Constant Loop Mode
  4097. */
  4098. private static _ANIMATIONLOOPMODE_CONSTANT;
  4099. /**
  4100. * Get the float animation type
  4101. */
  4102. static readonly ANIMATIONTYPE_FLOAT: number;
  4103. /**
  4104. * Get the Vector3 animation type
  4105. */
  4106. static readonly ANIMATIONTYPE_VECTOR3: number;
  4107. /**
  4108. * Get the Vectpr2 animation type
  4109. */
  4110. static readonly ANIMATIONTYPE_VECTOR2: number;
  4111. /**
  4112. * Get the Size animation type
  4113. */
  4114. static readonly ANIMATIONTYPE_SIZE: number;
  4115. /**
  4116. * Get the Quaternion animation type
  4117. */
  4118. static readonly ANIMATIONTYPE_QUATERNION: number;
  4119. /**
  4120. * Get the Matrix animation type
  4121. */
  4122. static readonly ANIMATIONTYPE_MATRIX: number;
  4123. /**
  4124. * Get the Color3 animation type
  4125. */
  4126. static readonly ANIMATIONTYPE_COLOR3: number;
  4127. /**
  4128. * Get the Relative Loop Mode
  4129. */
  4130. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4131. /**
  4132. * Get the Cycle Loop Mode
  4133. */
  4134. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4135. /**
  4136. * Get the Constant Loop Mode
  4137. */
  4138. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4139. /** @hidden */
  4140. static _UniversalLerp(left: any, right: any, amount: number): any;
  4141. /**
  4142. * Parses an animation object and creates an animation
  4143. * @param parsedAnimation Parsed animation object
  4144. * @returns Animation object
  4145. */
  4146. static Parse(parsedAnimation: any): Animation;
  4147. /**
  4148. * Appends the serialized animations from the source animations
  4149. * @param source Source containing the animations
  4150. * @param destination Target to store the animations
  4151. */
  4152. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4153. }
  4154. }
  4155. declare module BABYLON {
  4156. /**
  4157. * This class defines the direct association between an animation and a target
  4158. */
  4159. class TargetedAnimation {
  4160. animation: Animation;
  4161. target: any;
  4162. }
  4163. /**
  4164. * Use this class to create coordinated animations on multiple targets
  4165. */
  4166. class AnimationGroup implements IDisposable {
  4167. name: string;
  4168. private _scene;
  4169. private _targetedAnimations;
  4170. private _animatables;
  4171. private _from;
  4172. private _to;
  4173. private _isStarted;
  4174. private _speedRatio;
  4175. onAnimationEndObservable: Observable<TargetedAnimation>;
  4176. /**
  4177. * This observable will notify when all animations have ended.
  4178. */
  4179. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4180. /**
  4181. * Gets the first frame
  4182. */
  4183. readonly from: number;
  4184. /**
  4185. * Gets the last frame
  4186. */
  4187. readonly to: number;
  4188. /**
  4189. * Define if the animations are started
  4190. */
  4191. readonly isStarted: boolean;
  4192. /**
  4193. * Gets or sets the speed ratio to use for all animations
  4194. */
  4195. /**
  4196. * Gets or sets the speed ratio to use for all animations
  4197. */
  4198. speedRatio: number;
  4199. /**
  4200. * Gets the targeted animations for this animation group
  4201. */
  4202. readonly targetedAnimations: Array<TargetedAnimation>;
  4203. /**
  4204. * returning the list of animatables controlled by this animation group.
  4205. */
  4206. readonly animatables: Array<Animatable>;
  4207. constructor(name: string, scene?: Nullable<Scene>);
  4208. /**
  4209. * Add an animation (with its target) in the group
  4210. * @param animation defines the animation we want to add
  4211. * @param target defines the target of the animation
  4212. * @returns the {BABYLON.TargetedAnimation} object
  4213. */
  4214. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4215. /**
  4216. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4217. * It can add constant keys at begin or end
  4218. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4219. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4220. */
  4221. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4222. /**
  4223. * Start all animations on given targets
  4224. * @param loop defines if animations must loop
  4225. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4226. * @param from defines the from key (optional)
  4227. * @param to defines the to key (optional)
  4228. * @returns the current animation group
  4229. */
  4230. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4231. /**
  4232. * Pause all animations
  4233. */
  4234. pause(): AnimationGroup;
  4235. /**
  4236. * Play all animations to initial state
  4237. * This function will start() the animations if they were not started or will restart() them if they were paused
  4238. * @param loop defines if animations must loop
  4239. */
  4240. play(loop?: boolean): AnimationGroup;
  4241. /**
  4242. * Reset all animations to initial state
  4243. */
  4244. reset(): AnimationGroup;
  4245. /**
  4246. * Restart animations from key 0
  4247. */
  4248. restart(): AnimationGroup;
  4249. /**
  4250. * Stop all animations
  4251. */
  4252. stop(): AnimationGroup;
  4253. /**
  4254. * Set animation weight for all animatables
  4255. * @param weight defines the weight to use
  4256. * @return the animationGroup
  4257. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4258. */
  4259. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4260. /**
  4261. * Synchronize and normalize all animatables with a source animatable
  4262. * @param root defines the root animatable to synchronize with
  4263. * @return the animationGroup
  4264. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4265. */
  4266. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4267. /**
  4268. * Goes to a specific frame in this animation group
  4269. * @param frame the frame number to go to
  4270. * @return the animationGroup
  4271. */
  4272. goToFrame(frame: number): AnimationGroup;
  4273. /**
  4274. * Dispose all associated resources
  4275. */
  4276. dispose(): void;
  4277. private _checkAnimationGroupEnded(animatable);
  4278. }
  4279. }
  4280. declare module BABYLON {
  4281. /**
  4282. * Class used to override all child animations of a given target
  4283. */
  4284. class AnimationPropertiesOverride {
  4285. /**
  4286. * Gets or sets a value indicating if animation blending must be used
  4287. */
  4288. enableBlending: boolean;
  4289. /**
  4290. * Gets or sets the blending speed to use when enableBlending is true
  4291. */
  4292. blendingSpeed: number;
  4293. /**
  4294. * Gets or sets the default loop mode to use
  4295. */
  4296. loopMode: number;
  4297. }
  4298. }
  4299. declare module BABYLON {
  4300. interface IEasingFunction {
  4301. ease(gradient: number): number;
  4302. }
  4303. class EasingFunction implements IEasingFunction {
  4304. private static _EASINGMODE_EASEIN;
  4305. private static _EASINGMODE_EASEOUT;
  4306. private static _EASINGMODE_EASEINOUT;
  4307. static readonly EASINGMODE_EASEIN: number;
  4308. static readonly EASINGMODE_EASEOUT: number;
  4309. static readonly EASINGMODE_EASEINOUT: number;
  4310. private _easingMode;
  4311. setEasingMode(easingMode: number): void;
  4312. getEasingMode(): number;
  4313. easeInCore(gradient: number): number;
  4314. ease(gradient: number): number;
  4315. }
  4316. class CircleEase extends EasingFunction implements IEasingFunction {
  4317. easeInCore(gradient: number): number;
  4318. }
  4319. class BackEase extends EasingFunction implements IEasingFunction {
  4320. amplitude: number;
  4321. constructor(amplitude?: number);
  4322. easeInCore(gradient: number): number;
  4323. }
  4324. class BounceEase extends EasingFunction implements IEasingFunction {
  4325. bounces: number;
  4326. bounciness: number;
  4327. constructor(bounces?: number, bounciness?: number);
  4328. easeInCore(gradient: number): number;
  4329. }
  4330. class CubicEase extends EasingFunction implements IEasingFunction {
  4331. easeInCore(gradient: number): number;
  4332. }
  4333. class ElasticEase extends EasingFunction implements IEasingFunction {
  4334. oscillations: number;
  4335. springiness: number;
  4336. constructor(oscillations?: number, springiness?: number);
  4337. easeInCore(gradient: number): number;
  4338. }
  4339. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4340. exponent: number;
  4341. constructor(exponent?: number);
  4342. easeInCore(gradient: number): number;
  4343. }
  4344. class PowerEase extends EasingFunction implements IEasingFunction {
  4345. power: number;
  4346. constructor(power?: number);
  4347. easeInCore(gradient: number): number;
  4348. }
  4349. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4350. easeInCore(gradient: number): number;
  4351. }
  4352. class QuarticEase extends EasingFunction implements IEasingFunction {
  4353. easeInCore(gradient: number): number;
  4354. }
  4355. class QuinticEase extends EasingFunction implements IEasingFunction {
  4356. easeInCore(gradient: number): number;
  4357. }
  4358. class SineEase extends EasingFunction implements IEasingFunction {
  4359. easeInCore(gradient: number): number;
  4360. }
  4361. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4362. x1: number;
  4363. y1: number;
  4364. x2: number;
  4365. y2: number;
  4366. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4367. easeInCore(gradient: number): number;
  4368. }
  4369. }
  4370. declare module BABYLON {
  4371. /**
  4372. * Defines a runtime animation
  4373. */
  4374. class RuntimeAnimation {
  4375. private _events;
  4376. /**
  4377. * The current frame of the runtime animation
  4378. */
  4379. private _currentFrame;
  4380. /**
  4381. * The animation used by the runtime animation
  4382. */
  4383. private _animation;
  4384. /**
  4385. * The target of the runtime animation
  4386. */
  4387. private _target;
  4388. /**
  4389. * The initiating animatable
  4390. */
  4391. private _host;
  4392. /**
  4393. * The original value of the runtime animation
  4394. */
  4395. private _originalValue;
  4396. /**
  4397. * The original blend value of the runtime animation
  4398. */
  4399. private _originalBlendValue;
  4400. /**
  4401. * The offsets cache of the runtime animation
  4402. */
  4403. private _offsetsCache;
  4404. /**
  4405. * The high limits cache of the runtime animation
  4406. */
  4407. private _highLimitsCache;
  4408. /**
  4409. * Specifies if the runtime animation has been stopped
  4410. */
  4411. private _stopped;
  4412. /**
  4413. * The blending factor of the runtime animation
  4414. */
  4415. private _blendingFactor;
  4416. /**
  4417. * The BabylonJS scene
  4418. */
  4419. private _scene;
  4420. /**
  4421. * The current value of the runtime animation
  4422. */
  4423. private _currentValue;
  4424. /** @hidden */
  4425. _workValue: any;
  4426. /**
  4427. * The active target of the runtime animation
  4428. */
  4429. private _activeTarget;
  4430. /**
  4431. * The target path of the runtime animation
  4432. */
  4433. private _targetPath;
  4434. /**
  4435. * The weight of the runtime animation
  4436. */
  4437. private _weight;
  4438. /**
  4439. * The ratio offset of the runtime animation
  4440. */
  4441. private _ratioOffset;
  4442. /**
  4443. * The previous delay of the runtime animation
  4444. */
  4445. private _previousDelay;
  4446. /**
  4447. * The previous ratio of the runtime animation
  4448. */
  4449. private _previousRatio;
  4450. /**
  4451. * Gets the current frame of the runtime animation
  4452. */
  4453. readonly currentFrame: number;
  4454. /**
  4455. * Gets the weight of the runtime animation
  4456. */
  4457. readonly weight: number;
  4458. /**
  4459. * Gets the current value of the runtime animation
  4460. */
  4461. readonly currentValue: any;
  4462. /**
  4463. * Gets the target path of the runtime animation
  4464. */
  4465. readonly targetPath: string;
  4466. /**
  4467. * Gets the actual target of the runtime animation
  4468. */
  4469. readonly target: any;
  4470. /**
  4471. * Create a new RuntimeAnimation object
  4472. * @param target defines the target of the animation
  4473. * @param animation defines the source animation object
  4474. * @param scene defines the hosting scene
  4475. * @param host defines the initiating Animatable
  4476. */
  4477. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4478. /**
  4479. * Gets the animation from the runtime animation
  4480. */
  4481. readonly animation: Animation;
  4482. /**
  4483. * Resets the runtime animation to the beginning
  4484. * @param restoreOriginal defines whether to restore the target property to the original value
  4485. */
  4486. reset(restoreOriginal?: boolean): void;
  4487. /**
  4488. * Specifies if the runtime animation is stopped
  4489. * @returns Boolean specifying if the runtime animation is stopped
  4490. */
  4491. isStopped(): boolean;
  4492. /**
  4493. * Disposes of the runtime animation
  4494. */
  4495. dispose(): void;
  4496. /**
  4497. * Interpolates the animation from the current frame
  4498. * @param currentFrame The frame to interpolate the animation to
  4499. * @param repeatCount The number of times that the animation should loop
  4500. * @param loopMode The type of looping mode to use
  4501. * @param offsetValue Animation offset value
  4502. * @param highLimitValue The high limit value
  4503. * @returns The interpolated value
  4504. */
  4505. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4506. /**
  4507. * Apply the interpolated value to the target
  4508. * @param currentValue defines the value computed by the animation
  4509. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4510. */
  4511. setValue(currentValue: any, weight?: number): void;
  4512. private _setValue(target, currentValue, weight, targetIndex?);
  4513. /**
  4514. * Gets the loop pmode of the runtime animation
  4515. * @returns Loop Mode
  4516. */
  4517. private _getCorrectLoopMode();
  4518. /**
  4519. * Move the current animation to a given frame
  4520. * @param frame defines the frame to move to
  4521. */
  4522. goToFrame(frame: number): void;
  4523. /**
  4524. * @hidden Internal use only
  4525. */
  4526. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4527. /**
  4528. * Execute the current animation
  4529. * @param delay defines the delay to add to the current frame
  4530. * @param from defines the lower bound of the animation range
  4531. * @param to defines the upper bound of the animation range
  4532. * @param loop defines if the current animation must loop
  4533. * @param speedRatio defines the current speed ratio
  4534. * @param weight defines the weight of the animation (default is -1 so no weight)
  4535. * @returns a boolean indicating if the animation is running
  4536. */
  4537. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4538. }
  4539. }
  4540. declare module BABYLON {
  4541. /**
  4542. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4544. */
  4545. class Analyser {
  4546. /**
  4547. * Gets or sets the smoothing
  4548. * @ignorenaming
  4549. */
  4550. SMOOTHING: number;
  4551. /**
  4552. * Gets or sets the FFT table size
  4553. * @ignorenaming
  4554. */
  4555. FFT_SIZE: number;
  4556. /**
  4557. * Gets or sets the bar graph amplitude
  4558. * @ignorenaming
  4559. */
  4560. BARGRAPHAMPLITUDE: number;
  4561. /**
  4562. * Gets or sets the position of the debug canvas
  4563. * @ignorenaming
  4564. */
  4565. DEBUGCANVASPOS: {
  4566. x: number;
  4567. y: number;
  4568. };
  4569. /**
  4570. * Gets or sets the debug canvas size
  4571. * @ignorenaming
  4572. */
  4573. DEBUGCANVASSIZE: {
  4574. width: number;
  4575. height: number;
  4576. };
  4577. private _byteFreqs;
  4578. private _byteTime;
  4579. private _floatFreqs;
  4580. private _webAudioAnalyser;
  4581. private _debugCanvas;
  4582. private _debugCanvasContext;
  4583. private _scene;
  4584. private _registerFunc;
  4585. private _audioEngine;
  4586. /**
  4587. * Creates a new analyser
  4588. * @param scene defines hosting scene
  4589. */
  4590. constructor(scene: Scene);
  4591. /**
  4592. * Get the number of data values you will have to play with for the visualization
  4593. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4594. * @returns a number
  4595. */
  4596. getFrequencyBinCount(): number;
  4597. /**
  4598. * Gets the current frequency data as a byte array
  4599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4600. * @returns a Uint8Array
  4601. */
  4602. getByteFrequencyData(): Uint8Array;
  4603. /**
  4604. * Gets the current waveform as a byte array
  4605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4606. * @returns a Uint8Array
  4607. */
  4608. getByteTimeDomainData(): Uint8Array;
  4609. /**
  4610. * Gets the current frequency data as a float array
  4611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4612. * @returns a Float32Array
  4613. */
  4614. getFloatFrequencyData(): Float32Array;
  4615. /**
  4616. * Renders the debug canvas
  4617. */
  4618. drawDebugCanvas(): void;
  4619. /**
  4620. * Stops rendering the debug canvas and removes it
  4621. */
  4622. stopDebugCanvas(): void;
  4623. /**
  4624. * Connects two audio nodes
  4625. * @param inputAudioNode defines first node to connect
  4626. * @param outputAudioNode defines second node to connect
  4627. */
  4628. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4629. /**
  4630. * Releases all associated resources
  4631. */
  4632. dispose(): void;
  4633. }
  4634. }
  4635. declare module BABYLON {
  4636. class AudioEngine {
  4637. private _audioContext;
  4638. private _audioContextInitialized;
  4639. canUseWebAudio: boolean;
  4640. masterGain: GainNode;
  4641. private _connectedAnalyser;
  4642. WarnedWebAudioUnsupported: boolean;
  4643. unlocked: boolean;
  4644. onAudioUnlocked: () => any;
  4645. isMP3supported: boolean;
  4646. isOGGsupported: boolean;
  4647. readonly audioContext: Nullable<AudioContext>;
  4648. constructor();
  4649. private _unlockiOSaudio();
  4650. private _initializeAudioContext();
  4651. dispose(): void;
  4652. getGlobalVolume(): number;
  4653. setGlobalVolume(newVolume: number): void;
  4654. connectToAnalyser(analyser: Analyser): void;
  4655. }
  4656. }
  4657. declare module BABYLON {
  4658. class Sound {
  4659. name: string;
  4660. autoplay: boolean;
  4661. loop: boolean;
  4662. useCustomAttenuation: boolean;
  4663. soundTrackId: number;
  4664. spatialSound: boolean;
  4665. refDistance: number;
  4666. rolloffFactor: number;
  4667. maxDistance: number;
  4668. distanceModel: string;
  4669. private _panningModel;
  4670. onended: () => any;
  4671. private _playbackRate;
  4672. private _streaming;
  4673. private _startTime;
  4674. private _startOffset;
  4675. private _position;
  4676. private _localDirection;
  4677. private _volume;
  4678. private _isReadyToPlay;
  4679. isPlaying: boolean;
  4680. isPaused: boolean;
  4681. private _isDirectional;
  4682. private _readyToPlayCallback;
  4683. private _audioBuffer;
  4684. private _soundSource;
  4685. private _streamingSource;
  4686. private _soundPanner;
  4687. private _soundGain;
  4688. private _inputAudioNode;
  4689. private _ouputAudioNode;
  4690. private _coneInnerAngle;
  4691. private _coneOuterAngle;
  4692. private _coneOuterGain;
  4693. private _scene;
  4694. private _connectedMesh;
  4695. private _customAttenuationFunction;
  4696. private _registerFunc;
  4697. private _isOutputConnected;
  4698. private _htmlAudioElement;
  4699. private _urlType;
  4700. /**
  4701. * Create a sound and attach it to a scene
  4702. * @param name Name of your sound
  4703. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4704. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4705. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4706. */
  4707. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4708. dispose(): void;
  4709. isReady(): boolean;
  4710. private _soundLoaded(audioData);
  4711. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4712. updateOptions(options: any): void;
  4713. private _createSpatialParameters();
  4714. private _updateSpatialParameters();
  4715. switchPanningModelToHRTF(): void;
  4716. switchPanningModelToEqualPower(): void;
  4717. private _switchPanningModel();
  4718. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4719. /**
  4720. * Transform this sound into a directional source
  4721. * @param coneInnerAngle Size of the inner cone in degree
  4722. * @param coneOuterAngle Size of the outer cone in degree
  4723. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4724. */
  4725. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4726. setPosition(newPosition: Vector3): void;
  4727. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4728. private _updateDirection();
  4729. updateDistanceFromListener(): void;
  4730. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4731. /**
  4732. * Play the sound
  4733. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4734. * @param offset (optional) Start the sound setting it at a specific time
  4735. */
  4736. play(time?: number, offset?: number): void;
  4737. private _onended();
  4738. /**
  4739. * Stop the sound
  4740. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4741. */
  4742. stop(time?: number): void;
  4743. pause(): void;
  4744. setVolume(newVolume: number, time?: number): void;
  4745. setPlaybackRate(newPlaybackRate: number): void;
  4746. getVolume(): number;
  4747. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4748. detachFromMesh(): void;
  4749. private _onRegisterAfterWorldMatrixUpdate(node);
  4750. clone(): Nullable<Sound>;
  4751. getAudioBuffer(): AudioBuffer | null;
  4752. serialize(): any;
  4753. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4754. }
  4755. }
  4756. declare module BABYLON {
  4757. class SoundTrack {
  4758. private _outputAudioNode;
  4759. private _scene;
  4760. id: number;
  4761. soundCollection: Array<Sound>;
  4762. private _isMainTrack;
  4763. private _connectedAnalyser;
  4764. private _options;
  4765. private _isInitialized;
  4766. constructor(scene: Scene, options?: any);
  4767. private _initializeSoundTrackAudioGraph();
  4768. dispose(): void;
  4769. AddSound(sound: Sound): void;
  4770. RemoveSound(sound: Sound): void;
  4771. setVolume(newVolume: number): void;
  4772. switchPanningModelToHRTF(): void;
  4773. switchPanningModelToEqualPower(): void;
  4774. connectToAnalyser(analyser: Analyser): void;
  4775. }
  4776. }
  4777. declare module BABYLON {
  4778. /**
  4779. * Interface used to define a behavior
  4780. */
  4781. interface Behavior<T> {
  4782. /** gets or sets behavior's name */
  4783. name: string;
  4784. /**
  4785. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4786. */
  4787. init(): void;
  4788. /**
  4789. * Called when the behavior is attached to a target
  4790. * @param target defines the target where the behavior is attached to
  4791. */
  4792. attach(target: T): void;
  4793. /**
  4794. * Called when the behavior is detached from its target
  4795. */
  4796. detach(): void;
  4797. }
  4798. /**
  4799. * Interface implemented by classes supporting behaviors
  4800. */
  4801. interface IBehaviorAware<T> {
  4802. /**
  4803. * Attach a behavior
  4804. * @param behavior defines the behavior to attach
  4805. * @returns the current host
  4806. */
  4807. addBehavior(behavior: Behavior<T>): T;
  4808. /**
  4809. * Remove a behavior from the current object
  4810. * @param behavior defines the behavior to detach
  4811. * @returns the current host
  4812. */
  4813. removeBehavior(behavior: Behavior<T>): T;
  4814. /**
  4815. * Gets a behavior using its name to search
  4816. * @param name defines the name to search
  4817. * @returns the behavior or null if not found
  4818. */
  4819. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4820. }
  4821. }
  4822. declare module BABYLON {
  4823. /**
  4824. * Class used to store bone information
  4825. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4826. */
  4827. class Bone extends Node {
  4828. /**
  4829. * defines the bone name
  4830. */
  4831. name: string;
  4832. private static _tmpVecs;
  4833. private static _tmpQuat;
  4834. private static _tmpMats;
  4835. /**
  4836. * Gets the list of child bones
  4837. */
  4838. children: Bone[];
  4839. /** Gets the animations associated with this bone */
  4840. animations: Animation[];
  4841. /**
  4842. * Gets or sets bone length
  4843. */
  4844. length: number;
  4845. /**
  4846. * @hidden Internal only
  4847. * Set this value to map this bone to a different index in the transform matrices
  4848. * Set this value to -1 to exclude the bone from the transform matrices
  4849. */
  4850. _index: Nullable<number>;
  4851. private _skeleton;
  4852. private _localMatrix;
  4853. private _restPose;
  4854. private _baseMatrix;
  4855. private _absoluteTransform;
  4856. private _invertedAbsoluteTransform;
  4857. private _parent;
  4858. private _scalingDeterminant;
  4859. private _worldTransform;
  4860. private _localScaling;
  4861. private _localRotation;
  4862. private _localPosition;
  4863. private _needToDecompose;
  4864. private _needToCompose;
  4865. /** @hidden */
  4866. /** @hidden */
  4867. _matrix: Matrix;
  4868. /**
  4869. * Create a new bone
  4870. * @param name defines the bone name
  4871. * @param skeleton defines the parent skeleton
  4872. * @param parentBone defines the parent (can be null if the bone is the root)
  4873. * @param localMatrix defines the local matrix
  4874. * @param restPose defines the rest pose matrix
  4875. * @param baseMatrix defines the base matrix
  4876. * @param index defines index of the bone in the hiearchy
  4877. */
  4878. constructor(
  4879. /**
  4880. * defines the bone name
  4881. */
  4882. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4883. /**
  4884. * Gets the parent skeleton
  4885. * @returns a skeleton
  4886. */
  4887. getSkeleton(): Skeleton;
  4888. /**
  4889. * Gets parent bone
  4890. * @returns a bone or null if the bone is the root of the bone hierarchy
  4891. */
  4892. getParent(): Nullable<Bone>;
  4893. /**
  4894. * Sets the parent bone
  4895. * @param parent defines the parent (can be null if the bone is the root)
  4896. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4897. */
  4898. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4899. /**
  4900. * Gets the local matrix
  4901. * @returns a matrix
  4902. */
  4903. getLocalMatrix(): Matrix;
  4904. /**
  4905. * Gets the base matrix (initial matrix which remains unchanged)
  4906. * @returns a matrix
  4907. */
  4908. getBaseMatrix(): Matrix;
  4909. /**
  4910. * Gets the rest pose matrix
  4911. * @returns a matrix
  4912. */
  4913. getRestPose(): Matrix;
  4914. /**
  4915. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4916. */
  4917. getWorldMatrix(): Matrix;
  4918. /**
  4919. * Sets the local matrix to rest pose matrix
  4920. */
  4921. returnToRest(): void;
  4922. /**
  4923. * Gets the inverse of the absolute transform matrix.
  4924. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4925. * @returns a matrix
  4926. */
  4927. getInvertedAbsoluteTransform(): Matrix;
  4928. /**
  4929. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4930. * @returns a matrix
  4931. */
  4932. getAbsoluteTransform(): Matrix;
  4933. /** Gets or sets current position (in local space) */
  4934. position: Vector3;
  4935. /** Gets or sets current rotation (in local space) */
  4936. rotation: Vector3;
  4937. /** Gets or sets current rotation quaternion (in local space) */
  4938. rotationQuaternion: Quaternion;
  4939. /** Gets or sets current scaling (in local space) */
  4940. scaling: Vector3;
  4941. /**
  4942. * Gets the animation properties override
  4943. */
  4944. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4945. private _decompose();
  4946. private _compose();
  4947. /**
  4948. * Update the base and local matrices
  4949. * @param matrix defines the new base or local matrix
  4950. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4951. * @param updateLocalMatrix defines if the local matrix should be updated
  4952. */
  4953. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4954. /** @hidden */
  4955. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4956. /**
  4957. * Flag the bone as dirty (Forcing it to update everything)
  4958. */
  4959. markAsDirty(): void;
  4960. private _markAsDirtyAndCompose();
  4961. private _markAsDirtyAndDecompose();
  4962. /**
  4963. * Copy an animation range from another bone
  4964. * @param source defines the source bone
  4965. * @param rangeName defines the range name to copy
  4966. * @param frameOffset defines the frame offset
  4967. * @param rescaleAsRequired defines if rescaling must be applied if required
  4968. * @param skelDimensionsRatio defines the scaling ratio
  4969. * @returns true if operation was successful
  4970. */
  4971. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4972. /**
  4973. * Translate the bone in local or world space
  4974. * @param vec The amount to translate the bone
  4975. * @param space The space that the translation is in
  4976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4977. */
  4978. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4979. /**
  4980. * Set the postion of the bone in local or world space
  4981. * @param position The position to set the bone
  4982. * @param space The space that the position is in
  4983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4984. */
  4985. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4986. /**
  4987. * Set the absolute position of the bone (world space)
  4988. * @param position The position to set the bone
  4989. * @param mesh The mesh that this bone is attached to
  4990. */
  4991. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4992. /**
  4993. * Scale the bone on the x, y and z axes (in local space)
  4994. * @param x The amount to scale the bone on the x axis
  4995. * @param y The amount to scale the bone on the y axis
  4996. * @param z The amount to scale the bone on the z axis
  4997. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4998. */
  4999. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5000. /**
  5001. * Set the bone scaling in local space
  5002. * @param scale defines the scaling vector
  5003. */
  5004. setScale(scale: Vector3): void;
  5005. /**
  5006. * Gets the current scaling in local space
  5007. * @returns the current scaling vector
  5008. */
  5009. getScale(): Vector3;
  5010. /**
  5011. * Gets the current scaling in local space and stores it in a target vector
  5012. * @param result defines the target vector
  5013. */
  5014. getScaleToRef(result: Vector3): void;
  5015. /**
  5016. * Set the yaw, pitch, and roll of the bone in local or world space
  5017. * @param yaw The rotation of the bone on the y axis
  5018. * @param pitch The rotation of the bone on the x axis
  5019. * @param roll The rotation of the bone on the z axis
  5020. * @param space The space that the axes of rotation are in
  5021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5022. */
  5023. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5024. /**
  5025. * Add a rotation to the bone on an axis in local or world space
  5026. * @param axis The axis to rotate the bone on
  5027. * @param amount The amount to rotate the bone
  5028. * @param space The space that the axis is in
  5029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5030. */
  5031. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5032. /**
  5033. * Set the rotation of the bone to a particular axis angle in local or world space
  5034. * @param axis The axis to rotate the bone on
  5035. * @param angle The angle that the bone should be rotated to
  5036. * @param space The space that the axis is in
  5037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5038. */
  5039. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5040. /**
  5041. * Set the euler rotation of the bone in local of world space
  5042. * @param rotation The euler rotation that the bone should be set to
  5043. * @param space The space that the rotation is in
  5044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5045. */
  5046. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5047. /**
  5048. * Set the quaternion rotation of the bone in local of world space
  5049. * @param quat The quaternion rotation that the bone should be set to
  5050. * @param space The space that the rotation is in
  5051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5052. */
  5053. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5054. /**
  5055. * Set the rotation matrix of the bone in local of world space
  5056. * @param rotMat The rotation matrix that the bone should be set to
  5057. * @param space The space that the rotation is in
  5058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5059. */
  5060. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5061. private _rotateWithMatrix(rmat, space?, mesh?);
  5062. private _getNegativeRotationToRef(rotMatInv, mesh?);
  5063. /**
  5064. * Get the position of the bone in local or world space
  5065. * @param space The space that the returned position is in
  5066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5067. * @returns The position of the bone
  5068. */
  5069. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5070. /**
  5071. * Copy the position of the bone to a vector3 in local or world space
  5072. * @param space The space that the returned position is in
  5073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5074. * @param result The vector3 to copy the position to
  5075. */
  5076. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5077. /**
  5078. * Get the absolute position of the bone (world space)
  5079. * @param mesh The mesh that this bone is attached to
  5080. * @returns The absolute position of the bone
  5081. */
  5082. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5083. /**
  5084. * Copy the absolute position of the bone (world space) to the result param
  5085. * @param mesh The mesh that this bone is attached to
  5086. * @param result The vector3 to copy the absolute position to
  5087. */
  5088. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5089. /**
  5090. * Compute the absolute transforms of this bone and its children
  5091. */
  5092. computeAbsoluteTransforms(): void;
  5093. /**
  5094. * Get the world direction from an axis that is in the local space of the bone
  5095. * @param localAxis The local direction that is used to compute the world direction
  5096. * @param mesh The mesh that this bone is attached to
  5097. * @returns The world direction
  5098. */
  5099. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5100. /**
  5101. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5102. * @param localAxis The local direction that is used to compute the world direction
  5103. * @param mesh The mesh that this bone is attached to
  5104. * @param result The vector3 that the world direction will be copied to
  5105. */
  5106. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5107. /**
  5108. * Get the euler rotation of the bone in local or world space
  5109. * @param space The space that the rotation should be in
  5110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5111. * @returns The euler rotation
  5112. */
  5113. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5114. /**
  5115. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5116. * @param space The space that the rotation should be in
  5117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5118. * @param result The vector3 that the rotation should be copied to
  5119. */
  5120. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5121. /**
  5122. * Get the quaternion rotation of the bone in either local or world space
  5123. * @param space The space that the rotation should be in
  5124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5125. * @returns The quaternion rotation
  5126. */
  5127. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5128. /**
  5129. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5130. * @param space The space that the rotation should be in
  5131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5132. * @param result The quaternion that the rotation should be copied to
  5133. */
  5134. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5135. /**
  5136. * Get the rotation matrix of the bone in local or world space
  5137. * @param space The space that the rotation should be in
  5138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5139. * @returns The rotation matrix
  5140. */
  5141. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5142. /**
  5143. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5144. * @param space The space that the rotation should be in
  5145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5146. * @param result The quaternion that the rotation should be copied to
  5147. */
  5148. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5149. /**
  5150. * Get the world position of a point that is in the local space of the bone
  5151. * @param position The local position
  5152. * @param mesh The mesh that this bone is attached to
  5153. * @returns The world position
  5154. */
  5155. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5156. /**
  5157. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5158. * @param position The local position
  5159. * @param mesh The mesh that this bone is attached to
  5160. * @param result The vector3 that the world position should be copied to
  5161. */
  5162. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5163. /**
  5164. * Get the local position of a point that is in world space
  5165. * @param position The world position
  5166. * @param mesh The mesh that this bone is attached to
  5167. * @returns The local position
  5168. */
  5169. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5170. /**
  5171. * Get the local position of a point that is in world space and copy it to the result param
  5172. * @param position The world position
  5173. * @param mesh The mesh that this bone is attached to
  5174. * @param result The vector3 that the local position should be copied to
  5175. */
  5176. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5177. }
  5178. }
  5179. declare module BABYLON {
  5180. /**
  5181. * Class used to apply inverse kinematics to bones
  5182. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5183. */
  5184. class BoneIKController {
  5185. private static _tmpVecs;
  5186. private static _tmpQuat;
  5187. private static _tmpMats;
  5188. /**
  5189. * Gets or sets the target mesh
  5190. */
  5191. targetMesh: AbstractMesh;
  5192. /** Gets or sets the mesh used as pole */
  5193. poleTargetMesh: AbstractMesh;
  5194. /**
  5195. * Gets or sets the bone used as pole
  5196. */
  5197. poleTargetBone: Nullable<Bone>;
  5198. /**
  5199. * Gets or sets the target position
  5200. */
  5201. targetPosition: Vector3;
  5202. /**
  5203. * Gets or sets the pole target position
  5204. */
  5205. poleTargetPosition: Vector3;
  5206. /**
  5207. * Gets or sets the pole target local offset
  5208. */
  5209. poleTargetLocalOffset: Vector3;
  5210. /**
  5211. * Gets or sets the pole angle
  5212. */
  5213. poleAngle: number;
  5214. /**
  5215. * Gets or sets the mesh associated with the controller
  5216. */
  5217. mesh: AbstractMesh;
  5218. /**
  5219. * 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)
  5220. */
  5221. slerpAmount: number;
  5222. private _bone1Quat;
  5223. private _bone1Mat;
  5224. private _bone2Ang;
  5225. private _bone1;
  5226. private _bone2;
  5227. private _bone1Length;
  5228. private _bone2Length;
  5229. private _maxAngle;
  5230. private _maxReach;
  5231. private _rightHandedSystem;
  5232. private _bendAxis;
  5233. private _slerping;
  5234. private _adjustRoll;
  5235. /**
  5236. * Gets or sets maximum allowed angle
  5237. */
  5238. maxAngle: number;
  5239. /**
  5240. * Creates a new BoneIKController
  5241. * @param mesh defines the mesh to control
  5242. * @param bone defines the bone to control
  5243. * @param options defines options to set up the controller
  5244. */
  5245. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5246. targetMesh?: AbstractMesh;
  5247. poleTargetMesh?: AbstractMesh;
  5248. poleTargetBone?: Bone;
  5249. poleTargetLocalOffset?: Vector3;
  5250. poleAngle?: number;
  5251. bendAxis?: Vector3;
  5252. maxAngle?: number;
  5253. slerpAmount?: number;
  5254. });
  5255. private _setMaxAngle(ang);
  5256. /**
  5257. * Force the controller to update the bones
  5258. */
  5259. update(): void;
  5260. }
  5261. }
  5262. declare module BABYLON {
  5263. /**
  5264. * Class used to make a bone look toward a point in space
  5265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5266. */
  5267. class BoneLookController {
  5268. private static _tmpVecs;
  5269. private static _tmpQuat;
  5270. private static _tmpMats;
  5271. /**
  5272. * The target Vector3 that the bone will look at
  5273. */
  5274. target: Vector3;
  5275. /**
  5276. * The mesh that the bone is attached to
  5277. */
  5278. mesh: AbstractMesh;
  5279. /**
  5280. * The bone that will be looking to the target
  5281. */
  5282. bone: Bone;
  5283. /**
  5284. * The up axis of the coordinate system that is used when the bone is rotated
  5285. */
  5286. upAxis: Vector3;
  5287. /**
  5288. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5289. */
  5290. upAxisSpace: Space;
  5291. /**
  5292. * Used to make an adjustment to the yaw of the bone
  5293. */
  5294. adjustYaw: number;
  5295. /**
  5296. * Used to make an adjustment to the pitch of the bone
  5297. */
  5298. adjustPitch: number;
  5299. /**
  5300. * Used to make an adjustment to the roll of the bone
  5301. */
  5302. adjustRoll: number;
  5303. /**
  5304. * 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)
  5305. */
  5306. slerpAmount: number;
  5307. private _minYaw;
  5308. private _maxYaw;
  5309. private _minPitch;
  5310. private _maxPitch;
  5311. private _minYawSin;
  5312. private _minYawCos;
  5313. private _maxYawSin;
  5314. private _maxYawCos;
  5315. private _midYawConstraint;
  5316. private _minPitchTan;
  5317. private _maxPitchTan;
  5318. private _boneQuat;
  5319. private _slerping;
  5320. private _transformYawPitch;
  5321. private _transformYawPitchInv;
  5322. private _firstFrameSkipped;
  5323. private _yawRange;
  5324. private _fowardAxis;
  5325. /**
  5326. * Gets or sets the minimum yaw angle that the bone can look to
  5327. */
  5328. minYaw: number;
  5329. /**
  5330. * Gets or sets the maximum yaw angle that the bone can look to
  5331. */
  5332. maxYaw: number;
  5333. /**
  5334. * Gets or sets the minimum pitch angle that the bone can look to
  5335. */
  5336. minPitch: number;
  5337. /**
  5338. * Gets or sets the maximum pitch angle that the bone can look to
  5339. */
  5340. maxPitch: number;
  5341. /**
  5342. * Create a BoneLookController
  5343. * @param mesh the mesh that the bone belongs to
  5344. * @param bone the bone that will be looking to the target
  5345. * @param target the target Vector3 to look at
  5346. * @param settings optional settings:
  5347. * * maxYaw: the maximum angle the bone will yaw to
  5348. * * minYaw: the minimum angle the bone will yaw to
  5349. * * maxPitch: the maximum angle the bone will pitch to
  5350. * * minPitch: the minimum angle the bone will yaw to
  5351. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5352. * * upAxis: the up axis of the coordinate system
  5353. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5354. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5355. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5356. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5357. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5358. * * adjustRoll: used to make an adjustment to the roll of the bone
  5359. **/
  5360. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5361. maxYaw?: number;
  5362. minYaw?: number;
  5363. maxPitch?: number;
  5364. minPitch?: number;
  5365. slerpAmount?: number;
  5366. upAxis?: Vector3;
  5367. upAxisSpace?: Space;
  5368. yawAxis?: Vector3;
  5369. pitchAxis?: Vector3;
  5370. adjustYaw?: number;
  5371. adjustPitch?: number;
  5372. adjustRoll?: number;
  5373. });
  5374. /**
  5375. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5376. */
  5377. update(): void;
  5378. private _getAngleDiff(ang1, ang2);
  5379. private _getAngleBetween(ang1, ang2);
  5380. private _isAngleBetween(ang, ang1, ang2);
  5381. }
  5382. }
  5383. declare module BABYLON {
  5384. /**
  5385. * Class used to handle skinning animations
  5386. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5387. */
  5388. class Skeleton implements IAnimatable {
  5389. /** defines the skeleton name */
  5390. name: string;
  5391. /** defines the skeleton Id */
  5392. id: string;
  5393. /**
  5394. * Gets the list of child bones
  5395. */
  5396. bones: Bone[];
  5397. /**
  5398. * Gets an estimate of the dimension of the skeleton at rest
  5399. */
  5400. dimensionsAtRest: Vector3;
  5401. /**
  5402. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5403. */
  5404. needInitialSkinMatrix: boolean;
  5405. /**
  5406. * Gets the list of animations attached to this skeleton
  5407. */
  5408. animations: Array<Animation>;
  5409. private _scene;
  5410. private _isDirty;
  5411. private _transformMatrices;
  5412. private _meshesWithPoseMatrix;
  5413. private _animatables;
  5414. private _identity;
  5415. private _synchronizedWithMesh;
  5416. private _ranges;
  5417. private _lastAbsoluteTransformsUpdateId;
  5418. /**
  5419. * Specifies if the skeleton should be serialized
  5420. */
  5421. doNotSerialize: boolean;
  5422. private _animationPropertiesOverride;
  5423. /**
  5424. * Gets or sets the animation properties override
  5425. */
  5426. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5427. /**
  5428. * An observable triggered before computing the skeleton's matrices
  5429. */
  5430. onBeforeComputeObservable: Observable<Skeleton>;
  5431. /**
  5432. * Creates a new skeleton
  5433. * @param name defines the skeleton name
  5434. * @param id defines the skeleton Id
  5435. * @param scene defines the hosting scene
  5436. */
  5437. constructor(
  5438. /** defines the skeleton name */
  5439. name: string,
  5440. /** defines the skeleton Id */
  5441. id: string, scene: Scene);
  5442. /**
  5443. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5444. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5445. * @returns a Float32Array containing matrices data
  5446. */
  5447. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5448. /**
  5449. * Gets the current hosting scene
  5450. * @returns a scene object
  5451. */
  5452. getScene(): Scene;
  5453. /**
  5454. * Gets a string representing the current skeleton data
  5455. * @param fullDetails defines a boolean indicating if we want a verbose version
  5456. * @returns a string representing the current skeleton data
  5457. */
  5458. toString(fullDetails?: boolean): string;
  5459. /**
  5460. * Get bone's index searching by name
  5461. * @param name defines bone's name to search for
  5462. * @return the indice of the bone. Returns -1 if not found
  5463. */
  5464. getBoneIndexByName(name: string): number;
  5465. /**
  5466. * Creater a new animation range
  5467. * @param name defines the name of the range
  5468. * @param from defines the start key
  5469. * @param to defines the end key
  5470. */
  5471. createAnimationRange(name: string, from: number, to: number): void;
  5472. /**
  5473. * Delete a specific animation range
  5474. * @param name defines the name of the range
  5475. * @param deleteFrames defines if frames must be removed as well
  5476. */
  5477. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5478. /**
  5479. * Gets a specific animation range
  5480. * @param name defines the name of the range to look for
  5481. * @returns the requested animation range or null if not found
  5482. */
  5483. getAnimationRange(name: string): Nullable<AnimationRange>;
  5484. /**
  5485. * Gets the list of all animation ranges defined on this skeleton
  5486. * @returns an array
  5487. */
  5488. getAnimationRanges(): Nullable<AnimationRange>[];
  5489. /**
  5490. * Copy animation range from a source skeleton.
  5491. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5492. * @param source defines the source skeleton
  5493. * @param name defines the name of the range to copy
  5494. * @param rescaleAsRequired defines if rescaling must be applied if required
  5495. * @returns true if operation was successful
  5496. */
  5497. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5498. /**
  5499. * Forces the skeleton to go to rest pose
  5500. */
  5501. returnToRest(): void;
  5502. private _getHighestAnimationFrame();
  5503. /**
  5504. * Begin a specific animation range
  5505. * @param name defines the name of the range to start
  5506. * @param loop defines if looping must be turned on (false by default)
  5507. * @param speedRatio defines the speed ratio to apply (1 by default)
  5508. * @param onAnimationEnd defines a callback which will be called when animation will end
  5509. * @returns a new animatable
  5510. */
  5511. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5512. /** @hidden */
  5513. _markAsDirty(): void;
  5514. /** @hidden */
  5515. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5516. /** @hidden */
  5517. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5518. /** @hidden */
  5519. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5520. /**
  5521. * Build all resources required to render a skeleton
  5522. */
  5523. prepare(): void;
  5524. /**
  5525. * Gets the list of animatables currently running for this skeleton
  5526. * @returns an array of animatables
  5527. */
  5528. getAnimatables(): IAnimatable[];
  5529. /**
  5530. * Clone the current skeleton
  5531. * @param name defines the name of the new skeleton
  5532. * @param id defines the id of the enw skeleton
  5533. * @returns the new skeleton
  5534. */
  5535. clone(name: string, id: string): Skeleton;
  5536. /**
  5537. * Enable animation blending for this skeleton
  5538. * @param blendingSpeed defines the blending speed to apply
  5539. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5540. */
  5541. enableBlending(blendingSpeed?: number): void;
  5542. /**
  5543. * Releases all resources associated with the current skeleton
  5544. */
  5545. dispose(): void;
  5546. /**
  5547. * Serialize the skeleton in a JSON object
  5548. * @returns a JSON object
  5549. */
  5550. serialize(): any;
  5551. /**
  5552. * Creates a new skeleton from serialized data
  5553. * @param parsedSkeleton defines the serialized data
  5554. * @param scene defines the hosting scene
  5555. * @returns a new skeleton
  5556. */
  5557. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5558. /**
  5559. * Compute all node absolute transforms
  5560. * @param forceUpdate defines if computation must be done even if cache is up to date
  5561. */
  5562. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5563. /**
  5564. * Gets the root pose matrix
  5565. * @returns a matrix
  5566. */
  5567. getPoseMatrix(): Nullable<Matrix>;
  5568. /**
  5569. * Sorts bones per internal index
  5570. */
  5571. sortBones(): void;
  5572. private _sortBones(index, bones, visited);
  5573. }
  5574. }
  5575. declare module BABYLON {
  5576. class BoundingBox implements ICullable {
  5577. vectors: Vector3[];
  5578. center: Vector3;
  5579. centerWorld: Vector3;
  5580. extendSize: Vector3;
  5581. extendSizeWorld: Vector3;
  5582. directions: Vector3[];
  5583. vectorsWorld: Vector3[];
  5584. minimumWorld: Vector3;
  5585. maximumWorld: Vector3;
  5586. minimum: Vector3;
  5587. maximum: Vector3;
  5588. private _worldMatrix;
  5589. /**
  5590. * Creates a new bounding box
  5591. * @param min defines the minimum vector (in local space)
  5592. * @param max defines the maximum vector (in local space)
  5593. */
  5594. constructor(min: Vector3, max: Vector3);
  5595. /**
  5596. * Recreates the entire bounding box from scratch
  5597. * @param min defines the new minimum vector (in local space)
  5598. * @param max defines the new maximum vector (in local space)
  5599. */
  5600. reConstruct(min: Vector3, max: Vector3): void;
  5601. /**
  5602. * Scale the current bounding box by applying a scale factor
  5603. * @param factor defines the scale factor to apply
  5604. * @returns the current bounding box
  5605. */
  5606. scale(factor: number): BoundingBox;
  5607. getWorldMatrix(): Matrix;
  5608. setWorldMatrix(matrix: Matrix): BoundingBox;
  5609. _update(world: Matrix): void;
  5610. isInFrustum(frustumPlanes: Plane[]): boolean;
  5611. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5612. intersectsPoint(point: Vector3): boolean;
  5613. intersectsSphere(sphere: BoundingSphere): boolean;
  5614. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5615. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5616. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5617. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5618. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5619. }
  5620. }
  5621. declare module BABYLON {
  5622. interface ICullable {
  5623. isInFrustum(frustumPlanes: Plane[]): boolean;
  5624. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5625. }
  5626. class BoundingInfo implements ICullable {
  5627. minimum: Vector3;
  5628. maximum: Vector3;
  5629. boundingBox: BoundingBox;
  5630. boundingSphere: BoundingSphere;
  5631. private _isLocked;
  5632. constructor(minimum: Vector3, maximum: Vector3);
  5633. isLocked: boolean;
  5634. update(world: Matrix): void;
  5635. /**
  5636. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5637. * @param center New center of the bounding info
  5638. * @param extend New extend of the bounding info
  5639. */
  5640. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5641. /**
  5642. * Scale the current bounding info by applying a scale factor
  5643. * @param factor defines the scale factor to apply
  5644. * @returns the current bounding info
  5645. */
  5646. scale(factor: number): BoundingInfo;
  5647. isInFrustum(frustumPlanes: Plane[]): boolean;
  5648. /**
  5649. * Gets the world distance between the min and max points of the bounding box
  5650. */
  5651. readonly diagonalLength: number;
  5652. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5653. _checkCollision(collider: Collider): boolean;
  5654. intersectsPoint(point: Vector3): boolean;
  5655. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5656. }
  5657. }
  5658. declare module BABYLON {
  5659. class BoundingSphere {
  5660. center: Vector3;
  5661. radius: number;
  5662. centerWorld: Vector3;
  5663. radiusWorld: number;
  5664. minimum: Vector3;
  5665. maximum: Vector3;
  5666. private _tempRadiusVector;
  5667. /**
  5668. * Creates a new bounding sphere
  5669. * @param min defines the minimum vector (in local space)
  5670. * @param max defines the maximum vector (in local space)
  5671. */
  5672. constructor(min: Vector3, max: Vector3);
  5673. /**
  5674. * Recreates the entire bounding sphere from scratch
  5675. * @param min defines the new minimum vector (in local space)
  5676. * @param max defines the new maximum vector (in local space)
  5677. */
  5678. reConstruct(min: Vector3, max: Vector3): void;
  5679. /**
  5680. * Scale the current bounding sphere by applying a scale factor
  5681. * @param factor defines the scale factor to apply
  5682. * @returns the current bounding box
  5683. */
  5684. scale(factor: number): BoundingSphere;
  5685. _update(world: Matrix): void;
  5686. isInFrustum(frustumPlanes: Plane[]): boolean;
  5687. intersectsPoint(point: Vector3): boolean;
  5688. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5689. }
  5690. }
  5691. declare module BABYLON {
  5692. class Ray {
  5693. origin: Vector3;
  5694. direction: Vector3;
  5695. length: number;
  5696. private _edge1;
  5697. private _edge2;
  5698. private _pvec;
  5699. private _tvec;
  5700. private _qvec;
  5701. private _tmpRay;
  5702. constructor(origin: Vector3, direction: Vector3, length?: number);
  5703. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5704. intersectsBox(box: BoundingBox): boolean;
  5705. intersectsSphere(sphere: BoundingSphere): boolean;
  5706. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5707. intersectsPlane(plane: Plane): Nullable<number>;
  5708. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5709. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5710. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5711. private static smallnum;
  5712. private static rayl;
  5713. /**
  5714. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5715. * @param sega the first point of the segment to test the intersection against
  5716. * @param segb the second point of the segment to test the intersection against
  5717. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5718. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5719. */
  5720. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5721. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5722. static Zero(): Ray;
  5723. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5724. /**
  5725. * 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
  5726. * transformed to the given world matrix.
  5727. * @param origin The origin point
  5728. * @param end The end point
  5729. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5730. */
  5731. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5732. static Transform(ray: Ray, matrix: Matrix): Ray;
  5733. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5734. }
  5735. }
  5736. /**
  5737. * Module Debug contains the (visual) components to debug a scene correctly
  5738. */
  5739. declare module BABYLON.Debug {
  5740. /**
  5741. * The Axes viewer will show 3 axes in a specific point in space
  5742. */
  5743. class AxesViewer {
  5744. private _xline;
  5745. private _yline;
  5746. private _zline;
  5747. private _xmesh;
  5748. private _ymesh;
  5749. private _zmesh;
  5750. /**
  5751. * Gets the hosting scene
  5752. */
  5753. scene: Nullable<Scene>;
  5754. /**
  5755. * Gets or sets a number used to scale line length
  5756. */
  5757. scaleLines: number;
  5758. /**
  5759. * Creates a new AxesViewer
  5760. * @param scene defines the hosting scene
  5761. * @param scaleLines defines a number used to scale line length (1 by default)
  5762. */
  5763. constructor(scene: Scene, scaleLines?: number);
  5764. /**
  5765. * Force the viewer to update
  5766. * @param position defines the position of the viewer
  5767. * @param xaxis defines the x axis of the viewer
  5768. * @param yaxis defines the y axis of the viewer
  5769. * @param zaxis defines the z axis of the viewer
  5770. */
  5771. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5772. /** Releases resources */
  5773. dispose(): void;
  5774. }
  5775. }
  5776. declare module BABYLON.Debug {
  5777. /**
  5778. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5779. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  5780. */
  5781. class BoneAxesViewer extends AxesViewer {
  5782. /**
  5783. * Gets or sets the target mesh where to display the axes viewer
  5784. */
  5785. mesh: Nullable<Mesh>;
  5786. /**
  5787. * Gets or sets the target bone where to display the axes viewer
  5788. */
  5789. bone: Nullable<Bone>;
  5790. /** Gets current position */
  5791. pos: Vector3;
  5792. /** Gets direction of X axis */
  5793. xaxis: Vector3;
  5794. /** Gets direction of Y axis */
  5795. yaxis: Vector3;
  5796. /** Gets direction of Z axis */
  5797. zaxis: Vector3;
  5798. /**
  5799. * Creates a new BoneAxesViewer
  5800. * @param scene defines the hosting scene
  5801. * @param bone defines the target bone
  5802. * @param mesh defines the target mesh
  5803. * @param scaleLines defines a scaling factor for line length (1 by default)
  5804. */
  5805. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5806. /**
  5807. * Force the viewer to update
  5808. */
  5809. update(): void;
  5810. /** Releases resources */
  5811. dispose(): void;
  5812. }
  5813. }
  5814. declare module BABYLON {
  5815. class DebugLayer {
  5816. private _scene;
  5817. static InspectorURL: string;
  5818. private _inspector;
  5819. private BJSINSPECTOR;
  5820. onPropertyChangedObservable: Observable<{
  5821. object: any;
  5822. property: string;
  5823. value: any;
  5824. initialValue: any;
  5825. }>;
  5826. constructor(scene: Scene);
  5827. /** Creates the inspector window. */
  5828. private _createInspector(config?);
  5829. isVisible(): boolean;
  5830. hide(): void;
  5831. /**
  5832. *
  5833. * Launch the debugLayer.
  5834. *
  5835. * initialTab:
  5836. * | Value | Tab Name |
  5837. * | --- | --- |
  5838. * | 0 | Scene |
  5839. * | 1 | Console |
  5840. * | 2 | Stats |
  5841. * | 3 | Textures |
  5842. * | 4 | Mesh |
  5843. * | 5 | Light |
  5844. * | 6 | Material |
  5845. * | 7 | GLTF |
  5846. * | 8 | GUI |
  5847. * | 9 | Physics |
  5848. * | 10 | Camera |
  5849. * | 11 | Audio |
  5850. *
  5851. */
  5852. show(config?: {
  5853. popup?: boolean;
  5854. initialTab?: number;
  5855. parentElement?: HTMLElement;
  5856. newColors?: {
  5857. backgroundColor?: string;
  5858. backgroundColorLighter?: string;
  5859. backgroundColorLighter2?: string;
  5860. backgroundColorLighter3?: string;
  5861. color?: string;
  5862. colorTop?: string;
  5863. colorBot?: string;
  5864. };
  5865. }): void;
  5866. /**
  5867. * Gets the active tab
  5868. * @return the index of the active tab or -1 if the inspector is hidden
  5869. */
  5870. getActiveTab(): number;
  5871. }
  5872. }
  5873. declare module BABYLON.Debug {
  5874. /**
  5875. * Used to show the physics impostor around the specific mesh
  5876. */
  5877. class PhysicsViewer {
  5878. /** @hidden */
  5879. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5880. /** @hidden */
  5881. protected _meshes: Array<Nullable<AbstractMesh>>;
  5882. /** @hidden */
  5883. protected _scene: Nullable<Scene>;
  5884. /** @hidden */
  5885. protected _numMeshes: number;
  5886. /** @hidden */
  5887. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5888. private _renderFunction;
  5889. private _debugBoxMesh;
  5890. private _debugSphereMesh;
  5891. private _debugMaterial;
  5892. /**
  5893. * Creates a new PhysicsViewer
  5894. * @param scene defines the hosting scene
  5895. */
  5896. constructor(scene: Scene);
  5897. /** @hidden */
  5898. protected _updateDebugMeshes(): void;
  5899. /**
  5900. * Renders a specified physic impostor
  5901. * @param impostor defines the impostor to render
  5902. */
  5903. showImpostor(impostor: PhysicsImpostor): void;
  5904. /**
  5905. * Hides a specified physic impostor
  5906. * @param impostor defines the impostor to hide
  5907. */
  5908. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5909. private _getDebugMaterial(scene);
  5910. private _getDebugBoxMesh(scene);
  5911. private _getDebugSphereMesh(scene);
  5912. private _getDebugMesh(impostor, scene);
  5913. /** Releases all resources */
  5914. dispose(): void;
  5915. }
  5916. }
  5917. declare module BABYLON {
  5918. class RayHelper {
  5919. ray: Nullable<Ray>;
  5920. private _renderPoints;
  5921. private _renderLine;
  5922. private _renderFunction;
  5923. private _scene;
  5924. private _updateToMeshFunction;
  5925. private _attachedToMesh;
  5926. private _meshSpaceDirection;
  5927. private _meshSpaceOrigin;
  5928. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5929. constructor(ray: Ray);
  5930. show(scene: Scene, color?: Color3): void;
  5931. hide(): void;
  5932. private _render();
  5933. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5934. detachFromMesh(): void;
  5935. private _updateToMesh();
  5936. dispose(): void;
  5937. }
  5938. }
  5939. declare module BABYLON.Debug {
  5940. /**
  5941. * Class used to render a debug view of a given skeleton
  5942. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  5943. */
  5944. class SkeletonViewer {
  5945. /** defines the skeleton to render */
  5946. skeleton: Skeleton;
  5947. /** defines the mesh attached to the skeleton */
  5948. mesh: AbstractMesh;
  5949. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  5950. autoUpdateBonesMatrices: boolean;
  5951. /** defines the rendering group id to use with the viewer */
  5952. renderingGroupId: number;
  5953. /** Gets or sets the color used to render the skeleton */
  5954. color: Color3;
  5955. private _scene;
  5956. private _debugLines;
  5957. private _debugMesh;
  5958. private _isEnabled;
  5959. private _renderFunction;
  5960. /**
  5961. * Creates a new SkeletonViewer
  5962. * @param skeleton defines the skeleton to render
  5963. * @param mesh defines the mesh attached to the skeleton
  5964. * @param scene defines the hosting scene
  5965. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  5966. * @param renderingGroupId defines the rendering group id to use with the viewer
  5967. */
  5968. constructor(
  5969. /** defines the skeleton to render */
  5970. skeleton: Skeleton,
  5971. /** defines the mesh attached to the skeleton */
  5972. mesh: AbstractMesh, scene: Scene,
  5973. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  5974. autoUpdateBonesMatrices?: boolean,
  5975. /** defines the rendering group id to use with the viewer */
  5976. renderingGroupId?: number);
  5977. /** Gets or sets a boolean indicating if the viewer is enabled */
  5978. isEnabled: boolean;
  5979. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5980. private _getLinesForBonesWithLength(bones, meshMat);
  5981. private _getLinesForBonesNoLength(bones, meshMat);
  5982. /** Update the viewer to sync with current skeleton state */
  5983. update(): void;
  5984. /** Release associated resources */
  5985. dispose(): void;
  5986. }
  5987. }
  5988. declare module BABYLON {
  5989. /**
  5990. * Interface for attribute information associated with buffer instanciation
  5991. */
  5992. class InstancingAttributeInfo {
  5993. /**
  5994. * Index/offset of the attribute in the vertex shader
  5995. */
  5996. index: number;
  5997. /**
  5998. * size of the attribute, 1, 2, 3 or 4
  5999. */
  6000. attributeSize: number;
  6001. /**
  6002. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6003. * default is FLOAT
  6004. */
  6005. attribyteType: number;
  6006. /**
  6007. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6008. */
  6009. normalized: boolean;
  6010. /**
  6011. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6012. */
  6013. offset: number;
  6014. /**
  6015. * Name of the GLSL attribute, for debugging purpose only
  6016. */
  6017. attributeName: string;
  6018. }
  6019. /**
  6020. * Define options used to create a render target texture
  6021. */
  6022. class RenderTargetCreationOptions {
  6023. /**
  6024. * Specifies is mipmaps must be generated
  6025. */
  6026. generateMipMaps?: boolean;
  6027. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6028. generateDepthBuffer?: boolean;
  6029. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6030. generateStencilBuffer?: boolean;
  6031. /** Defines texture type (int by default) */
  6032. type?: number;
  6033. /** Defines sampling mode (trilinear by default) */
  6034. samplingMode?: number;
  6035. /** Defines format (RGBA by default) */
  6036. format?: number;
  6037. }
  6038. /**
  6039. * Define options used to create a depth texture
  6040. */
  6041. class DepthTextureCreationOptions {
  6042. /** Specifies whether or not a stencil should be allocated in the texture */
  6043. generateStencil?: boolean;
  6044. /** Specifies whether or not bilinear filtering is enable on the texture */
  6045. bilinearFiltering?: boolean;
  6046. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6047. comparisonFunction?: number;
  6048. /** Specifies if the created texture is a cube texture */
  6049. isCube?: boolean;
  6050. }
  6051. /**
  6052. * Class used to describe the capabilities of the engine relatively to the current browser
  6053. */
  6054. class EngineCapabilities {
  6055. /** Maximum textures units per fragment shader */
  6056. maxTexturesImageUnits: number;
  6057. /** Maximum texture units per vertex shader */
  6058. maxVertexTextureImageUnits: number;
  6059. /** Maximum textures units in the entire pipeline */
  6060. maxCombinedTexturesImageUnits: number;
  6061. /** Maximum texture size */
  6062. maxTextureSize: number;
  6063. /** Maximum cube texture size */
  6064. maxCubemapTextureSize: number;
  6065. /** Maximum render texture size */
  6066. maxRenderTextureSize: number;
  6067. /** Maximum number of vertex attributes */
  6068. maxVertexAttribs: number;
  6069. /** Maximum number of varyings */
  6070. maxVaryingVectors: number;
  6071. /** Maximum number of uniforms per vertex shader */
  6072. maxVertexUniformVectors: number;
  6073. /** Maximum number of uniforms per fragment shader */
  6074. maxFragmentUniformVectors: number;
  6075. /** Defines if standard derivates (dx/dy) are supported */
  6076. standardDerivatives: boolean;
  6077. /** Defines if s3tc texture compression is supported */
  6078. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6079. /** Defines if pvrtc texture compression is supported */
  6080. pvrtc: any;
  6081. /** Defines if etc1 texture compression is supported */
  6082. etc1: any;
  6083. /** Defines if etc2 texture compression is supported */
  6084. etc2: any;
  6085. /** Defines if astc texture compression is supported */
  6086. astc: any;
  6087. /** Defines if float textures are supported */
  6088. textureFloat: boolean;
  6089. /** Defines if vertex array objects are supported */
  6090. vertexArrayObject: boolean;
  6091. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6092. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6093. /** Gets the maximum level of anisotropy supported */
  6094. maxAnisotropy: number;
  6095. /** Defines if instancing is supported */
  6096. instancedArrays: boolean;
  6097. /** Defines if 32 bits indices are supported */
  6098. uintIndices: boolean;
  6099. /** Defines if high precision shaders are supported */
  6100. highPrecisionShaderSupported: boolean;
  6101. /** Defines if depth reading in the fragment shader is supported */
  6102. fragmentDepthSupported: boolean;
  6103. /** Defines if float texture linear filtering is supported*/
  6104. textureFloatLinearFiltering: boolean;
  6105. /** Defines if rendering to float textures is supported */
  6106. textureFloatRender: boolean;
  6107. /** Defines if half float textures are supported*/
  6108. textureHalfFloat: boolean;
  6109. /** Defines if half float texture linear filtering is supported*/
  6110. textureHalfFloatLinearFiltering: boolean;
  6111. /** Defines if rendering to half float textures is supported */
  6112. textureHalfFloatRender: boolean;
  6113. /** Defines if textureLOD shader command is supported */
  6114. textureLOD: boolean;
  6115. /** Defines if draw buffers extension is supported */
  6116. drawBuffersExtension: boolean;
  6117. /** Defines if depth textures are supported */
  6118. depthTextureExtension: boolean;
  6119. /** Defines if float color buffer are supported */
  6120. colorBufferFloat: boolean;
  6121. /** Gets disjoint timer query extension (null if not supported) */
  6122. timerQuery: EXT_disjoint_timer_query;
  6123. /** Defines if timestamp can be used with timer query */
  6124. canUseTimestampForTimerQuery: boolean;
  6125. }
  6126. /** Interface defining initialization parameters for Engine class */
  6127. interface EngineOptions extends WebGLContextAttributes {
  6128. /**
  6129. * Defines if the engine should no exceed a specified device ratio
  6130. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6131. */
  6132. limitDeviceRatio?: number;
  6133. /**
  6134. * Defines if webvr should be enabled automatically
  6135. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6136. */
  6137. autoEnableWebVR?: boolean;
  6138. /**
  6139. * Defines if webgl2 should be turned off even if supported
  6140. * @see http://doc.babylonjs.com/features/webgl2
  6141. */
  6142. disableWebGL2Support?: boolean;
  6143. /**
  6144. * Defines if webaudio should be initialized as well
  6145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6146. */
  6147. audioEngine?: boolean;
  6148. /**
  6149. * Defines if animations should run using a deterministic lock step
  6150. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6151. */
  6152. deterministicLockstep?: boolean;
  6153. /** Defines the maximum steps to use with deterministic lock step mode */
  6154. lockstepMaxSteps?: number;
  6155. /**
  6156. * Defines that engine should ignore context lost events
  6157. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6158. */
  6159. doNotHandleContextLost?: boolean;
  6160. }
  6161. /**
  6162. * Defines the interface used by display changed events
  6163. */
  6164. interface IDisplayChangedEventArgs {
  6165. /** Gets the vrDisplay object (if any) */
  6166. vrDisplay: Nullable<any>;
  6167. /** Gets a boolean indicating if webVR is supported */
  6168. vrSupported: boolean;
  6169. }
  6170. /**
  6171. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6172. */
  6173. class Engine {
  6174. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6175. static ExceptionList: ({
  6176. key: string;
  6177. capture: string;
  6178. captureConstraint: number;
  6179. targets: string[];
  6180. } | {
  6181. key: string;
  6182. capture: null;
  6183. captureConstraint: null;
  6184. targets: string[];
  6185. })[];
  6186. /** Gets the list of created engines */
  6187. static Instances: Engine[];
  6188. /**
  6189. * Gets the latest created engine
  6190. */
  6191. static readonly LastCreatedEngine: Nullable<Engine>;
  6192. /**
  6193. * Gets the latest created scene
  6194. */
  6195. static readonly LastCreatedScene: Nullable<Scene>;
  6196. /**
  6197. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6198. * @param flag defines which part of the materials must be marked as dirty
  6199. * @param predicate defines a predicate used to filter which materials should be affected
  6200. */
  6201. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6202. /** Defines that alpha blending is disabled */
  6203. static readonly ALPHA_DISABLE: number;
  6204. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6205. static readonly ALPHA_ADD: number;
  6206. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6207. static readonly ALPHA_COMBINE: number;
  6208. /** Defines that alpha blending to DEST - SRC * DEST */
  6209. static readonly ALPHA_SUBTRACT: number;
  6210. /** Defines that alpha blending to SRC * DEST */
  6211. static readonly ALPHA_MULTIPLY: number;
  6212. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6213. static readonly ALPHA_MAXIMIZED: number;
  6214. /** Defines that alpha blending to SRC + DEST */
  6215. static readonly ALPHA_ONEONE: number;
  6216. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6217. static readonly ALPHA_PREMULTIPLIED: number;
  6218. /**
  6219. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6220. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6221. */
  6222. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6223. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6224. static readonly ALPHA_INTERPOLATE: number;
  6225. /**
  6226. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6227. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6228. */
  6229. static readonly ALPHA_SCREENMODE: number;
  6230. /** Defines that the ressource is not delayed*/
  6231. static readonly DELAYLOADSTATE_NONE: number;
  6232. /** Defines that the ressource was successfully delay loaded */
  6233. static readonly DELAYLOADSTATE_LOADED: number;
  6234. /** Defines that the ressource is currently delay loading */
  6235. static readonly DELAYLOADSTATE_LOADING: number;
  6236. /** Defines that the ressource is delayed and has not started loading */
  6237. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6238. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6239. static readonly NEVER: number;
  6240. /** 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 */
  6241. static readonly ALWAYS: number;
  6242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6243. static readonly LESS: number;
  6244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6245. static readonly EQUAL: number;
  6246. /** 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 */
  6247. static readonly LEQUAL: number;
  6248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6249. static readonly GREATER: number;
  6250. /** 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 */
  6251. static readonly GEQUAL: number;
  6252. /** 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 */
  6253. static readonly NOTEQUAL: number;
  6254. /** Passed to stencilOperation to specify that stencil value must be kept */
  6255. static readonly KEEP: number;
  6256. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6257. static readonly REPLACE: number;
  6258. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6259. static readonly INCR: number;
  6260. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6261. static readonly DECR: number;
  6262. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6263. static readonly INVERT: number;
  6264. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6265. static readonly INCR_WRAP: number;
  6266. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6267. static readonly DECR_WRAP: number;
  6268. /** Texture is not repeating outside of 0..1 UVs */
  6269. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  6270. /** Texture is repeating outside of 0..1 UVs */
  6271. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  6272. /** Texture is repeating and mirrored */
  6273. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  6274. /** ALPHA */
  6275. static readonly TEXTUREFORMAT_ALPHA: number;
  6276. /** LUMINANCE */
  6277. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6278. /** LUMINANCE_ALPHA */
  6279. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6280. /** RGB */
  6281. static readonly TEXTUREFORMAT_RGB: number;
  6282. /** RGBA */
  6283. static readonly TEXTUREFORMAT_RGBA: number;
  6284. /** R */
  6285. static readonly TEXTUREFORMAT_R: number;
  6286. /** RG */
  6287. static readonly TEXTUREFORMAT_RG: number;
  6288. /** UNSIGNED_INT */
  6289. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6290. /** FLOAT */
  6291. static readonly TEXTURETYPE_FLOAT: number;
  6292. /** HALF_FLOAT */
  6293. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6294. /** nearest is mag = nearest and min = nearest and mip = linear */
  6295. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  6296. /** Bilinear is mag = linear and min = linear and mip = nearest */
  6297. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  6298. /** Trilinear is mag = linear and min = linear and mip = linear */
  6299. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  6300. /** nearest is mag = nearest and min = nearest and mip = linear */
  6301. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  6302. /** Bilinear is mag = linear and min = linear and mip = nearest */
  6303. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  6304. /** Trilinear is mag = linear and min = linear and mip = linear */
  6305. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  6306. /** mag = nearest and min = nearest and mip = nearest */
  6307. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  6308. /** mag = nearest and min = linear and mip = nearest */
  6309. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  6310. /** mag = nearest and min = linear and mip = linear */
  6311. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  6312. /** mag = nearest and min = linear and mip = none */
  6313. static readonly TEXTURE_NEAREST_LINEAR: number;
  6314. /** mag = nearest and min = nearest and mip = none */
  6315. static readonly TEXTURE_NEAREST_NEAREST: number;
  6316. /** mag = linear and min = nearest and mip = nearest */
  6317. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  6318. /** mag = linear and min = nearest and mip = linear */
  6319. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  6320. /** mag = linear and min = linear and mip = none */
  6321. static readonly TEXTURE_LINEAR_LINEAR: number;
  6322. /** mag = linear and min = nearest and mip = none */
  6323. static readonly TEXTURE_LINEAR_NEAREST: number;
  6324. /** Explicit coordinates mode */
  6325. static readonly TEXTURE_EXPLICIT_MODE: number;
  6326. /** Spherical coordinates mode */
  6327. static readonly TEXTURE_SPHERICAL_MODE: number;
  6328. /** Planar coordinates mode */
  6329. static readonly TEXTURE_PLANAR_MODE: number;
  6330. /** Cubic coordinates mode */
  6331. static readonly TEXTURE_CUBIC_MODE: number;
  6332. /** Projection coordinates mode */
  6333. static readonly TEXTURE_PROJECTION_MODE: number;
  6334. /** Skybox coordinates mode */
  6335. static readonly TEXTURE_SKYBOX_MODE: number;
  6336. /** Inverse Cubic coordinates mode */
  6337. static readonly TEXTURE_INVCUBIC_MODE: number;
  6338. /** Equirectangular coordinates mode */
  6339. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  6340. /** Equirectangular Fixed coordinates mode */
  6341. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  6342. /** Equirectangular Fixed Mirrored coordinates mode */
  6343. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  6344. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6345. static readonly SCALEMODE_FLOOR: number;
  6346. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6347. static readonly SCALEMODE_NEAREST: number;
  6348. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6349. static readonly SCALEMODE_CEILING: number;
  6350. /**
  6351. * Returns the current version of the framework
  6352. */
  6353. static readonly Version: string;
  6354. /**
  6355. * Gets or sets the epsilon value used by collision engine
  6356. */
  6357. static CollisionsEpsilon: number;
  6358. /**
  6359. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6360. */
  6361. static CodeRepository: string;
  6362. /**
  6363. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6364. */
  6365. static ShadersRepository: string;
  6366. /**
  6367. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6368. */
  6369. forcePOTTextures: boolean;
  6370. /**
  6371. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6372. */
  6373. isFullscreen: boolean;
  6374. /**
  6375. * Gets a boolean indicating if the pointer is currently locked
  6376. */
  6377. isPointerLock: boolean;
  6378. /**
  6379. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6380. */
  6381. cullBackFaces: boolean;
  6382. /**
  6383. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6384. */
  6385. renderEvenInBackground: boolean;
  6386. /**
  6387. * Gets or sets a boolean indicating that cache can be kept between frames
  6388. */
  6389. preventCacheWipeBetweenFrames: boolean;
  6390. /**
  6391. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6392. **/
  6393. enableOfflineSupport: boolean;
  6394. /**
  6395. * 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)
  6396. **/
  6397. disableManifestCheck: boolean;
  6398. /**
  6399. * Gets the list of created scenes
  6400. */
  6401. scenes: Scene[];
  6402. /**
  6403. * Gets the list of created postprocesses
  6404. */
  6405. postProcesses: PostProcess[];
  6406. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  6407. validateShaderPrograms: boolean;
  6408. /**
  6409. * Observable event triggered each time the rendering canvas is resized
  6410. */
  6411. onResizeObservable: Observable<Engine>;
  6412. /**
  6413. * Observable event triggered each time the canvas loses focus
  6414. */
  6415. onCanvasBlurObservable: Observable<Engine>;
  6416. /**
  6417. * Observable event triggered each time the canvas gains focus
  6418. */
  6419. onCanvasFocusObservable: Observable<Engine>;
  6420. /**
  6421. * Observable event triggered each time the canvas receives pointerout event
  6422. */
  6423. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6424. /**
  6425. * Observable event triggered before each texture is initialized
  6426. */
  6427. onBeforeTextureInitObservable: Observable<Texture>;
  6428. private _vrDisplay;
  6429. private _vrSupported;
  6430. private _oldSize;
  6431. private _oldHardwareScaleFactor;
  6432. private _vrExclusivePointerMode;
  6433. private _webVRInitPromise;
  6434. /**
  6435. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6436. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6437. */
  6438. readonly isInVRExclusivePointerMode: boolean;
  6439. /**
  6440. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6441. */
  6442. disableUniformBuffers: boolean;
  6443. /** @hidden */
  6444. _uniformBuffers: UniformBuffer[];
  6445. /**
  6446. * Gets a boolean indicating that the engine supports uniform buffers
  6447. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6448. */
  6449. readonly supportsUniformBuffers: boolean;
  6450. /**
  6451. * Observable raised when the engine begins a new frame
  6452. */
  6453. onBeginFrameObservable: Observable<Engine>;
  6454. /**
  6455. * Observable raised when the engine ends the current frame
  6456. */
  6457. onEndFrameObservable: Observable<Engine>;
  6458. /**
  6459. * Observable raised when the engine is about to compile a shader
  6460. */
  6461. onBeforeShaderCompilationObservable: Observable<Engine>;
  6462. /**
  6463. * Observable raised when the engine has jsut compiled a shader
  6464. */
  6465. onAfterShaderCompilationObservable: Observable<Engine>;
  6466. /** @hidden */
  6467. _gl: WebGLRenderingContext;
  6468. private _renderingCanvas;
  6469. private _windowIsBackground;
  6470. private _webGLVersion;
  6471. /**
  6472. * Gets a boolean indicating that only power of 2 textures are supported
  6473. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6474. */
  6475. readonly needPOTTextures: boolean;
  6476. /** @hidden */
  6477. _badOS: boolean;
  6478. /** @hidden */
  6479. _badDesktopOS: boolean;
  6480. /**
  6481. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6482. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6483. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6484. */
  6485. disableTextureBindingOptimization: boolean;
  6486. /**
  6487. * Gets the audio engine
  6488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6489. * @ignorenaming
  6490. */
  6491. static audioEngine: AudioEngine;
  6492. private _onFocus;
  6493. private _onBlur;
  6494. private _onCanvasPointerOut;
  6495. private _onCanvasBlur;
  6496. private _onCanvasFocus;
  6497. private _onFullscreenChange;
  6498. private _onPointerLockChange;
  6499. private _onVRDisplayPointerRestricted;
  6500. private _onVRDisplayPointerUnrestricted;
  6501. private _onVrDisplayConnect;
  6502. private _onVrDisplayDisconnect;
  6503. private _onVrDisplayPresentChange;
  6504. /**
  6505. * Observable signaled when VR display mode changes
  6506. */
  6507. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6508. /**
  6509. * Observable signaled when VR request present is complete
  6510. */
  6511. onVRRequestPresentComplete: Observable<boolean>;
  6512. /**
  6513. * Observable signaled when VR request present starts
  6514. */
  6515. onVRRequestPresentStart: Observable<Engine>;
  6516. private _hardwareScalingLevel;
  6517. /** @hidden */
  6518. protected _caps: EngineCapabilities;
  6519. private _pointerLockRequested;
  6520. private _isStencilEnable;
  6521. private _colorWrite;
  6522. private _loadingScreen;
  6523. /** @hidden */
  6524. _drawCalls: PerfCounter;
  6525. /** @hidden */
  6526. _textureCollisions: PerfCounter;
  6527. private _glVersion;
  6528. private _glRenderer;
  6529. private _glVendor;
  6530. private _videoTextureSupported;
  6531. private _renderingQueueLaunched;
  6532. private _activeRenderLoops;
  6533. private _deterministicLockstep;
  6534. private _lockstepMaxSteps;
  6535. /**
  6536. * Observable signaled when a context lost event is raised
  6537. */
  6538. onContextLostObservable: Observable<Engine>;
  6539. /**
  6540. * Observable signaled when a context restored event is raised
  6541. */
  6542. onContextRestoredObservable: Observable<Engine>;
  6543. private _onContextLost;
  6544. private _onContextRestored;
  6545. private _contextWasLost;
  6546. private _doNotHandleContextLost;
  6547. /**
  6548. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  6549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  6550. */
  6551. doNotHandleContextLost: boolean;
  6552. private _performanceMonitor;
  6553. private _fps;
  6554. private _deltaTime;
  6555. /**
  6556. * Turn this value on if you want to pause FPS computation when in background
  6557. */
  6558. disablePerformanceMonitorInBackground: boolean;
  6559. /**
  6560. * Gets the performance monitor attached to this engine
  6561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6562. */
  6563. readonly performanceMonitor: PerformanceMonitor;
  6564. /** @hidden */
  6565. protected _depthCullingState: _DepthCullingState;
  6566. /** @hidden */
  6567. protected _stencilState: _StencilState;
  6568. /** @hidden */
  6569. protected _alphaState: _AlphaState;
  6570. /** @hidden */
  6571. protected _alphaMode: number;
  6572. protected _internalTexturesCache: InternalTexture[];
  6573. /** @hidden */
  6574. protected _activeChannel: number;
  6575. private _currentTextureChannel;
  6576. /** @hidden */
  6577. protected _boundTexturesCache: {
  6578. [key: string]: Nullable<InternalTexture>;
  6579. };
  6580. /** @hidden */
  6581. protected _currentEffect: Nullable<Effect>;
  6582. /** @hidden */
  6583. protected _currentProgram: Nullable<WebGLProgram>;
  6584. private _compiledEffects;
  6585. private _vertexAttribArraysEnabled;
  6586. /** @hidden */
  6587. protected _cachedViewport: Nullable<Viewport>;
  6588. private _cachedVertexArrayObject;
  6589. /** @hidden */
  6590. protected _cachedVertexBuffers: any;
  6591. /** @hidden */
  6592. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6593. /** @hidden */
  6594. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6595. /** @hidden */
  6596. protected _currentRenderTarget: Nullable<InternalTexture>;
  6597. private _uintIndicesCurrentlySet;
  6598. private _currentBoundBuffer;
  6599. /** @hidden */
  6600. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6601. private _currentBufferPointers;
  6602. private _currentInstanceLocations;
  6603. private _currentInstanceBuffers;
  6604. private _textureUnits;
  6605. private _firstBoundInternalTextureTracker;
  6606. private _lastBoundInternalTextureTracker;
  6607. private _workingCanvas;
  6608. private _workingContext;
  6609. private _rescalePostProcess;
  6610. private _dummyFramebuffer;
  6611. private _externalData;
  6612. private _bindedRenderFunction;
  6613. private _vaoRecordInProgress;
  6614. private _mustWipeVertexAttributes;
  6615. private _emptyTexture;
  6616. private _emptyCubeTexture;
  6617. private _emptyTexture3D;
  6618. private _frameHandler;
  6619. private _nextFreeTextureSlots;
  6620. private _maxSimultaneousTextures;
  6621. private _activeRequests;
  6622. private _texturesSupported;
  6623. private _textureFormatInUse;
  6624. /**
  6625. * Gets the list of texture formats supported
  6626. */
  6627. readonly texturesSupported: Array<string>;
  6628. /**
  6629. * Gets the list of texture formats in use
  6630. */
  6631. readonly textureFormatInUse: Nullable<string>;
  6632. /**
  6633. * Gets the current viewport
  6634. */
  6635. readonly currentViewport: Nullable<Viewport>;
  6636. /**
  6637. * Gets the default empty texture
  6638. */
  6639. readonly emptyTexture: InternalTexture;
  6640. /**
  6641. * Gets the default empty 3D texture
  6642. */
  6643. readonly emptyTexture3D: InternalTexture;
  6644. /**
  6645. * Gets the default empty cube texture
  6646. */
  6647. readonly emptyCubeTexture: InternalTexture;
  6648. /**
  6649. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  6650. */
  6651. readonly premultipliedAlpha: boolean;
  6652. /**
  6653. * Creates a new engine
  6654. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6655. * @param antialias defines enable antialiasing (default: false)
  6656. * @param options defines further options to be sent to the getContext() function
  6657. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6658. */
  6659. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6660. private _rebuildInternalTextures();
  6661. private _rebuildEffects();
  6662. private _rebuildBuffers();
  6663. private _initGLContext();
  6664. /**
  6665. * Gets version of the current webGL context
  6666. */
  6667. readonly webGLVersion: number;
  6668. /**
  6669. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6670. */
  6671. readonly isStencilEnable: boolean;
  6672. private _prepareWorkingCanvas();
  6673. /**
  6674. * Reset the texture cache to empty state
  6675. */
  6676. resetTextureCache(): void;
  6677. /**
  6678. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6679. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6680. * @returns true if engine is in deterministic lock step mode
  6681. */
  6682. isDeterministicLockStep(): boolean;
  6683. /**
  6684. * Gets the max steps when engine is running in deterministic lock step
  6685. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6686. * @returns the max steps
  6687. */
  6688. getLockstepMaxSteps(): number;
  6689. /**
  6690. * Gets an object containing information about the current webGL context
  6691. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6692. */
  6693. getGlInfo(): {
  6694. vendor: string;
  6695. renderer: string;
  6696. version: string;
  6697. };
  6698. /**
  6699. * Gets current aspect ratio
  6700. * @param camera defines the camera to use to get the aspect ratio
  6701. * @param useScreen defines if screen size must be used (or the current render target if any)
  6702. * @returns a number defining the aspect ratio
  6703. */
  6704. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6705. /**
  6706. * Gets current screen aspect ratio
  6707. * @returns a number defining the aspect ratio
  6708. */
  6709. getScreenAspectRatio(): number;
  6710. /**
  6711. * Gets the current render width
  6712. * @param useScreen defines if screen size must be used (or the current render target if any)
  6713. * @returns a number defining the current render width
  6714. */
  6715. getRenderWidth(useScreen?: boolean): number;
  6716. /**
  6717. * Gets the current render height
  6718. * @param useScreen defines if screen size must be used (or the current render target if any)
  6719. * @returns a number defining the current render height
  6720. */
  6721. getRenderHeight(useScreen?: boolean): number;
  6722. /**
  6723. * Gets the HTML canvas attached with the current webGL context
  6724. * @returns a HTML canvas
  6725. */
  6726. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6727. /**
  6728. * Gets the client rect of the HTML canvas attached with the current webGL context
  6729. * @returns a client rectanglee
  6730. */
  6731. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6732. /**
  6733. * Defines the hardware scaling level.
  6734. * By default the hardware scaling level is computed from the window device ratio.
  6735. * 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.
  6736. * @param level defines the level to use
  6737. */
  6738. setHardwareScalingLevel(level: number): void;
  6739. /**
  6740. * Gets the current hardware scaling level.
  6741. * By default the hardware scaling level is computed from the window device ratio.
  6742. * 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.
  6743. * @returns a number indicating the current hardware scaling level
  6744. */
  6745. getHardwareScalingLevel(): number;
  6746. /**
  6747. * Gets the list of loaded textures
  6748. * @returns an array containing all loaded textures
  6749. */
  6750. getLoadedTexturesCache(): InternalTexture[];
  6751. /**
  6752. * Gets the object containing all engine capabilities
  6753. * @returns the EngineCapabilities object
  6754. */
  6755. getCaps(): EngineCapabilities;
  6756. /** @hidden */
  6757. readonly drawCalls: number;
  6758. /** @hidden */
  6759. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6760. /**
  6761. * Gets the current depth function
  6762. * @returns a number defining the depth function
  6763. */
  6764. getDepthFunction(): Nullable<number>;
  6765. /**
  6766. * Sets the current depth function
  6767. * @param depthFunc defines the function to use
  6768. */
  6769. setDepthFunction(depthFunc: number): void;
  6770. /**
  6771. * Sets the current depth function to GREATER
  6772. */
  6773. setDepthFunctionToGreater(): void;
  6774. /**
  6775. * Sets the current depth function to GEQUAL
  6776. */
  6777. setDepthFunctionToGreaterOrEqual(): void;
  6778. /**
  6779. * Sets the current depth function to LESS
  6780. */
  6781. setDepthFunctionToLess(): void;
  6782. /**
  6783. * Sets the current depth function to LEQUAL
  6784. */
  6785. setDepthFunctionToLessOrEqual(): void;
  6786. /**
  6787. * Gets a boolean indicating if stencil buffer is enabled
  6788. * @returns the current stencil buffer state
  6789. */
  6790. getStencilBuffer(): boolean;
  6791. /**
  6792. * Enable or disable the stencil buffer
  6793. * @param enable defines if the stencil buffer must be enabled or disabled
  6794. */
  6795. setStencilBuffer(enable: boolean): void;
  6796. /**
  6797. * Gets the current stencil mask
  6798. * @returns a number defining the new stencil mask to use
  6799. */
  6800. getStencilMask(): number;
  6801. /**
  6802. * Sets the current stencil mask
  6803. * @param mask defines the new stencil mask to use
  6804. */
  6805. setStencilMask(mask: number): void;
  6806. /**
  6807. * Gets the current stencil function
  6808. * @returns a number defining the stencil function to use
  6809. */
  6810. getStencilFunction(): number;
  6811. /**
  6812. * Gets the current stencil reference value
  6813. * @returns a number defining the stencil reference value to use
  6814. */
  6815. getStencilFunctionReference(): number;
  6816. /**
  6817. * Gets the current stencil mask
  6818. * @returns a number defining the stencil mask to use
  6819. */
  6820. getStencilFunctionMask(): number;
  6821. /**
  6822. * Sets the current stencil function
  6823. * @param stencilFunc defines the new stencil function to use
  6824. */
  6825. setStencilFunction(stencilFunc: number): void;
  6826. /**
  6827. * Sets the current stencil reference
  6828. * @param reference defines the new stencil reference to use
  6829. */
  6830. setStencilFunctionReference(reference: number): void;
  6831. /**
  6832. * Sets the current stencil mask
  6833. * @param mask defines the new stencil mask to use
  6834. */
  6835. setStencilFunctionMask(mask: number): void;
  6836. /**
  6837. * Gets the current stencil operation when stencil fails
  6838. * @returns a number defining stencil operation to use when stencil fails
  6839. */
  6840. getStencilOperationFail(): number;
  6841. /**
  6842. * Gets the current stencil operation when depth fails
  6843. * @returns a number defining stencil operation to use when depth fails
  6844. */
  6845. getStencilOperationDepthFail(): number;
  6846. /**
  6847. * Gets the current stencil operation when stencil passes
  6848. * @returns a number defining stencil operation to use when stencil passes
  6849. */
  6850. getStencilOperationPass(): number;
  6851. /**
  6852. * Sets the stencil operation to use when stencil fails
  6853. * @param operation defines the stencil operation to use when stencil fails
  6854. */
  6855. setStencilOperationFail(operation: number): void;
  6856. /**
  6857. * Sets the stencil operation to use when depth fails
  6858. * @param operation defines the stencil operation to use when depth fails
  6859. */
  6860. setStencilOperationDepthFail(operation: number): void;
  6861. /**
  6862. * Sets the stencil operation to use when stencil passes
  6863. * @param operation defines the stencil operation to use when stencil passes
  6864. */
  6865. setStencilOperationPass(operation: number): void;
  6866. /**
  6867. * Sets a boolean indicating if the dithering state is enabled or disabled
  6868. * @param value defines the dithering state
  6869. */
  6870. setDitheringState(value: boolean): void;
  6871. /**
  6872. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  6873. * @param value defines the rasterizer state
  6874. */
  6875. setRasterizerState(value: boolean): void;
  6876. /**
  6877. * stop executing a render loop function and remove it from the execution array
  6878. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  6879. */
  6880. stopRenderLoop(renderFunction?: () => void): void;
  6881. /** @hidden */
  6882. _renderLoop(): void;
  6883. /**
  6884. * Register and execute a render loop. The engine can have more than one render function
  6885. * @param renderFunction defines the function to continuously execute
  6886. */
  6887. runRenderLoop(renderFunction: () => void): void;
  6888. /**
  6889. * Toggle full screen mode
  6890. * @param requestPointerLock defines if a pointer lock should be requested from the user
  6891. * @param options defines an option object to be sent to the requestFullscreen function
  6892. */
  6893. switchFullscreen(requestPointerLock: boolean): void;
  6894. /**
  6895. * Clear the current render buffer or the current render target (if any is set up)
  6896. * @param color defines the color to use
  6897. * @param backBuffer defines if the back buffer must be cleared
  6898. * @param depth defines if the depth buffer must be cleared
  6899. * @param stencil defines if the stencil buffer must be cleared
  6900. */
  6901. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6902. /**
  6903. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  6904. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  6905. * @param y defines the y-coordinate of the corner of the clear rectangle
  6906. * @param width defines the width of the clear rectangle
  6907. * @param height defines the height of the clear rectangle
  6908. * @param clearColor defines the clear color
  6909. */
  6910. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6911. private _viewportCached;
  6912. /** @hidden */
  6913. _viewport(x: number, y: number, width: number, height: number): void;
  6914. /**
  6915. * Set the WebGL's viewport
  6916. * @param viewport defines the viewport element to be used
  6917. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  6918. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  6919. */
  6920. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6921. /**
  6922. * Directly set the WebGL Viewport
  6923. * @param x defines the x coordinate of the viewport (in screen space)
  6924. * @param y defines the y coordinate of the viewport (in screen space)
  6925. * @param width defines the width of the viewport (in screen space)
  6926. * @param height defines the height of the viewport (in screen space)
  6927. * @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
  6928. */
  6929. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6930. /**
  6931. * Begin a new frame
  6932. */
  6933. beginFrame(): void;
  6934. /**
  6935. * Enf the current frame
  6936. */
  6937. endFrame(): void;
  6938. /**
  6939. * Resize the view according to the canvas' size
  6940. */
  6941. resize(): void;
  6942. /**
  6943. * Force a specific size of the canvas
  6944. * @param width defines the new canvas' width
  6945. * @param height defines the new canvas' height
  6946. */
  6947. setSize(width: number, height: number): void;
  6948. /**
  6949. * Gets a boolean indicating if a webVR device was detected
  6950. * @returns true if a webVR device was detected
  6951. */
  6952. isVRDevicePresent(): boolean;
  6953. /**
  6954. * Gets the current webVR device
  6955. * @returns the current webVR device (or null)
  6956. */
  6957. getVRDevice(): any;
  6958. /**
  6959. * Initializes a webVR display and starts listening to display change events
  6960. * The onVRDisplayChangedObservable will be notified upon these changes
  6961. * @returns The onVRDisplayChangedObservable
  6962. */
  6963. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6964. /**
  6965. * Initializes a webVR display and starts listening to display change events
  6966. * The onVRDisplayChangedObservable will be notified upon these changes
  6967. * @returns A promise containing a VRDisplay and if vr is supported
  6968. */
  6969. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6970. /**
  6971. * Call this function to switch to webVR mode
  6972. * Will do nothing if webVR is not supported or if there is no webVR device
  6973. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6974. */
  6975. enableVR(): void;
  6976. /**
  6977. * Call this function to leave webVR mode
  6978. * Will do nothing if webVR is not supported or if there is no webVR device
  6979. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6980. */
  6981. disableVR(): void;
  6982. private _onVRFullScreenTriggered;
  6983. private _getVRDisplaysAsync();
  6984. /**
  6985. * Binds the frame buffer to the specified texture.
  6986. * @param texture The texture to render to or null for the default canvas
  6987. * @param faceIndex The face of the texture to render to in case of cube texture
  6988. * @param requiredWidth The width of the target to render to
  6989. * @param requiredHeight The height of the target to render to
  6990. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6991. * @param depthStencilTexture The depth stencil texture to use to render
  6992. * @param lodLevel defines le lod level to bind to the frame buffer
  6993. */
  6994. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  6995. private bindUnboundFramebuffer(framebuffer);
  6996. /**
  6997. * Unbind the current render target texture from the webGL context
  6998. * @param texture defines the render target texture to unbind
  6999. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7000. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7001. */
  7002. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7003. /**
  7004. * Unbind a list of render target textures from the webGL context
  7005. * This is used only when drawBuffer extension or webGL2 are active
  7006. * @param textures defines the render target textures to unbind
  7007. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7008. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7009. */
  7010. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7011. /**
  7012. * Force the mipmap generation for the given render target texture
  7013. * @param texture defines the render target texture to use
  7014. */
  7015. generateMipMapsForCubemap(texture: InternalTexture): void;
  7016. /**
  7017. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7018. */
  7019. flushFramebuffer(): void;
  7020. /**
  7021. * Unbind the current render target and bind the default framebuffer
  7022. */
  7023. restoreDefaultFramebuffer(): void;
  7024. /**
  7025. * Create an uniform buffer
  7026. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7027. * @param elements defines the content of the uniform buffer
  7028. * @returns the webGL uniform buffer
  7029. */
  7030. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7031. /**
  7032. * Create a dynamic uniform buffer
  7033. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7034. * @param elements defines the content of the uniform buffer
  7035. * @returns the webGL uniform buffer
  7036. */
  7037. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7038. /**
  7039. * Update an existing uniform buffer
  7040. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7041. * @param uniformBuffer defines the target uniform buffer
  7042. * @param elements defines the content to update
  7043. * @param offset defines the offset in the uniform buffer where update should start
  7044. * @param count defines the size of the data to update
  7045. */
  7046. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7047. private _resetVertexBufferBinding();
  7048. /**
  7049. * Creates a vertex buffer
  7050. * @param data the data for the vertex buffer
  7051. * @returns the new WebGL static buffer
  7052. */
  7053. createVertexBuffer(data: DataArray): WebGLBuffer;
  7054. /**
  7055. * Creates a dynamic vertex buffer
  7056. * @param data the data for the dynamic vertex buffer
  7057. * @returns the new WebGL dynamic buffer
  7058. */
  7059. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7060. /**
  7061. * Update a dynamic index buffer
  7062. * @param indexBuffer defines the target index buffer
  7063. * @param indices defines the data to update
  7064. * @param offset defines the offset in the target index buffer where update should start
  7065. */
  7066. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7067. /**
  7068. * Updates a dynamic vertex buffer.
  7069. * @param vertexBuffer the vertex buffer to update
  7070. * @param data the data used to update the vertex buffer
  7071. * @param byteOffset the byte offset of the data
  7072. * @param byteLength the byte length of the data
  7073. */
  7074. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7075. private _resetIndexBufferBinding();
  7076. /**
  7077. * Creates a new index buffer
  7078. * @param indices defines the content of the index buffer
  7079. * @param updatable defines if the index buffer must be updatable
  7080. * @returns a new webGL buffer
  7081. */
  7082. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7083. /**
  7084. * Bind a webGL buffer to the webGL context
  7085. * @param buffer defines the buffer to bind
  7086. */
  7087. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7088. /**
  7089. * Bind an uniform buffer to the current webGL context
  7090. * @param buffer defines the buffer to bind
  7091. */
  7092. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7093. /**
  7094. * Bind a buffer to the current webGL context at a given location
  7095. * @param buffer defines the buffer to bind
  7096. * @param location defines the index where to bind the buffer
  7097. */
  7098. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7099. /**
  7100. * Bind a specific block at a given index in a specific shader program
  7101. * @param shaderProgram defines the shader program
  7102. * @param blockName defines the block name
  7103. * @param index defines the index where to bind the block
  7104. */
  7105. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7106. private bindIndexBuffer(buffer);
  7107. private bindBuffer(buffer, target);
  7108. /**
  7109. * update the bound buffer with the given data
  7110. * @param data defines the data to update
  7111. */
  7112. updateArrayBuffer(data: Float32Array): void;
  7113. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7114. private _bindIndexBufferWithCache(indexBuffer);
  7115. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7116. /**
  7117. * Records a vertex array object
  7118. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7119. * @param vertexBuffers defines the list of vertex buffers to store
  7120. * @param indexBuffer defines the index buffer to store
  7121. * @param effect defines the effect to store
  7122. * @returns the new vertex array object
  7123. */
  7124. recordVertexArrayObject(vertexBuffers: {
  7125. [key: string]: VertexBuffer;
  7126. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7127. /**
  7128. * Bind a specific vertex array object
  7129. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7130. * @param vertexArrayObject defines the vertex array object to bind
  7131. * @param indexBuffer defines the index buffer to bind
  7132. */
  7133. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7134. /**
  7135. * Bind webGl buffers directly to the webGL context
  7136. * @param vertexBuffer defines the vertex buffer to bind
  7137. * @param indexBuffer defines the index buffer to bind
  7138. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7139. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7140. * @param effect defines the effect associated with the vertex buffer
  7141. */
  7142. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7143. private _unbindVertexArrayObject();
  7144. /**
  7145. * Bind a list of vertex buffers to the webGL context
  7146. * @param vertexBuffers defines the list of vertex buffers to bind
  7147. * @param indexBuffer defines the index buffer to bind
  7148. * @param effect defines the effect associated with the vertex buffers
  7149. */
  7150. bindBuffers(vertexBuffers: {
  7151. [key: string]: Nullable<VertexBuffer>;
  7152. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7153. /**
  7154. * Unbind all instance attributes
  7155. */
  7156. unbindInstanceAttributes(): void;
  7157. /**
  7158. * Release and free the memory of a vertex array object
  7159. * @param vao defines the vertex array object to delete
  7160. */
  7161. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7162. /** @hidden */
  7163. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7164. /**
  7165. * Creates a webGL buffer to use with instanciation
  7166. * @param capacity defines the size of the buffer
  7167. * @returns the webGL buffer
  7168. */
  7169. createInstancesBuffer(capacity: number): WebGLBuffer;
  7170. /**
  7171. * Delete a webGL buffer used with instanciation
  7172. * @param buffer defines the webGL buffer to delete
  7173. */
  7174. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7175. /**
  7176. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7177. * @param instancesBuffer defines the webGL buffer to update and bind
  7178. * @param data defines the data to store in the buffer
  7179. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7180. */
  7181. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7182. /**
  7183. * Apply all cached states (depth, culling, stencil and alpha)
  7184. */
  7185. applyStates(): void;
  7186. /**
  7187. * Send a draw order
  7188. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7189. * @param indexStart defines the starting index
  7190. * @param indexCount defines the number of index to draw
  7191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7192. */
  7193. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7194. /**
  7195. * Draw a list of points
  7196. * @param verticesStart defines the index of first vertex to draw
  7197. * @param verticesCount defines the count of vertices to draw
  7198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7199. */
  7200. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7201. /**
  7202. * Draw a list of unindexed primitives
  7203. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7204. * @param verticesStart defines the index of first vertex to draw
  7205. * @param verticesCount defines the count of vertices to draw
  7206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7207. */
  7208. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7209. /**
  7210. * Draw a list of indexed primitives
  7211. * @param fillMode defines the primitive to use
  7212. * @param indexStart defines the starting index
  7213. * @param indexCount defines the number of index to draw
  7214. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7215. */
  7216. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7217. /**
  7218. * Draw a list of unindexed primitives
  7219. * @param fillMode defines the primitive to use
  7220. * @param verticesStart defines the index of first vertex to draw
  7221. * @param verticesCount defines the count of vertices to draw
  7222. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7223. */
  7224. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7225. private _drawMode(fillMode);
  7226. /** @hidden */
  7227. _releaseEffect(effect: Effect): void;
  7228. /** @hidden */
  7229. _deleteProgram(program: WebGLProgram): void;
  7230. /**
  7231. * Create a new effect (used to store vertex/fragment shaders)
  7232. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7233. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7234. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7235. * @param samplers defines an array of string used to represent textures
  7236. * @param defines defines the string containing the defines to use to compile the shaders
  7237. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7238. * @param onCompiled defines a function to call when the effect creation is successful
  7239. * @param onError defines a function to call when the effect creation has failed
  7240. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7241. * @returns the new Effect
  7242. */
  7243. 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;
  7244. private _compileShader(source, type, defines, shaderVersion);
  7245. private _compileRawShader(source, type);
  7246. /**
  7247. * Directly creates a webGL program
  7248. * @param vertexCode defines the vertex shader code to use
  7249. * @param fragmentCode defines the fragment shader code to use
  7250. * @param context defines the webGL context to use (if not set, the current one will be used)
  7251. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7252. * @returns the new webGL program
  7253. */
  7254. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7255. /**
  7256. * Creates a webGL program
  7257. * @param vertexCode defines the vertex shader code to use
  7258. * @param fragmentCode defines the fragment shader code to use
  7259. * @param defines defines the string containing the defines to use to compile the shaders
  7260. * @param context defines the webGL context to use (if not set, the current one will be used)
  7261. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7262. * @returns the new webGL program
  7263. */
  7264. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7265. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7266. /**
  7267. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7268. * @param shaderProgram defines the webGL program to use
  7269. * @param uniformsNames defines the list of uniform names
  7270. * @returns an array of webGL uniform locations
  7271. */
  7272. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7273. /**
  7274. * Gets the lsit of active attributes for a given webGL program
  7275. * @param shaderProgram defines the webGL program to use
  7276. * @param attributesNames defines the list of attribute names to get
  7277. * @returns an array of indices indicating the offset of each attribute
  7278. */
  7279. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7280. /**
  7281. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7282. * @param effect defines the effect to activate
  7283. */
  7284. enableEffect(effect: Nullable<Effect>): void;
  7285. /**
  7286. * Set the value of an uniform to an array of int32
  7287. * @param uniform defines the webGL uniform location where to store the value
  7288. * @param array defines the array of int32 to store
  7289. */
  7290. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7291. /**
  7292. * Set the value of an uniform to an array of int32 (stored as vec2)
  7293. * @param uniform defines the webGL uniform location where to store the value
  7294. * @param array defines the array of int32 to store
  7295. */
  7296. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7297. /**
  7298. * Set the value of an uniform to an array of int32 (stored as vec3)
  7299. * @param uniform defines the webGL uniform location where to store the value
  7300. * @param array defines the array of int32 to store
  7301. */
  7302. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7303. /**
  7304. * Set the value of an uniform to an array of int32 (stored as vec4)
  7305. * @param uniform defines the webGL uniform location where to store the value
  7306. * @param array defines the array of int32 to store
  7307. */
  7308. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7309. /**
  7310. * Set the value of an uniform to an array of float32
  7311. * @param uniform defines the webGL uniform location where to store the value
  7312. * @param array defines the array of float32 to store
  7313. */
  7314. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7315. /**
  7316. * Set the value of an uniform to an array of float32 (stored as vec2)
  7317. * @param uniform defines the webGL uniform location where to store the value
  7318. * @param array defines the array of float32 to store
  7319. */
  7320. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7321. /**
  7322. * Set the value of an uniform to an array of float32 (stored as vec3)
  7323. * @param uniform defines the webGL uniform location where to store the value
  7324. * @param array defines the array of float32 to store
  7325. */
  7326. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7327. /**
  7328. * Set the value of an uniform to an array of float32 (stored as vec4)
  7329. * @param uniform defines the webGL uniform location where to store the value
  7330. * @param array defines the array of float32 to store
  7331. */
  7332. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7333. /**
  7334. * Set the value of an uniform to an array of number
  7335. * @param uniform defines the webGL uniform location where to store the value
  7336. * @param array defines the array of number to store
  7337. */
  7338. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7339. /**
  7340. * Set the value of an uniform to an array of number (stored as vec2)
  7341. * @param uniform defines the webGL uniform location where to store the value
  7342. * @param array defines the array of number to store
  7343. */
  7344. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7345. /**
  7346. * Set the value of an uniform to an array of number (stored as vec3)
  7347. * @param uniform defines the webGL uniform location where to store the value
  7348. * @param array defines the array of number to store
  7349. */
  7350. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7351. /**
  7352. * Set the value of an uniform to an array of number (stored as vec4)
  7353. * @param uniform defines the webGL uniform location where to store the value
  7354. * @param array defines the array of number to store
  7355. */
  7356. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7357. /**
  7358. * Set the value of an uniform to an array of float32 (stored as matrices)
  7359. * @param uniform defines the webGL uniform location where to store the value
  7360. * @param matrices defines the array of float32 to store
  7361. */
  7362. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7363. /**
  7364. * Set the value of an uniform to a matrix
  7365. * @param uniform defines the webGL uniform location where to store the value
  7366. * @param matrix defines the matrix to store
  7367. */
  7368. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7369. /**
  7370. * Set the value of an uniform to a matrix (3x3)
  7371. * @param uniform defines the webGL uniform location where to store the value
  7372. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7373. */
  7374. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7375. /**
  7376. * Set the value of an uniform to a matrix (2x2)
  7377. * @param uniform defines the webGL uniform location where to store the value
  7378. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7379. */
  7380. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7381. /**
  7382. * Set the value of an uniform to a number (int)
  7383. * @param uniform defines the webGL uniform location where to store the value
  7384. * @param value defines the int number to store
  7385. */
  7386. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7387. /**
  7388. * Set the value of an uniform to a number (float)
  7389. * @param uniform defines the webGL uniform location where to store the value
  7390. * @param value defines the float number to store
  7391. */
  7392. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7393. /**
  7394. * Set the value of an uniform to a vec2
  7395. * @param uniform defines the webGL uniform location where to store the value
  7396. * @param x defines the 1st component of the value
  7397. * @param y defines the 2nd component of the value
  7398. */
  7399. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7400. /**
  7401. * Set the value of an uniform to a vec3
  7402. * @param uniform defines the webGL uniform location where to store the value
  7403. * @param x defines the 1st component of the value
  7404. * @param y defines the 2nd component of the value
  7405. * @param z defines the 3rd component of the value
  7406. */
  7407. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7408. /**
  7409. * Set the value of an uniform to a boolean
  7410. * @param uniform defines the webGL uniform location where to store the value
  7411. * @param bool defines the boolean to store
  7412. */
  7413. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7414. /**
  7415. * Set the value of an uniform to a vec4
  7416. * @param uniform defines the webGL uniform location where to store the value
  7417. * @param x defines the 1st component of the value
  7418. * @param y defines the 2nd component of the value
  7419. * @param z defines the 3rd component of the value
  7420. * @param w defines the 4th component of the value
  7421. */
  7422. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7423. /**
  7424. * Set the value of an uniform to a Color3
  7425. * @param uniform defines the webGL uniform location where to store the value
  7426. * @param color3 defines the color to store
  7427. */
  7428. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7429. /**
  7430. * Set the value of an uniform to a Color3 and an alpha value
  7431. * @param uniform defines the webGL uniform location where to store the value
  7432. * @param color3 defines the color to store
  7433. * @param alpha defines the alpha component to store
  7434. */
  7435. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7436. /**
  7437. * Sets a Color4 on a uniform variable
  7438. * @param uniform defines the uniform location
  7439. * @param color4 defines the value to be set
  7440. */
  7441. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7442. /**
  7443. * Set various states to the webGL context
  7444. * @param culling defines backface culling state
  7445. * @param zOffset defines the value to apply to zOffset (0 by default)
  7446. * @param force defines if states must be applied even if cache is up to date
  7447. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7448. */
  7449. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7450. /**
  7451. * Set the z offset to apply to current rendering
  7452. * @param value defines the offset to apply
  7453. */
  7454. setZOffset(value: number): void;
  7455. /**
  7456. * Gets the current value of the zOffset
  7457. * @returns the current zOffset state
  7458. */
  7459. getZOffset(): number;
  7460. /**
  7461. * Enable or disable depth buffering
  7462. * @param enable defines the state to set
  7463. */
  7464. setDepthBuffer(enable: boolean): void;
  7465. /**
  7466. * Gets a boolean indicating if depth writing is enabled
  7467. * @returns the current depth writing state
  7468. */
  7469. getDepthWrite(): boolean;
  7470. /**
  7471. * Enable or disable depth writing
  7472. * @param enable defines the state to set
  7473. */
  7474. setDepthWrite(enable: boolean): void;
  7475. /**
  7476. * Enable or disable color writing
  7477. * @param enable defines the state to set
  7478. */
  7479. setColorWrite(enable: boolean): void;
  7480. /**
  7481. * Gets a boolean indicating if color writing is enabled
  7482. * @returns the current color writing state
  7483. */
  7484. getColorWrite(): boolean;
  7485. /**
  7486. * Sets alpha constants used by some alpha blending modes
  7487. * @param r defines the red component
  7488. * @param g defines the green component
  7489. * @param b defines the blue component
  7490. * @param a defines the alpha component
  7491. */
  7492. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7493. /**
  7494. * Sets the current alpha mode
  7495. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7496. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7497. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7498. */
  7499. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7500. /**
  7501. * Gets the current alpha mode
  7502. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7503. * @returns the current alpha mode
  7504. */
  7505. getAlphaMode(): number;
  7506. /**
  7507. * Clears the list of texture accessible through engine.
  7508. * This can help preventing texture load conflict due to name collision.
  7509. */
  7510. clearInternalTexturesCache(): void;
  7511. /**
  7512. * Force the entire cache to be cleared
  7513. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7514. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7515. */
  7516. wipeCaches(bruteForce?: boolean): void;
  7517. /**
  7518. * Set the compressed texture format to use, based on the formats you have, and the formats
  7519. * supported by the hardware / browser.
  7520. *
  7521. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7522. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7523. * to API arguments needed to compressed textures. This puts the burden on the container
  7524. * generator to house the arcane code for determining these for current & future formats.
  7525. *
  7526. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7527. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7528. *
  7529. * Note: The result of this call is not taken into account when a texture is base64.
  7530. *
  7531. * @param formatsAvailable defines the list of those format families you have created
  7532. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7533. *
  7534. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7535. * @returns The extension selected.
  7536. */
  7537. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7538. private _getSamplingParameters(samplingMode, generateMipMaps);
  7539. private _partialLoadImg(url, index, loadedImages, scene, onfinish, onErrorCallBack?);
  7540. private _cascadeLoadImgs(rootUrl, scene, onfinish, files, onError?);
  7541. /** @hidden */
  7542. _createTexture(): WebGLTexture;
  7543. /**
  7544. * Usually called from BABYLON.Texture.ts.
  7545. * Passed information to create a WebGLTexture
  7546. * @param urlArg defines a value which contains one of the following:
  7547. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7548. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7549. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7551. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7552. * @param scene needed for loading to the correct scene
  7553. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7554. * @param onLoad optional callback to be called upon successful completion
  7555. * @param onError optional callback to be called upon failure
  7556. * @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
  7557. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7558. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7559. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7560. */
  7561. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  7562. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7563. /**
  7564. * Update a raw texture
  7565. * @param texture defines the texture to update
  7566. * @param data defines the data to store in the texture
  7567. * @param format defines the format of the data
  7568. * @param invertY defines if data must be stored with Y axis inverted
  7569. * @param compression defines the compression used (null by default)
  7570. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7571. */
  7572. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7573. /**
  7574. * Creates a raw texture
  7575. * @param data defines the data to store in the texture
  7576. * @param width defines the width of the texture
  7577. * @param height defines the height of the texture
  7578. * @param format defines the format of the data
  7579. * @param generateMipMaps defines if the engine should generate the mip levels
  7580. * @param invertY defines if data must be stored with Y axis inverted
  7581. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7582. * @param compression defines the compression used (null by default)
  7583. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7584. * @returns the raw texture inside an InternalTexture
  7585. */
  7586. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7587. private _unpackFlipYCached;
  7588. /** @hidden */
  7589. _unpackFlipY(value: boolean): void;
  7590. /** @hidden */
  7591. _getUnpackAlignement(): number;
  7592. /**
  7593. * Creates a dynamic texture
  7594. * @param width defines the width of the texture
  7595. * @param height defines the height of the texture
  7596. * @param generateMipMaps defines if the engine should generate the mip levels
  7597. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7598. * @returns the dynamic texture inside an InternalTexture
  7599. */
  7600. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7601. /**
  7602. * Update the sampling mode of a given texture
  7603. * @param samplingMode defines the required sampling mode
  7604. * @param texture defines the texture to update
  7605. */
  7606. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7607. /**
  7608. * Update the content of a dynamic texture
  7609. * @param texture defines the texture to update
  7610. * @param canvas defines the canvas containing the source
  7611. * @param invertY defines if data must be stored with Y axis inverted
  7612. * @param premulAlpha defines if alpha is stored as premultiplied
  7613. * @param format defines the format of the data
  7614. */
  7615. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7616. /**
  7617. * Update a video texture
  7618. * @param texture defines the texture to update
  7619. * @param video defines the video element to use
  7620. * @param invertY defines if data must be stored with Y axis inverted
  7621. */
  7622. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7623. /**
  7624. * Updates a depth texture Comparison Mode and Function.
  7625. * If the comparison Function is equal to 0, the mode will be set to none.
  7626. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7627. * @param texture The texture to set the comparison function for
  7628. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7629. */
  7630. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7631. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7632. /**
  7633. * Creates a depth stencil texture.
  7634. * This is only available in WebGL 2 or with the depth texture extension available.
  7635. * @param size The size of face edge in the texture.
  7636. * @param options The options defining the texture.
  7637. * @returns The texture
  7638. */
  7639. createDepthStencilTexture(size: number | {
  7640. width: number;
  7641. height: number;
  7642. }, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a depth stencil texture.
  7645. * This is only available in WebGL 2 or with the depth texture extension available.
  7646. * @param size The size of face edge in the texture.
  7647. * @param options The options defining the texture.
  7648. * @returns The texture
  7649. */
  7650. private _createDepthStencilTexture(size, options);
  7651. /**
  7652. * Creates a depth stencil cube texture.
  7653. * This is only available in WebGL 2.
  7654. * @param size The size of face edge in the cube texture.
  7655. * @param options The options defining the cube texture.
  7656. * @returns The cube texture
  7657. */
  7658. private _createDepthStencilCubeTexture(size, options);
  7659. /**
  7660. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7661. * @param renderTarget The render target to set the frame buffer for
  7662. */
  7663. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7664. /**
  7665. * Creates a new render target texture
  7666. * @param size defines the size of the texture
  7667. * @param options defines the options used to create the texture
  7668. * @returns a new render target texture stored in an InternalTexture
  7669. */
  7670. createRenderTargetTexture(size: number | {
  7671. width: number;
  7672. height: number;
  7673. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7674. /**
  7675. * Create a multi render target texture
  7676. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7677. * @param size defines the size of the texture
  7678. * @param options defines the creation options
  7679. * @returns the cube texture as an InternalTexture
  7680. */
  7681. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7682. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7683. /**
  7684. * Updates the sample count of a render target texture
  7685. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7686. * @param texture defines the texture to update
  7687. * @param samples defines the sample count to set
  7688. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7689. */
  7690. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7691. /**
  7692. * Update the sample count for a given multiple render target texture
  7693. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7694. * @param textures defines the textures to update
  7695. * @param samples defines the sample count to set
  7696. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7697. */
  7698. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7699. /** @hidden */
  7700. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  7701. /** @hidden */
  7702. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  7703. /** @hidden */
  7704. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  7705. /** @hidden */
  7706. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  7707. /**
  7708. * Creates a new render target cube texture
  7709. * @param size defines the size of the texture
  7710. * @param options defines the options used to create the texture
  7711. * @returns a new render target cube texture stored in an InternalTexture
  7712. */
  7713. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7714. /**
  7715. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7716. * @param rootUrl defines the url where the file to load is located
  7717. * @param scene defines the current scene
  7718. * @param lodScale defines scale to apply to the mip map selection
  7719. * @param lodOffset defines offset to apply to the mip map selection
  7720. * @param onLoad defines an optional callback raised when the texture is loaded
  7721. * @param onError defines an optional callback raised if there is an issue to load the texture
  7722. * @param format defines the format of the data
  7723. * @param forcedExtension defines the extension to use to pick the right loader
  7724. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  7725. * @returns the cube texture as an InternalTexture
  7726. */
  7727. 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;
  7728. /**
  7729. * Creates a cube texture
  7730. * @param rootUrl defines the url where the files to load is located
  7731. * @param scene defines the current scene
  7732. * @param files defines the list of files to load (1 per face)
  7733. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7734. * @param onLoad defines an optional callback raised when the texture is loaded
  7735. * @param onError defines an optional callback raised if there is an issue to load the texture
  7736. * @param format defines the format of the data
  7737. * @param forcedExtension defines the extension to use to pick the right loader
  7738. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7739. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7740. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7741. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7742. * @returns the cube texture as an InternalTexture
  7743. */
  7744. 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;
  7745. private setCubeMapTextureParams(gl, loadMipmap);
  7746. /**
  7747. * Update a raw cube texture
  7748. * @param texture defines the texture to udpdate
  7749. * @param data defines the data to store
  7750. * @param format defines the data format
  7751. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7752. * @param invertY defines if data must be stored with Y axis inverted
  7753. * @param compression defines the compression used (null by default)
  7754. * @param level defines which level of the texture to update
  7755. */
  7756. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  7757. /**
  7758. * Creates a new raw cube texture
  7759. * @param data defines the array of data to use to create each face
  7760. * @param size defines the size of the textures
  7761. * @param format defines the format of the data
  7762. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7763. * @param generateMipMaps defines if the engine should generate the mip levels
  7764. * @param invertY defines if data must be stored with Y axis inverted
  7765. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7766. * @param compression defines the compression used (null by default)
  7767. * @returns the cube texture as an InternalTexture
  7768. */
  7769. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7770. /**
  7771. * Creates a new raw cube texture from a specified url
  7772. * @param url defines the url where the data is located
  7773. * @param scene defines the current scene
  7774. * @param size defines the size of the textures
  7775. * @param format defines the format of the data
  7776. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7777. * @param noMipmap defines if the engine should avoid generating the mip levels
  7778. * @param callback defines a callback used to extract texture data from loaded data
  7779. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  7780. * @param onLoad defines a callback called when texture is loaded
  7781. * @param onError defines a callback called if there is an error
  7782. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7783. * @param invertY defines if data must be stored with Y axis inverted
  7784. * @returns the cube texture as an InternalTexture
  7785. */
  7786. 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;
  7787. /**
  7788. * Update a raw 3D texture
  7789. * @param texture defines the texture to update
  7790. * @param data defines the data to store
  7791. * @param format defines the data format
  7792. * @param invertY defines if data must be stored with Y axis inverted
  7793. * @param compression defines the used compression (can be null)
  7794. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  7795. */
  7796. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  7797. /**
  7798. * Creates a new raw 3D texture
  7799. * @param data defines the data used to create the texture
  7800. * @param width defines the width of the texture
  7801. * @param height defines the height of the texture
  7802. * @param depth defines the depth of the texture
  7803. * @param format defines the format of the texture
  7804. * @param generateMipMaps defines if the engine must generate mip levels
  7805. * @param invertY defines if data must be stored with Y axis inverted
  7806. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7807. * @param compression defines the compressed used (can be null)
  7808. * @param textureType defines the compressed used (can be null)
  7809. * @returns a new raw 3D texture (stored in an InternalTexture)
  7810. */
  7811. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  7812. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  7813. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  7814. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  7815. /** @hidden */
  7816. _releaseFramebufferObjects(texture: InternalTexture): void;
  7817. /** @hidden */
  7818. _releaseTexture(texture: InternalTexture): void;
  7819. private setProgram(program);
  7820. private _boundUniforms;
  7821. /**
  7822. * Binds an effect to the webGL context
  7823. * @param effect defines the effect to bind
  7824. */
  7825. bindSamplers(effect: Effect): void;
  7826. private _moveBoundTextureOnTop(internalTexture);
  7827. private _getCorrectTextureChannel(channel, internalTexture);
  7828. private _linkTrackers(previous, next);
  7829. private _removeDesignatedSlot(internalTexture);
  7830. private _activateCurrentTexture();
  7831. /** @hidden */
  7832. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  7833. /** @hidden */
  7834. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  7835. /**
  7836. * Sets a texture to the webGL context from a postprocess
  7837. * @param channel defines the channel to use
  7838. * @param postProcess defines the source postprocess
  7839. */
  7840. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  7841. /**
  7842. * Binds the output of the passed in post process to the texture channel specified
  7843. * @param channel The channel the texture should be bound to
  7844. * @param postProcess The post process which's output should be bound
  7845. */
  7846. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  7847. /**
  7848. * Unbind all textures from the webGL context
  7849. */
  7850. unbindAllTextures(): void;
  7851. /**
  7852. * Sets a texture to the according uniform.
  7853. * @param channel The texture channel
  7854. * @param uniform The uniform to set
  7855. * @param texture The texture to apply
  7856. */
  7857. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  7858. /**
  7859. * Sets a depth stencil texture from a render target to the according uniform.
  7860. * @param channel The texture channel
  7861. * @param uniform The uniform to set
  7862. * @param texture The render target texture containing the depth stencil texture to apply
  7863. */
  7864. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  7865. private _bindSamplerUniformToChannel(sourceSlot, destination);
  7866. private _getTextureWrapMode(mode);
  7867. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  7868. /**
  7869. * Sets an array of texture to the webGL context
  7870. * @param channel defines the channel where the texture array must be set
  7871. * @param uniform defines the associated uniform location
  7872. * @param textures defines the array of textures to bind
  7873. */
  7874. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  7875. /** @hidden */
  7876. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  7877. private _setTextureParameterFloat(target, parameter, value, texture);
  7878. private _setTextureParameterInteger(target, parameter, value, texture?);
  7879. /**
  7880. * Reads pixels from the current frame buffer. Please note that this function can be slow
  7881. * @param x defines the x coordinate of the rectangle where pixels must be read
  7882. * @param y defines the y coordinate of the rectangle where pixels must be read
  7883. * @param width defines the width of the rectangle where pixels must be read
  7884. * @param height defines the height of the rectangle where pixels must be read
  7885. * @returns a Uint8Array containing RGBA colors
  7886. */
  7887. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  7888. /**
  7889. * Add an externaly attached data from its key.
  7890. * This method call will fail and return false, if such key already exists.
  7891. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  7892. * @param key the unique key that identifies the data
  7893. * @param data the data object to associate to the key for this Engine instance
  7894. * @return true if no such key were already present and the data was added successfully, false otherwise
  7895. */
  7896. addExternalData<T>(key: string, data: T): boolean;
  7897. /**
  7898. * Get an externaly attached data from its key
  7899. * @param key the unique key that identifies the data
  7900. * @return the associated data, if present (can be null), or undefined if not present
  7901. */
  7902. getExternalData<T>(key: string): T;
  7903. /**
  7904. * Get an externaly attached data from its key, create it using a factory if it's not already present
  7905. * @param key the unique key that identifies the data
  7906. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  7907. * @return the associated data, can be null if the factory returned null.
  7908. */
  7909. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  7910. /**
  7911. * Remove an externaly attached data from the Engine instance
  7912. * @param key the unique key that identifies the data
  7913. * @return true if the data was successfully removed, false if it doesn't exist
  7914. */
  7915. removeExternalData(key: string): boolean;
  7916. /**
  7917. * Unbind all vertex attributes from the webGL context
  7918. */
  7919. unbindAllAttributes(): void;
  7920. /**
  7921. * 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
  7922. */
  7923. releaseEffects(): void;
  7924. /**
  7925. * Dispose and release all associated resources
  7926. */
  7927. dispose(): void;
  7928. /**
  7929. * Display the loading screen
  7930. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7931. */
  7932. displayLoadingUI(): void;
  7933. /**
  7934. * Hide the loading screen
  7935. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7936. */
  7937. hideLoadingUI(): void;
  7938. /**
  7939. * Gets the current loading screen object
  7940. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7941. */
  7942. /**
  7943. * Sets the current loading screen object
  7944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7945. */
  7946. loadingScreen: ILoadingScreen;
  7947. /**
  7948. * Sets the current loading screen text
  7949. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7950. */
  7951. loadingUIText: string;
  7952. /**
  7953. * Sets the current loading screen background color
  7954. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7955. */
  7956. loadingUIBackgroundColor: string;
  7957. /**
  7958. * Attach a new callback raised when context lost event is fired
  7959. * @param callback defines the callback to call
  7960. */
  7961. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7962. /**
  7963. * Attach a new callback raised when context restored event is fired
  7964. * @param callback defines the callback to call
  7965. */
  7966. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7967. /**
  7968. * Gets the source code of the vertex shader associated with a specific webGL program
  7969. * @param program defines the program to use
  7970. * @returns a string containing the source code of the vertex shader associated with the program
  7971. */
  7972. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  7973. /**
  7974. * Gets the source code of the fragment shader associated with a specific webGL program
  7975. * @param program defines the program to use
  7976. * @returns a string containing the source code of the fragment shader associated with the program
  7977. */
  7978. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  7979. /**
  7980. * Get the current error code of the webGL context
  7981. * @returns the error code
  7982. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  7983. */
  7984. getError(): number;
  7985. /**
  7986. * Gets the current framerate
  7987. * @returns a number representing the framerate
  7988. */
  7989. getFps(): number;
  7990. /**
  7991. * Gets the time spent between current and previous frame
  7992. * @returns a number representing the delta time in ms
  7993. */
  7994. getDeltaTime(): number;
  7995. private _measureFps();
  7996. /** @hidden */
  7997. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  7998. private _canRenderToFloatFramebuffer();
  7999. private _canRenderToHalfFloatFramebuffer();
  8000. private _canRenderToFramebuffer(type);
  8001. /** @hidden */
  8002. _getWebGLTextureType(type: number): number;
  8003. private _getInternalFormat(format);
  8004. /** @hidden */
  8005. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8006. /** @hidden */
  8007. _getRGBAMultiSampleBufferFormat(type: number): number;
  8008. /** @hidden */
  8009. _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;
  8010. /** @hidden */
  8011. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8012. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8013. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8014. /**
  8015. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8016. * @returns true if the engine can be created
  8017. * @ignorenaming
  8018. */
  8019. static isSupported(): boolean;
  8020. }
  8021. }
  8022. declare module BABYLON {
  8023. class NullEngineOptions {
  8024. renderWidth: number;
  8025. renderHeight: number;
  8026. textureSize: number;
  8027. deterministicLockstep: boolean;
  8028. lockstepMaxSteps: number;
  8029. }
  8030. /**
  8031. * The null engine class provides support for headless version of babylon.js.
  8032. * This can be used in server side scenario or for testing purposes
  8033. */
  8034. class NullEngine extends Engine {
  8035. private _options;
  8036. isDeterministicLockStep(): boolean;
  8037. getLockstepMaxSteps(): number;
  8038. getHardwareScalingLevel(): number;
  8039. constructor(options?: NullEngineOptions);
  8040. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8041. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8042. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8043. getRenderWidth(useScreen?: boolean): number;
  8044. getRenderHeight(useScreen?: boolean): number;
  8045. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8046. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8047. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8048. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8049. bindSamplers(effect: Effect): void;
  8050. enableEffect(effect: Effect): void;
  8051. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8052. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8053. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8054. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8055. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8056. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8057. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8058. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8059. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8060. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8061. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8062. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8063. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8064. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8065. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8066. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8067. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8068. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8069. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8070. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8071. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8072. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8073. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8074. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8075. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8076. bindBuffers(vertexBuffers: {
  8077. [key: string]: VertexBuffer;
  8078. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8079. wipeCaches(bruteForce?: boolean): void;
  8080. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8081. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8082. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8083. _createTexture(): WebGLTexture;
  8084. _releaseTexture(texture: InternalTexture): void;
  8085. 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;
  8086. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8087. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8088. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8089. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8090. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8091. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8092. /**
  8093. * Get the current error code of the webGL context
  8094. * @returns the error code
  8095. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8096. */
  8097. getError(): number;
  8098. /** @hidden */
  8099. _getUnpackAlignement(): number;
  8100. /** @hidden */
  8101. _unpackFlipY(value: boolean): void;
  8102. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8103. /**
  8104. * Updates a dynamic vertex buffer.
  8105. * @param vertexBuffer the vertex buffer to update
  8106. * @param data the data used to update the vertex buffer
  8107. * @param byteOffset the byte offset of the data (optional)
  8108. * @param byteLength the byte length of the data (optional)
  8109. */
  8110. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8111. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  8112. _bindTexture(channel: number, texture: InternalTexture): void;
  8113. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8114. releaseEffects(): void;
  8115. displayLoadingUI(): void;
  8116. hideLoadingUI(): void;
  8117. /** @hidden */
  8118. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8119. /** @hidden */
  8120. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8121. /** @hidden */
  8122. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8123. /** @hidden */
  8124. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8125. }
  8126. }
  8127. interface WebGLRenderingContext {
  8128. readonly RASTERIZER_DISCARD: number;
  8129. readonly DEPTH_COMPONENT24: number;
  8130. readonly TEXTURE_3D: number;
  8131. readonly TEXTURE_2D_ARRAY: number;
  8132. readonly TEXTURE_COMPARE_FUNC: number;
  8133. readonly TEXTURE_COMPARE_MODE: number;
  8134. readonly COMPARE_REF_TO_TEXTURE: number;
  8135. readonly TEXTURE_WRAP_R: number;
  8136. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8137. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8138. 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;
  8139. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8140. readonly TRANSFORM_FEEDBACK: number;
  8141. readonly INTERLEAVED_ATTRIBS: number;
  8142. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8143. createTransformFeedback(): WebGLTransformFeedback;
  8144. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8145. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8146. beginTransformFeedback(primitiveMode: number): void;
  8147. endTransformFeedback(): void;
  8148. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8149. }
  8150. interface ImageBitmap {
  8151. readonly width: number;
  8152. readonly height: number;
  8153. close(): void;
  8154. }
  8155. interface WebGLQuery extends WebGLObject {
  8156. }
  8157. declare var WebGLQuery: {
  8158. prototype: WebGLQuery;
  8159. new (): WebGLQuery;
  8160. };
  8161. interface WebGLSampler extends WebGLObject {
  8162. }
  8163. declare var WebGLSampler: {
  8164. prototype: WebGLSampler;
  8165. new (): WebGLSampler;
  8166. };
  8167. interface WebGLSync extends WebGLObject {
  8168. }
  8169. declare var WebGLSync: {
  8170. prototype: WebGLSync;
  8171. new (): WebGLSync;
  8172. };
  8173. interface WebGLTransformFeedback extends WebGLObject {
  8174. }
  8175. declare var WebGLTransformFeedback: {
  8176. prototype: WebGLTransformFeedback;
  8177. new (): WebGLTransformFeedback;
  8178. };
  8179. interface WebGLVertexArrayObject extends WebGLObject {
  8180. }
  8181. declare var WebGLVertexArrayObject: {
  8182. prototype: WebGLVertexArrayObject;
  8183. new (): WebGLVertexArrayObject;
  8184. };
  8185. declare module BABYLON {
  8186. class ArcRotateCamera extends TargetCamera {
  8187. alpha: number;
  8188. beta: number;
  8189. radius: number;
  8190. protected _target: Vector3;
  8191. protected _targetHost: Nullable<AbstractMesh>;
  8192. target: Vector3;
  8193. inertialAlphaOffset: number;
  8194. inertialBetaOffset: number;
  8195. inertialRadiusOffset: number;
  8196. lowerAlphaLimit: Nullable<number>;
  8197. upperAlphaLimit: Nullable<number>;
  8198. lowerBetaLimit: number;
  8199. upperBetaLimit: number;
  8200. lowerRadiusLimit: Nullable<number>;
  8201. upperRadiusLimit: Nullable<number>;
  8202. inertialPanningX: number;
  8203. inertialPanningY: number;
  8204. pinchToPanMaxDistance: number;
  8205. panningDistanceLimit: Nullable<number>;
  8206. panningOriginTarget: Vector3;
  8207. panningInertia: number;
  8208. angularSensibilityX: number;
  8209. angularSensibilityY: number;
  8210. pinchPrecision: number;
  8211. pinchDeltaPercentage: number;
  8212. panningSensibility: number;
  8213. keysUp: number[];
  8214. keysDown: number[];
  8215. keysLeft: number[];
  8216. keysRight: number[];
  8217. wheelPrecision: number;
  8218. wheelDeltaPercentage: number;
  8219. zoomOnFactor: number;
  8220. targetScreenOffset: Vector2;
  8221. allowUpsideDown: boolean;
  8222. _viewMatrix: Matrix;
  8223. _useCtrlForPanning: boolean;
  8224. _panningMouseButton: number;
  8225. inputs: ArcRotateCameraInputsManager;
  8226. _reset: () => void;
  8227. panningAxis: Vector3;
  8228. protected _localDirection: Vector3;
  8229. protected _transformedDirection: Vector3;
  8230. private _bouncingBehavior;
  8231. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8232. useBouncingBehavior: boolean;
  8233. private _framingBehavior;
  8234. readonly framingBehavior: Nullable<FramingBehavior>;
  8235. useFramingBehavior: boolean;
  8236. private _autoRotationBehavior;
  8237. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8238. useAutoRotationBehavior: boolean;
  8239. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8240. onCollide: (collidedMesh: AbstractMesh) => void;
  8241. checkCollisions: boolean;
  8242. collisionRadius: Vector3;
  8243. protected _collider: Collider;
  8244. protected _previousPosition: Vector3;
  8245. protected _collisionVelocity: Vector3;
  8246. protected _newPosition: Vector3;
  8247. protected _previousAlpha: number;
  8248. protected _previousBeta: number;
  8249. protected _previousRadius: number;
  8250. protected _collisionTriggered: boolean;
  8251. protected _targetBoundingCenter: Nullable<Vector3>;
  8252. private _computationVector;
  8253. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8254. _initCache(): void;
  8255. _updateCache(ignoreParentClass?: boolean): void;
  8256. protected _getTargetPosition(): Vector3;
  8257. /**
  8258. * Store current camera state (fov, position, etc..)
  8259. */
  8260. private _storedAlpha;
  8261. private _storedBeta;
  8262. private _storedRadius;
  8263. private _storedTarget;
  8264. storeState(): Camera;
  8265. /**
  8266. * Restored camera state. You must call storeState() first
  8267. */
  8268. _restoreStateValues(): boolean;
  8269. _isSynchronizedViewMatrix(): boolean;
  8270. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8271. detachControl(element: HTMLElement): void;
  8272. _checkInputs(): void;
  8273. protected _checkLimits(): void;
  8274. rebuildAnglesAndRadius(): void;
  8275. setPosition(position: Vector3): void;
  8276. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8277. _getViewMatrix(): Matrix;
  8278. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8279. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8280. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8281. min: Vector3;
  8282. max: Vector3;
  8283. distance: number;
  8284. }, doNotUpdateMaxZ?: boolean): void;
  8285. /**
  8286. * @override
  8287. * Override Camera.createRigCamera
  8288. */
  8289. createRigCamera(name: string, cameraIndex: number): Camera;
  8290. /**
  8291. * @override
  8292. * Override Camera._updateRigCameras
  8293. */
  8294. _updateRigCameras(): void;
  8295. dispose(): void;
  8296. getClassName(): string;
  8297. }
  8298. }
  8299. declare module BABYLON {
  8300. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8301. constructor(camera: ArcRotateCamera);
  8302. addMouseWheel(): ArcRotateCameraInputsManager;
  8303. addPointers(): ArcRotateCameraInputsManager;
  8304. addKeyboard(): ArcRotateCameraInputsManager;
  8305. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8306. }
  8307. }
  8308. declare module BABYLON {
  8309. class Camera extends Node {
  8310. inputs: CameraInputsManager<Camera>;
  8311. private static _PERSPECTIVE_CAMERA;
  8312. private static _ORTHOGRAPHIC_CAMERA;
  8313. private static _FOVMODE_VERTICAL_FIXED;
  8314. private static _FOVMODE_HORIZONTAL_FIXED;
  8315. private static _RIG_MODE_NONE;
  8316. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  8317. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  8318. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  8319. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  8320. private static _RIG_MODE_VR;
  8321. private static _RIG_MODE_WEBVR;
  8322. static readonly PERSPECTIVE_CAMERA: number;
  8323. static readonly ORTHOGRAPHIC_CAMERA: number;
  8324. /**
  8325. * This is the default FOV mode for perspective cameras.
  8326. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8327. *
  8328. */
  8329. static readonly FOVMODE_VERTICAL_FIXED: number;
  8330. /**
  8331. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8332. *
  8333. */
  8334. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8335. static readonly RIG_MODE_NONE: number;
  8336. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8337. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8338. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8339. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8340. static readonly RIG_MODE_VR: number;
  8341. static readonly RIG_MODE_WEBVR: number;
  8342. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8343. static UseAlternateWebVRRendering: boolean;
  8344. position: Vector3;
  8345. /**
  8346. * The vector the camera should consider as up.
  8347. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8348. */
  8349. upVector: Vector3;
  8350. orthoLeft: Nullable<number>;
  8351. orthoRight: Nullable<number>;
  8352. orthoBottom: Nullable<number>;
  8353. orthoTop: Nullable<number>;
  8354. /**
  8355. * FOV is set in Radians. (default is 0.8)
  8356. */
  8357. fov: number;
  8358. minZ: number;
  8359. maxZ: number;
  8360. inertia: number;
  8361. mode: number;
  8362. isIntermediate: boolean;
  8363. viewport: Viewport;
  8364. /**
  8365. * Restricts the camera to viewing objects with the same layerMask.
  8366. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8367. */
  8368. layerMask: number;
  8369. /**
  8370. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8371. */
  8372. fovMode: number;
  8373. cameraRigMode: number;
  8374. interaxialDistance: number;
  8375. isStereoscopicSideBySide: boolean;
  8376. _cameraRigParams: any;
  8377. _rigCameras: Camera[];
  8378. _rigPostProcess: Nullable<PostProcess>;
  8379. protected _webvrViewMatrix: Matrix;
  8380. _skipRendering: boolean;
  8381. _alternateCamera: Camera;
  8382. customRenderTargets: RenderTargetTexture[];
  8383. onViewMatrixChangedObservable: Observable<Camera>;
  8384. onProjectionMatrixChangedObservable: Observable<Camera>;
  8385. onAfterCheckInputsObservable: Observable<Camera>;
  8386. onRestoreStateObservable: Observable<Camera>;
  8387. private _computedViewMatrix;
  8388. _projectionMatrix: Matrix;
  8389. private _doNotComputeProjectionMatrix;
  8390. private _worldMatrix;
  8391. _postProcesses: Nullable<PostProcess>[];
  8392. private _transformMatrix;
  8393. _activeMeshes: SmartArray<AbstractMesh>;
  8394. protected _globalPosition: Vector3;
  8395. private _frustumPlanes;
  8396. private _refreshFrustumPlanes;
  8397. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8398. private _storedFov;
  8399. private _stateStored;
  8400. /**
  8401. * Store current camera state (fov, position, etc..)
  8402. */
  8403. storeState(): Camera;
  8404. /**
  8405. * Restores the camera state values if it has been stored. You must call storeState() first
  8406. */
  8407. protected _restoreStateValues(): boolean;
  8408. /**
  8409. * Restored camera state. You must call storeState() first
  8410. */
  8411. restoreState(): boolean;
  8412. getClassName(): string;
  8413. /**
  8414. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8415. */
  8416. toString(fullDetails?: boolean): string;
  8417. readonly globalPosition: Vector3;
  8418. getActiveMeshes(): SmartArray<AbstractMesh>;
  8419. isActiveMesh(mesh: Mesh): boolean;
  8420. /**
  8421. * Is this camera ready to be used/rendered
  8422. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8423. * @return true if the camera is ready
  8424. */
  8425. isReady(completeCheck?: boolean): boolean;
  8426. _initCache(): void;
  8427. _updateCache(ignoreParentClass?: boolean): void;
  8428. _isSynchronized(): boolean;
  8429. _isSynchronizedViewMatrix(): boolean;
  8430. _isSynchronizedProjectionMatrix(): boolean;
  8431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8432. detachControl(element: HTMLElement): void;
  8433. update(): void;
  8434. _checkInputs(): void;
  8435. readonly rigCameras: Camera[];
  8436. readonly rigPostProcess: Nullable<PostProcess>;
  8437. /**
  8438. * Internal, gets the first post proces.
  8439. * @returns the first post process to be run on this camera.
  8440. */
  8441. _getFirstPostProcess(): Nullable<PostProcess>;
  8442. private _cascadePostProcessesToRigCams();
  8443. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8444. detachPostProcess(postProcess: PostProcess): void;
  8445. getWorldMatrix(): Matrix;
  8446. _getViewMatrix(): Matrix;
  8447. getViewMatrix(force?: boolean): Matrix;
  8448. freezeProjectionMatrix(projection?: Matrix): void;
  8449. unfreezeProjectionMatrix(): void;
  8450. getProjectionMatrix(force?: boolean): Matrix;
  8451. getTranformationMatrix(): Matrix;
  8452. private updateFrustumPlanes();
  8453. isInFrustum(target: ICullable): boolean;
  8454. isCompletelyInFrustum(target: ICullable): boolean;
  8455. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8456. /**
  8457. * Releases resources associated with this node.
  8458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8460. */
  8461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8462. readonly leftCamera: Nullable<FreeCamera>;
  8463. readonly rightCamera: Nullable<FreeCamera>;
  8464. getLeftTarget(): Nullable<Vector3>;
  8465. getRightTarget(): Nullable<Vector3>;
  8466. setCameraRigMode(mode: number, rigParams: any): void;
  8467. private _getVRProjectionMatrix();
  8468. protected _updateCameraRotationMatrix(): void;
  8469. protected _updateWebVRCameraRotationMatrix(): void;
  8470. /**
  8471. * This function MUST be overwritten by the different WebVR cameras available.
  8472. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8473. */
  8474. protected _getWebVRProjectionMatrix(): Matrix;
  8475. /**
  8476. * This function MUST be overwritten by the different WebVR cameras available.
  8477. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8478. */
  8479. protected _getWebVRViewMatrix(): Matrix;
  8480. setCameraRigParameter(name: string, value: any): void;
  8481. /**
  8482. * needs to be overridden by children so sub has required properties to be copied
  8483. */
  8484. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8485. /**
  8486. * May need to be overridden by children
  8487. */
  8488. _updateRigCameras(): void;
  8489. _setupInputs(): void;
  8490. serialize(): any;
  8491. clone(name: string): Camera;
  8492. getDirection(localAxis: Vector3): Vector3;
  8493. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8494. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8495. computeWorldMatrix(): Matrix;
  8496. static Parse(parsedCamera: any, scene: Scene): Camera;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. var CameraInputTypes: {};
  8501. interface ICameraInput<TCamera extends Camera> {
  8502. camera: Nullable<TCamera>;
  8503. getClassName(): string;
  8504. getSimpleName(): string;
  8505. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  8506. detachControl: (element: Nullable<HTMLElement>) => void;
  8507. checkInputs?: () => void;
  8508. }
  8509. interface CameraInputsMap<TCamera extends Camera> {
  8510. [name: string]: ICameraInput<TCamera>;
  8511. [idx: number]: ICameraInput<TCamera>;
  8512. }
  8513. class CameraInputsManager<TCamera extends Camera> {
  8514. attached: CameraInputsMap<TCamera>;
  8515. attachedElement: Nullable<HTMLElement>;
  8516. noPreventDefault: boolean;
  8517. camera: TCamera;
  8518. checkInputs: () => void;
  8519. constructor(camera: TCamera);
  8520. /**
  8521. * Add an input method to a camera
  8522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8523. * @param input camera input method
  8524. */
  8525. add(input: ICameraInput<TCamera>): void;
  8526. /**
  8527. * Remove a specific input method from a camera
  8528. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8529. * @param inputToRemove camera input method
  8530. */
  8531. remove(inputToRemove: ICameraInput<TCamera>): void;
  8532. removeByType(inputType: string): void;
  8533. private _addCheckInputs(fn);
  8534. attachInput(input: ICameraInput<TCamera>): void;
  8535. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8536. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8537. rebuildInputCheck(): void;
  8538. /**
  8539. * Remove all attached input methods from a camera
  8540. */
  8541. clear(): void;
  8542. serialize(serializedCamera: any): void;
  8543. parse(parsedCamera: any): void;
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8549. * being tilted forward or back and left or right.
  8550. */
  8551. class DeviceOrientationCamera extends FreeCamera {
  8552. private _initialQuaternion;
  8553. private _quaternionCache;
  8554. /**
  8555. * Creates a new device orientation camera
  8556. * @param name The name of the camera
  8557. * @param position The start position camera
  8558. * @param scene The scene the camera belongs to
  8559. */
  8560. constructor(name: string, position: Vector3, scene: Scene);
  8561. /**
  8562. * Gets the current instance class name ("DeviceOrientationCamera").
  8563. * This helps avoiding instanceof at run time.
  8564. * @returns the class name
  8565. */
  8566. getClassName(): string;
  8567. /**
  8568. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8569. */
  8570. _checkInputs(): void;
  8571. /**
  8572. * Reset the camera to its default orientation on the specified axis only.
  8573. * @param axis The axis to reset
  8574. */
  8575. resetToCurrentRotation(axis?: Axis): void;
  8576. }
  8577. }
  8578. declare module BABYLON {
  8579. class FollowCamera extends TargetCamera {
  8580. radius: number;
  8581. rotationOffset: number;
  8582. heightOffset: number;
  8583. cameraAcceleration: number;
  8584. maxCameraSpeed: number;
  8585. lockedTarget: Nullable<AbstractMesh>;
  8586. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8587. private getRadians(degrees);
  8588. private follow(cameraTarget);
  8589. _checkInputs(): void;
  8590. getClassName(): string;
  8591. }
  8592. class ArcFollowCamera extends TargetCamera {
  8593. alpha: number;
  8594. beta: number;
  8595. radius: number;
  8596. target: Nullable<AbstractMesh>;
  8597. private _cartesianCoordinates;
  8598. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  8599. private follow();
  8600. _checkInputs(): void;
  8601. getClassName(): string;
  8602. }
  8603. }
  8604. declare module BABYLON {
  8605. class FreeCamera extends TargetCamera {
  8606. ellipsoid: Vector3;
  8607. ellipsoidOffset: Vector3;
  8608. checkCollisions: boolean;
  8609. applyGravity: boolean;
  8610. inputs: FreeCameraInputsManager;
  8611. /**
  8612. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8613. * Higher values reduce sensitivity.
  8614. */
  8615. /**
  8616. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8617. * Higher values reduce sensitivity.
  8618. */
  8619. angularSensibility: number;
  8620. keysUp: number[];
  8621. keysDown: number[];
  8622. keysLeft: number[];
  8623. keysRight: number[];
  8624. onCollide: (collidedMesh: AbstractMesh) => void;
  8625. private _collider;
  8626. private _needMoveForGravity;
  8627. private _oldPosition;
  8628. private _diffPosition;
  8629. private _newPosition;
  8630. _localDirection: Vector3;
  8631. _transformedDirection: Vector3;
  8632. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8634. detachControl(element: HTMLElement): void;
  8635. private _collisionMask;
  8636. collisionMask: number;
  8637. _collideWithWorld(displacement: Vector3): void;
  8638. private _onCollisionPositionChange;
  8639. _checkInputs(): void;
  8640. _decideIfNeedsToMove(): boolean;
  8641. _updatePosition(): void;
  8642. dispose(): void;
  8643. getClassName(): string;
  8644. }
  8645. }
  8646. declare module BABYLON {
  8647. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8648. constructor(camera: FreeCamera);
  8649. addKeyboard(): FreeCameraInputsManager;
  8650. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8651. addDeviceOrientation(): FreeCameraInputsManager;
  8652. addTouch(): FreeCameraInputsManager;
  8653. addVirtualJoystick(): FreeCameraInputsManager;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. class GamepadCamera extends UniversalCamera {
  8658. gamepadAngularSensibility: number;
  8659. gamepadMoveSensibility: number;
  8660. constructor(name: string, position: Vector3, scene: Scene);
  8661. getClassName(): string;
  8662. }
  8663. }
  8664. declare module BABYLON {
  8665. class TargetCamera extends Camera {
  8666. cameraDirection: Vector3;
  8667. cameraRotation: Vector2;
  8668. rotation: Vector3;
  8669. rotationQuaternion: Quaternion;
  8670. speed: number;
  8671. noRotationConstraint: boolean;
  8672. lockedTarget: any;
  8673. _currentTarget: Vector3;
  8674. _viewMatrix: Matrix;
  8675. _camMatrix: Matrix;
  8676. _cameraTransformMatrix: Matrix;
  8677. _cameraRotationMatrix: Matrix;
  8678. private _rigCamTransformMatrix;
  8679. _referencePoint: Vector3;
  8680. private _currentUpVector;
  8681. _transformedReferencePoint: Vector3;
  8682. protected _globalCurrentTarget: Vector3;
  8683. protected _globalCurrentUpVector: Vector3;
  8684. _reset: () => void;
  8685. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8686. getFrontPosition(distance: number): Vector3;
  8687. _getLockedTargetPosition(): Nullable<Vector3>;
  8688. /**
  8689. * Store current camera state (fov, position, etc..)
  8690. */
  8691. private _storedPosition;
  8692. private _storedRotation;
  8693. private _storedRotationQuaternion;
  8694. storeState(): Camera;
  8695. /**
  8696. * Restored camera state. You must call storeState() first
  8697. */
  8698. _restoreStateValues(): boolean;
  8699. _initCache(): void;
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. _isSynchronizedViewMatrix(): boolean;
  8702. _computeLocalCameraSpeed(): number;
  8703. setTarget(target: Vector3): void;
  8704. /**
  8705. * Return the current target position of the camera. This value is expressed in local space.
  8706. */
  8707. getTarget(): Vector3;
  8708. _decideIfNeedsToMove(): boolean;
  8709. _updatePosition(): void;
  8710. _checkInputs(): void;
  8711. protected _updateCameraRotationMatrix(): void;
  8712. _getViewMatrix(): Matrix;
  8713. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8714. /**
  8715. * @override
  8716. * Override Camera.createRigCamera
  8717. */
  8718. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8719. /**
  8720. * @override
  8721. * Override Camera._updateRigCameras
  8722. */
  8723. _updateRigCameras(): void;
  8724. private _getRigCamPosition(halfSpace, result);
  8725. getClassName(): string;
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. class TouchCamera extends FreeCamera {
  8730. touchAngularSensibility: number;
  8731. touchMoveSensibility: number;
  8732. constructor(name: string, position: Vector3, scene: Scene);
  8733. getClassName(): string;
  8734. _setupInputs(): void;
  8735. }
  8736. }
  8737. declare module BABYLON {
  8738. class UniversalCamera extends TouchCamera {
  8739. gamepadAngularSensibility: number;
  8740. gamepadMoveSensibility: number;
  8741. constructor(name: string, position: Vector3, scene: Scene);
  8742. getClassName(): string;
  8743. }
  8744. }
  8745. declare module BABYLON {
  8746. class VirtualJoysticksCamera extends FreeCamera {
  8747. constructor(name: string, position: Vector3, scene: Scene);
  8748. getClassName(): string;
  8749. }
  8750. }
  8751. interface VRDisplay extends EventTarget {
  8752. /**
  8753. * Dictionary of capabilities describing the VRDisplay.
  8754. */
  8755. readonly capabilities: VRDisplayCapabilities;
  8756. /**
  8757. * z-depth defining the far plane of the eye view frustum
  8758. * enables mapping of values in the render target depth
  8759. * attachment to scene coordinates. Initially set to 10000.0.
  8760. */
  8761. depthFar: number;
  8762. /**
  8763. * z-depth defining the near plane of the eye view frustum
  8764. * enables mapping of values in the render target depth
  8765. * attachment to scene coordinates. Initially set to 0.01.
  8766. */
  8767. depthNear: number;
  8768. /**
  8769. * An identifier for this distinct VRDisplay. Used as an
  8770. * association point in the Gamepad API.
  8771. */
  8772. readonly displayId: number;
  8773. /**
  8774. * A display name, a user-readable name identifying it.
  8775. */
  8776. readonly displayName: string;
  8777. readonly isConnected: boolean;
  8778. readonly isPresenting: boolean;
  8779. /**
  8780. * If this VRDisplay supports room-scale experiences, the optional
  8781. * stage attribute contains details on the room-scale parameters.
  8782. */
  8783. readonly stageParameters: VRStageParameters | null;
  8784. /**
  8785. * Passing the value returned by `requestAnimationFrame` to
  8786. * `cancelAnimationFrame` will unregister the callback.
  8787. */
  8788. cancelAnimationFrame(handle: number): void;
  8789. /**
  8790. * Stops presenting to the VRDisplay.
  8791. */
  8792. exitPresent(): Promise<void>;
  8793. getEyeParameters(whichEye: string): VREyeParameters;
  8794. /**
  8795. * Populates the passed VRFrameData with the information required to render
  8796. * the current frame.
  8797. */
  8798. getFrameData(frameData: VRFrameData): boolean;
  8799. /**
  8800. * Get the layers currently being presented.
  8801. */
  8802. getLayers(): VRLayer[];
  8803. /**
  8804. * Return a VRPose containing the future predicted pose of the VRDisplay
  8805. * when the current frame will be presented. The value returned will not
  8806. * change until JavaScript has returned control to the browser.
  8807. *
  8808. * The VRPose will contain the position, orientation, velocity,
  8809. * and acceleration of each of these properties.
  8810. */
  8811. getPose(): VRPose;
  8812. /**
  8813. * Return the current instantaneous pose of the VRDisplay, with no
  8814. * prediction applied.
  8815. */
  8816. getImmediatePose(): VRPose;
  8817. /**
  8818. * The callback passed to `requestAnimationFrame` will be called
  8819. * any time a new frame should be rendered. When the VRDisplay is
  8820. * presenting the callback will be called at the native refresh
  8821. * rate of the HMD. When not presenting this function acts
  8822. * identically to how window.requestAnimationFrame acts. Content should
  8823. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8824. * asynchronously from other displays and at differing refresh rates.
  8825. */
  8826. requestAnimationFrame(callback: FrameRequestCallback): number;
  8827. /**
  8828. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8829. * Repeat calls while already presenting will update the VRLayers being displayed.
  8830. */
  8831. requestPresent(layers: VRLayer[]): Promise<void>;
  8832. /**
  8833. * Reset the pose for this display, treating its current position and
  8834. * orientation as the "origin/zero" values. VRPose.position,
  8835. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8836. * updated when calling resetPose(). This should be called in only
  8837. * sitting-space experiences.
  8838. */
  8839. resetPose(): void;
  8840. /**
  8841. * The VRLayer provided to the VRDisplay will be captured and presented
  8842. * in the HMD. Calling this function has the same effect on the source
  8843. * canvas as any other operation that uses its source image, and canvases
  8844. * created without preserveDrawingBuffer set to true will be cleared.
  8845. */
  8846. submitFrame(pose?: VRPose): void;
  8847. }
  8848. declare var VRDisplay: {
  8849. prototype: VRDisplay;
  8850. new (): VRDisplay;
  8851. };
  8852. interface VRLayer {
  8853. leftBounds?: number[] | null;
  8854. rightBounds?: number[] | null;
  8855. source?: HTMLCanvasElement | null;
  8856. }
  8857. interface VRDisplayCapabilities {
  8858. readonly canPresent: boolean;
  8859. readonly hasExternalDisplay: boolean;
  8860. readonly hasOrientation: boolean;
  8861. readonly hasPosition: boolean;
  8862. readonly maxLayers: number;
  8863. }
  8864. interface VREyeParameters {
  8865. /** @deprecated */
  8866. readonly fieldOfView: VRFieldOfView;
  8867. readonly offset: Float32Array;
  8868. readonly renderHeight: number;
  8869. readonly renderWidth: number;
  8870. }
  8871. interface VRFieldOfView {
  8872. readonly downDegrees: number;
  8873. readonly leftDegrees: number;
  8874. readonly rightDegrees: number;
  8875. readonly upDegrees: number;
  8876. }
  8877. interface VRFrameData {
  8878. readonly leftProjectionMatrix: Float32Array;
  8879. readonly leftViewMatrix: Float32Array;
  8880. readonly pose: VRPose;
  8881. readonly rightProjectionMatrix: Float32Array;
  8882. readonly rightViewMatrix: Float32Array;
  8883. readonly timestamp: number;
  8884. }
  8885. interface VRPose {
  8886. readonly angularAcceleration: Float32Array | null;
  8887. readonly angularVelocity: Float32Array | null;
  8888. readonly linearAcceleration: Float32Array | null;
  8889. readonly linearVelocity: Float32Array | null;
  8890. readonly orientation: Float32Array | null;
  8891. readonly position: Float32Array | null;
  8892. readonly timestamp: number;
  8893. }
  8894. interface VRStageParameters {
  8895. sittingToStandingTransform?: Float32Array;
  8896. sizeX?: number;
  8897. sizeY?: number;
  8898. }
  8899. interface Navigator {
  8900. getVRDisplays(): Promise<VRDisplay[]>;
  8901. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8902. }
  8903. interface Window {
  8904. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8905. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8906. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8907. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8908. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8909. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8910. }
  8911. interface Gamepad {
  8912. readonly displayId: number;
  8913. }
  8914. declare module BABYLON {
  8915. class Collider {
  8916. /** Define if a collision was found */
  8917. collisionFound: boolean;
  8918. /**
  8919. * Define last intersection point in local space
  8920. */
  8921. intersectionPoint: Vector3;
  8922. /**
  8923. * Define last collided mesh
  8924. */
  8925. collidedMesh: Nullable<AbstractMesh>;
  8926. private _collisionPoint;
  8927. private _planeIntersectionPoint;
  8928. private _tempVector;
  8929. private _tempVector2;
  8930. private _tempVector3;
  8931. private _tempVector4;
  8932. private _edge;
  8933. private _baseToVertex;
  8934. private _destinationPoint;
  8935. private _slidePlaneNormal;
  8936. private _displacementVector;
  8937. _radius: Vector3;
  8938. _retry: number;
  8939. private _velocity;
  8940. private _basePoint;
  8941. private _epsilon;
  8942. _velocityWorldLength: number;
  8943. _basePointWorld: Vector3;
  8944. private _velocityWorld;
  8945. private _normalizedVelocity;
  8946. _initialVelocity: Vector3;
  8947. _initialPosition: Vector3;
  8948. private _nearestDistance;
  8949. private _collisionMask;
  8950. collisionMask: number;
  8951. /**
  8952. * Gets the plane normal used to compute the sliding response (in local space)
  8953. */
  8954. readonly slidePlaneNormal: Vector3;
  8955. _initialize(source: Vector3, dir: Vector3, e: number): void;
  8956. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  8957. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  8958. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  8959. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  8960. _getResponse(pos: Vector3, vel: Vector3): void;
  8961. }
  8962. }
  8963. declare module BABYLON {
  8964. var CollisionWorker: string;
  8965. interface ICollisionCoordinator {
  8966. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8967. init(scene: Scene): void;
  8968. destroy(): void;
  8969. onMeshAdded(mesh: AbstractMesh): void;
  8970. onMeshUpdated(mesh: AbstractMesh): void;
  8971. onMeshRemoved(mesh: AbstractMesh): void;
  8972. onGeometryAdded(geometry: Geometry): void;
  8973. onGeometryUpdated(geometry: Geometry): void;
  8974. onGeometryDeleted(geometry: Geometry): void;
  8975. }
  8976. interface SerializedMesh {
  8977. id: string;
  8978. name: string;
  8979. uniqueId: number;
  8980. geometryId: Nullable<string>;
  8981. sphereCenter: Array<number>;
  8982. sphereRadius: number;
  8983. boxMinimum: Array<number>;
  8984. boxMaximum: Array<number>;
  8985. worldMatrixFromCache: any;
  8986. subMeshes: Array<SerializedSubMesh>;
  8987. checkCollisions: boolean;
  8988. }
  8989. interface SerializedSubMesh {
  8990. position: number;
  8991. verticesStart: number;
  8992. verticesCount: number;
  8993. indexStart: number;
  8994. indexCount: number;
  8995. hasMaterial: boolean;
  8996. sphereCenter: Array<number>;
  8997. sphereRadius: number;
  8998. boxMinimum: Array<number>;
  8999. boxMaximum: Array<number>;
  9000. }
  9001. /**
  9002. * Interface describing the value associated with a geometry
  9003. */
  9004. interface SerializedGeometry {
  9005. /**
  9006. * Defines the unique ID of the geometry
  9007. */
  9008. id: string;
  9009. /**
  9010. * Defines the array containing the positions
  9011. */
  9012. positions: Float32Array;
  9013. /**
  9014. * Defines the array containing the indices
  9015. */
  9016. indices: Uint32Array;
  9017. /**
  9018. * Defines the array containing the normals
  9019. */
  9020. normals: Float32Array;
  9021. }
  9022. interface BabylonMessage {
  9023. taskType: WorkerTaskType;
  9024. payload: InitPayload | CollidePayload | UpdatePayload;
  9025. }
  9026. interface SerializedColliderToWorker {
  9027. position: Array<number>;
  9028. velocity: Array<number>;
  9029. radius: Array<number>;
  9030. }
  9031. /** Defines supported task for worker process */
  9032. enum WorkerTaskType {
  9033. /** Initialization */
  9034. INIT = 0,
  9035. /** Update of geometry */
  9036. UPDATE = 1,
  9037. /** Evaluate collision */
  9038. COLLIDE = 2,
  9039. }
  9040. interface WorkerReply {
  9041. error: WorkerReplyType;
  9042. taskType: WorkerTaskType;
  9043. payload?: any;
  9044. }
  9045. interface CollisionReplyPayload {
  9046. newPosition: Array<number>;
  9047. collisionId: number;
  9048. collidedMeshUniqueId: number;
  9049. }
  9050. interface InitPayload {
  9051. }
  9052. interface CollidePayload {
  9053. collisionId: number;
  9054. collider: SerializedColliderToWorker;
  9055. maximumRetry: number;
  9056. excludedMeshUniqueId: Nullable<number>;
  9057. }
  9058. interface UpdatePayload {
  9059. updatedMeshes: {
  9060. [n: number]: SerializedMesh;
  9061. };
  9062. updatedGeometries: {
  9063. [s: string]: SerializedGeometry;
  9064. };
  9065. removedMeshes: Array<number>;
  9066. removedGeometries: Array<string>;
  9067. }
  9068. /** Defines kind of replies returned by worker */
  9069. enum WorkerReplyType {
  9070. /** Success */
  9071. SUCCESS = 0,
  9072. /** Unkown error */
  9073. UNKNOWN_ERROR = 1,
  9074. }
  9075. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9076. private _scene;
  9077. private _scaledPosition;
  9078. private _scaledVelocity;
  9079. private _collisionsCallbackArray;
  9080. private _init;
  9081. private _runningUpdated;
  9082. private _worker;
  9083. private _addUpdateMeshesList;
  9084. private _addUpdateGeometriesList;
  9085. private _toRemoveMeshesArray;
  9086. private _toRemoveGeometryArray;
  9087. constructor();
  9088. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9089. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9090. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9091. init(scene: Scene): void;
  9092. destroy(): void;
  9093. onMeshAdded(mesh: AbstractMesh): void;
  9094. onMeshUpdated: (transformNode: TransformNode) => void;
  9095. onMeshRemoved(mesh: AbstractMesh): void;
  9096. onGeometryAdded(geometry: Geometry): void;
  9097. onGeometryUpdated: (geometry: Geometry) => void;
  9098. onGeometryDeleted(geometry: Geometry): void;
  9099. private _afterRender;
  9100. private _onMessageFromWorker;
  9101. }
  9102. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9103. private _scene;
  9104. private _scaledPosition;
  9105. private _scaledVelocity;
  9106. private _finalPosition;
  9107. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9108. init(scene: Scene): void;
  9109. destroy(): void;
  9110. onMeshAdded(mesh: AbstractMesh): void;
  9111. onMeshUpdated(mesh: AbstractMesh): void;
  9112. onMeshRemoved(mesh: AbstractMesh): void;
  9113. onGeometryAdded(geometry: Geometry): void;
  9114. onGeometryUpdated(geometry: Geometry): void;
  9115. onGeometryDeleted(geometry: Geometry): void;
  9116. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  9117. }
  9118. }
  9119. declare function importScripts(...urls: string[]): void;
  9120. declare const safePostMessage: any;
  9121. declare module BABYLON {
  9122. var WorkerIncluded: boolean;
  9123. class CollisionCache {
  9124. private _meshes;
  9125. private _geometries;
  9126. getMeshes(): {
  9127. [n: number]: SerializedMesh;
  9128. };
  9129. getGeometries(): {
  9130. [s: number]: SerializedGeometry;
  9131. };
  9132. getMesh(id: any): SerializedMesh;
  9133. addMesh(mesh: SerializedMesh): void;
  9134. removeMesh(uniqueId: number): void;
  9135. getGeometry(id: string): SerializedGeometry;
  9136. addGeometry(geometry: SerializedGeometry): void;
  9137. removeGeometry(id: string): void;
  9138. }
  9139. class CollideWorker {
  9140. collider: Collider;
  9141. private _collisionCache;
  9142. private finalPosition;
  9143. private collisionsScalingMatrix;
  9144. private collisionTranformationMatrix;
  9145. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9146. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9147. private checkCollision(mesh);
  9148. private processCollisionsForSubMeshes(transformMatrix, mesh);
  9149. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  9150. private checkSubmeshCollision(subMesh);
  9151. }
  9152. interface ICollisionDetector {
  9153. onInit(payload: InitPayload): void;
  9154. onUpdate(payload: UpdatePayload): void;
  9155. onCollision(payload: CollidePayload): void;
  9156. }
  9157. class CollisionDetectorTransferable implements ICollisionDetector {
  9158. private _collisionCache;
  9159. onInit(payload: InitPayload): void;
  9160. onUpdate(payload: UpdatePayload): void;
  9161. onCollision(payload: CollidePayload): void;
  9162. }
  9163. }
  9164. declare module BABYLON {
  9165. class IntersectionInfo {
  9166. bu: Nullable<number>;
  9167. bv: Nullable<number>;
  9168. distance: number;
  9169. faceId: number;
  9170. subMeshId: number;
  9171. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9172. }
  9173. /**
  9174. * Information about the result of picking within a scene
  9175. * See https://doc.babylonjs.com/babylon101/picking_collisions
  9176. */
  9177. class PickingInfo {
  9178. /**
  9179. * If the pick collided with an object
  9180. */
  9181. hit: boolean;
  9182. /**
  9183. * Distance away where the pick collided
  9184. */
  9185. distance: number;
  9186. /**
  9187. * The location of pick collision
  9188. */
  9189. pickedPoint: Nullable<Vector3>;
  9190. /**
  9191. * The mesh corrisponding the the pick collision
  9192. */
  9193. pickedMesh: Nullable<AbstractMesh>;
  9194. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9195. bu: number;
  9196. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9197. bv: number;
  9198. /** The id of the face on the mesh that was picked */
  9199. faceId: number;
  9200. /** Id of the the submesh that was picked */
  9201. subMeshId: number;
  9202. /** If a sprite was picked, this will be the sprite the pick collided with */
  9203. pickedSprite: Nullable<Sprite>;
  9204. /**
  9205. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9206. */
  9207. originMesh: Nullable<AbstractMesh>;
  9208. /**
  9209. * The ray that was used to perform the picking.
  9210. */
  9211. ray: Nullable<Ray>;
  9212. /**
  9213. * Gets the normal corrispodning to the face the pick collided with
  9214. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9215. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9216. * @returns The normal corrispodning to the face the pick collided with
  9217. */
  9218. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9219. /**
  9220. * Gets the texture coordinates of where the pick occured
  9221. * @returns the vector containing the coordnates of the texture
  9222. */
  9223. getTextureCoordinates(): Nullable<Vector2>;
  9224. }
  9225. }
  9226. declare module BABYLON {
  9227. class KeyboardEventTypes {
  9228. static _KEYDOWN: number;
  9229. static _KEYUP: number;
  9230. static readonly KEYDOWN: number;
  9231. static readonly KEYUP: number;
  9232. }
  9233. class KeyboardInfo {
  9234. type: number;
  9235. event: KeyboardEvent;
  9236. constructor(type: number, event: KeyboardEvent);
  9237. }
  9238. /**
  9239. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9240. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9241. */
  9242. class KeyboardInfoPre extends KeyboardInfo {
  9243. constructor(type: number, event: KeyboardEvent);
  9244. skipOnPointerObservable: boolean;
  9245. }
  9246. }
  9247. declare module BABYLON {
  9248. class PointerEventTypes {
  9249. static _POINTERDOWN: number;
  9250. static _POINTERUP: number;
  9251. static _POINTERMOVE: number;
  9252. static _POINTERWHEEL: number;
  9253. static _POINTERPICK: number;
  9254. static _POINTERTAP: number;
  9255. static _POINTERDOUBLETAP: number;
  9256. static readonly POINTERDOWN: number;
  9257. static readonly POINTERUP: number;
  9258. static readonly POINTERMOVE: number;
  9259. static readonly POINTERWHEEL: number;
  9260. static readonly POINTERPICK: number;
  9261. static readonly POINTERTAP: number;
  9262. static readonly POINTERDOUBLETAP: number;
  9263. }
  9264. class PointerInfoBase {
  9265. type: number;
  9266. event: PointerEvent | MouseWheelEvent;
  9267. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9268. }
  9269. /**
  9270. * This class is used to store pointer related info for the onPrePointerObservable event.
  9271. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9272. */
  9273. class PointerInfoPre extends PointerInfoBase {
  9274. /**
  9275. * Ray from a pointer if availible (eg. 6dof controller)
  9276. */
  9277. ray: Nullable<Ray>;
  9278. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9279. localPosition: Vector2;
  9280. skipOnPointerObservable: boolean;
  9281. }
  9282. /**
  9283. * This type contains all the data related to a pointer event in Babylon.js.
  9284. * 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.
  9285. */
  9286. class PointerInfo extends PointerInfoBase {
  9287. pickInfo: Nullable<PickingInfo>;
  9288. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9289. }
  9290. }
  9291. declare module BABYLON {
  9292. class StickValues {
  9293. x: number;
  9294. y: number;
  9295. constructor(x: number, y: number);
  9296. }
  9297. interface GamepadButtonChanges {
  9298. changed: boolean;
  9299. pressChanged: boolean;
  9300. touchChanged: boolean;
  9301. valueChanged: boolean;
  9302. }
  9303. class Gamepad {
  9304. id: string;
  9305. index: number;
  9306. browserGamepad: any;
  9307. type: number;
  9308. private _leftStick;
  9309. private _rightStick;
  9310. _isConnected: boolean;
  9311. private _leftStickAxisX;
  9312. private _leftStickAxisY;
  9313. private _rightStickAxisX;
  9314. private _rightStickAxisY;
  9315. private _onleftstickchanged;
  9316. private _onrightstickchanged;
  9317. static GAMEPAD: number;
  9318. static GENERIC: number;
  9319. static XBOX: number;
  9320. static POSE_ENABLED: number;
  9321. protected _invertLeftStickY: boolean;
  9322. readonly isConnected: boolean;
  9323. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9324. onleftstickchanged(callback: (values: StickValues) => void): void;
  9325. onrightstickchanged(callback: (values: StickValues) => void): void;
  9326. leftStick: StickValues;
  9327. rightStick: StickValues;
  9328. update(): void;
  9329. dispose(): void;
  9330. }
  9331. class GenericPad extends Gamepad {
  9332. private _buttons;
  9333. private _onbuttondown;
  9334. private _onbuttonup;
  9335. onButtonDownObservable: Observable<number>;
  9336. onButtonUpObservable: Observable<number>;
  9337. onbuttondown(callback: (buttonPressed: number) => void): void;
  9338. onbuttonup(callback: (buttonReleased: number) => void): void;
  9339. constructor(id: string, index: number, browserGamepad: any);
  9340. private _setButtonValue(newValue, currentValue, buttonIndex);
  9341. update(): void;
  9342. dispose(): void;
  9343. }
  9344. }
  9345. declare module BABYLON {
  9346. class GamepadManager {
  9347. private _scene;
  9348. private _babylonGamepads;
  9349. private _oneGamepadConnected;
  9350. _isMonitoring: boolean;
  9351. private _gamepadEventSupported;
  9352. private _gamepadSupport;
  9353. onGamepadConnectedObservable: Observable<Gamepad>;
  9354. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9355. private _onGamepadConnectedEvent;
  9356. private _onGamepadDisconnectedEvent;
  9357. constructor(_scene?: Scene | undefined);
  9358. readonly gamepads: Gamepad[];
  9359. getGamepadByType(type?: number): Nullable<Gamepad>;
  9360. dispose(): void;
  9361. private _addNewGamepad(gamepad);
  9362. private _startMonitoringGamepads();
  9363. private _stopMonitoringGamepads();
  9364. _checkGamepadsStatus(): void;
  9365. private _updateGamepadObjects();
  9366. }
  9367. }
  9368. declare module BABYLON {
  9369. interface Scene {
  9370. /** @hidden */
  9371. _gamepadManager: Nullable<GamepadManager>;
  9372. /**
  9373. * Gets the gamepad manager associated with the scene
  9374. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9375. */
  9376. gamepadManager: GamepadManager;
  9377. }
  9378. interface FreeCameraInputsManager {
  9379. addGamepad(): FreeCameraInputsManager;
  9380. }
  9381. interface ArcRotateCameraInputsManager {
  9382. addGamepad(): ArcRotateCameraInputsManager;
  9383. }
  9384. /**
  9385. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9386. */
  9387. class GamepadSystemSceneComponent implements ISceneComponent {
  9388. /**
  9389. * The component name helpfull to identify the component in the list of scene components.
  9390. */
  9391. readonly name: string;
  9392. /**
  9393. * The scene the component belongs to.
  9394. */
  9395. scene: Scene;
  9396. /**
  9397. * Creates a new instance of the component for the given scene
  9398. * @param scene Defines the scene to register the component in
  9399. */
  9400. constructor(scene: Scene);
  9401. /**
  9402. * Registers the component in a given scene
  9403. */
  9404. register(): void;
  9405. /**
  9406. * Rebuilds the elements related to this component in case of
  9407. * context lost for instance.
  9408. */
  9409. rebuild(): void;
  9410. /**
  9411. * Disposes the component and the associated ressources
  9412. */
  9413. dispose(): void;
  9414. private _beforeCameraUpdate();
  9415. }
  9416. }
  9417. declare module BABYLON {
  9418. /**
  9419. * Defines supported buttons for XBox360 compatible gamepads
  9420. */
  9421. enum Xbox360Button {
  9422. /** A */
  9423. A = 0,
  9424. /** B */
  9425. B = 1,
  9426. /** X */
  9427. X = 2,
  9428. /** Y */
  9429. Y = 3,
  9430. /** Start */
  9431. Start = 4,
  9432. /** Back */
  9433. Back = 5,
  9434. /** Left button */
  9435. LB = 6,
  9436. /** Right button */
  9437. RB = 7,
  9438. /** Left stick */
  9439. LeftStick = 8,
  9440. /** Right stick */
  9441. RightStick = 9,
  9442. }
  9443. /** Defines values for XBox360 DPad */
  9444. enum Xbox360Dpad {
  9445. /** Up */
  9446. Up = 0,
  9447. /** Down */
  9448. Down = 1,
  9449. /** Left */
  9450. Left = 2,
  9451. /** Right */
  9452. Right = 3,
  9453. }
  9454. /**
  9455. * Defines a XBox360 gamepad
  9456. */
  9457. class Xbox360Pad extends Gamepad {
  9458. private _leftTrigger;
  9459. private _rightTrigger;
  9460. private _onlefttriggerchanged;
  9461. private _onrighttriggerchanged;
  9462. private _onbuttondown;
  9463. private _onbuttonup;
  9464. private _ondpaddown;
  9465. private _ondpadup;
  9466. /** Observable raised when a button is pressed */
  9467. onButtonDownObservable: Observable<Xbox360Button>;
  9468. /** Observable raised when a button is released */
  9469. onButtonUpObservable: Observable<Xbox360Button>;
  9470. /** Observable raised when a pad is pressed */
  9471. onPadDownObservable: Observable<Xbox360Dpad>;
  9472. /** Observable raised when a pad is released */
  9473. onPadUpObservable: Observable<Xbox360Dpad>;
  9474. private _buttonA;
  9475. private _buttonB;
  9476. private _buttonX;
  9477. private _buttonY;
  9478. private _buttonBack;
  9479. private _buttonStart;
  9480. private _buttonLB;
  9481. private _buttonRB;
  9482. private _buttonLeftStick;
  9483. private _buttonRightStick;
  9484. private _dPadUp;
  9485. private _dPadDown;
  9486. private _dPadLeft;
  9487. private _dPadRight;
  9488. private _isXboxOnePad;
  9489. /**
  9490. * Creates a new XBox360 gamepad object
  9491. * @param id defines the id of this gamepad
  9492. * @param index defines its index
  9493. * @param gamepad defines the internal HTML gamepad object
  9494. * @param xboxOne defines if it is a XBox One gamepad
  9495. */
  9496. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9497. /**
  9498. * Defines the callback to call when left trigger is pressed
  9499. * @param callback defines the callback to use
  9500. */
  9501. onlefttriggerchanged(callback: (value: number) => void): void;
  9502. /**
  9503. * Defines the callback to call when right trigger is pressed
  9504. * @param callback defines the callback to use
  9505. */
  9506. onrighttriggerchanged(callback: (value: number) => void): void;
  9507. /**
  9508. * Gets or sets left trigger value
  9509. */
  9510. leftTrigger: number;
  9511. /**
  9512. * Gets or sets right trigger value
  9513. */
  9514. rightTrigger: number;
  9515. /**
  9516. * Defines the callback to call when a button is pressed
  9517. * @param callback defines the callback to use
  9518. */
  9519. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9520. /**
  9521. * Defines the callback to call when a button is released
  9522. * @param callback defines the callback to use
  9523. */
  9524. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9525. /**
  9526. * Defines the callback to call when a pad is pressed
  9527. * @param callback defines the callback to use
  9528. */
  9529. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9530. /**
  9531. * Defines the callback to call when a pad is released
  9532. * @param callback defines the callback to use
  9533. */
  9534. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9535. private _setButtonValue(newValue, currentValue, buttonType);
  9536. private _setDPadValue(newValue, currentValue, buttonType);
  9537. /** Gets or sets value of A button */
  9538. buttonA: number;
  9539. /** Gets or sets value of B button */
  9540. buttonB: number;
  9541. /** Gets or sets value of X button */
  9542. buttonX: number;
  9543. /** Gets or sets value of Y button */
  9544. buttonY: number;
  9545. /** Gets or sets value of Start button */
  9546. buttonStart: number;
  9547. /** Gets or sets value of Back button */
  9548. buttonBack: number;
  9549. /** Gets or sets value of Left button */
  9550. buttonLB: number;
  9551. /** Gets or sets value of Right button */
  9552. buttonRB: number;
  9553. /** Gets or sets value of left stick */
  9554. buttonLeftStick: number;
  9555. /** Gets or sets value of right stick */
  9556. buttonRightStick: number;
  9557. /** Gets or sets value of DPad up */
  9558. dPadUp: number;
  9559. /** Gets or sets value of DPad down */
  9560. dPadDown: number;
  9561. /** Gets or sets value of DPad left */
  9562. dPadLeft: number;
  9563. /** Gets or sets value of DPad right */
  9564. dPadRight: number;
  9565. /**
  9566. * Force the gamepad to synchronize with device values
  9567. */
  9568. update(): void;
  9569. dispose(): void;
  9570. }
  9571. }
  9572. declare module BABYLON {
  9573. /**
  9574. * This class can be used to get instrumentation data from a Babylon engine
  9575. */
  9576. class EngineInstrumentation implements IDisposable {
  9577. engine: Engine;
  9578. private _captureGPUFrameTime;
  9579. private _gpuFrameTimeToken;
  9580. private _gpuFrameTime;
  9581. private _captureShaderCompilationTime;
  9582. private _shaderCompilationTime;
  9583. private _onBeginFrameObserver;
  9584. private _onEndFrameObserver;
  9585. private _onBeforeShaderCompilationObserver;
  9586. private _onAfterShaderCompilationObserver;
  9587. /**
  9588. * Gets the perf counter used for GPU frame time
  9589. */
  9590. readonly gpuFrameTimeCounter: PerfCounter;
  9591. /**
  9592. * Gets the GPU frame time capture status
  9593. */
  9594. /**
  9595. * Enable or disable the GPU frame time capture
  9596. */
  9597. captureGPUFrameTime: boolean;
  9598. /**
  9599. * Gets the perf counter used for shader compilation time
  9600. */
  9601. readonly shaderCompilationTimeCounter: PerfCounter;
  9602. /**
  9603. * Gets the shader compilation time capture status
  9604. */
  9605. /**
  9606. * Enable or disable the shader compilation time capture
  9607. */
  9608. captureShaderCompilationTime: boolean;
  9609. constructor(engine: Engine);
  9610. dispose(): void;
  9611. }
  9612. }
  9613. declare module BABYLON {
  9614. /**
  9615. * This class can be used to get instrumentation data from a Babylon engine
  9616. */
  9617. class SceneInstrumentation implements IDisposable {
  9618. scene: Scene;
  9619. private _captureActiveMeshesEvaluationTime;
  9620. private _activeMeshesEvaluationTime;
  9621. private _captureRenderTargetsRenderTime;
  9622. private _renderTargetsRenderTime;
  9623. private _captureFrameTime;
  9624. private _frameTime;
  9625. private _captureRenderTime;
  9626. private _renderTime;
  9627. private _captureInterFrameTime;
  9628. private _interFrameTime;
  9629. private _captureParticlesRenderTime;
  9630. private _particlesRenderTime;
  9631. private _captureSpritesRenderTime;
  9632. private _spritesRenderTime;
  9633. private _capturePhysicsTime;
  9634. private _physicsTime;
  9635. private _captureAnimationsTime;
  9636. private _animationsTime;
  9637. private _captureCameraRenderTime;
  9638. private _cameraRenderTime;
  9639. private _onBeforeActiveMeshesEvaluationObserver;
  9640. private _onAfterActiveMeshesEvaluationObserver;
  9641. private _onBeforeRenderTargetsRenderObserver;
  9642. private _onAfterRenderTargetsRenderObserver;
  9643. private _onAfterRenderObserver;
  9644. private _onBeforeDrawPhaseObserver;
  9645. private _onAfterDrawPhaseObserver;
  9646. private _onBeforeAnimationsObserver;
  9647. private _onBeforeParticlesRenderingObserver;
  9648. private _onAfterParticlesRenderingObserver;
  9649. private _onBeforeSpritesRenderingObserver;
  9650. private _onAfterSpritesRenderingObserver;
  9651. private _onBeforePhysicsObserver;
  9652. private _onAfterPhysicsObserver;
  9653. private _onAfterAnimationsObserver;
  9654. private _onBeforeCameraRenderObserver;
  9655. private _onAfterCameraRenderObserver;
  9656. /**
  9657. * Gets the perf counter used for active meshes evaluation time
  9658. */
  9659. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9660. /**
  9661. * Gets the active meshes evaluation time capture status
  9662. */
  9663. /**
  9664. * Enable or disable the active meshes evaluation time capture
  9665. */
  9666. captureActiveMeshesEvaluationTime: boolean;
  9667. /**
  9668. * Gets the perf counter used for render targets render time
  9669. */
  9670. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9671. /**
  9672. * Gets the render targets render time capture status
  9673. */
  9674. /**
  9675. * Enable or disable the render targets render time capture
  9676. */
  9677. captureRenderTargetsRenderTime: boolean;
  9678. /**
  9679. * Gets the perf counter used for particles render time
  9680. */
  9681. readonly particlesRenderTimeCounter: PerfCounter;
  9682. /**
  9683. * Gets the particles render time capture status
  9684. */
  9685. /**
  9686. * Enable or disable the particles render time capture
  9687. */
  9688. captureParticlesRenderTime: boolean;
  9689. /**
  9690. * Gets the perf counter used for sprites render time
  9691. */
  9692. readonly spritesRenderTimeCounter: PerfCounter;
  9693. /**
  9694. * Gets the sprites render time capture status
  9695. */
  9696. /**
  9697. * Enable or disable the sprites render time capture
  9698. */
  9699. captureSpritesRenderTime: boolean;
  9700. /**
  9701. * Gets the perf counter used for physics time
  9702. */
  9703. readonly physicsTimeCounter: PerfCounter;
  9704. /**
  9705. * Gets the physics time capture status
  9706. */
  9707. /**
  9708. * Enable or disable the physics time capture
  9709. */
  9710. capturePhysicsTime: boolean;
  9711. /**
  9712. * Gets the perf counter used for animations time
  9713. */
  9714. readonly animationsTimeCounter: PerfCounter;
  9715. /**
  9716. * Gets the animations time capture status
  9717. */
  9718. /**
  9719. * Enable or disable the animations time capture
  9720. */
  9721. captureAnimationsTime: boolean;
  9722. /**
  9723. * Gets the perf counter used for frame time capture
  9724. */
  9725. readonly frameTimeCounter: PerfCounter;
  9726. /**
  9727. * Gets the frame time capture status
  9728. */
  9729. /**
  9730. * Enable or disable the frame time capture
  9731. */
  9732. captureFrameTime: boolean;
  9733. /**
  9734. * Gets the perf counter used for inter-frames time capture
  9735. */
  9736. readonly interFrameTimeCounter: PerfCounter;
  9737. /**
  9738. * Gets the inter-frames time capture status
  9739. */
  9740. /**
  9741. * Enable or disable the inter-frames time capture
  9742. */
  9743. captureInterFrameTime: boolean;
  9744. /**
  9745. * Gets the perf counter used for render time capture
  9746. */
  9747. readonly renderTimeCounter: PerfCounter;
  9748. /**
  9749. * Gets the render time capture status
  9750. */
  9751. /**
  9752. * Enable or disable the render time capture
  9753. */
  9754. captureRenderTime: boolean;
  9755. /**
  9756. * Gets the perf counter used for camera render time capture
  9757. */
  9758. readonly cameraRenderTimeCounter: PerfCounter;
  9759. /**
  9760. * Gets the camera render time capture status
  9761. */
  9762. /**
  9763. * Enable or disable the camera render time capture
  9764. */
  9765. captureCameraRenderTime: boolean;
  9766. /**
  9767. * Gets the perf counter used for draw calls
  9768. */
  9769. readonly drawCallsCounter: PerfCounter;
  9770. /**
  9771. * Gets the perf counter used for texture collisions
  9772. */
  9773. readonly textureCollisionsCounter: PerfCounter;
  9774. constructor(scene: Scene);
  9775. dispose(): void;
  9776. }
  9777. }
  9778. declare module BABYLON {
  9779. /**
  9780. * @hidden
  9781. **/
  9782. class _TimeToken {
  9783. _startTimeQuery: Nullable<WebGLQuery>;
  9784. _endTimeQuery: Nullable<WebGLQuery>;
  9785. _timeElapsedQuery: Nullable<WebGLQuery>;
  9786. _timeElapsedQueryEnded: boolean;
  9787. }
  9788. }
  9789. declare module BABYLON {
  9790. /**
  9791. * Single axis drag gizmo
  9792. */
  9793. class AxisDragGizmo extends Gizmo {
  9794. /**
  9795. * Drag behavior responsible for the gizmos dragging interactions
  9796. */
  9797. dragBehavior: PointerDragBehavior;
  9798. private _pointerObserver;
  9799. /**
  9800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9801. */
  9802. snapDistance: number;
  9803. /**
  9804. * Event that fires each time the gizmo snaps to a new location.
  9805. * * snapDistance is the the change in distance
  9806. */
  9807. onSnapObservable: Observable<{
  9808. snapDistance: number;
  9809. }>;
  9810. /**
  9811. * Creates an AxisDragGizmo
  9812. * @param gizmoLayer The utility layer the gizmo will be added to
  9813. * @param dragAxis The axis which the gizmo will be able to drag on
  9814. * @param color The color of the gizmo
  9815. */
  9816. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9817. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9818. /**
  9819. * Disposes of the gizmo
  9820. */
  9821. dispose(): void;
  9822. }
  9823. }
  9824. declare module BABYLON {
  9825. /**
  9826. * Single axis scale gizmo
  9827. */
  9828. class AxisScaleGizmo extends Gizmo {
  9829. /**
  9830. * Drag behavior responsible for the gizmos dragging interactions
  9831. */
  9832. dragBehavior: PointerDragBehavior;
  9833. private _pointerObserver;
  9834. /**
  9835. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9836. */
  9837. snapDistance: number;
  9838. /**
  9839. * Event that fires each time the gizmo snaps to a new location.
  9840. * * snapDistance is the the change in distance
  9841. */
  9842. onSnapObservable: Observable<{
  9843. snapDistance: number;
  9844. }>;
  9845. /**
  9846. * Creates an AxisScaleGizmo
  9847. * @param gizmoLayer The utility layer the gizmo will be added to
  9848. * @param dragAxis The axis which the gizmo will be able to scale on
  9849. * @param color The color of the gizmo
  9850. */
  9851. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9852. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9853. /**
  9854. * Disposes of the gizmo
  9855. */
  9856. dispose(): void;
  9857. }
  9858. }
  9859. declare module BABYLON {
  9860. /**
  9861. * Bounding box gizmo
  9862. */
  9863. class BoundingBoxGizmo extends Gizmo {
  9864. private _lineBoundingBox;
  9865. private _rotateSpheresParent;
  9866. private _scaleBoxesParent;
  9867. private _boundingDimensions;
  9868. private _renderObserver;
  9869. private _pointerObserver;
  9870. private _scaleDragSpeed;
  9871. private _tmpQuaternion;
  9872. private _tmpVector;
  9873. /**
  9874. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9875. */
  9876. rotationSphereSize: number;
  9877. /**
  9878. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9879. */
  9880. scaleBoxSize: number;
  9881. /**
  9882. * 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)
  9883. */
  9884. fixedDragMeshScreenSize: boolean;
  9885. /**
  9886. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9887. */
  9888. fixedDragMeshScreenSizeDistanceFactor: number;
  9889. /**
  9890. * Fired when a rotation sphere or scale box is dragged
  9891. */
  9892. onDragStartObservable: Observable<{}>;
  9893. /**
  9894. * Fired when a rotation sphere or scale box drag is started
  9895. */
  9896. onDragObservable: Observable<{}>;
  9897. /**
  9898. * Fired when a rotation sphere or scale box drag is needed
  9899. */
  9900. onDragEndObservable: Observable<{}>;
  9901. private _anchorMesh;
  9902. /**
  9903. * Creates an BoundingBoxGizmo
  9904. * @param gizmoLayer The utility layer the gizmo will be added to
  9905. * @param color The color of the gizmo
  9906. */
  9907. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9908. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9909. private _selectNode(selectedMesh);
  9910. private _recurseComputeWorld(mesh);
  9911. private _updateBoundingBox();
  9912. /**
  9913. * Enables rotation on the specified axis and disables rotation on the others
  9914. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9915. */
  9916. setEnabledRotationAxis(axis: string): void;
  9917. /**
  9918. * Disposes of the gizmo
  9919. */
  9920. dispose(): void;
  9921. /**
  9922. * 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)
  9923. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  9924. * @returns the bounding box mesh with the passed in mesh as a child
  9925. */
  9926. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  9927. }
  9928. }
  9929. declare module BABYLON {
  9930. /**
  9931. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9932. */
  9933. class Gizmo implements IDisposable {
  9934. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9935. /**
  9936. * The root mesh of the gizmo
  9937. */
  9938. protected _rootMesh: Mesh;
  9939. private _attachedMesh;
  9940. private _scaleFactor;
  9941. private _tmpMatrix;
  9942. /**
  9943. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9944. * * When set, interactions will be enabled
  9945. */
  9946. attachedMesh: Nullable<AbstractMesh>;
  9947. /**
  9948. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9949. */
  9950. updateGizmoRotationToMatchAttachedMesh: boolean;
  9951. /**
  9952. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9953. */
  9954. updateGizmoPositionToMatchAttachedMesh: boolean;
  9955. /**
  9956. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9957. */
  9958. protected _updateScale: boolean;
  9959. protected _interactionsEnabled: boolean;
  9960. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9961. private _beforeRenderObserver;
  9962. /**
  9963. * Creates a gizmo
  9964. * @param gizmoLayer The utility layer the gizmo will be added to
  9965. */
  9966. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer?: UtilityLayerRenderer);
  9967. /**
  9968. * Disposes of the gizmo
  9969. */
  9970. dispose(): void;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9976. */
  9977. class GizmoManager implements IDisposable {
  9978. private scene;
  9979. private _gizmoSet;
  9980. private _gizmoLayer;
  9981. private _pointerObserver;
  9982. private _attachedMesh;
  9983. private _boundingBoxColor;
  9984. private _boundingBoxUtilLayer;
  9985. private _dragBehavior;
  9986. /**
  9987. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  9988. */
  9989. attachableMeshes: Nullable<Array<AbstractMesh>>;
  9990. /**
  9991. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  9992. */
  9993. usePointerToAttachGizmos: boolean;
  9994. /**
  9995. * Instatiates a gizmo manager
  9996. * @param scene the scene to overlay the gizmos on top of
  9997. */
  9998. constructor(scene: Scene);
  9999. /**
  10000. * Attaches a set of gizmos to the specified mesh
  10001. * @param mesh The mesh the gizmo's should be attached to
  10002. */
  10003. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10004. /**
  10005. * If the position gizmo is enabled
  10006. */
  10007. positionGizmoEnabled: boolean;
  10008. /**
  10009. * If the rotation gizmo is enabled
  10010. */
  10011. rotationGizmoEnabled: boolean;
  10012. /**
  10013. * If the scale gizmo is enabled
  10014. */
  10015. scaleGizmoEnabled: boolean;
  10016. /**
  10017. * If the boundingBox gizmo is enabled
  10018. */
  10019. boundingBoxGizmoEnabled: boolean;
  10020. /**
  10021. * Disposes of the gizmo manager
  10022. */
  10023. dispose(): void;
  10024. }
  10025. }
  10026. declare module BABYLON {
  10027. /**
  10028. * Single plane rotation gizmo
  10029. */
  10030. class PlaneRotationGizmo extends Gizmo {
  10031. /**
  10032. * Drag behavior responsible for the gizmos dragging interactions
  10033. */
  10034. dragBehavior: PointerDragBehavior;
  10035. private _pointerObserver;
  10036. /**
  10037. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10038. */
  10039. snapDistance: number;
  10040. /**
  10041. * Event that fires each time the gizmo snaps to a new location.
  10042. * * snapDistance is the the change in distance
  10043. */
  10044. onSnapObservable: Observable<{
  10045. snapDistance: number;
  10046. }>;
  10047. /**
  10048. * Creates a PlaneRotationGizmo
  10049. * @param gizmoLayer The utility layer the gizmo will be added to
  10050. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10051. * @param color The color of the gizmo
  10052. */
  10053. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10054. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10055. /**
  10056. * Disposes of the gizmo
  10057. */
  10058. dispose(): void;
  10059. }
  10060. }
  10061. declare module BABYLON {
  10062. /**
  10063. * Gizmo that enables dragging a mesh along 3 axis
  10064. */
  10065. class PositionGizmo extends Gizmo {
  10066. /**
  10067. * Internal gizmo used for interactions on the x axis
  10068. */
  10069. xGizmo: AxisDragGizmo;
  10070. /**
  10071. * Internal gizmo used for interactions on the y axis
  10072. */
  10073. yGizmo: AxisDragGizmo;
  10074. /**
  10075. * Internal gizmo used for interactions on the z axis
  10076. */
  10077. zGizmo: AxisDragGizmo;
  10078. attachedMesh: Nullable<AbstractMesh>;
  10079. /**
  10080. * Creates a PositionGizmo
  10081. * @param gizmoLayer The utility layer the gizmo will be added to
  10082. */
  10083. constructor(gizmoLayer?: UtilityLayerRenderer);
  10084. updateGizmoRotationToMatchAttachedMesh: boolean;
  10085. /**
  10086. * Disposes of the gizmo
  10087. */
  10088. dispose(): void;
  10089. }
  10090. }
  10091. declare module BABYLON {
  10092. /**
  10093. * Gizmo that enables rotating a mesh along 3 axis
  10094. */
  10095. class RotationGizmo extends Gizmo {
  10096. /**
  10097. * Internal gizmo used for interactions on the x axis
  10098. */
  10099. xGizmo: PlaneRotationGizmo;
  10100. /**
  10101. * Internal gizmo used for interactions on the y axis
  10102. */
  10103. yGizmo: PlaneRotationGizmo;
  10104. /**
  10105. * Internal gizmo used for interactions on the z axis
  10106. */
  10107. zGizmo: PlaneRotationGizmo;
  10108. attachedMesh: Nullable<AbstractMesh>;
  10109. /**
  10110. * Creates a RotationGizmo
  10111. * @param gizmoLayer The utility layer the gizmo will be added to
  10112. */
  10113. constructor(gizmoLayer?: UtilityLayerRenderer);
  10114. updateGizmoRotationToMatchAttachedMesh: boolean;
  10115. /**
  10116. * Disposes of the gizmo
  10117. */
  10118. dispose(): void;
  10119. }
  10120. }
  10121. declare module BABYLON {
  10122. /**
  10123. * Gizmo that enables scaling a mesh along 3 axis
  10124. */
  10125. class ScaleGizmo extends Gizmo {
  10126. /**
  10127. * Internal gizmo used for interactions on the x axis
  10128. */
  10129. xGizmo: AxisScaleGizmo;
  10130. /**
  10131. * Internal gizmo used for interactions on the y axis
  10132. */
  10133. yGizmo: AxisScaleGizmo;
  10134. /**
  10135. * Internal gizmo used for interactions on the z axis
  10136. */
  10137. zGizmo: AxisScaleGizmo;
  10138. attachedMesh: Nullable<AbstractMesh>;
  10139. /**
  10140. * Creates a ScaleGizmo
  10141. * @param gizmoLayer The utility layer the gizmo will be added to
  10142. */
  10143. constructor(gizmoLayer?: UtilityLayerRenderer);
  10144. updateGizmoRotationToMatchAttachedMesh: boolean;
  10145. /**
  10146. * Disposes of the gizmo
  10147. */
  10148. dispose(): void;
  10149. }
  10150. }
  10151. declare module BABYLON {
  10152. /**
  10153. * Represents the different options available during the creation of
  10154. * a Environment helper.
  10155. *
  10156. * This can control the default ground, skybox and image processing setup of your scene.
  10157. */
  10158. interface IEnvironmentHelperOptions {
  10159. /**
  10160. * Specifies wether or not to create a ground.
  10161. * True by default.
  10162. */
  10163. createGround: boolean;
  10164. /**
  10165. * Specifies the ground size.
  10166. * 15 by default.
  10167. */
  10168. groundSize: number;
  10169. /**
  10170. * The texture used on the ground for the main color.
  10171. * Comes from the BabylonJS CDN by default.
  10172. *
  10173. * Remarks: Can be either a texture or a url.
  10174. */
  10175. groundTexture: string | BaseTexture;
  10176. /**
  10177. * The color mixed in the ground texture by default.
  10178. * BabylonJS clearColor by default.
  10179. */
  10180. groundColor: Color3;
  10181. /**
  10182. * Specifies the ground opacity.
  10183. * 1 by default.
  10184. */
  10185. groundOpacity: number;
  10186. /**
  10187. * Enables the ground to receive shadows.
  10188. * True by default.
  10189. */
  10190. enableGroundShadow: boolean;
  10191. /**
  10192. * Helps preventing the shadow to be fully black on the ground.
  10193. * 0.5 by default.
  10194. */
  10195. groundShadowLevel: number;
  10196. /**
  10197. * Creates a mirror texture attach to the ground.
  10198. * false by default.
  10199. */
  10200. enableGroundMirror: boolean;
  10201. /**
  10202. * Specifies the ground mirror size ratio.
  10203. * 0.3 by default as the default kernel is 64.
  10204. */
  10205. groundMirrorSizeRatio: number;
  10206. /**
  10207. * Specifies the ground mirror blur kernel size.
  10208. * 64 by default.
  10209. */
  10210. groundMirrorBlurKernel: number;
  10211. /**
  10212. * Specifies the ground mirror visibility amount.
  10213. * 1 by default
  10214. */
  10215. groundMirrorAmount: number;
  10216. /**
  10217. * Specifies the ground mirror reflectance weight.
  10218. * This uses the standard weight of the background material to setup the fresnel effect
  10219. * of the mirror.
  10220. * 1 by default.
  10221. */
  10222. groundMirrorFresnelWeight: number;
  10223. /**
  10224. * Specifies the ground mirror Falloff distance.
  10225. * This can helps reducing the size of the reflection.
  10226. * 0 by Default.
  10227. */
  10228. groundMirrorFallOffDistance: number;
  10229. /**
  10230. * Specifies the ground mirror texture type.
  10231. * Unsigned Int by Default.
  10232. */
  10233. groundMirrorTextureType: number;
  10234. /**
  10235. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10236. * the shown objects.
  10237. */
  10238. groundYBias: number;
  10239. /**
  10240. * Specifies wether or not to create a skybox.
  10241. * True by default.
  10242. */
  10243. createSkybox: boolean;
  10244. /**
  10245. * Specifies the skybox size.
  10246. * 20 by default.
  10247. */
  10248. skyboxSize: number;
  10249. /**
  10250. * The texture used on the skybox for the main color.
  10251. * Comes from the BabylonJS CDN by default.
  10252. *
  10253. * Remarks: Can be either a texture or a url.
  10254. */
  10255. skyboxTexture: string | BaseTexture;
  10256. /**
  10257. * The color mixed in the skybox texture by default.
  10258. * BabylonJS clearColor by default.
  10259. */
  10260. skyboxColor: Color3;
  10261. /**
  10262. * The background rotation around the Y axis of the scene.
  10263. * This helps aligning the key lights of your scene with the background.
  10264. * 0 by default.
  10265. */
  10266. backgroundYRotation: number;
  10267. /**
  10268. * Compute automatically the size of the elements to best fit with the scene.
  10269. */
  10270. sizeAuto: boolean;
  10271. /**
  10272. * Default position of the rootMesh if autoSize is not true.
  10273. */
  10274. rootPosition: Vector3;
  10275. /**
  10276. * Sets up the image processing in the scene.
  10277. * true by default.
  10278. */
  10279. setupImageProcessing: boolean;
  10280. /**
  10281. * The texture used as your environment texture in the scene.
  10282. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10283. *
  10284. * Remarks: Can be either a texture or a url.
  10285. */
  10286. environmentTexture: string | BaseTexture;
  10287. /**
  10288. * The value of the exposure to apply to the scene.
  10289. * 0.6 by default if setupImageProcessing is true.
  10290. */
  10291. cameraExposure: number;
  10292. /**
  10293. * The value of the contrast to apply to the scene.
  10294. * 1.6 by default if setupImageProcessing is true.
  10295. */
  10296. cameraContrast: number;
  10297. /**
  10298. * Specifies wether or not tonemapping should be enabled in the scene.
  10299. * true by default if setupImageProcessing is true.
  10300. */
  10301. toneMappingEnabled: boolean;
  10302. }
  10303. /**
  10304. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10305. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10306. * It also helps with the default setup of your imageProcessing configuration.
  10307. */
  10308. class EnvironmentHelper {
  10309. /**
  10310. * Default ground texture URL.
  10311. */
  10312. private static _groundTextureCDNUrl;
  10313. /**
  10314. * Default skybox texture URL.
  10315. */
  10316. private static _skyboxTextureCDNUrl;
  10317. /**
  10318. * Default environment texture URL.
  10319. */
  10320. private static _environmentTextureCDNUrl;
  10321. /**
  10322. * Creates the default options for the helper.
  10323. */
  10324. private static _getDefaultOptions();
  10325. private _rootMesh;
  10326. /**
  10327. * Gets the root mesh created by the helper.
  10328. */
  10329. readonly rootMesh: Mesh;
  10330. private _skybox;
  10331. /**
  10332. * Gets the skybox created by the helper.
  10333. */
  10334. readonly skybox: Nullable<Mesh>;
  10335. private _skyboxTexture;
  10336. /**
  10337. * Gets the skybox texture created by the helper.
  10338. */
  10339. readonly skyboxTexture: Nullable<BaseTexture>;
  10340. private _skyboxMaterial;
  10341. /**
  10342. * Gets the skybox material created by the helper.
  10343. */
  10344. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10345. private _ground;
  10346. /**
  10347. * Gets the ground mesh created by the helper.
  10348. */
  10349. readonly ground: Nullable<Mesh>;
  10350. private _groundTexture;
  10351. /**
  10352. * Gets the ground texture created by the helper.
  10353. */
  10354. readonly groundTexture: Nullable<BaseTexture>;
  10355. private _groundMirror;
  10356. /**
  10357. * Gets the ground mirror created by the helper.
  10358. */
  10359. readonly groundMirror: Nullable<MirrorTexture>;
  10360. /**
  10361. * Gets the ground mirror render list to helps pushing the meshes
  10362. * you wish in the ground reflection.
  10363. */
  10364. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10365. private _groundMaterial;
  10366. /**
  10367. * Gets the ground material created by the helper.
  10368. */
  10369. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10370. /**
  10371. * Stores the creation options.
  10372. */
  10373. private readonly _scene;
  10374. private _options;
  10375. /**
  10376. * This observable will be notified with any error during the creation of the environment,
  10377. * mainly texture creation errors.
  10378. */
  10379. onErrorObservable: Observable<{
  10380. message?: string;
  10381. exception?: any;
  10382. }>;
  10383. /**
  10384. * constructor
  10385. * @param options
  10386. * @param scene The scene to add the material to
  10387. */
  10388. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10389. /**
  10390. * Updates the background according to the new options
  10391. * @param options
  10392. */
  10393. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10394. /**
  10395. * Sets the primary color of all the available elements.
  10396. * @param color the main color to affect to the ground and the background
  10397. */
  10398. setMainColor(color: Color3): void;
  10399. /**
  10400. * Setup the image processing according to the specified options.
  10401. */
  10402. private _setupImageProcessing();
  10403. /**
  10404. * Setup the environment texture according to the specified options.
  10405. */
  10406. private _setupEnvironmentTexture();
  10407. /**
  10408. * Setup the background according to the specified options.
  10409. */
  10410. private _setupBackground();
  10411. /**
  10412. * Get the scene sizes according to the setup.
  10413. */
  10414. private _getSceneSize();
  10415. /**
  10416. * Setup the ground according to the specified options.
  10417. */
  10418. private _setupGround(sceneSize);
  10419. /**
  10420. * Setup the ground material according to the specified options.
  10421. */
  10422. private _setupGroundMaterial();
  10423. /**
  10424. * Setup the ground diffuse texture according to the specified options.
  10425. */
  10426. private _setupGroundDiffuseTexture();
  10427. /**
  10428. * Setup the ground mirror texture according to the specified options.
  10429. */
  10430. private _setupGroundMirrorTexture(sceneSize);
  10431. /**
  10432. * Setup the ground to receive the mirror texture.
  10433. */
  10434. private _setupMirrorInGroundMaterial();
  10435. /**
  10436. * Setup the skybox according to the specified options.
  10437. */
  10438. private _setupSkybox(sceneSize);
  10439. /**
  10440. * Setup the skybox material according to the specified options.
  10441. */
  10442. private _setupSkyboxMaterial();
  10443. /**
  10444. * Setup the skybox reflection texture according to the specified options.
  10445. */
  10446. private _setupSkyboxReflectionTexture();
  10447. private _errorHandler;
  10448. /**
  10449. * Dispose all the elements created by the Helper.
  10450. */
  10451. dispose(): void;
  10452. }
  10453. }
  10454. declare module BABYLON {
  10455. /**
  10456. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10457. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10458. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10459. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10460. */
  10461. class PhotoDome extends Node {
  10462. private _useDirectMapping;
  10463. /**
  10464. * The texture being displayed on the sphere
  10465. */
  10466. protected _photoTexture: Texture;
  10467. /**
  10468. * Gets or sets the texture being displayed on the sphere
  10469. */
  10470. photoTexture: Texture;
  10471. /**
  10472. * The skybox material
  10473. */
  10474. protected _material: BackgroundMaterial;
  10475. /**
  10476. * The surface used for the skybox
  10477. */
  10478. protected _mesh: Mesh;
  10479. /**
  10480. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10481. * Also see the options.resolution property.
  10482. */
  10483. fovMultiplier: number;
  10484. /**
  10485. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10486. * @param name Element's name, child elements will append suffixes for their own names.
  10487. * @param urlsOfPhoto define the url of the photo to display
  10488. * @param options An object containing optional or exposed sub element properties
  10489. */
  10490. constructor(name: string, urlOfPhoto: string, options: {
  10491. resolution?: number;
  10492. size?: number;
  10493. useDirectMapping?: boolean;
  10494. }, scene: Scene);
  10495. /**
  10496. * Releases resources associated with this node.
  10497. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10498. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10499. */
  10500. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10501. }
  10502. }
  10503. declare module BABYLON {
  10504. /**
  10505. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10506. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10507. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10508. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10509. */
  10510. class VideoDome extends Node {
  10511. private _useDirectMapping;
  10512. /**
  10513. * The video texture being displayed on the sphere
  10514. */
  10515. protected _videoTexture: VideoTexture;
  10516. /**
  10517. * Gets the video texture being displayed on the sphere
  10518. */
  10519. readonly videoTexture: VideoTexture;
  10520. /**
  10521. * The skybox material
  10522. */
  10523. protected _material: BackgroundMaterial;
  10524. /**
  10525. * The surface used for the skybox
  10526. */
  10527. protected _mesh: Mesh;
  10528. /**
  10529. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10530. * Also see the options.resolution property.
  10531. */
  10532. fovMultiplier: number;
  10533. /**
  10534. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10535. * @param name Element's name, child elements will append suffixes for their own names.
  10536. * @param urlsOrVideo defines the url(s) or the video element to use
  10537. * @param options An object containing optional or exposed sub element properties
  10538. */
  10539. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10540. resolution?: number;
  10541. clickToPlay?: boolean;
  10542. autoPlay?: boolean;
  10543. loop?: boolean;
  10544. size?: number;
  10545. poster?: string;
  10546. useDirectMapping?: boolean;
  10547. }, scene: Scene);
  10548. /**
  10549. * Releases resources associated with this node.
  10550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10552. */
  10553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10554. }
  10555. }
  10556. declare module BABYLON {
  10557. class LensFlare {
  10558. size: number;
  10559. position: number;
  10560. color: Color3;
  10561. texture: Nullable<Texture>;
  10562. alphaMode: number;
  10563. private _system;
  10564. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10565. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10566. dispose(): void;
  10567. }
  10568. }
  10569. declare module BABYLON {
  10570. class LensFlareSystem {
  10571. name: string;
  10572. lensFlares: LensFlare[];
  10573. borderLimit: number;
  10574. viewportBorder: number;
  10575. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10576. layerMask: number;
  10577. id: string;
  10578. private _scene;
  10579. private _emitter;
  10580. private _vertexBuffers;
  10581. private _indexBuffer;
  10582. private _effect;
  10583. private _positionX;
  10584. private _positionY;
  10585. private _isEnabled;
  10586. constructor(name: string, emitter: any, scene: Scene);
  10587. isEnabled: boolean;
  10588. getScene(): Scene;
  10589. getEmitter(): any;
  10590. setEmitter(newEmitter: any): void;
  10591. getEmitterPosition(): Vector3;
  10592. computeEffectivePosition(globalViewport: Viewport): boolean;
  10593. _isVisible(): boolean;
  10594. render(): boolean;
  10595. dispose(): void;
  10596. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10597. serialize(): any;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. interface AbstractScene {
  10602. /**
  10603. * The list of lens flare system added to the scene
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  10605. */
  10606. lensFlareSystems: Array<LensFlareSystem>;
  10607. /**
  10608. * Removes the given lens flare system from this scene.
  10609. * @param toRemove The lens flare system to remove
  10610. * @returns The index of the removed lens flare system
  10611. */
  10612. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  10613. /**
  10614. * Adds the given lens flare system to this scene
  10615. * @param newLensFlareSystem The lens flare system to add
  10616. */
  10617. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  10618. /**
  10619. * Gets a lens flare system using its name
  10620. * @param name defines the name to look for
  10621. * @returns the lens flare system or null if not found
  10622. */
  10623. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  10624. /**
  10625. * Gets a lens flare system using its id
  10626. * @param id defines the id to look for
  10627. * @returns the lens flare system or null if not found
  10628. */
  10629. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  10630. }
  10631. /**
  10632. * Defines the lens flare scene component responsible to manage any lens flares
  10633. * in a given scene.
  10634. */
  10635. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  10636. /**
  10637. * The component name helpfull to identify the component in the list of scene components.
  10638. */
  10639. readonly name: string;
  10640. /**
  10641. * The scene the component belongs to.
  10642. */
  10643. scene: Scene;
  10644. /**
  10645. * Creates a new instance of the component for the given scene
  10646. * @param scene Defines the scene to register the component in
  10647. */
  10648. constructor(scene: Scene);
  10649. /**
  10650. * Registers the component in a given scene
  10651. */
  10652. register(): void;
  10653. /**
  10654. * Rebuilds the elements related to this component in case of
  10655. * context lost for instance.
  10656. */
  10657. rebuild(): void;
  10658. /**
  10659. * Adds all the element from the container to the scene
  10660. * @param container the container holding the elements
  10661. */
  10662. addFromContainer(container: AbstractScene): void;
  10663. /**
  10664. * Removes all the elements in the container from the scene
  10665. * @param container contains the elements to remove
  10666. */
  10667. removeFromContainer(container: AbstractScene): void;
  10668. /**
  10669. * Serializes the component data to the specified json object
  10670. * @param serializationObject The object to serialize to
  10671. */
  10672. serialize(serializationObject: any): void;
  10673. /**
  10674. * Disposes the component and the associated ressources.
  10675. */
  10676. dispose(): void;
  10677. private _draw(camera);
  10678. }
  10679. }
  10680. declare module BABYLON {
  10681. /**
  10682. * Effect layer options. This helps customizing the behaviour
  10683. * of the effect layer.
  10684. */
  10685. interface IEffectLayerOptions {
  10686. /**
  10687. * Multiplication factor apply to the canvas size to compute the render target size
  10688. * used to generated the objects (the smaller the faster).
  10689. */
  10690. mainTextureRatio: number;
  10691. /**
  10692. * Enforces a fixed size texture to ensure effect stability across devices.
  10693. */
  10694. mainTextureFixedSize?: number;
  10695. /**
  10696. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10697. */
  10698. alphaBlendingMode: number;
  10699. /**
  10700. * The camera attached to the layer.
  10701. */
  10702. camera: Nullable<Camera>;
  10703. /**
  10704. * The rendering group to draw the layer in.
  10705. */
  10706. renderingGroupId: number;
  10707. }
  10708. /**
  10709. * The effect layer Helps adding post process effect blended with the main pass.
  10710. *
  10711. * This can be for instance use to generate glow or higlight effects on the scene.
  10712. *
  10713. * The effect layer class can not be used directly and is intented to inherited from to be
  10714. * customized per effects.
  10715. */
  10716. abstract class EffectLayer {
  10717. private _vertexBuffers;
  10718. private _indexBuffer;
  10719. private _cachedDefines;
  10720. private _effectLayerMapGenerationEffect;
  10721. private _effectLayerOptions;
  10722. private _mergeEffect;
  10723. protected _scene: Scene;
  10724. protected _engine: Engine;
  10725. protected _maxSize: number;
  10726. protected _mainTextureDesiredSize: ISize;
  10727. protected _mainTexture: RenderTargetTexture;
  10728. protected _shouldRender: boolean;
  10729. protected _postProcesses: PostProcess[];
  10730. protected _textures: BaseTexture[];
  10731. protected _emissiveTextureAndColor: {
  10732. texture: Nullable<BaseTexture>;
  10733. color: Color4;
  10734. };
  10735. /**
  10736. * The name of the layer
  10737. */
  10738. name: string;
  10739. /**
  10740. * The clear color of the texture used to generate the glow map.
  10741. */
  10742. neutralColor: Color4;
  10743. /**
  10744. * Specifies wether the highlight layer is enabled or not.
  10745. */
  10746. isEnabled: boolean;
  10747. /**
  10748. * Gets the camera attached to the layer.
  10749. */
  10750. readonly camera: Nullable<Camera>;
  10751. /**
  10752. * Gets the rendering group id the layer should render in.
  10753. */
  10754. readonly renderingGroupId: number;
  10755. /**
  10756. * An event triggered when the effect layer has been disposed.
  10757. */
  10758. onDisposeObservable: Observable<EffectLayer>;
  10759. /**
  10760. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10761. */
  10762. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10763. /**
  10764. * An event triggered when the generated texture is being merged in the scene.
  10765. */
  10766. onBeforeComposeObservable: Observable<EffectLayer>;
  10767. /**
  10768. * An event triggered when the generated texture has been merged in the scene.
  10769. */
  10770. onAfterComposeObservable: Observable<EffectLayer>;
  10771. /**
  10772. * An event triggered when the efffect layer changes its size.
  10773. */
  10774. onSizeChangedObservable: Observable<EffectLayer>;
  10775. /**
  10776. * Instantiates a new effect Layer and references it in the scene.
  10777. * @param name The name of the layer
  10778. * @param scene The scene to use the layer in
  10779. */
  10780. constructor(
  10781. /** The Friendly of the effect in the scene */
  10782. name: string, scene: Scene);
  10783. /**
  10784. * Get the effect name of the layer.
  10785. * @return The effect name
  10786. */
  10787. abstract getEffectName(): string;
  10788. /**
  10789. * Checks for the readiness of the element composing the layer.
  10790. * @param subMesh the mesh to check for
  10791. * @param useInstances specify wether or not to use instances to render the mesh
  10792. * @return true if ready otherwise, false
  10793. */
  10794. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10795. /**
  10796. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10797. * @returns true if the effect requires stencil during the main canvas render pass.
  10798. */
  10799. abstract needStencil(): boolean;
  10800. /**
  10801. * Create the merge effect. This is the shader use to blit the information back
  10802. * to the main canvas at the end of the scene rendering.
  10803. * @returns The effect containing the shader used to merge the effect on the main canvas
  10804. */
  10805. protected abstract _createMergeEffect(): Effect;
  10806. /**
  10807. * Creates the render target textures and post processes used in the effect layer.
  10808. */
  10809. protected abstract _createTextureAndPostProcesses(): void;
  10810. /**
  10811. * Implementation specific of rendering the generating effect on the main canvas.
  10812. * @param effect The effect used to render through
  10813. */
  10814. protected abstract _internalRender(effect: Effect): void;
  10815. /**
  10816. * Sets the required values for both the emissive texture and and the main color.
  10817. */
  10818. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10819. /**
  10820. * Free any resources and references associated to a mesh.
  10821. * Internal use
  10822. * @param mesh The mesh to free.
  10823. */
  10824. abstract _disposeMesh(mesh: Mesh): void;
  10825. /**
  10826. * Serializes this layer (Glow or Highlight for example)
  10827. * @returns a serialized layer object
  10828. */
  10829. abstract serialize?(): any;
  10830. /**
  10831. * Initializes the effect layer with the required options.
  10832. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10833. */
  10834. protected _init(options: Partial<IEffectLayerOptions>): void;
  10835. /**
  10836. * Generates the index buffer of the full screen quad blending to the main canvas.
  10837. */
  10838. private _generateIndexBuffer();
  10839. /**
  10840. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10841. */
  10842. private _genrateVertexBuffer();
  10843. /**
  10844. * Sets the main texture desired size which is the closest power of two
  10845. * of the engine canvas size.
  10846. */
  10847. private _setMainTextureSize();
  10848. /**
  10849. * Creates the main texture for the effect layer.
  10850. */
  10851. protected _createMainTexture(): void;
  10852. /**
  10853. * Checks for the readiness of the element composing the layer.
  10854. * @param subMesh the mesh to check for
  10855. * @param useInstances specify wether or not to use instances to render the mesh
  10856. * @param emissiveTexture the associated emissive texture used to generate the glow
  10857. * @return true if ready otherwise, false
  10858. */
  10859. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10860. /**
  10861. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10862. */
  10863. render(): void;
  10864. /**
  10865. * Determine if a given mesh will be used in the current effect.
  10866. * @param mesh mesh to test
  10867. * @returns true if the mesh will be used
  10868. */
  10869. hasMesh(mesh: AbstractMesh): boolean;
  10870. /**
  10871. * Returns true if the layer contains information to display, otherwise false.
  10872. * @returns true if the glow layer should be rendered
  10873. */
  10874. shouldRender(): boolean;
  10875. /**
  10876. * Returns true if the mesh should render, otherwise false.
  10877. * @param mesh The mesh to render
  10878. * @returns true if it should render otherwise false
  10879. */
  10880. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10881. /**
  10882. * Returns true if the mesh should render, otherwise false.
  10883. * @param mesh The mesh to render
  10884. * @returns true if it should render otherwise false
  10885. */
  10886. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10887. /**
  10888. * Renders the submesh passed in parameter to the generation map.
  10889. */
  10890. protected _renderSubMesh(subMesh: SubMesh): void;
  10891. /**
  10892. * Rebuild the required buffers.
  10893. * @hidden Internal use only.
  10894. */
  10895. _rebuild(): void;
  10896. /**
  10897. * Dispose only the render target textures and post process.
  10898. */
  10899. private _disposeTextureAndPostProcesses();
  10900. /**
  10901. * Dispose the highlight layer and free resources.
  10902. */
  10903. dispose(): void;
  10904. /**
  10905. * Gets the class name of the effect layer
  10906. * @returns the string with the class name of the effect layer
  10907. */
  10908. getClassName(): string;
  10909. /**
  10910. * Creates an effect layer from parsed effect layer data
  10911. * @param parsedEffectLayer defines effect layer data
  10912. * @param scene defines the current scene
  10913. * @param rootUrl defines the root URL containing the effect layer information
  10914. * @returns a parsed effect Layer
  10915. */
  10916. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10917. }
  10918. }
  10919. declare module BABYLON {
  10920. interface AbstractScene {
  10921. /**
  10922. * The list of effect layers (highlights/glow) added to the scene
  10923. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10924. * @see http://doc.babylonjs.com/how_to/glow_layer
  10925. */
  10926. effectLayers: Array<EffectLayer>;
  10927. /**
  10928. * Removes the given effect layer from this scene.
  10929. * @param toRemove defines the effect layer to remove
  10930. * @returns the index of the removed effect layer
  10931. */
  10932. removeEffectLayer(toRemove: EffectLayer): number;
  10933. /**
  10934. * Adds the given effect layer to this scene
  10935. * @param newEffectLayer defines the effect layer to add
  10936. */
  10937. addEffectLayer(newEffectLayer: EffectLayer): void;
  10938. }
  10939. /**
  10940. * Defines the layer scene component responsible to manage any effect layers
  10941. * in a given scene.
  10942. */
  10943. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  10944. /**
  10945. * The component name helpfull to identify the component in the list of scene components.
  10946. */
  10947. readonly name: string;
  10948. /**
  10949. * The scene the component belongs to.
  10950. */
  10951. scene: Scene;
  10952. private _engine;
  10953. private _renderEffects;
  10954. private _needStencil;
  10955. private _previousStencilState;
  10956. /**
  10957. * Creates a new instance of the component for the given scene
  10958. * @param scene Defines the scene to register the component in
  10959. */
  10960. constructor(scene: Scene);
  10961. /**
  10962. * Registers the component in a given scene
  10963. */
  10964. register(): void;
  10965. /**
  10966. * Rebuilds the elements related to this component in case of
  10967. * context lost for instance.
  10968. */
  10969. rebuild(): void;
  10970. /**
  10971. * Serializes the component data to the specified json object
  10972. * @param serializationObject The object to serialize to
  10973. */
  10974. serialize(serializationObject: any): void;
  10975. /**
  10976. * Adds all the element from the container to the scene
  10977. * @param container the container holding the elements
  10978. */
  10979. addFromContainer(container: AbstractScene): void;
  10980. /**
  10981. * Removes all the elements in the container from the scene
  10982. * @param container contains the elements to remove
  10983. */
  10984. removeFromContainer(container: AbstractScene): void;
  10985. /**
  10986. * Disposes the component and the associated ressources.
  10987. */
  10988. dispose(): void;
  10989. private _isReadyForMesh(mesh, hardwareInstancedRendering);
  10990. private _renderMainTexture(camera);
  10991. private _setStencil(camera);
  10992. private _setStencilBack(camera);
  10993. private _draw(renderingGroupId);
  10994. private _drawCamera(camera);
  10995. private _drawRenderingGroup(index);
  10996. }
  10997. }
  10998. declare module BABYLON {
  10999. interface AbstractScene {
  11000. /**
  11001. * Return a the first highlight layer of the scene with a given name.
  11002. * @param name The name of the highlight layer to look for.
  11003. * @return The highlight layer if found otherwise null.
  11004. */
  11005. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11006. }
  11007. /**
  11008. * Glow layer options. This helps customizing the behaviour
  11009. * of the glow layer.
  11010. */
  11011. interface IGlowLayerOptions {
  11012. /**
  11013. * Multiplication factor apply to the canvas size to compute the render target size
  11014. * used to generated the glowing objects (the smaller the faster).
  11015. */
  11016. mainTextureRatio: number;
  11017. /**
  11018. * Enforces a fixed size texture to ensure resize independant blur.
  11019. */
  11020. mainTextureFixedSize?: number;
  11021. /**
  11022. * How big is the kernel of the blur texture.
  11023. */
  11024. blurKernelSize: number;
  11025. /**
  11026. * The camera attached to the layer.
  11027. */
  11028. camera: Nullable<Camera>;
  11029. /**
  11030. * Enable MSAA by chosing the number of samples.
  11031. */
  11032. mainTextureSamples?: number;
  11033. /**
  11034. * The rendering group to draw the layer in.
  11035. */
  11036. renderingGroupId: number;
  11037. }
  11038. /**
  11039. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11040. *
  11041. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11042. * glowy meshes to your scene.
  11043. *
  11044. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11045. */
  11046. class GlowLayer extends EffectLayer {
  11047. /**
  11048. * Effect Name of the layer.
  11049. */
  11050. static readonly EffectName: string;
  11051. /**
  11052. * The default blur kernel size used for the glow.
  11053. */
  11054. static DefaultBlurKernelSize: number;
  11055. /**
  11056. * The default texture size ratio used for the glow.
  11057. */
  11058. static DefaultTextureRatio: number;
  11059. /**
  11060. * Gets the kernel size of the blur.
  11061. */
  11062. /**
  11063. * Sets the kernel size of the blur.
  11064. */
  11065. blurKernelSize: number;
  11066. /**
  11067. * Gets the glow intensity.
  11068. */
  11069. /**
  11070. * Sets the glow intensity.
  11071. */
  11072. intensity: number;
  11073. private _options;
  11074. private _intensity;
  11075. private _horizontalBlurPostprocess1;
  11076. private _verticalBlurPostprocess1;
  11077. private _horizontalBlurPostprocess2;
  11078. private _verticalBlurPostprocess2;
  11079. private _blurTexture1;
  11080. private _blurTexture2;
  11081. private _postProcesses1;
  11082. private _postProcesses2;
  11083. private _includedOnlyMeshes;
  11084. private _excludedMeshes;
  11085. /**
  11086. * Callback used to let the user override the color selection on a per mesh basis
  11087. */
  11088. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11089. /**
  11090. * Callback used to let the user override the texture selection on a per mesh basis
  11091. */
  11092. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11093. /**
  11094. * Instantiates a new glow Layer and references it to the scene.
  11095. * @param name The name of the layer
  11096. * @param scene The scene to use the layer in
  11097. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11098. */
  11099. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11100. /**
  11101. * Get the effect name of the layer.
  11102. * @return The effect name
  11103. */
  11104. getEffectName(): string;
  11105. /**
  11106. * Create the merge effect. This is the shader use to blit the information back
  11107. * to the main canvas at the end of the scene rendering.
  11108. */
  11109. protected _createMergeEffect(): Effect;
  11110. /**
  11111. * Creates the render target textures and post processes used in the glow layer.
  11112. */
  11113. protected _createTextureAndPostProcesses(): void;
  11114. /**
  11115. * Checks for the readiness of the element composing the layer.
  11116. * @param subMesh the mesh to check for
  11117. * @param useInstances specify wether or not to use instances to render the mesh
  11118. * @param emissiveTexture the associated emissive texture used to generate the glow
  11119. * @return true if ready otherwise, false
  11120. */
  11121. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11122. /**
  11123. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11124. */
  11125. needStencil(): boolean;
  11126. /**
  11127. * Implementation specific of rendering the generating effect on the main canvas.
  11128. * @param effect The effect used to render through
  11129. */
  11130. protected _internalRender(effect: Effect): void;
  11131. /**
  11132. * Sets the required values for both the emissive texture and and the main color.
  11133. */
  11134. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11135. /**
  11136. * Returns true if the mesh should render, otherwise false.
  11137. * @param mesh The mesh to render
  11138. * @returns true if it should render otherwise false
  11139. */
  11140. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11141. /**
  11142. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11143. * @param mesh The mesh to exclude from the glow layer
  11144. */
  11145. addExcludedMesh(mesh: Mesh): void;
  11146. /**
  11147. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11148. * @param mesh The mesh to remove
  11149. */
  11150. removeExcludedMesh(mesh: Mesh): void;
  11151. /**
  11152. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11153. * @param mesh The mesh to include in the glow layer
  11154. */
  11155. addIncludedOnlyMesh(mesh: Mesh): void;
  11156. /**
  11157. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11158. * @param mesh The mesh to remove
  11159. */
  11160. removeIncludedOnlyMesh(mesh: Mesh): void;
  11161. /**
  11162. * Determine if a given mesh will be used in the glow layer
  11163. * @param mesh The mesh to test
  11164. * @returns true if the mesh will be highlighted by the current glow layer
  11165. */
  11166. hasMesh(mesh: AbstractMesh): boolean;
  11167. /**
  11168. * Free any resources and references associated to a mesh.
  11169. * Internal use
  11170. * @param mesh The mesh to free.
  11171. */
  11172. _disposeMesh(mesh: Mesh): void;
  11173. /**
  11174. * Gets the class name of the effect layer
  11175. * @returns the string with the class name of the effect layer
  11176. */
  11177. getClassName(): string;
  11178. /**
  11179. * Serializes this glow layer
  11180. * @returns a serialized glow layer object
  11181. */
  11182. serialize(): any;
  11183. /**
  11184. * Creates a Glow Layer from parsed glow layer data
  11185. * @param parsedGlowLayer defines glow layer data
  11186. * @param scene defines the current scene
  11187. * @param rootUrl defines the root URL containing the glow layer information
  11188. * @returns a parsed Glow Layer
  11189. */
  11190. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11191. }
  11192. }
  11193. declare module BABYLON {
  11194. interface AbstractScene {
  11195. /**
  11196. * Return a the first highlight layer of the scene with a given name.
  11197. * @param name The name of the highlight layer to look for.
  11198. * @return The highlight layer if found otherwise null.
  11199. */
  11200. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11201. }
  11202. /**
  11203. * Highlight layer options. This helps customizing the behaviour
  11204. * of the highlight layer.
  11205. */
  11206. interface IHighlightLayerOptions {
  11207. /**
  11208. * Multiplication factor apply to the canvas size to compute the render target size
  11209. * used to generated the glowing objects (the smaller the faster).
  11210. */
  11211. mainTextureRatio: number;
  11212. /**
  11213. * Enforces a fixed size texture to ensure resize independant blur.
  11214. */
  11215. mainTextureFixedSize?: number;
  11216. /**
  11217. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11218. * of the picture to blur (the smaller the faster).
  11219. */
  11220. blurTextureSizeRatio: number;
  11221. /**
  11222. * How big in texel of the blur texture is the vertical blur.
  11223. */
  11224. blurVerticalSize: number;
  11225. /**
  11226. * How big in texel of the blur texture is the horizontal blur.
  11227. */
  11228. blurHorizontalSize: number;
  11229. /**
  11230. * Alpha blending mode used to apply the blur. Default is combine.
  11231. */
  11232. alphaBlendingMode: number;
  11233. /**
  11234. * The camera attached to the layer.
  11235. */
  11236. camera: Nullable<Camera>;
  11237. /**
  11238. * Should we display highlight as a solid stroke?
  11239. */
  11240. isStroke?: boolean;
  11241. /**
  11242. * The rendering group to draw the layer in.
  11243. */
  11244. renderingGroupId: number;
  11245. }
  11246. /**
  11247. * The highlight layer Helps adding a glow effect around a mesh.
  11248. *
  11249. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11250. * glowy meshes to your scene.
  11251. *
  11252. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11253. */
  11254. class HighlightLayer extends EffectLayer {
  11255. name: string;
  11256. /**
  11257. * Effect Name of the highlight layer.
  11258. */
  11259. static readonly EffectName: string;
  11260. /**
  11261. * The neutral color used during the preparation of the glow effect.
  11262. * This is black by default as the blend operation is a blend operation.
  11263. */
  11264. static NeutralColor: Color4;
  11265. /**
  11266. * Stencil value used for glowing meshes.
  11267. */
  11268. static GlowingMeshStencilReference: number;
  11269. /**
  11270. * Stencil value used for the other meshes in the scene.
  11271. */
  11272. static NormalMeshStencilReference: number;
  11273. /**
  11274. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11275. */
  11276. innerGlow: boolean;
  11277. /**
  11278. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11279. */
  11280. outerGlow: boolean;
  11281. /**
  11282. * Gets the horizontal size of the blur.
  11283. */
  11284. /**
  11285. * Specifies the horizontal size of the blur.
  11286. */
  11287. blurHorizontalSize: number;
  11288. /**
  11289. * Gets the vertical size of the blur.
  11290. */
  11291. /**
  11292. * Specifies the vertical size of the blur.
  11293. */
  11294. blurVerticalSize: number;
  11295. /**
  11296. * An event triggered when the highlight layer is being blurred.
  11297. */
  11298. onBeforeBlurObservable: Observable<HighlightLayer>;
  11299. /**
  11300. * An event triggered when the highlight layer has been blurred.
  11301. */
  11302. onAfterBlurObservable: Observable<HighlightLayer>;
  11303. private _instanceGlowingMeshStencilReference;
  11304. private _options;
  11305. private _downSamplePostprocess;
  11306. private _horizontalBlurPostprocess;
  11307. private _verticalBlurPostprocess;
  11308. private _blurTexture;
  11309. private _meshes;
  11310. private _excludedMeshes;
  11311. /**
  11312. * Instantiates a new highlight Layer and references it to the scene..
  11313. * @param name The name of the layer
  11314. * @param scene The scene to use the layer in
  11315. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11316. */
  11317. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11318. /**
  11319. * Get the effect name of the layer.
  11320. * @return The effect name
  11321. */
  11322. getEffectName(): string;
  11323. /**
  11324. * Create the merge effect. This is the shader use to blit the information back
  11325. * to the main canvas at the end of the scene rendering.
  11326. */
  11327. protected _createMergeEffect(): Effect;
  11328. /**
  11329. * Creates the render target textures and post processes used in the highlight layer.
  11330. */
  11331. protected _createTextureAndPostProcesses(): void;
  11332. /**
  11333. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11334. */
  11335. needStencil(): boolean;
  11336. /**
  11337. * Checks for the readiness of the element composing the layer.
  11338. * @param subMesh the mesh to check for
  11339. * @param useInstances specify wether or not to use instances to render the mesh
  11340. * @param emissiveTexture the associated emissive texture used to generate the glow
  11341. * @return true if ready otherwise, false
  11342. */
  11343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11344. /**
  11345. * Implementation specific of rendering the generating effect on the main canvas.
  11346. * @param effect The effect used to render through
  11347. */
  11348. protected _internalRender(effect: Effect): void;
  11349. /**
  11350. * Returns true if the layer contains information to display, otherwise false.
  11351. */
  11352. shouldRender(): boolean;
  11353. /**
  11354. * Returns true if the mesh should render, otherwise false.
  11355. * @param mesh The mesh to render
  11356. * @returns true if it should render otherwise false
  11357. */
  11358. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11359. /**
  11360. * Sets the required values for both the emissive texture and and the main color.
  11361. */
  11362. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11363. /**
  11364. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11365. * @param mesh The mesh to exclude from the highlight layer
  11366. */
  11367. addExcludedMesh(mesh: Mesh): void;
  11368. /**
  11369. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11370. * @param mesh The mesh to highlight
  11371. */
  11372. removeExcludedMesh(mesh: Mesh): void;
  11373. /**
  11374. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11375. * @param mesh mesh to test
  11376. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11377. */
  11378. hasMesh(mesh: AbstractMesh): boolean;
  11379. /**
  11380. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11381. * @param mesh The mesh to highlight
  11382. * @param color The color of the highlight
  11383. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11384. */
  11385. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11386. /**
  11387. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11388. * @param mesh The mesh to highlight
  11389. */
  11390. removeMesh(mesh: Mesh): void;
  11391. /**
  11392. * Force the stencil to the normal expected value for none glowing parts
  11393. */
  11394. private _defaultStencilReference(mesh);
  11395. /**
  11396. * Free any resources and references associated to a mesh.
  11397. * Internal use
  11398. * @param mesh The mesh to free.
  11399. */
  11400. _disposeMesh(mesh: Mesh): void;
  11401. /**
  11402. * Dispose the highlight layer and free resources.
  11403. */
  11404. dispose(): void;
  11405. /**
  11406. * Gets the class name of the effect layer
  11407. * @returns the string with the class name of the effect layer
  11408. */
  11409. getClassName(): string;
  11410. /**
  11411. * Serializes this Highlight layer
  11412. * @returns a serialized Highlight layer object
  11413. */
  11414. serialize(): any;
  11415. /**
  11416. * Creates a Highlight layer from parsed Highlight layer data
  11417. * @param parsedHightlightLayer defines the Highlight layer data
  11418. * @param scene defines the current scene
  11419. * @param rootUrl defines the root URL containing the Highlight layer information
  11420. * @returns a parsed Highlight layer
  11421. */
  11422. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11423. }
  11424. }
  11425. declare module BABYLON {
  11426. class Layer {
  11427. name: string;
  11428. texture: Nullable<Texture>;
  11429. isBackground: boolean;
  11430. color: Color4;
  11431. scale: Vector2;
  11432. offset: Vector2;
  11433. alphaBlendingMode: number;
  11434. alphaTest: boolean;
  11435. layerMask: number;
  11436. private _scene;
  11437. private _vertexBuffers;
  11438. private _indexBuffer;
  11439. private _effect;
  11440. private _alphaTestEffect;
  11441. /**
  11442. * An event triggered when the layer is disposed.
  11443. */
  11444. onDisposeObservable: Observable<Layer>;
  11445. private _onDisposeObserver;
  11446. onDispose: () => void;
  11447. /**
  11448. * An event triggered before rendering the scene
  11449. */
  11450. onBeforeRenderObservable: Observable<Layer>;
  11451. private _onBeforeRenderObserver;
  11452. onBeforeRender: () => void;
  11453. /**
  11454. * An event triggered after rendering the scene
  11455. */
  11456. onAfterRenderObservable: Observable<Layer>;
  11457. private _onAfterRenderObserver;
  11458. onAfterRender: () => void;
  11459. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11460. private _createIndexBuffer();
  11461. _rebuild(): void;
  11462. render(): void;
  11463. dispose(): void;
  11464. }
  11465. }
  11466. declare module BABYLON {
  11467. interface AbstractScene {
  11468. /**
  11469. * The list of layers (background and foreground) of the scene
  11470. */
  11471. layers: Array<Layer>;
  11472. }
  11473. /**
  11474. * Defines the layer scene component responsible to manage any layers
  11475. * in a given scene.
  11476. */
  11477. class LayerSceneComponent implements ISceneComponent {
  11478. /**
  11479. * The component name helpfull to identify the component in the list of scene components.
  11480. */
  11481. readonly name: string;
  11482. /**
  11483. * The scene the component belongs to.
  11484. */
  11485. scene: Scene;
  11486. private _engine;
  11487. /**
  11488. * Creates a new instance of the component for the given scene
  11489. * @param scene Defines the scene to register the component in
  11490. */
  11491. constructor(scene: Scene);
  11492. /**
  11493. * Registers the component in a given scene
  11494. */
  11495. register(): void;
  11496. /**
  11497. * Rebuilds the elements related to this component in case of
  11498. * context lost for instance.
  11499. */
  11500. rebuild(): void;
  11501. /**
  11502. * Disposes the component and the associated ressources.
  11503. */
  11504. dispose(): void;
  11505. private _draw(camera, isBackground);
  11506. private _drawBackground(camera);
  11507. private _drawForeground(camera);
  11508. }
  11509. }
  11510. declare module BABYLON {
  11511. /**
  11512. * A directional light is defined by a direction (what a surprise!).
  11513. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11514. * 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.
  11515. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11516. */
  11517. class DirectionalLight extends ShadowLight {
  11518. private _shadowFrustumSize;
  11519. /**
  11520. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11521. */
  11522. /**
  11523. * Specifies a fix frustum size for the shadow generation.
  11524. */
  11525. shadowFrustumSize: number;
  11526. private _shadowOrthoScale;
  11527. /**
  11528. * Gets the shadow projection scale against the optimal computed one.
  11529. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11530. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11531. */
  11532. /**
  11533. * Sets the shadow projection scale against the optimal computed one.
  11534. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11535. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11536. */
  11537. shadowOrthoScale: number;
  11538. /**
  11539. * Automatically compute the projection matrix to best fit (including all the casters)
  11540. * on each frame.
  11541. */
  11542. autoUpdateExtends: boolean;
  11543. private _orthoLeft;
  11544. private _orthoRight;
  11545. private _orthoTop;
  11546. private _orthoBottom;
  11547. /**
  11548. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11549. * The directional light is emitted from everywhere in the given direction.
  11550. * It can cast shawdows.
  11551. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11552. * @param name The friendly name of the light
  11553. * @param direction The direction of the light
  11554. * @param scene The scene the light belongs to
  11555. */
  11556. constructor(name: string, direction: Vector3, scene: Scene);
  11557. /**
  11558. * Returns the string "DirectionalLight".
  11559. * @return The class name
  11560. */
  11561. getClassName(): string;
  11562. /**
  11563. * Returns the integer 1.
  11564. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11565. */
  11566. getTypeID(): number;
  11567. /**
  11568. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11569. * Returns the DirectionalLight Shadow projection matrix.
  11570. */
  11571. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11572. /**
  11573. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11574. * Returns the DirectionalLight Shadow projection matrix.
  11575. */
  11576. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11577. /**
  11578. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11579. * Returns the DirectionalLight Shadow projection matrix.
  11580. */
  11581. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11582. protected _buildUniformLayout(): void;
  11583. /**
  11584. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11585. * @param effect The effect to update
  11586. * @param lightIndex The index of the light in the effect to update
  11587. * @returns The directional light
  11588. */
  11589. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11590. /**
  11591. * Gets the minZ used for shadow according to both the scene and the light.
  11592. *
  11593. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11594. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11595. * @param activeCamera The camera we are returning the min for
  11596. * @returns the depth min z
  11597. */
  11598. getDepthMinZ(activeCamera: Camera): number;
  11599. /**
  11600. * Gets the maxZ used for shadow according to both the scene and the light.
  11601. *
  11602. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11603. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11604. * @param activeCamera The camera we are returning the max for
  11605. * @returns the depth max z
  11606. */
  11607. getDepthMaxZ(activeCamera: Camera): number;
  11608. /**
  11609. * Prepares the list of defines specific to the light type.
  11610. * @param defines the list of defines
  11611. * @param lightIndex defines the index of the light for the effect
  11612. */
  11613. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11614. }
  11615. }
  11616. declare module BABYLON {
  11617. /**
  11618. * The HemisphericLight simulates the ambient environment light,
  11619. * so the passed direction is the light reflection direction, not the incoming direction.
  11620. */
  11621. class HemisphericLight extends Light {
  11622. /**
  11623. * The groundColor is the light in the opposite direction to the one specified during creation.
  11624. * 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.
  11625. */
  11626. groundColor: Color3;
  11627. /**
  11628. * The light reflection direction, not the incoming direction.
  11629. */
  11630. direction: Vector3;
  11631. private _worldMatrix;
  11632. /**
  11633. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11634. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11635. * The HemisphericLight can't cast shadows.
  11636. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11637. * @param name The friendly name of the light
  11638. * @param direction The direction of the light reflection
  11639. * @param scene The scene the light belongs to
  11640. */
  11641. constructor(name: string, direction: Vector3, scene: Scene);
  11642. protected _buildUniformLayout(): void;
  11643. /**
  11644. * Returns the string "HemisphericLight".
  11645. * @return The class name
  11646. */
  11647. getClassName(): string;
  11648. /**
  11649. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11650. * Returns the updated direction.
  11651. * @param target The target the direction should point to
  11652. * @return The computed direction
  11653. */
  11654. setDirectionToTarget(target: Vector3): Vector3;
  11655. /**
  11656. * Returns the shadow generator associated to the light.
  11657. * @returns Always null for hemispheric lights because it does not support shadows.
  11658. */
  11659. getShadowGenerator(): Nullable<ShadowGenerator>;
  11660. /**
  11661. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11662. * @param effect The effect to update
  11663. * @param lightIndex The index of the light in the effect to update
  11664. * @returns The hemispheric light
  11665. */
  11666. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11667. /**
  11668. * @hidden internal use only.
  11669. */
  11670. _getWorldMatrix(): Matrix;
  11671. /**
  11672. * Returns the integer 3.
  11673. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11674. */
  11675. getTypeID(): number;
  11676. /**
  11677. * Prepares the list of defines specific to the light type.
  11678. * @param defines the list of defines
  11679. * @param lightIndex defines the index of the light for the effect
  11680. */
  11681. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11682. }
  11683. }
  11684. declare module BABYLON {
  11685. /**
  11686. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11687. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11688. * 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.
  11689. */
  11690. abstract class Light extends Node {
  11691. /**
  11692. * If every light affecting the material is in this lightmapMode,
  11693. * material.lightmapTexture adds or multiplies
  11694. * (depends on material.useLightmapAsShadowmap)
  11695. * after every other light calculations.
  11696. */
  11697. static readonly LIGHTMAP_DEFAULT: number;
  11698. /**
  11699. * material.lightmapTexture as only diffuse lighting from this light
  11700. * adds only specular lighting from this light
  11701. * adds dynamic shadows
  11702. */
  11703. static readonly LIGHTMAP_SPECULAR: number;
  11704. /**
  11705. * material.lightmapTexture as only lighting
  11706. * no light calculation from this light
  11707. * only adds dynamic shadows from this light
  11708. */
  11709. static readonly LIGHTMAP_SHADOWSONLY: number;
  11710. /**
  11711. * Each light type uses the default quantity according to its type:
  11712. * point/spot lights use luminous intensity
  11713. * directional lights use illuminance
  11714. */
  11715. static readonly INTENSITYMODE_AUTOMATIC: number;
  11716. /**
  11717. * lumen (lm)
  11718. */
  11719. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11720. /**
  11721. * candela (lm/sr)
  11722. */
  11723. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11724. /**
  11725. * lux (lm/m^2)
  11726. */
  11727. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11728. /**
  11729. * nit (cd/m^2)
  11730. */
  11731. static readonly INTENSITYMODE_LUMINANCE: number;
  11732. /**
  11733. * Light type const id of the point light.
  11734. */
  11735. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11736. /**
  11737. * Light type const id of the directional light.
  11738. */
  11739. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11740. /**
  11741. * Light type const id of the spot light.
  11742. */
  11743. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11744. /**
  11745. * Light type const id of the hemispheric light.
  11746. */
  11747. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11748. /**
  11749. * Diffuse gives the basic color to an object.
  11750. */
  11751. diffuse: Color3;
  11752. /**
  11753. * Specular produces a highlight color on an object.
  11754. * Note: This is note affecting PBR materials.
  11755. */
  11756. specular: Color3;
  11757. /**
  11758. * Strength of the light.
  11759. * Note: By default it is define in the framework own unit.
  11760. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11761. */
  11762. intensity: number;
  11763. /**
  11764. * Defines how far from the source the light is impacting in scene units.
  11765. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11766. */
  11767. range: number;
  11768. /**
  11769. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11770. * of light.
  11771. */
  11772. private _photometricScale;
  11773. private _intensityMode;
  11774. /**
  11775. * Gets the photometric scale used to interpret the intensity.
  11776. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11777. */
  11778. /**
  11779. * Sets the photometric scale used to interpret the intensity.
  11780. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11781. */
  11782. intensityMode: number;
  11783. private _radius;
  11784. /**
  11785. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11786. */
  11787. /**
  11788. * sets the light radius used by PBR Materials to simulate soft area lights.
  11789. */
  11790. radius: number;
  11791. private _renderPriority;
  11792. /**
  11793. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11794. * exceeding the number allowed of the materials.
  11795. */
  11796. renderPriority: number;
  11797. private _shadowEnabled;
  11798. /**
  11799. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11800. * the current shadow generator.
  11801. */
  11802. /**
  11803. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11804. * the current shadow generator.
  11805. */
  11806. shadowEnabled: boolean;
  11807. private _includedOnlyMeshes;
  11808. /**
  11809. * Gets the only meshes impacted by this light.
  11810. */
  11811. /**
  11812. * Sets the only meshes impacted by this light.
  11813. */
  11814. includedOnlyMeshes: AbstractMesh[];
  11815. private _excludedMeshes;
  11816. /**
  11817. * Gets the meshes not impacted by this light.
  11818. */
  11819. /**
  11820. * Sets the meshes not impacted by this light.
  11821. */
  11822. excludedMeshes: AbstractMesh[];
  11823. private _excludeWithLayerMask;
  11824. /**
  11825. * Gets the layer id use to find what meshes are not impacted by the light.
  11826. * Inactive if 0
  11827. */
  11828. /**
  11829. * Sets the layer id use to find what meshes are not impacted by the light.
  11830. * Inactive if 0
  11831. */
  11832. excludeWithLayerMask: number;
  11833. private _includeOnlyWithLayerMask;
  11834. /**
  11835. * Gets the layer id use to find what meshes are impacted by the light.
  11836. * Inactive if 0
  11837. */
  11838. /**
  11839. * Sets the layer id use to find what meshes are impacted by the light.
  11840. * Inactive if 0
  11841. */
  11842. includeOnlyWithLayerMask: number;
  11843. private _lightmapMode;
  11844. /**
  11845. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11846. */
  11847. /**
  11848. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11849. */
  11850. lightmapMode: number;
  11851. private _parentedWorldMatrix;
  11852. /**
  11853. * Shadow generator associted to the light.
  11854. * Internal use only.
  11855. */
  11856. _shadowGenerator: Nullable<IShadowGenerator>;
  11857. /**
  11858. * @hidden Internal use only.
  11859. */
  11860. _excludedMeshesIds: string[];
  11861. /**
  11862. * @hidden Internal use only.
  11863. */
  11864. _includedOnlyMeshesIds: string[];
  11865. /**
  11866. * The current light unifom buffer.
  11867. * @hidden Internal use only.
  11868. */
  11869. _uniformBuffer: UniformBuffer;
  11870. /**
  11871. * Creates a Light object in the scene.
  11872. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11873. * @param name The firendly name of the light
  11874. * @param scene The scene the light belongs too
  11875. */
  11876. constructor(name: string, scene: Scene);
  11877. protected abstract _buildUniformLayout(): void;
  11878. /**
  11879. * Sets the passed Effect "effect" with the Light information.
  11880. * @param effect The effect to update
  11881. * @param lightIndex The index of the light in the effect to update
  11882. * @returns The light
  11883. */
  11884. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11885. /**
  11886. * @hidden internal use only.
  11887. */
  11888. abstract _getWorldMatrix(): Matrix;
  11889. /**
  11890. * Returns the string "Light".
  11891. * @returns the class name
  11892. */
  11893. getClassName(): string;
  11894. /**
  11895. * Converts the light information to a readable string for debug purpose.
  11896. * @param fullDetails Supports for multiple levels of logging within scene loading
  11897. * @returns the human readable light info
  11898. */
  11899. toString(fullDetails?: boolean): string;
  11900. /**
  11901. * Set the enabled state of this node.
  11902. * @param value - the new enabled state
  11903. */
  11904. setEnabled(value: boolean): void;
  11905. /**
  11906. * Returns the Light associated shadow generator if any.
  11907. * @return the associated shadow generator.
  11908. */
  11909. getShadowGenerator(): Nullable<IShadowGenerator>;
  11910. /**
  11911. * Returns a Vector3, the absolute light position in the World.
  11912. * @returns the world space position of the light
  11913. */
  11914. getAbsolutePosition(): Vector3;
  11915. /**
  11916. * Specifies if the light will affect the passed mesh.
  11917. * @param mesh The mesh to test against the light
  11918. * @return true the mesh is affected otherwise, false.
  11919. */
  11920. canAffectMesh(mesh: AbstractMesh): boolean;
  11921. /**
  11922. * Computes and Returns the light World matrix.
  11923. * @returns the world matrix
  11924. */
  11925. getWorldMatrix(): Matrix;
  11926. /**
  11927. * Sort function to order lights for rendering.
  11928. * @param a First Light object to compare to second.
  11929. * @param b Second Light object to compare first.
  11930. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11931. */
  11932. static CompareLightsPriority(a: Light, b: Light): number;
  11933. /**
  11934. * Releases resources associated with this node.
  11935. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11936. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11937. */
  11938. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11939. /**
  11940. * Returns the light type ID (integer).
  11941. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11942. */
  11943. getTypeID(): number;
  11944. /**
  11945. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11946. * @returns the scaled intensity in intensity mode unit
  11947. */
  11948. getScaledIntensity(): number;
  11949. /**
  11950. * Returns a new Light object, named "name", from the current one.
  11951. * @param name The name of the cloned light
  11952. * @returns the new created light
  11953. */
  11954. clone(name: string): Nullable<Light>;
  11955. /**
  11956. * Serializes the current light into a Serialization object.
  11957. * @returns the serialized object.
  11958. */
  11959. serialize(): any;
  11960. /**
  11961. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11962. * This new light is named "name" and added to the passed scene.
  11963. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11964. * @param name The friendly name of the light
  11965. * @param scene The scene the new light will belong to
  11966. * @returns the constructor function
  11967. */
  11968. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11969. /**
  11970. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11971. * @param parsedLight The JSON representation of the light
  11972. * @param scene The scene to create the parsed light in
  11973. * @returns the created light after parsing
  11974. */
  11975. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11976. private _hookArrayForExcluded(array);
  11977. private _hookArrayForIncludedOnly(array);
  11978. private _resyncMeshes();
  11979. /**
  11980. * Forces the meshes to update their light related information in their rendering used effects
  11981. * @hidden Internal Use Only
  11982. */
  11983. _markMeshesAsLightDirty(): void;
  11984. /**
  11985. * Recomputes the cached photometric scale if needed.
  11986. */
  11987. private _computePhotometricScale();
  11988. /**
  11989. * Returns the Photometric Scale according to the light type and intensity mode.
  11990. */
  11991. private _getPhotometricScale();
  11992. /**
  11993. * Reorder the light in the scene according to their defined priority.
  11994. * @hidden Internal Use Only
  11995. */
  11996. _reorderLightsInScene(): void;
  11997. /**
  11998. * Prepares the list of defines specific to the light type.
  11999. * @param defines the list of defines
  12000. * @param lightIndex defines the index of the light for the effect
  12001. */
  12002. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12003. }
  12004. }
  12005. declare module BABYLON {
  12006. /**
  12007. * A point light is a light defined by an unique point in world space.
  12008. * The light is emitted in every direction from this point.
  12009. * A good example of a point light is a standard light bulb.
  12010. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12011. */
  12012. class PointLight extends ShadowLight {
  12013. private _shadowAngle;
  12014. /**
  12015. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12016. * This specifies what angle the shadow will use to be created.
  12017. *
  12018. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12019. */
  12020. /**
  12021. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12022. * This specifies what angle the shadow will use to be created.
  12023. *
  12024. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12025. */
  12026. shadowAngle: number;
  12027. /**
  12028. * Gets the direction if it has been set.
  12029. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12030. */
  12031. /**
  12032. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12033. */
  12034. direction: Vector3;
  12035. /**
  12036. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12037. * A PointLight emits the light in every direction.
  12038. * It can cast shadows.
  12039. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12040. * ```javascript
  12041. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12042. * ```
  12043. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12044. * @param name The light friendly name
  12045. * @param position The position of the point light in the scene
  12046. * @param scene The scene the lights belongs to
  12047. */
  12048. constructor(name: string, position: Vector3, scene: Scene);
  12049. /**
  12050. * Returns the string "PointLight"
  12051. * @returns the class name
  12052. */
  12053. getClassName(): string;
  12054. /**
  12055. * Returns the integer 0.
  12056. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12057. */
  12058. getTypeID(): number;
  12059. /**
  12060. * Specifies wether or not the shadowmap should be a cube texture.
  12061. * @returns true if the shadowmap needs to be a cube texture.
  12062. */
  12063. needCube(): boolean;
  12064. /**
  12065. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12068. */
  12069. getShadowDirection(faceIndex?: number): Vector3;
  12070. /**
  12071. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12072. * - fov = PI / 2
  12073. * - aspect ratio : 1.0
  12074. * - z-near and far equal to the active camera minZ and maxZ.
  12075. * Returns the PointLight.
  12076. */
  12077. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12078. protected _buildUniformLayout(): void;
  12079. /**
  12080. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12081. * @param effect The effect to update
  12082. * @param lightIndex The index of the light in the effect to update
  12083. * @returns The point light
  12084. */
  12085. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12086. /**
  12087. * Prepares the list of defines specific to the light type.
  12088. * @param defines the list of defines
  12089. * @param lightIndex defines the index of the light for the effect
  12090. */
  12091. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12092. }
  12093. }
  12094. declare module BABYLON {
  12095. /**
  12096. * Interface describing all the common properties and methods a shadow light needs to implement.
  12097. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12098. * as well as binding the different shadow properties to the effects.
  12099. */
  12100. interface IShadowLight extends Light {
  12101. /**
  12102. * The light id in the scene (used in scene.findLighById for instance)
  12103. */
  12104. id: string;
  12105. /**
  12106. * The position the shdow will be casted from.
  12107. */
  12108. position: Vector3;
  12109. /**
  12110. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12111. */
  12112. direction: Vector3;
  12113. /**
  12114. * The transformed position. Position of the light in world space taking parenting in account.
  12115. */
  12116. transformedPosition: Vector3;
  12117. /**
  12118. * The transformed direction. Direction of the light in world space taking parenting in account.
  12119. */
  12120. transformedDirection: Vector3;
  12121. /**
  12122. * The friendly name of the light in the scene.
  12123. */
  12124. name: string;
  12125. /**
  12126. * Defines the shadow projection clipping minimum z value.
  12127. */
  12128. shadowMinZ: number;
  12129. /**
  12130. * Defines the shadow projection clipping maximum z value.
  12131. */
  12132. shadowMaxZ: number;
  12133. /**
  12134. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12135. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12136. */
  12137. computeTransformedInformation(): boolean;
  12138. /**
  12139. * Gets the scene the light belongs to.
  12140. * @returns The scene
  12141. */
  12142. getScene(): Scene;
  12143. /**
  12144. * Callback defining a custom Projection Matrix Builder.
  12145. * This can be used to override the default projection matrix computation.
  12146. */
  12147. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12148. /**
  12149. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12150. * @param matrix The materix to updated with the projection information
  12151. * @param viewMatrix The transform matrix of the light
  12152. * @param renderList The list of mesh to render in the map
  12153. * @returns The current light
  12154. */
  12155. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12156. /**
  12157. * Gets the current depth scale used in ESM.
  12158. * @returns The scale
  12159. */
  12160. getDepthScale(): number;
  12161. /**
  12162. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12163. * @returns true if a cube texture needs to be use
  12164. */
  12165. needCube(): boolean;
  12166. /**
  12167. * Detects if the projection matrix requires to be recomputed this frame.
  12168. * @returns true if it requires to be recomputed otherwise, false.
  12169. */
  12170. needProjectionMatrixCompute(): boolean;
  12171. /**
  12172. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12173. */
  12174. forceProjectionMatrixCompute(): void;
  12175. /**
  12176. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12177. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12178. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12179. */
  12180. getShadowDirection(faceIndex?: number): Vector3;
  12181. /**
  12182. * Gets the minZ used for shadow according to both the scene and the light.
  12183. * @param activeCamera The camera we are returning the min for
  12184. * @returns the depth min z
  12185. */
  12186. getDepthMinZ(activeCamera: Camera): number;
  12187. /**
  12188. * Gets the maxZ used for shadow according to both the scene and the light.
  12189. * @param activeCamera The camera we are returning the max for
  12190. * @returns the depth max z
  12191. */
  12192. getDepthMaxZ(activeCamera: Camera): number;
  12193. }
  12194. /**
  12195. * Base implementation IShadowLight
  12196. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12197. */
  12198. abstract class ShadowLight extends Light implements IShadowLight {
  12199. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12200. protected _position: Vector3;
  12201. protected _setPosition(value: Vector3): void;
  12202. /**
  12203. * Sets the position the shadow will be casted from. Also use as the light position for both
  12204. * point and spot lights.
  12205. */
  12206. /**
  12207. * Sets the position the shadow will be casted from. Also use as the light position for both
  12208. * point and spot lights.
  12209. */
  12210. position: Vector3;
  12211. protected _direction: Vector3;
  12212. protected _setDirection(value: Vector3): void;
  12213. /**
  12214. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12215. * Also use as the light direction on spot and directional lights.
  12216. */
  12217. /**
  12218. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12219. * Also use as the light direction on spot and directional lights.
  12220. */
  12221. direction: Vector3;
  12222. private _shadowMinZ;
  12223. /**
  12224. * Gets the shadow projection clipping minimum z value.
  12225. */
  12226. /**
  12227. * Sets the shadow projection clipping minimum z value.
  12228. */
  12229. shadowMinZ: number;
  12230. private _shadowMaxZ;
  12231. /**
  12232. * Sets the shadow projection clipping maximum z value.
  12233. */
  12234. /**
  12235. * Gets the shadow projection clipping maximum z value.
  12236. */
  12237. shadowMaxZ: number;
  12238. /**
  12239. * Callback defining a custom Projection Matrix Builder.
  12240. * This can be used to override the default projection matrix computation.
  12241. */
  12242. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12243. /**
  12244. * The transformed position. Position of the light in world space taking parenting in account.
  12245. */
  12246. transformedPosition: Vector3;
  12247. /**
  12248. * The transformed direction. Direction of the light in world space taking parenting in account.
  12249. */
  12250. transformedDirection: Vector3;
  12251. private _worldMatrix;
  12252. private _needProjectionMatrixCompute;
  12253. /**
  12254. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12255. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12256. */
  12257. computeTransformedInformation(): boolean;
  12258. /**
  12259. * Return the depth scale used for the shadow map.
  12260. * @returns the depth scale.
  12261. */
  12262. getDepthScale(): number;
  12263. /**
  12264. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12265. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12266. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12267. */
  12268. getShadowDirection(faceIndex?: number): Vector3;
  12269. /**
  12270. * Returns the ShadowLight absolute position in the World.
  12271. * @returns the position vector in world space
  12272. */
  12273. getAbsolutePosition(): Vector3;
  12274. /**
  12275. * Sets the ShadowLight direction toward the passed target.
  12276. * @param target The point tot target in local space
  12277. * @returns the updated ShadowLight direction
  12278. */
  12279. setDirectionToTarget(target: Vector3): Vector3;
  12280. /**
  12281. * Returns the light rotation in euler definition.
  12282. * @returns the x y z rotation in local space.
  12283. */
  12284. getRotation(): Vector3;
  12285. /**
  12286. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12287. * @returns true if a cube texture needs to be use
  12288. */
  12289. needCube(): boolean;
  12290. /**
  12291. * Detects if the projection matrix requires to be recomputed this frame.
  12292. * @returns true if it requires to be recomputed otherwise, false.
  12293. */
  12294. needProjectionMatrixCompute(): boolean;
  12295. /**
  12296. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12297. */
  12298. forceProjectionMatrixCompute(): void;
  12299. /**
  12300. * Get the world matrix of the sahdow lights.
  12301. * @hidden Internal Use Only
  12302. */
  12303. _getWorldMatrix(): Matrix;
  12304. /**
  12305. * Gets the minZ used for shadow according to both the scene and the light.
  12306. * @param activeCamera The camera we are returning the min for
  12307. * @returns the depth min z
  12308. */
  12309. getDepthMinZ(activeCamera: Camera): number;
  12310. /**
  12311. * Gets the maxZ used for shadow according to both the scene and the light.
  12312. * @param activeCamera The camera we are returning the max for
  12313. * @returns the depth max z
  12314. */
  12315. getDepthMaxZ(activeCamera: Camera): number;
  12316. /**
  12317. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12318. * @param matrix The materix to updated with the projection information
  12319. * @param viewMatrix The transform matrix of the light
  12320. * @param renderList The list of mesh to render in the map
  12321. * @returns The current light
  12322. */
  12323. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12324. }
  12325. }
  12326. declare module BABYLON {
  12327. /**
  12328. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12329. * These values define a cone of light starting from the position, emitting toward the direction.
  12330. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12331. * and the exponent defines the speed of the decay of the light with distance (reach).
  12332. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12333. */
  12334. class SpotLight extends ShadowLight {
  12335. private _angle;
  12336. /**
  12337. * Gets the cone angle of the spot light in Radians.
  12338. */
  12339. /**
  12340. * Sets the cone angle of the spot light in Radians.
  12341. */
  12342. angle: number;
  12343. private _shadowAngleScale;
  12344. /**
  12345. * Allows scaling the angle of the light for shadow generation only.
  12346. */
  12347. /**
  12348. * Allows scaling the angle of the light for shadow generation only.
  12349. */
  12350. shadowAngleScale: number;
  12351. /**
  12352. * The light decay speed with the distance from the emission spot.
  12353. */
  12354. exponent: number;
  12355. private _projectionTextureMatrix;
  12356. /**
  12357. * Allows reading the projecton texture
  12358. */
  12359. readonly projectionTextureMatrix: Matrix;
  12360. protected _projectionTextureLightNear: number;
  12361. /**
  12362. * Gets the near clip of the Spotlight for texture projection.
  12363. */
  12364. /**
  12365. * Sets the near clip of the Spotlight for texture projection.
  12366. */
  12367. projectionTextureLightNear: number;
  12368. protected _projectionTextureLightFar: number;
  12369. /**
  12370. * Gets the far clip of the Spotlight for texture projection.
  12371. */
  12372. /**
  12373. * Sets the far clip of the Spotlight for texture projection.
  12374. */
  12375. projectionTextureLightFar: number;
  12376. protected _projectionTextureUpDirection: Vector3;
  12377. /**
  12378. * Gets the Up vector of the Spotlight for texture projection.
  12379. */
  12380. /**
  12381. * Sets the Up vector of the Spotlight for texture projection.
  12382. */
  12383. projectionTextureUpDirection: Vector3;
  12384. private _projectionTexture;
  12385. /**
  12386. * Gets the projection texture of the light.
  12387. */
  12388. /**
  12389. * Sets the projection texture of the light.
  12390. */
  12391. projectionTexture: Nullable<BaseTexture>;
  12392. private _projectionTextureViewLightDirty;
  12393. private _projectionTextureProjectionLightDirty;
  12394. private _projectionTextureDirty;
  12395. private _projectionTextureViewTargetVector;
  12396. private _projectionTextureViewLightMatrix;
  12397. private _projectionTextureProjectionLightMatrix;
  12398. private _projectionTextureScalingMatrix;
  12399. /**
  12400. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12401. * It can cast shadows.
  12402. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12403. * @param name The light friendly name
  12404. * @param position The position of the spot light in the scene
  12405. * @param direction The direction of the light in the scene
  12406. * @param angle The cone angle of the light in Radians
  12407. * @param exponent The light decay speed with the distance from the emission spot
  12408. * @param scene The scene the lights belongs to
  12409. */
  12410. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12411. /**
  12412. * Returns the string "SpotLight".
  12413. * @returns the class name
  12414. */
  12415. getClassName(): string;
  12416. /**
  12417. * Returns the integer 2.
  12418. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12419. */
  12420. getTypeID(): number;
  12421. /**
  12422. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12423. */
  12424. protected _setDirection(value: Vector3): void;
  12425. /**
  12426. * Overrides the position setter to recompute the projection texture view light Matrix.
  12427. */
  12428. protected _setPosition(value: Vector3): void;
  12429. /**
  12430. * 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.
  12431. * Returns the SpotLight.
  12432. */
  12433. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12434. protected _computeProjectionTextureViewLightMatrix(): void;
  12435. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12436. /**
  12437. * Main function for light texture projection matrix computing.
  12438. */
  12439. protected _computeProjectionTextureMatrix(): void;
  12440. protected _buildUniformLayout(): void;
  12441. /**
  12442. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12443. * @param effect The effect to update
  12444. * @param lightIndex The index of the light in the effect to update
  12445. * @returns The spot light
  12446. */
  12447. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12448. /**
  12449. * Disposes the light and the associated resources.
  12450. */
  12451. dispose(): void;
  12452. /**
  12453. * Prepares the list of defines specific to the light type.
  12454. * @param defines the list of defines
  12455. * @param lightIndex defines the index of the light for the effect
  12456. */
  12457. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12458. }
  12459. }
  12460. declare module BABYLON {
  12461. interface ILoadingScreen {
  12462. displayLoadingUI: () => void;
  12463. hideLoadingUI: () => void;
  12464. loadingUIBackgroundColor: string;
  12465. loadingUIText: string;
  12466. }
  12467. class DefaultLoadingScreen implements ILoadingScreen {
  12468. private _renderingCanvas;
  12469. private _loadingText;
  12470. private _loadingDivBackgroundColor;
  12471. private _loadingDiv;
  12472. private _loadingTextDiv;
  12473. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12474. displayLoadingUI(): void;
  12475. hideLoadingUI(): void;
  12476. loadingUIText: string;
  12477. loadingUIBackgroundColor: string;
  12478. private _resizeLoadingUI;
  12479. }
  12480. }
  12481. declare module BABYLON {
  12482. class SceneLoaderProgressEvent {
  12483. readonly lengthComputable: boolean;
  12484. readonly loaded: number;
  12485. readonly total: number;
  12486. constructor(lengthComputable: boolean, loaded: number, total: number);
  12487. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12488. }
  12489. interface ISceneLoaderPluginExtensions {
  12490. [extension: string]: {
  12491. isBinary: boolean;
  12492. };
  12493. }
  12494. interface ISceneLoaderPluginFactory {
  12495. name: string;
  12496. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12497. canDirectLoad?: (data: string) => boolean;
  12498. }
  12499. interface ISceneLoaderPlugin {
  12500. /**
  12501. * The friendly name of this plugin.
  12502. */
  12503. name: string;
  12504. /**
  12505. * The file extensions supported by this plugin.
  12506. */
  12507. extensions: string | ISceneLoaderPluginExtensions;
  12508. /**
  12509. * Import meshes into a scene.
  12510. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12511. * @param scene The scene to import into
  12512. * @param data The data to import
  12513. * @param rootUrl The root url for scene and resources
  12514. * @param meshes The meshes array to import into
  12515. * @param particleSystems The particle systems array to import into
  12516. * @param skeletons The skeletons array to import into
  12517. * @param onError The callback when import fails
  12518. * @returns True if successful or false otherwise
  12519. */
  12520. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12521. /**
  12522. * Load into a scene.
  12523. * @param scene The scene to load into
  12524. * @param data The data to import
  12525. * @param rootUrl The root url for scene and resources
  12526. * @param onError The callback when import fails
  12527. * @returns true if successful or false otherwise
  12528. */
  12529. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12530. /**
  12531. * The callback that returns true if the data can be directly loaded.
  12532. */
  12533. canDirectLoad?: (data: string) => boolean;
  12534. /**
  12535. * The callback that allows custom handling of the root url based on the response url.
  12536. */
  12537. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12538. /**
  12539. * Load into an asset container.
  12540. * @param scene The scene to load into
  12541. * @param data The data to import
  12542. * @param rootUrl The root url for scene and resources
  12543. * @param onError The callback when import fails
  12544. * @returns The loaded asset container
  12545. */
  12546. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12547. }
  12548. interface ISceneLoaderPluginAsync {
  12549. /**
  12550. * The friendly name of this plugin.
  12551. */
  12552. name: string;
  12553. /**
  12554. * The file extensions supported by this plugin.
  12555. */
  12556. extensions: string | ISceneLoaderPluginExtensions;
  12557. /**
  12558. * Import meshes into a scene.
  12559. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12560. * @param scene The scene to import into
  12561. * @param data The data to import
  12562. * @param rootUrl The root url for scene and resources
  12563. * @param onProgress The callback when the load progresses
  12564. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12565. */
  12566. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12567. meshes: AbstractMesh[];
  12568. particleSystems: IParticleSystem[];
  12569. skeletons: Skeleton[];
  12570. animationGroups: AnimationGroup[];
  12571. }>;
  12572. /**
  12573. * Load into a scene.
  12574. * @param scene The scene to load into
  12575. * @param data The data to import
  12576. * @param rootUrl The root url for scene and resources
  12577. * @param onProgress The callback when the load progresses
  12578. * @returns Nothing
  12579. */
  12580. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12581. /**
  12582. * The callback that returns true if the data can be directly loaded.
  12583. */
  12584. canDirectLoad?: (data: string) => boolean;
  12585. /**
  12586. * The callback that allows custom handling of the root url based on the response url.
  12587. */
  12588. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12589. /**
  12590. * Load into an asset container.
  12591. * @param scene The scene to load into
  12592. * @param data The data to import
  12593. * @param rootUrl The root url for scene and resources
  12594. * @param onProgress The callback when the load progresses
  12595. * @returns The loaded asset container
  12596. */
  12597. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12598. }
  12599. class SceneLoader {
  12600. private static _ForceFullSceneLoadingForIncremental;
  12601. private static _ShowLoadingScreen;
  12602. private static _CleanBoneMatrixWeights;
  12603. static readonly NO_LOGGING: number;
  12604. static readonly MINIMAL_LOGGING: number;
  12605. static readonly SUMMARY_LOGGING: number;
  12606. static readonly DETAILED_LOGGING: number;
  12607. private static _loggingLevel;
  12608. static ForceFullSceneLoadingForIncremental: boolean;
  12609. static ShowLoadingScreen: boolean;
  12610. static loggingLevel: number;
  12611. static CleanBoneMatrixWeights: boolean;
  12612. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12613. private static _registeredPlugins;
  12614. private static _getDefaultPlugin();
  12615. private static _getPluginForExtension(extension);
  12616. private static _getPluginForDirectLoad(data);
  12617. private static _getPluginForFilename(sceneFilename);
  12618. private static _getDirectLoad(sceneFilename);
  12619. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12620. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12621. static IsPluginForExtensionAvailable(extension: string): boolean;
  12622. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12623. /**
  12624. * Import meshes into a scene
  12625. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12626. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12627. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12628. * @param scene the instance of BABYLON.Scene to append to
  12629. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12630. * @param onProgress a callback with a progress event for each file being loaded
  12631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12632. * @param pluginExtension the extension used to determine the plugin
  12633. * @returns The loaded plugin
  12634. */
  12635. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12636. /**
  12637. * Import meshes into a scene
  12638. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12639. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12640. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12641. * @param scene the instance of BABYLON.Scene to append to
  12642. * @param onProgress a callback with a progress event for each file being loaded
  12643. * @param pluginExtension the extension used to determine the plugin
  12644. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12645. */
  12646. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12647. meshes: AbstractMesh[];
  12648. particleSystems: IParticleSystem[];
  12649. skeletons: Skeleton[];
  12650. animationGroups: AnimationGroup[];
  12651. }>;
  12652. /**
  12653. * Load a scene
  12654. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12655. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12656. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12657. * @param onSuccess a callback with the scene when import succeeds
  12658. * @param onProgress a callback with a progress event for each file being loaded
  12659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12660. * @param pluginExtension the extension used to determine the plugin
  12661. * @returns The loaded plugin
  12662. */
  12663. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12664. /**
  12665. * Load a scene
  12666. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12667. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12669. * @param onProgress a callback with a progress event for each file being loaded
  12670. * @param pluginExtension the extension used to determine the plugin
  12671. * @returns The loaded scene
  12672. */
  12673. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12674. /**
  12675. * Append a scene
  12676. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12677. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12678. * @param scene is the instance of BABYLON.Scene to append to
  12679. * @param onSuccess a callback with the scene when import succeeds
  12680. * @param onProgress a callback with a progress event for each file being loaded
  12681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12682. * @param pluginExtension the extension used to determine the plugin
  12683. * @returns The loaded plugin
  12684. */
  12685. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12686. /**
  12687. * Append a scene
  12688. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12689. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12690. * @param scene is the instance of BABYLON.Scene to append to
  12691. * @param onProgress a callback with a progress event for each file being loaded
  12692. * @param pluginExtension the extension used to determine the plugin
  12693. * @returns The given scene
  12694. */
  12695. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12696. /**
  12697. * Load a scene into an asset container
  12698. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12699. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12700. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12701. * @param onSuccess a callback with the scene when import succeeds
  12702. * @param onProgress a callback with a progress event for each file being loaded
  12703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12704. * @param pluginExtension the extension used to determine the plugin
  12705. * @returns The loaded plugin
  12706. */
  12707. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12708. /**
  12709. * Load a scene into an asset container
  12710. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12711. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12712. * @param scene is the instance of BABYLON.Scene to append to
  12713. * @param onProgress a callback with a progress event for each file being loaded
  12714. * @param pluginExtension the extension used to determine the plugin
  12715. * @returns The loaded asset container
  12716. */
  12717. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12718. }
  12719. }
  12720. declare module BABYLON {
  12721. /**
  12722. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12723. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12724. * 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;
  12725. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12726. */
  12727. class ColorCurves {
  12728. private _dirty;
  12729. private _tempColor;
  12730. private _globalCurve;
  12731. private _highlightsCurve;
  12732. private _midtonesCurve;
  12733. private _shadowsCurve;
  12734. private _positiveCurve;
  12735. private _negativeCurve;
  12736. private _globalHue;
  12737. private _globalDensity;
  12738. private _globalSaturation;
  12739. private _globalExposure;
  12740. /**
  12741. * Gets the global Hue value.
  12742. * 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).
  12743. */
  12744. /**
  12745. * Sets the global Hue value.
  12746. * 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).
  12747. */
  12748. globalHue: number;
  12749. /**
  12750. * Gets the global Density value.
  12751. * 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.
  12752. * Values less than zero provide a filter of opposite hue.
  12753. */
  12754. /**
  12755. * Sets the global Density value.
  12756. * 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.
  12757. * Values less than zero provide a filter of opposite hue.
  12758. */
  12759. globalDensity: number;
  12760. /**
  12761. * Gets the global Saturation value.
  12762. * 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.
  12763. */
  12764. /**
  12765. * Sets the global Saturation value.
  12766. * 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.
  12767. */
  12768. globalSaturation: number;
  12769. /**
  12770. * Gets the global Exposure value.
  12771. * 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.
  12772. */
  12773. /**
  12774. * Sets the global Exposure value.
  12775. * 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.
  12776. */
  12777. globalExposure: number;
  12778. private _highlightsHue;
  12779. private _highlightsDensity;
  12780. private _highlightsSaturation;
  12781. private _highlightsExposure;
  12782. /**
  12783. * Gets the highlights Hue value.
  12784. * 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).
  12785. */
  12786. /**
  12787. * Sets the highlights Hue value.
  12788. * 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).
  12789. */
  12790. highlightsHue: number;
  12791. /**
  12792. * Gets the highlights Density value.
  12793. * 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.
  12794. * Values less than zero provide a filter of opposite hue.
  12795. */
  12796. /**
  12797. * Sets the highlights Density value.
  12798. * 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.
  12799. * Values less than zero provide a filter of opposite hue.
  12800. */
  12801. highlightsDensity: number;
  12802. /**
  12803. * Gets the highlights Saturation value.
  12804. * 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.
  12805. */
  12806. /**
  12807. * Sets the highlights Saturation value.
  12808. * 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.
  12809. */
  12810. highlightsSaturation: number;
  12811. /**
  12812. * Gets the highlights Exposure value.
  12813. * 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.
  12814. */
  12815. /**
  12816. * Sets the highlights Exposure value.
  12817. * 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.
  12818. */
  12819. highlightsExposure: number;
  12820. private _midtonesHue;
  12821. private _midtonesDensity;
  12822. private _midtonesSaturation;
  12823. private _midtonesExposure;
  12824. /**
  12825. * Gets the midtones Hue value.
  12826. * 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).
  12827. */
  12828. /**
  12829. * Sets the midtones Hue value.
  12830. * 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).
  12831. */
  12832. midtonesHue: number;
  12833. /**
  12834. * Gets the midtones Density value.
  12835. * 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.
  12836. * Values less than zero provide a filter of opposite hue.
  12837. */
  12838. /**
  12839. * Sets the midtones Density value.
  12840. * 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.
  12841. * Values less than zero provide a filter of opposite hue.
  12842. */
  12843. midtonesDensity: number;
  12844. /**
  12845. * Gets the midtones Saturation value.
  12846. * 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.
  12847. */
  12848. /**
  12849. * Sets the midtones Saturation value.
  12850. * 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.
  12851. */
  12852. midtonesSaturation: number;
  12853. /**
  12854. * Gets the midtones Exposure value.
  12855. * 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.
  12856. */
  12857. /**
  12858. * Sets the midtones Exposure value.
  12859. * 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.
  12860. */
  12861. midtonesExposure: number;
  12862. private _shadowsHue;
  12863. private _shadowsDensity;
  12864. private _shadowsSaturation;
  12865. private _shadowsExposure;
  12866. /**
  12867. * Gets the shadows Hue value.
  12868. * 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).
  12869. */
  12870. /**
  12871. * Sets the shadows Hue value.
  12872. * 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).
  12873. */
  12874. shadowsHue: number;
  12875. /**
  12876. * Gets the shadows Density value.
  12877. * 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.
  12878. * Values less than zero provide a filter of opposite hue.
  12879. */
  12880. /**
  12881. * Sets the shadows Density value.
  12882. * 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.
  12883. * Values less than zero provide a filter of opposite hue.
  12884. */
  12885. shadowsDensity: number;
  12886. /**
  12887. * Gets the shadows Saturation value.
  12888. * 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.
  12889. */
  12890. /**
  12891. * Sets the shadows Saturation value.
  12892. * 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.
  12893. */
  12894. shadowsSaturation: number;
  12895. /**
  12896. * Gets the shadows Exposure value.
  12897. * 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.
  12898. */
  12899. /**
  12900. * Sets the shadows Exposure value.
  12901. * 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.
  12902. */
  12903. shadowsExposure: number;
  12904. getClassName(): string;
  12905. /**
  12906. * Binds the color curves to the shader.
  12907. * @param colorCurves The color curve to bind
  12908. * @param effect The effect to bind to
  12909. */
  12910. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12911. /**
  12912. * Prepare the list of uniforms associated with the ColorCurves effects.
  12913. * @param uniformsList The list of uniforms used in the effect
  12914. */
  12915. static PrepareUniforms(uniformsList: string[]): void;
  12916. /**
  12917. * Returns color grading data based on a hue, density, saturation and exposure value.
  12918. * @param filterHue The hue of the color filter.
  12919. * @param filterDensity The density of the color filter.
  12920. * @param saturation The saturation.
  12921. * @param exposure The exposure.
  12922. * @param result The result data container.
  12923. */
  12924. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12925. /**
  12926. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12927. * @param value The input slider value in range [-100,100].
  12928. * @returns Adjusted value.
  12929. */
  12930. private static applyColorGradingSliderNonlinear(value);
  12931. /**
  12932. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12933. * @param hue The hue (H) input.
  12934. * @param saturation The saturation (S) input.
  12935. * @param brightness The brightness (B) input.
  12936. * @result An RGBA color represented as Vector4.
  12937. */
  12938. private static fromHSBToRef(hue, saturation, brightness, result);
  12939. /**
  12940. * Returns a value clamped between min and max
  12941. * @param value The value to clamp
  12942. * @param min The minimum of value
  12943. * @param max The maximum of value
  12944. * @returns The clamped value.
  12945. */
  12946. private static clamp(value, min, max);
  12947. /**
  12948. * Clones the current color curve instance.
  12949. * @return The cloned curves
  12950. */
  12951. clone(): ColorCurves;
  12952. /**
  12953. * Serializes the current color curve instance to a json representation.
  12954. * @return a JSON representation
  12955. */
  12956. serialize(): any;
  12957. /**
  12958. * Parses the color curve from a json representation.
  12959. * @param source the JSON source to parse
  12960. * @return The parsed curves
  12961. */
  12962. static Parse(source: any): ColorCurves;
  12963. }
  12964. }
  12965. declare module BABYLON {
  12966. /**
  12967. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12968. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12969. */
  12970. class EffectFallbacks {
  12971. private _defines;
  12972. private _currentRank;
  12973. private _maxRank;
  12974. private _mesh;
  12975. /**
  12976. * Removes the fallback from the bound mesh.
  12977. */
  12978. unBindMesh(): void;
  12979. /**
  12980. * Adds a fallback on the specified property.
  12981. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12982. * @param define The name of the define in the shader
  12983. */
  12984. addFallback(rank: number, define: string): void;
  12985. /**
  12986. * Sets the mesh to use CPU skinning when needing to fallback.
  12987. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12988. * @param mesh The mesh to use the fallbacks.
  12989. */
  12990. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12991. /**
  12992. * Checks to see if more fallbacks are still availible.
  12993. */
  12994. readonly isMoreFallbacks: boolean;
  12995. /**
  12996. * Removes the defines that shoould be removed when falling back.
  12997. * @param currentDefines defines the current define statements for the shader.
  12998. * @param effect defines the current effect we try to compile
  12999. * @returns The resulting defines with defines of the current rank removed.
  13000. */
  13001. reduce(currentDefines: string, effect: Effect): string;
  13002. }
  13003. /**
  13004. * Options to be used when creating an effect.
  13005. */
  13006. class EffectCreationOptions {
  13007. /**
  13008. * Atrributes that will be used in the shader.
  13009. */
  13010. attributes: string[];
  13011. /**
  13012. * Uniform varible names that will be set in the shader.
  13013. */
  13014. uniformsNames: string[];
  13015. /**
  13016. * Uniform buffer varible names that will be set in the shader.
  13017. */
  13018. uniformBuffersNames: string[];
  13019. /**
  13020. * Sampler texture variable names that will be set in the shader.
  13021. */
  13022. samplers: string[];
  13023. /**
  13024. * Define statements that will be set in the shader.
  13025. */
  13026. defines: any;
  13027. /**
  13028. * Possible fallbacks for this effect to improve performance when needed.
  13029. */
  13030. fallbacks: Nullable<EffectFallbacks>;
  13031. /**
  13032. * Callback that will be called when the shader is compiled.
  13033. */
  13034. onCompiled: Nullable<(effect: Effect) => void>;
  13035. /**
  13036. * Callback that will be called if an error occurs during shader compilation.
  13037. */
  13038. onError: Nullable<(effect: Effect, errors: string) => void>;
  13039. /**
  13040. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13041. */
  13042. indexParameters: any;
  13043. /**
  13044. * Max number of lights that can be used in the shader.
  13045. */
  13046. maxSimultaneousLights: number;
  13047. /**
  13048. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13049. */
  13050. transformFeedbackVaryings: Nullable<string[]>;
  13051. }
  13052. /**
  13053. * Effect containing vertex and fragment shader that can be executed on an object.
  13054. */
  13055. class Effect {
  13056. /**
  13057. * Name of the effect.
  13058. */
  13059. name: any;
  13060. /**
  13061. * String container all the define statements that should be set on the shader.
  13062. */
  13063. defines: string;
  13064. /**
  13065. * Callback that will be called when the shader is compiled.
  13066. */
  13067. onCompiled: Nullable<(effect: Effect) => void>;
  13068. /**
  13069. * Callback that will be called if an error occurs during shader compilation.
  13070. */
  13071. onError: Nullable<(effect: Effect, errors: string) => void>;
  13072. /**
  13073. * Callback that will be called when effect is bound.
  13074. */
  13075. onBind: Nullable<(effect: Effect) => void>;
  13076. /**
  13077. * Unique ID of the effect.
  13078. */
  13079. uniqueId: number;
  13080. /**
  13081. * Observable that will be called when the shader is compiled.
  13082. */
  13083. onCompileObservable: Observable<Effect>;
  13084. /**
  13085. * Observable that will be called if an error occurs during shader compilation.
  13086. */
  13087. onErrorObservable: Observable<Effect>;
  13088. /**
  13089. * Observable that will be called when effect is bound.
  13090. */
  13091. onBindObservable: Observable<Effect>;
  13092. /** @hidden */
  13093. _bonesComputationForcedToCPU: boolean;
  13094. private static _uniqueIdSeed;
  13095. private _engine;
  13096. private _uniformBuffersNames;
  13097. private _uniformsNames;
  13098. private _samplers;
  13099. private _isReady;
  13100. private _compilationError;
  13101. private _attributesNames;
  13102. private _attributes;
  13103. private _uniforms;
  13104. /**
  13105. * Key for the effect.
  13106. */
  13107. _key: string;
  13108. private _indexParameters;
  13109. private _fallbacks;
  13110. private _vertexSourceCode;
  13111. private _fragmentSourceCode;
  13112. private _vertexSourceCodeOverride;
  13113. private _fragmentSourceCodeOverride;
  13114. private _transformFeedbackVaryings;
  13115. /**
  13116. * Compiled shader to webGL program.
  13117. */
  13118. _program: WebGLProgram;
  13119. private _valueCache;
  13120. private static _baseCache;
  13121. /**
  13122. * Instantiates an effect.
  13123. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13124. * @param baseName Name of the effect.
  13125. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13126. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13127. * @param samplers List of sampler variables that will be passed to the shader.
  13128. * @param engine Engine to be used to render the effect
  13129. * @param defines Define statements to be added to the shader.
  13130. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13131. * @param onCompiled Callback that will be called when the shader is compiled.
  13132. * @param onError Callback that will be called if an error occurs during shader compilation.
  13133. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13134. */
  13135. 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);
  13136. /**
  13137. * Unique key for this effect
  13138. */
  13139. readonly key: string;
  13140. /**
  13141. * If the effect has been compiled and prepared.
  13142. * @returns if the effect is compiled and prepared.
  13143. */
  13144. isReady(): boolean;
  13145. /**
  13146. * The engine the effect was initialized with.
  13147. * @returns the engine.
  13148. */
  13149. getEngine(): Engine;
  13150. /**
  13151. * The compiled webGL program for the effect
  13152. * @returns the webGL program.
  13153. */
  13154. getProgram(): WebGLProgram;
  13155. /**
  13156. * The set of names of attribute variables for the shader.
  13157. * @returns An array of attribute names.
  13158. */
  13159. getAttributesNames(): string[];
  13160. /**
  13161. * Returns the attribute at the given index.
  13162. * @param index The index of the attribute.
  13163. * @returns The location of the attribute.
  13164. */
  13165. getAttributeLocation(index: number): number;
  13166. /**
  13167. * Returns the attribute based on the name of the variable.
  13168. * @param name of the attribute to look up.
  13169. * @returns the attribute location.
  13170. */
  13171. getAttributeLocationByName(name: string): number;
  13172. /**
  13173. * The number of attributes.
  13174. * @returns the numnber of attributes.
  13175. */
  13176. getAttributesCount(): number;
  13177. /**
  13178. * Gets the index of a uniform variable.
  13179. * @param uniformName of the uniform to look up.
  13180. * @returns the index.
  13181. */
  13182. getUniformIndex(uniformName: string): number;
  13183. /**
  13184. * Returns the attribute based on the name of the variable.
  13185. * @param uniformName of the uniform to look up.
  13186. * @returns the location of the uniform.
  13187. */
  13188. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13189. /**
  13190. * Returns an array of sampler variable names
  13191. * @returns The array of sampler variable neames.
  13192. */
  13193. getSamplers(): string[];
  13194. /**
  13195. * The error from the last compilation.
  13196. * @returns the error string.
  13197. */
  13198. getCompilationError(): string;
  13199. /**
  13200. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13201. * @param func The callback to be used.
  13202. */
  13203. executeWhenCompiled(func: (effect: Effect) => void): void;
  13204. /** @hidden */
  13205. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13206. /** @hidden */
  13207. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13208. /** @hidden */
  13209. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13210. private _processShaderConversion(sourceCode, isFragment, callback);
  13211. private _processIncludes(sourceCode, callback);
  13212. private _processPrecision(source);
  13213. /**
  13214. * Recompiles the webGL program
  13215. * @param vertexSourceCode The source code for the vertex shader.
  13216. * @param fragmentSourceCode The source code for the fragment shader.
  13217. * @param onCompiled Callback called when completed.
  13218. * @param onError Callback called on error.
  13219. */
  13220. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13221. /**
  13222. * Gets the uniform locations of the the specified variable names
  13223. * @param names THe names of the variables to lookup.
  13224. * @returns Array of locations in the same order as variable names.
  13225. */
  13226. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13227. /**
  13228. * Prepares the effect
  13229. */
  13230. _prepareEffect(): void;
  13231. /**
  13232. * Checks if the effect is supported. (Must be called after compilation)
  13233. */
  13234. readonly isSupported: boolean;
  13235. /**
  13236. * Binds a texture to the engine to be used as output of the shader.
  13237. * @param channel Name of the output variable.
  13238. * @param texture Texture to bind.
  13239. */
  13240. _bindTexture(channel: string, texture: InternalTexture): void;
  13241. /**
  13242. * Sets a texture on the engine to be used in the shader.
  13243. * @param channel Name of the sampler variable.
  13244. * @param texture Texture to set.
  13245. */
  13246. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13247. /**
  13248. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13249. * @param channel Name of the sampler variable.
  13250. * @param texture Texture to set.
  13251. */
  13252. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13253. /**
  13254. * Sets an array of textures on the engine to be used in the shader.
  13255. * @param channel Name of the variable.
  13256. * @param textures Textures to set.
  13257. */
  13258. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13259. /**
  13260. * 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)
  13261. * @param channel Name of the sampler variable.
  13262. * @param postProcess Post process to get the input texture from.
  13263. */
  13264. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13265. /**
  13266. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13267. * 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)
  13268. * @param channel Name of the sampler variable.
  13269. * @param postProcess Post process to get the output texture from.
  13270. */
  13271. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13272. /** @hidden */
  13273. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13274. /** @hidden */
  13275. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13276. /** @hidden */
  13277. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13278. /** @hidden */
  13279. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13280. /**
  13281. * Binds a buffer to a uniform.
  13282. * @param buffer Buffer to bind.
  13283. * @param name Name of the uniform variable to bind to.
  13284. */
  13285. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13286. /**
  13287. * Binds block to a uniform.
  13288. * @param blockName Name of the block to bind.
  13289. * @param index Index to bind.
  13290. */
  13291. bindUniformBlock(blockName: string, index: number): void;
  13292. /**
  13293. * Sets an interger value on a uniform variable.
  13294. * @param uniformName Name of the variable.
  13295. * @param value Value to be set.
  13296. * @returns this effect.
  13297. */
  13298. setInt(uniformName: string, value: number): Effect;
  13299. /**
  13300. * Sets an int array on a uniform variable.
  13301. * @param uniformName Name of the variable.
  13302. * @param array array to be set.
  13303. * @returns this effect.
  13304. */
  13305. setIntArray(uniformName: string, array: Int32Array): Effect;
  13306. /**
  13307. * 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)
  13308. * @param uniformName Name of the variable.
  13309. * @param array array to be set.
  13310. * @returns this effect.
  13311. */
  13312. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13313. /**
  13314. * 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)
  13315. * @param uniformName Name of the variable.
  13316. * @param array array to be set.
  13317. * @returns this effect.
  13318. */
  13319. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13320. /**
  13321. * 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)
  13322. * @param uniformName Name of the variable.
  13323. * @param array array to be set.
  13324. * @returns this effect.
  13325. */
  13326. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13327. /**
  13328. * Sets an float array on a uniform variable.
  13329. * @param uniformName Name of the variable.
  13330. * @param array array to be set.
  13331. * @returns this effect.
  13332. */
  13333. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13334. /**
  13335. * 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)
  13336. * @param uniformName Name of the variable.
  13337. * @param array array to be set.
  13338. * @returns this effect.
  13339. */
  13340. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13341. /**
  13342. * 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)
  13343. * @param uniformName Name of the variable.
  13344. * @param array array to be set.
  13345. * @returns this effect.
  13346. */
  13347. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13348. /**
  13349. * 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)
  13350. * @param uniformName Name of the variable.
  13351. * @param array array to be set.
  13352. * @returns this effect.
  13353. */
  13354. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13355. /**
  13356. * Sets an array on a uniform variable.
  13357. * @param uniformName Name of the variable.
  13358. * @param array array to be set.
  13359. * @returns this effect.
  13360. */
  13361. setArray(uniformName: string, array: number[]): Effect;
  13362. /**
  13363. * 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)
  13364. * @param uniformName Name of the variable.
  13365. * @param array array to be set.
  13366. * @returns this effect.
  13367. */
  13368. setArray2(uniformName: string, array: number[]): Effect;
  13369. /**
  13370. * 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)
  13371. * @param uniformName Name of the variable.
  13372. * @param array array to be set.
  13373. * @returns this effect.
  13374. */
  13375. setArray3(uniformName: string, array: number[]): Effect;
  13376. /**
  13377. * 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)
  13378. * @param uniformName Name of the variable.
  13379. * @param array array to be set.
  13380. * @returns this effect.
  13381. */
  13382. setArray4(uniformName: string, array: number[]): Effect;
  13383. /**
  13384. * Sets matrices on a uniform variable.
  13385. * @param uniformName Name of the variable.
  13386. * @param matrices matrices to be set.
  13387. * @returns this effect.
  13388. */
  13389. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13390. /**
  13391. * Sets matrix on a uniform variable.
  13392. * @param uniformName Name of the variable.
  13393. * @param matrix matrix to be set.
  13394. * @returns this effect.
  13395. */
  13396. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13397. /**
  13398. * 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)
  13399. * @param uniformName Name of the variable.
  13400. * @param matrix matrix to be set.
  13401. * @returns this effect.
  13402. */
  13403. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13404. /**
  13405. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13406. * @param uniformName Name of the variable.
  13407. * @param matrix matrix to be set.
  13408. * @returns this effect.
  13409. */
  13410. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13411. /**
  13412. * Sets a float on a uniform variable.
  13413. * @param uniformName Name of the variable.
  13414. * @param value value to be set.
  13415. * @returns this effect.
  13416. */
  13417. setFloat(uniformName: string, value: number): Effect;
  13418. /**
  13419. * Sets a boolean on a uniform variable.
  13420. * @param uniformName Name of the variable.
  13421. * @param bool value to be set.
  13422. * @returns this effect.
  13423. */
  13424. setBool(uniformName: string, bool: boolean): Effect;
  13425. /**
  13426. * Sets a Vector2 on a uniform variable.
  13427. * @param uniformName Name of the variable.
  13428. * @param vector2 vector2 to be set.
  13429. * @returns this effect.
  13430. */
  13431. setVector2(uniformName: string, vector2: Vector2): Effect;
  13432. /**
  13433. * Sets a float2 on a uniform variable.
  13434. * @param uniformName Name of the variable.
  13435. * @param x First float in float2.
  13436. * @param y Second float in float2.
  13437. * @returns this effect.
  13438. */
  13439. setFloat2(uniformName: string, x: number, y: number): Effect;
  13440. /**
  13441. * Sets a Vector3 on a uniform variable.
  13442. * @param uniformName Name of the variable.
  13443. * @param vector3 Value to be set.
  13444. * @returns this effect.
  13445. */
  13446. setVector3(uniformName: string, vector3: Vector3): Effect;
  13447. /**
  13448. * Sets a float3 on a uniform variable.
  13449. * @param uniformName Name of the variable.
  13450. * @param x First float in float3.
  13451. * @param y Second float in float3.
  13452. * @param z Third float in float3.
  13453. * @returns this effect.
  13454. */
  13455. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13456. /**
  13457. * Sets a Vector4 on a uniform variable.
  13458. * @param uniformName Name of the variable.
  13459. * @param vector4 Value to be set.
  13460. * @returns this effect.
  13461. */
  13462. setVector4(uniformName: string, vector4: Vector4): Effect;
  13463. /**
  13464. * Sets a float4 on a uniform variable.
  13465. * @param uniformName Name of the variable.
  13466. * @param x First float in float4.
  13467. * @param y Second float in float4.
  13468. * @param z Third float in float4.
  13469. * @param w Fourth float in float4.
  13470. * @returns this effect.
  13471. */
  13472. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13473. /**
  13474. * Sets a Color3 on a uniform variable.
  13475. * @param uniformName Name of the variable.
  13476. * @param color3 Value to be set.
  13477. * @returns this effect.
  13478. */
  13479. setColor3(uniformName: string, color3: Color3): Effect;
  13480. /**
  13481. * Sets a Color4 on a uniform variable.
  13482. * @param uniformName Name of the variable.
  13483. * @param color3 Value to be set.
  13484. * @param alpha Alpha value to be set.
  13485. * @returns this effect.
  13486. */
  13487. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13488. /**
  13489. * Sets a Color4 on a uniform variable
  13490. * @param uniformName defines the name of the variable
  13491. * @param color4 defines the value to be set
  13492. * @returns this effect.
  13493. */
  13494. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13495. /**
  13496. * Store of each shader (The can be looked up using effect.key)
  13497. */
  13498. static ShadersStore: {
  13499. [key: string]: string;
  13500. };
  13501. /**
  13502. * Store of each included file for a shader (The can be looked up using effect.key)
  13503. */
  13504. static IncludesShadersStore: {
  13505. [key: string]: string;
  13506. };
  13507. /**
  13508. * Resets the cache of effects.
  13509. */
  13510. static ResetCache(): void;
  13511. }
  13512. }
  13513. declare module BABYLON {
  13514. class FresnelParameters {
  13515. private _isEnabled;
  13516. isEnabled: boolean;
  13517. leftColor: Color3;
  13518. rightColor: Color3;
  13519. bias: number;
  13520. power: number;
  13521. clone(): FresnelParameters;
  13522. serialize(): any;
  13523. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13524. }
  13525. }
  13526. declare module BABYLON {
  13527. /**
  13528. * Interface to follow in your material defines to integrate easily the
  13529. * Image proccessing functions.
  13530. * @hidden
  13531. */
  13532. interface IImageProcessingConfigurationDefines {
  13533. IMAGEPROCESSING: boolean;
  13534. VIGNETTE: boolean;
  13535. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13536. VIGNETTEBLENDMODEOPAQUE: boolean;
  13537. TONEMAPPING: boolean;
  13538. CONTRAST: boolean;
  13539. EXPOSURE: boolean;
  13540. COLORCURVES: boolean;
  13541. COLORGRADING: boolean;
  13542. COLORGRADING3D: boolean;
  13543. SAMPLER3DGREENDEPTH: boolean;
  13544. SAMPLER3DBGRMAP: boolean;
  13545. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13546. }
  13547. /**
  13548. * This groups together the common properties used for image processing either in direct forward pass
  13549. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13550. * or not.
  13551. */
  13552. class ImageProcessingConfiguration {
  13553. /**
  13554. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13555. */
  13556. colorCurves: Nullable<ColorCurves>;
  13557. private _colorCurvesEnabled;
  13558. /**
  13559. * Gets wether the color curves effect is enabled.
  13560. */
  13561. /**
  13562. * Sets wether the color curves effect is enabled.
  13563. */
  13564. colorCurvesEnabled: boolean;
  13565. /**
  13566. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13567. */
  13568. colorGradingTexture: Nullable<BaseTexture>;
  13569. private _colorGradingEnabled;
  13570. /**
  13571. * Gets wether the color grading effect is enabled.
  13572. */
  13573. /**
  13574. * Sets wether the color grading effect is enabled.
  13575. */
  13576. colorGradingEnabled: boolean;
  13577. private _colorGradingWithGreenDepth;
  13578. /**
  13579. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13580. */
  13581. /**
  13582. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13583. */
  13584. colorGradingWithGreenDepth: boolean;
  13585. private _colorGradingBGR;
  13586. /**
  13587. * Gets wether the color grading texture contains BGR values.
  13588. */
  13589. /**
  13590. * Sets wether the color grading texture contains BGR values.
  13591. */
  13592. colorGradingBGR: boolean;
  13593. _exposure: number;
  13594. /**
  13595. * Gets the Exposure used in the effect.
  13596. */
  13597. /**
  13598. * Sets the Exposure used in the effect.
  13599. */
  13600. exposure: number;
  13601. private _toneMappingEnabled;
  13602. /**
  13603. * Gets wether the tone mapping effect is enabled.
  13604. */
  13605. /**
  13606. * Sets wether the tone mapping effect is enabled.
  13607. */
  13608. toneMappingEnabled: boolean;
  13609. protected _contrast: number;
  13610. /**
  13611. * Gets the contrast used in the effect.
  13612. */
  13613. /**
  13614. * Sets the contrast used in the effect.
  13615. */
  13616. contrast: number;
  13617. /**
  13618. * Vignette stretch size.
  13619. */
  13620. vignetteStretch: number;
  13621. /**
  13622. * Vignette centre X Offset.
  13623. */
  13624. vignetteCentreX: number;
  13625. /**
  13626. * Vignette centre Y Offset.
  13627. */
  13628. vignetteCentreY: number;
  13629. /**
  13630. * Vignette weight or intensity of the vignette effect.
  13631. */
  13632. vignetteWeight: number;
  13633. /**
  13634. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13635. * if vignetteEnabled is set to true.
  13636. */
  13637. vignetteColor: Color4;
  13638. /**
  13639. * Camera field of view used by the Vignette effect.
  13640. */
  13641. vignetteCameraFov: number;
  13642. private _vignetteBlendMode;
  13643. /**
  13644. * Gets the vignette blend mode allowing different kind of effect.
  13645. */
  13646. /**
  13647. * Sets the vignette blend mode allowing different kind of effect.
  13648. */
  13649. vignetteBlendMode: number;
  13650. private _vignetteEnabled;
  13651. /**
  13652. * Gets wether the vignette effect is enabled.
  13653. */
  13654. /**
  13655. * Sets wether the vignette effect is enabled.
  13656. */
  13657. vignetteEnabled: boolean;
  13658. private _applyByPostProcess;
  13659. /**
  13660. * Gets wether the image processing is applied through a post process or not.
  13661. */
  13662. /**
  13663. * Sets wether the image processing is applied through a post process or not.
  13664. */
  13665. applyByPostProcess: boolean;
  13666. private _isEnabled;
  13667. /**
  13668. * Gets wether the image processing is enabled or not.
  13669. */
  13670. /**
  13671. * Sets wether the image processing is enabled or not.
  13672. */
  13673. isEnabled: boolean;
  13674. /**
  13675. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13676. */
  13677. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13678. /**
  13679. * Method called each time the image processing information changes requires to recompile the effect.
  13680. */
  13681. protected _updateParameters(): void;
  13682. getClassName(): string;
  13683. /**
  13684. * Prepare the list of uniforms associated with the Image Processing effects.
  13685. * @param uniformsList The list of uniforms used in the effect
  13686. * @param defines the list of defines currently in use
  13687. */
  13688. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13689. /**
  13690. * Prepare the list of samplers associated with the Image Processing effects.
  13691. * @param uniformsList The list of uniforms used in the effect
  13692. * @param defines the list of defines currently in use
  13693. */
  13694. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13695. /**
  13696. * Prepare the list of defines associated to the shader.
  13697. * @param defines the list of defines to complete
  13698. */
  13699. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13700. /**
  13701. * Returns true if all the image processing information are ready.
  13702. */
  13703. isReady(): boolean;
  13704. /**
  13705. * Binds the image processing to the shader.
  13706. * @param effect The effect to bind to
  13707. */
  13708. bind(effect: Effect, aspectRatio?: number): void;
  13709. /**
  13710. * Clones the current image processing instance.
  13711. * @return The cloned image processing
  13712. */
  13713. clone(): ImageProcessingConfiguration;
  13714. /**
  13715. * Serializes the current image processing instance to a json representation.
  13716. * @return a JSON representation
  13717. */
  13718. serialize(): any;
  13719. /**
  13720. * Parses the image processing from a json representation.
  13721. * @param source the JSON source to parse
  13722. * @return The parsed image processing
  13723. */
  13724. static Parse(source: any): ImageProcessingConfiguration;
  13725. private static _VIGNETTEMODE_MULTIPLY;
  13726. private static _VIGNETTEMODE_OPAQUE;
  13727. /**
  13728. * Used to apply the vignette as a mix with the pixel color.
  13729. */
  13730. static readonly VIGNETTEMODE_MULTIPLY: number;
  13731. /**
  13732. * Used to apply the vignette as a replacement of the pixel color.
  13733. */
  13734. static readonly VIGNETTEMODE_OPAQUE: number;
  13735. }
  13736. }
  13737. declare module BABYLON {
  13738. /**
  13739. * Manages the defines for the Material
  13740. */
  13741. class MaterialDefines {
  13742. private _keys;
  13743. private _isDirty;
  13744. /** @hidden */
  13745. _renderId: number;
  13746. /** @hidden */
  13747. _areLightsDirty: boolean;
  13748. /** @hidden */
  13749. _areAttributesDirty: boolean;
  13750. /** @hidden */
  13751. _areTexturesDirty: boolean;
  13752. /** @hidden */
  13753. _areFresnelDirty: boolean;
  13754. /** @hidden */
  13755. _areMiscDirty: boolean;
  13756. /** @hidden */
  13757. _areImageProcessingDirty: boolean;
  13758. /** @hidden */
  13759. _normals: boolean;
  13760. /** @hidden */
  13761. _uvs: boolean;
  13762. /** @hidden */
  13763. _needNormals: boolean;
  13764. /** @hidden */
  13765. _needUVs: boolean;
  13766. /**
  13767. * Specifies if the material needs to be re-calculated
  13768. */
  13769. readonly isDirty: boolean;
  13770. /**
  13771. * Marks the material to indicate that it has been re-calculated
  13772. */
  13773. markAsProcessed(): void;
  13774. /**
  13775. * Marks the material to indicate that it needs to be re-calculated
  13776. */
  13777. markAsUnprocessed(): void;
  13778. /**
  13779. * Marks the material to indicate all of its defines need to be re-calculated
  13780. */
  13781. markAllAsDirty(): void;
  13782. /**
  13783. * Marks the material to indicate that image processing needs to be re-calculated
  13784. */
  13785. markAsImageProcessingDirty(): void;
  13786. /**
  13787. * Marks the material to indicate the lights need to be re-calculated
  13788. */
  13789. markAsLightDirty(): void;
  13790. /**
  13791. * Marks the attribute state as changed
  13792. */
  13793. markAsAttributesDirty(): void;
  13794. /**
  13795. * Marks the texture state as changed
  13796. */
  13797. markAsTexturesDirty(): void;
  13798. /**
  13799. * Marks the fresnel state as changed
  13800. */
  13801. markAsFresnelDirty(): void;
  13802. /**
  13803. * Marks the misc state as changed
  13804. */
  13805. markAsMiscDirty(): void;
  13806. /**
  13807. * Rebuilds the material defines
  13808. */
  13809. rebuild(): void;
  13810. /**
  13811. * Specifies if two material defines are equal
  13812. * @param other - A material define instance to compare to
  13813. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13814. */
  13815. isEqual(other: MaterialDefines): boolean;
  13816. /**
  13817. * Clones this instance's defines to another instance
  13818. * @param other - material defines to clone values to
  13819. */
  13820. cloneTo(other: MaterialDefines): void;
  13821. /**
  13822. * Resets the material define values
  13823. */
  13824. reset(): void;
  13825. /**
  13826. * Converts the material define values to a string
  13827. * @returns - String of material define information
  13828. */
  13829. toString(): string;
  13830. }
  13831. /**
  13832. * Base class for the main features of a material in Babylon.js
  13833. */
  13834. class Material implements IAnimatable {
  13835. private static _TriangleFillMode;
  13836. private static _WireFrameFillMode;
  13837. private static _PointFillMode;
  13838. private static _PointListDrawMode;
  13839. private static _LineListDrawMode;
  13840. private static _LineLoopDrawMode;
  13841. private static _LineStripDrawMode;
  13842. private static _TriangleStripDrawMode;
  13843. private static _TriangleFanDrawMode;
  13844. /**
  13845. * Returns the triangle fill mode
  13846. */
  13847. static readonly TriangleFillMode: number;
  13848. /**
  13849. * Returns the wireframe mode
  13850. */
  13851. static readonly WireFrameFillMode: number;
  13852. /**
  13853. * Returns the point fill mode
  13854. */
  13855. static readonly PointFillMode: number;
  13856. /**
  13857. * Returns the point list draw mode
  13858. */
  13859. static readonly PointListDrawMode: number;
  13860. /**
  13861. * Returns the line list draw mode
  13862. */
  13863. static readonly LineListDrawMode: number;
  13864. /**
  13865. * Returns the line loop draw mode
  13866. */
  13867. static readonly LineLoopDrawMode: number;
  13868. /**
  13869. * Returns the line strip draw mode
  13870. */
  13871. static readonly LineStripDrawMode: number;
  13872. /**
  13873. * Returns the triangle strip draw mode
  13874. */
  13875. static readonly TriangleStripDrawMode: number;
  13876. /**
  13877. * Returns the triangle fan draw mode
  13878. */
  13879. static readonly TriangleFanDrawMode: number;
  13880. /**
  13881. * Stores the clock-wise side orientation
  13882. */
  13883. private static _ClockWiseSideOrientation;
  13884. /**
  13885. * Stores the counter clock-wise side orientation
  13886. */
  13887. private static _CounterClockWiseSideOrientation;
  13888. /**
  13889. * Returns the clock-wise side orientation
  13890. */
  13891. static readonly ClockWiseSideOrientation: number;
  13892. /**
  13893. * Returns the counter clock-wise side orientation
  13894. */
  13895. static readonly CounterClockWiseSideOrientation: number;
  13896. /**
  13897. * The dirty texture flag value
  13898. */
  13899. private static _TextureDirtyFlag;
  13900. /**
  13901. * The dirty light flag value
  13902. */
  13903. private static _LightDirtyFlag;
  13904. /**
  13905. * The dirty fresnel flag value
  13906. */
  13907. private static _FresnelDirtyFlag;
  13908. /**
  13909. * The dirty attribute flag value
  13910. */
  13911. private static _AttributesDirtyFlag;
  13912. /**
  13913. * The dirty misc flag value
  13914. */
  13915. private static _MiscDirtyFlag;
  13916. /**
  13917. * Returns the dirty texture flag value
  13918. */
  13919. static readonly TextureDirtyFlag: number;
  13920. /**
  13921. * Returns the dirty light flag value
  13922. */
  13923. static readonly LightDirtyFlag: number;
  13924. /**
  13925. * Returns the dirty fresnel flag value
  13926. */
  13927. static readonly FresnelDirtyFlag: number;
  13928. /**
  13929. * Returns the dirty attributes flag value
  13930. */
  13931. static readonly AttributesDirtyFlag: number;
  13932. /**
  13933. * Returns the dirty misc flag value
  13934. */
  13935. static readonly MiscDirtyFlag: number;
  13936. /**
  13937. * The ID of the material
  13938. */
  13939. id: string;
  13940. /**
  13941. * Gets or sets the unique id of the material
  13942. */
  13943. uniqueId: number;
  13944. /**
  13945. * The name of the material
  13946. */
  13947. name: string;
  13948. /**
  13949. * Specifies if the ready state should be checked on each call
  13950. */
  13951. checkReadyOnEveryCall: boolean;
  13952. /**
  13953. * Specifies if the ready state should be checked once
  13954. */
  13955. checkReadyOnlyOnce: boolean;
  13956. /**
  13957. * The state of the material
  13958. */
  13959. state: string;
  13960. /**
  13961. * The alpha value of the material
  13962. */
  13963. protected _alpha: number;
  13964. /**
  13965. * Gets the alpha value of the material
  13966. */
  13967. /**
  13968. * Sets the alpha value of the material
  13969. */
  13970. alpha: number;
  13971. /**
  13972. * Specifies if back face culling is enabled
  13973. */
  13974. protected _backFaceCulling: boolean;
  13975. /**
  13976. * Gets the back-face culling state
  13977. */
  13978. /**
  13979. * Sets the back-face culling state
  13980. */
  13981. backFaceCulling: boolean;
  13982. /**
  13983. * Stores the value for side orientation
  13984. */
  13985. sideOrientation: number;
  13986. /**
  13987. * Callback triggered when the material is compiled
  13988. */
  13989. onCompiled: (effect: Effect) => void;
  13990. /**
  13991. * Callback triggered when an error occurs
  13992. */
  13993. onError: (effect: Effect, errors: string) => void;
  13994. /**
  13995. * Callback triggered to get the render target textures
  13996. */
  13997. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13998. /**
  13999. * Specifies if the material should be serialized
  14000. */
  14001. doNotSerialize: boolean;
  14002. /**
  14003. * Specifies if the effect should be stored on sub meshes
  14004. */
  14005. storeEffectOnSubMeshes: boolean;
  14006. /**
  14007. * Stores the animations for the material
  14008. */
  14009. animations: Array<Animation>;
  14010. /**
  14011. * An event triggered when the material is disposed
  14012. */
  14013. onDisposeObservable: Observable<Material>;
  14014. /**
  14015. * An observer which watches for dispose events
  14016. */
  14017. private _onDisposeObserver;
  14018. /**
  14019. * Called during a dispose event
  14020. */
  14021. onDispose: () => void;
  14022. /**
  14023. * An event triggered when the material is bound
  14024. */
  14025. onBindObservable: Observable<AbstractMesh>;
  14026. /**
  14027. * An observer which watches for bind events
  14028. */
  14029. private _onBindObserver;
  14030. /**
  14031. * Called during a bind event
  14032. */
  14033. onBind: (Mesh: AbstractMesh) => void;
  14034. /**
  14035. * An event triggered when the material is unbound
  14036. */
  14037. onUnBindObservable: Observable<Material>;
  14038. /**
  14039. * Stores the value of the alpha mode
  14040. */
  14041. private _alphaMode;
  14042. /**
  14043. * Gets the value of the alpha mode
  14044. */
  14045. /**
  14046. * Sets the value of the alpha mode.
  14047. *
  14048. * | Value | Type | Description |
  14049. * | --- | --- | --- |
  14050. * | 0 | ALPHA_DISABLE | |
  14051. * | 1 | ALPHA_ADD | |
  14052. * | 2 | ALPHA_COMBINE | |
  14053. * | 3 | ALPHA_SUBTRACT | |
  14054. * | 4 | ALPHA_MULTIPLY | |
  14055. * | 5 | ALPHA_MAXIMIZED | |
  14056. * | 6 | ALPHA_ONEONE | |
  14057. * | 7 | ALPHA_PREMULTIPLIED | |
  14058. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14059. * | 9 | ALPHA_INTERPOLATE | |
  14060. * | 10 | ALPHA_SCREENMODE | |
  14061. *
  14062. */
  14063. alphaMode: number;
  14064. /**
  14065. * Stores the state of the need depth pre-pass value
  14066. */
  14067. private _needDepthPrePass;
  14068. /**
  14069. * Gets the depth pre-pass value
  14070. */
  14071. /**
  14072. * Sets the need depth pre-pass value
  14073. */
  14074. needDepthPrePass: boolean;
  14075. /**
  14076. * Specifies if depth writing should be disabled
  14077. */
  14078. disableDepthWrite: boolean;
  14079. /**
  14080. * Specifies if depth writing should be forced
  14081. */
  14082. forceDepthWrite: boolean;
  14083. /**
  14084. * Specifies if there should be a separate pass for culling
  14085. */
  14086. separateCullingPass: boolean;
  14087. /**
  14088. * Stores the state specifing if fog should be enabled
  14089. */
  14090. private _fogEnabled;
  14091. /**
  14092. * Gets the value of the fog enabled state
  14093. */
  14094. /**
  14095. * Sets the state for enabling fog
  14096. */
  14097. fogEnabled: boolean;
  14098. /**
  14099. * Stores the size of points
  14100. */
  14101. pointSize: number;
  14102. /**
  14103. * Stores the z offset value
  14104. */
  14105. zOffset: number;
  14106. /**
  14107. * Gets a value specifying if wireframe mode is enabled
  14108. */
  14109. /**
  14110. * Sets the state of wireframe mode
  14111. */
  14112. wireframe: boolean;
  14113. /**
  14114. * Gets the value specifying if point clouds are enabled
  14115. */
  14116. /**
  14117. * Sets the state of point cloud mode
  14118. */
  14119. pointsCloud: boolean;
  14120. /**
  14121. * Gets the material fill mode
  14122. */
  14123. /**
  14124. * Sets the material fill mode
  14125. */
  14126. fillMode: number;
  14127. /**
  14128. * Stores the effects for the material
  14129. */
  14130. _effect: Nullable<Effect>;
  14131. /**
  14132. * Specifies if the material was previously ready
  14133. */
  14134. _wasPreviouslyReady: boolean;
  14135. /**
  14136. * Specifies if uniform buffers should be used
  14137. */
  14138. private _useUBO;
  14139. /**
  14140. * Stores a reference to the scene
  14141. */
  14142. private _scene;
  14143. /**
  14144. * Stores the fill mode state
  14145. */
  14146. private _fillMode;
  14147. /**
  14148. * Specifies if the depth write state should be cached
  14149. */
  14150. private _cachedDepthWriteState;
  14151. /**
  14152. * Stores the uniform buffer
  14153. */
  14154. protected _uniformBuffer: UniformBuffer;
  14155. /**
  14156. * Creates a material instance
  14157. * @param name defines the name of the material
  14158. * @param scene defines the scene to reference
  14159. * @param doNotAdd specifies if the material should be added to the scene
  14160. */
  14161. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14162. /**
  14163. * Returns a string representation of the current material
  14164. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14165. * @returns a string with material information
  14166. */
  14167. toString(fullDetails?: boolean): string;
  14168. /**
  14169. * Gets the class name of the material
  14170. * @returns a string with the class name of the material
  14171. */
  14172. getClassName(): string;
  14173. /**
  14174. * Specifies if updates for the material been locked
  14175. */
  14176. readonly isFrozen: boolean;
  14177. /**
  14178. * Locks updates for the material
  14179. */
  14180. freeze(): void;
  14181. /**
  14182. * Unlocks updates for the material
  14183. */
  14184. unfreeze(): void;
  14185. /**
  14186. * Specifies if the material is ready to be used
  14187. * @param mesh defines the mesh to check
  14188. * @param useInstances specifies if instances should be used
  14189. * @returns a boolean indicating if the material is ready to be used
  14190. */
  14191. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14192. /**
  14193. * Specifies that the submesh is ready to be used
  14194. * @param mesh defines the mesh to check
  14195. * @param subMesh defines which submesh to check
  14196. * @param useInstances specifies that instances should be used
  14197. * @returns a boolean indicating that the submesh is ready or not
  14198. */
  14199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14200. /**
  14201. * Returns the material effect
  14202. * @returns the effect associated with the material
  14203. */
  14204. getEffect(): Nullable<Effect>;
  14205. /**
  14206. * Returns the current scene
  14207. * @returns a Scene
  14208. */
  14209. getScene(): Scene;
  14210. /**
  14211. * Specifies if the material will require alpha blending
  14212. * @returns a boolean specifying if alpha blending is needed
  14213. */
  14214. needAlphaBlending(): boolean;
  14215. /**
  14216. * Specifies if the mesh will require alpha blending
  14217. * @param mesh defines the mesh to check
  14218. * @returns a boolean specifying if alpha blending is needed for the mesh
  14219. */
  14220. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14221. /**
  14222. * Specifies if this material should be rendered in alpha test mode
  14223. * @returns a boolean specifying if an alpha test is needed.
  14224. */
  14225. needAlphaTesting(): boolean;
  14226. /**
  14227. * Gets the texture used for the alpha test
  14228. * @returns the texture to use for alpha testing
  14229. */
  14230. getAlphaTestTexture(): Nullable<BaseTexture>;
  14231. /**
  14232. * Marks the material to indicate that it needs to be re-calculated
  14233. */
  14234. markDirty(): void;
  14235. /** @hidden */
  14236. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14237. /**
  14238. * Binds the material to the mesh
  14239. * @param world defines the world transformation matrix
  14240. * @param mesh defines the mesh to bind the material to
  14241. */
  14242. bind(world: Matrix, mesh?: Mesh): void;
  14243. /**
  14244. * Binds the submesh to the material
  14245. * @param world defines the world transformation matrix
  14246. * @param mesh defines the mesh containing the submesh
  14247. * @param subMesh defines the submesh to bind the material to
  14248. */
  14249. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14250. /**
  14251. * Binds the world matrix to the material
  14252. * @param world defines the world transformation matrix
  14253. */
  14254. bindOnlyWorldMatrix(world: Matrix): void;
  14255. /**
  14256. * Binds the scene's uniform buffer to the effect.
  14257. * @param effect defines the effect to bind to the scene uniform buffer
  14258. * @param sceneUbo defines the uniform buffer storing scene data
  14259. */
  14260. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14261. /**
  14262. * Binds the view matrix to the effect
  14263. * @param effect defines the effect to bind the view matrix to
  14264. */
  14265. bindView(effect: Effect): void;
  14266. /**
  14267. * Binds the view projection matrix to the effect
  14268. * @param effect defines the effect to bind the view projection matrix to
  14269. */
  14270. bindViewProjection(effect: Effect): void;
  14271. /**
  14272. * Specifies if material alpha testing should be turned on for the mesh
  14273. * @param mesh defines the mesh to check
  14274. */
  14275. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14276. /**
  14277. * Processes to execute after binding the material to a mesh
  14278. * @param mesh defines the rendered mesh
  14279. */
  14280. protected _afterBind(mesh?: Mesh): void;
  14281. /**
  14282. * Unbinds the material from the mesh
  14283. */
  14284. unbind(): void;
  14285. /**
  14286. * Gets the active textures from the material
  14287. * @returns an array of textures
  14288. */
  14289. getActiveTextures(): BaseTexture[];
  14290. /**
  14291. * Specifies if the material uses a texture
  14292. * @param texture defines the texture to check against the material
  14293. * @returns a boolean specifying if the material uses the texture
  14294. */
  14295. hasTexture(texture: BaseTexture): boolean;
  14296. /**
  14297. * Makes a duplicate of the material, and gives it a new name
  14298. * @param name defines the new name for the duplicated material
  14299. * @returns the cloned material
  14300. */
  14301. clone(name: string): Nullable<Material>;
  14302. /**
  14303. * Gets the meshes bound to the material
  14304. * @returns an array of meshes bound to the material
  14305. */
  14306. getBindedMeshes(): AbstractMesh[];
  14307. /**
  14308. * Force shader compilation
  14309. * @param mesh defines the mesh associated with this material
  14310. * @param onCompiled defines a function to execute once the material is compiled
  14311. * @param options defines the options to configure the compilation
  14312. */
  14313. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14314. clipPlane: boolean;
  14315. }>): void;
  14316. /**
  14317. * Force shader compilation
  14318. * @param mesh defines the mesh that will use this material
  14319. * @param options defines additional options for compiling the shaders
  14320. * @returns a promise that resolves when the compilation completes
  14321. */
  14322. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14323. clipPlane: boolean;
  14324. }>): Promise<void>;
  14325. /**
  14326. * Marks a define in the material to indicate that it needs to be re-computed
  14327. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14328. */
  14329. markAsDirty(flag: number): void;
  14330. /**
  14331. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14332. * @param func defines a function which checks material defines against the submeshes
  14333. */
  14334. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14335. /**
  14336. * Indicates that image processing needs to be re-calculated for all submeshes
  14337. */
  14338. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14339. /**
  14340. * Indicates that textures need to be re-calculated for all submeshes
  14341. */
  14342. protected _markAllSubMeshesAsTexturesDirty(): void;
  14343. /**
  14344. * Indicates that fresnel needs to be re-calculated for all submeshes
  14345. */
  14346. protected _markAllSubMeshesAsFresnelDirty(): void;
  14347. /**
  14348. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14349. */
  14350. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14351. /**
  14352. * Indicates that lights need to be re-calculated for all submeshes
  14353. */
  14354. protected _markAllSubMeshesAsLightsDirty(): void;
  14355. /**
  14356. * Indicates that attributes need to be re-calculated for all submeshes
  14357. */
  14358. protected _markAllSubMeshesAsAttributesDirty(): void;
  14359. /**
  14360. * Indicates that misc needs to be re-calculated for all submeshes
  14361. */
  14362. protected _markAllSubMeshesAsMiscDirty(): void;
  14363. /**
  14364. * Indicates that textures and misc need to be re-calculated for all submeshes
  14365. */
  14366. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14367. /**
  14368. * Disposes the material
  14369. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14370. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14371. */
  14372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14373. /**
  14374. * Serializes this material
  14375. * @returns the serialized material object
  14376. */
  14377. serialize(): any;
  14378. /**
  14379. * Creates a MultiMaterial from parsed MultiMaterial data.
  14380. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14381. * @param scene defines the hosting scene
  14382. * @returns a new MultiMaterial
  14383. */
  14384. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14385. /**
  14386. * Creates a material from parsed material data
  14387. * @param parsedMaterial defines parsed material data
  14388. * @param scene defines the hosting scene
  14389. * @param rootUrl defines the root URL to use to load textures
  14390. * @returns a new material
  14391. */
  14392. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14393. }
  14394. }
  14395. declare module BABYLON {
  14396. /**
  14397. * "Static Class" containing the most commonly used helper while dealing with material for
  14398. * rendering purpose.
  14399. *
  14400. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14401. *
  14402. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14403. */
  14404. class MaterialHelper {
  14405. /**
  14406. * Bind the current view position to an effect.
  14407. * @param effect The effect to be bound
  14408. * @param scene The scene the eyes position is used from
  14409. */
  14410. static BindEyePosition(effect: Effect, scene: Scene): void;
  14411. /**
  14412. * Helps preparing the defines values about the UVs in used in the effect.
  14413. * UVs are shared as much as we can accross chanels in the shaders.
  14414. * @param texture The texture we are preparing the UVs for
  14415. * @param defines The defines to update
  14416. * @param key The chanel key "diffuse", "specular"... used in the shader
  14417. */
  14418. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14419. /**
  14420. * Binds a texture matrix value to its corrsponding uniform
  14421. * @param texture The texture to bind the matrix for
  14422. * @param uniformBuffer The uniform buffer receivin the data
  14423. * @param key The chanel key "diffuse", "specular"... used in the shader
  14424. */
  14425. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14426. /**
  14427. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14428. * @param mesh defines the current mesh
  14429. * @param scene defines the current scene
  14430. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14431. * @param pointsCloud defines if point cloud rendering has to be turned on
  14432. * @param fogEnabled defines if fog has to be turned on
  14433. * @param alphaTest defines if alpha testing has to be turned on
  14434. * @param defines defines the current list of defines
  14435. */
  14436. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14437. /**
  14438. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14439. * @param scene defines the current scene
  14440. * @param engine defines the current engine
  14441. * @param defines specifies the list of active defines
  14442. * @param useInstances defines if instances have to be turned on
  14443. * @param useClipPlane defines if clip plane have to be turned on
  14444. */
  14445. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14446. /**
  14447. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14448. * @param mesh The mesh containing the geometry data we will draw
  14449. * @param defines The defines to update
  14450. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14451. * @param useBones Precise whether bones should be used or not (override mesh info)
  14452. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14453. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14454. * @returns false if defines are considered not dirty and have not been checked
  14455. */
  14456. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14457. /**
  14458. * Prepares the defines related to the light information passed in parameter
  14459. * @param scene The scene we are intending to draw
  14460. * @param mesh The mesh the effect is compiling for
  14461. * @param defines The defines to update
  14462. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14463. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14464. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14465. * @returns true if normals will be required for the rest of the effect
  14466. */
  14467. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14468. /**
  14469. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14470. * that won t be acctive due to defines being turned off.
  14471. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14472. * @param samplersList The samplers list
  14473. * @param defines The defines helping in the list generation
  14474. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14475. */
  14476. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14477. /**
  14478. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14479. * @param defines The defines to update while falling back
  14480. * @param fallbacks The authorized effect fallbacks
  14481. * @param maxSimultaneousLights The maximum number of lights allowed
  14482. * @param rank the current rank of the Effect
  14483. * @returns The newly affected rank
  14484. */
  14485. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14486. /**
  14487. * Prepares the list of attributes required for morph targets according to the effect defines.
  14488. * @param attribs The current list of supported attribs
  14489. * @param mesh The mesh to prepare the morph targets attributes for
  14490. * @param defines The current Defines of the effect
  14491. */
  14492. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14493. /**
  14494. * Prepares the list of attributes required for bones according to the effect defines.
  14495. * @param attribs The current list of supported attribs
  14496. * @param mesh The mesh to prepare the bones attributes for
  14497. * @param defines The current Defines of the effect
  14498. * @param fallbacks The current efffect fallback strategy
  14499. */
  14500. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14501. /**
  14502. * Prepares the list of attributes required for instances according to the effect defines.
  14503. * @param attribs The current list of supported attribs
  14504. * @param defines The current Defines of the effect
  14505. */
  14506. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14507. /**
  14508. * Binds the light shadow information to the effect for the given mesh.
  14509. * @param light The light containing the generator
  14510. * @param scene The scene the lights belongs to
  14511. * @param mesh The mesh we are binding the information to render
  14512. * @param lightIndex The light index in the effect used to render the mesh
  14513. * @param effect The effect we are binding the data to
  14514. */
  14515. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14516. /**
  14517. * Binds the light information to the effect.
  14518. * @param light The light containing the generator
  14519. * @param effect The effect we are binding the data to
  14520. * @param lightIndex The light index in the effect used to render
  14521. */
  14522. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14523. /**
  14524. * Binds the lights information from the scene to the effect for the given mesh.
  14525. * @param scene The scene the lights belongs to
  14526. * @param mesh The mesh we are binding the information to render
  14527. * @param effect The effect we are binding the data to
  14528. * @param defines The generated defines for the effect
  14529. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14530. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14531. */
  14532. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14533. /**
  14534. * Binds the fog information from the scene to the effect for the given mesh.
  14535. * @param scene The scene the lights belongs to
  14536. * @param mesh The mesh we are binding the information to render
  14537. * @param effect The effect we are binding the data to
  14538. */
  14539. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14540. /**
  14541. * Binds the bones information from the mesh to the effect.
  14542. * @param mesh The mesh we are binding the information to render
  14543. * @param effect The effect we are binding the data to
  14544. */
  14545. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14546. /**
  14547. * Binds the morph targets information from the mesh to the effect.
  14548. * @param abstractMesh The mesh we are binding the information to render
  14549. * @param effect The effect we are binding the data to
  14550. */
  14551. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14552. /**
  14553. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14554. * @param defines The generated defines used in the effect
  14555. * @param effect The effect we are binding the data to
  14556. * @param scene The scene we are willing to render with logarithmic scale for
  14557. */
  14558. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14559. /**
  14560. * Binds the clip plane information from the scene to the effect.
  14561. * @param scene The scene the clip plane information are extracted from
  14562. * @param effect The effect we are binding the data to
  14563. */
  14564. static BindClipPlane(effect: Effect, scene: Scene): void;
  14565. }
  14566. }
  14567. declare module BABYLON {
  14568. class MultiMaterial extends Material {
  14569. private _subMaterials;
  14570. subMaterials: Nullable<Material>[];
  14571. constructor(name: string, scene: Scene);
  14572. private _hookArray(array);
  14573. getSubMaterial(index: number): Nullable<Material>;
  14574. getActiveTextures(): BaseTexture[];
  14575. getClassName(): string;
  14576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14577. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14578. serialize(): any;
  14579. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14580. }
  14581. }
  14582. declare module BABYLON {
  14583. class PushMaterial extends Material {
  14584. protected _activeEffect: Effect;
  14585. protected _normalMatrix: Matrix;
  14586. constructor(name: string, scene: Scene);
  14587. getEffect(): Effect;
  14588. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14589. /**
  14590. * Binds the given world matrix to the active effect
  14591. *
  14592. * @param world the matrix to bind
  14593. */
  14594. bindOnlyWorldMatrix(world: Matrix): void;
  14595. /**
  14596. * Binds the given normal matrix to the active effect
  14597. *
  14598. * @param normalMatrix the matrix to bind
  14599. */
  14600. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14601. bind(world: Matrix, mesh?: Mesh): void;
  14602. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14603. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14604. }
  14605. }
  14606. declare module BABYLON {
  14607. class ShaderMaterial extends Material {
  14608. private _shaderPath;
  14609. private _options;
  14610. private _textures;
  14611. private _textureArrays;
  14612. private _floats;
  14613. private _ints;
  14614. private _floatsArrays;
  14615. private _colors3;
  14616. private _colors3Arrays;
  14617. private _colors4;
  14618. private _vectors2;
  14619. private _vectors3;
  14620. private _vectors4;
  14621. private _matrices;
  14622. private _matrices3x3;
  14623. private _matrices2x2;
  14624. private _vectors2Arrays;
  14625. private _vectors3Arrays;
  14626. private _cachedWorldViewMatrix;
  14627. private _renderId;
  14628. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14629. getClassName(): string;
  14630. needAlphaBlending(): boolean;
  14631. needAlphaTesting(): boolean;
  14632. private _checkUniform(uniformName);
  14633. setTexture(name: string, texture: Texture): ShaderMaterial;
  14634. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14635. setFloat(name: string, value: number): ShaderMaterial;
  14636. setInt(name: string, value: number): ShaderMaterial;
  14637. setFloats(name: string, value: number[]): ShaderMaterial;
  14638. setColor3(name: string, value: Color3): ShaderMaterial;
  14639. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14640. setColor4(name: string, value: Color4): ShaderMaterial;
  14641. setVector2(name: string, value: Vector2): ShaderMaterial;
  14642. setVector3(name: string, value: Vector3): ShaderMaterial;
  14643. setVector4(name: string, value: Vector4): ShaderMaterial;
  14644. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14645. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14646. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14647. setArray2(name: string, value: number[]): ShaderMaterial;
  14648. setArray3(name: string, value: number[]): ShaderMaterial;
  14649. private _checkCache(scene, mesh?, useInstances?);
  14650. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14651. bindOnlyWorldMatrix(world: Matrix): void;
  14652. bind(world: Matrix, mesh?: Mesh): void;
  14653. getActiveTextures(): BaseTexture[];
  14654. hasTexture(texture: BaseTexture): boolean;
  14655. clone(name: string): ShaderMaterial;
  14656. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14657. serialize(): any;
  14658. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14659. }
  14660. }
  14661. declare module BABYLON {
  14662. /** @hidden */
  14663. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14664. MAINUV1: boolean;
  14665. MAINUV2: boolean;
  14666. DIFFUSE: boolean;
  14667. DIFFUSEDIRECTUV: number;
  14668. AMBIENT: boolean;
  14669. AMBIENTDIRECTUV: number;
  14670. OPACITY: boolean;
  14671. OPACITYDIRECTUV: number;
  14672. OPACITYRGB: boolean;
  14673. REFLECTION: boolean;
  14674. EMISSIVE: boolean;
  14675. EMISSIVEDIRECTUV: number;
  14676. SPECULAR: boolean;
  14677. SPECULARDIRECTUV: number;
  14678. BUMP: boolean;
  14679. BUMPDIRECTUV: number;
  14680. PARALLAX: boolean;
  14681. PARALLAXOCCLUSION: boolean;
  14682. SPECULAROVERALPHA: boolean;
  14683. CLIPPLANE: boolean;
  14684. ALPHATEST: boolean;
  14685. DEPTHPREPASS: boolean;
  14686. ALPHAFROMDIFFUSE: boolean;
  14687. POINTSIZE: boolean;
  14688. FOG: boolean;
  14689. SPECULARTERM: boolean;
  14690. DIFFUSEFRESNEL: boolean;
  14691. OPACITYFRESNEL: boolean;
  14692. REFLECTIONFRESNEL: boolean;
  14693. REFRACTIONFRESNEL: boolean;
  14694. EMISSIVEFRESNEL: boolean;
  14695. FRESNEL: boolean;
  14696. NORMAL: boolean;
  14697. UV1: boolean;
  14698. UV2: boolean;
  14699. VERTEXCOLOR: boolean;
  14700. VERTEXALPHA: boolean;
  14701. NUM_BONE_INFLUENCERS: number;
  14702. BonesPerMesh: number;
  14703. INSTANCES: boolean;
  14704. GLOSSINESS: boolean;
  14705. ROUGHNESS: boolean;
  14706. EMISSIVEASILLUMINATION: boolean;
  14707. LINKEMISSIVEWITHDIFFUSE: boolean;
  14708. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14709. LIGHTMAP: boolean;
  14710. LIGHTMAPDIRECTUV: number;
  14711. OBJECTSPACE_NORMALMAP: boolean;
  14712. USELIGHTMAPASSHADOWMAP: boolean;
  14713. REFLECTIONMAP_3D: boolean;
  14714. REFLECTIONMAP_SPHERICAL: boolean;
  14715. REFLECTIONMAP_PLANAR: boolean;
  14716. REFLECTIONMAP_CUBIC: boolean;
  14717. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14718. REFLECTIONMAP_PROJECTION: boolean;
  14719. REFLECTIONMAP_SKYBOX: boolean;
  14720. REFLECTIONMAP_EXPLICIT: boolean;
  14721. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14722. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14723. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14724. INVERTCUBICMAP: boolean;
  14725. LOGARITHMICDEPTH: boolean;
  14726. REFRACTION: boolean;
  14727. REFRACTIONMAP_3D: boolean;
  14728. REFLECTIONOVERALPHA: boolean;
  14729. TWOSIDEDLIGHTING: boolean;
  14730. SHADOWFLOAT: boolean;
  14731. MORPHTARGETS: boolean;
  14732. MORPHTARGETS_NORMAL: boolean;
  14733. MORPHTARGETS_TANGENT: boolean;
  14734. NUM_MORPH_INFLUENCERS: number;
  14735. NONUNIFORMSCALING: boolean;
  14736. PREMULTIPLYALPHA: boolean;
  14737. IMAGEPROCESSING: boolean;
  14738. VIGNETTE: boolean;
  14739. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14740. VIGNETTEBLENDMODEOPAQUE: boolean;
  14741. TONEMAPPING: boolean;
  14742. CONTRAST: boolean;
  14743. COLORCURVES: boolean;
  14744. COLORGRADING: boolean;
  14745. COLORGRADING3D: boolean;
  14746. SAMPLER3DGREENDEPTH: boolean;
  14747. SAMPLER3DBGRMAP: boolean;
  14748. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14749. /**
  14750. * If the reflection texture on this material is in linear color space
  14751. * @hidden
  14752. */
  14753. IS_REFLECTION_LINEAR: boolean;
  14754. /**
  14755. * If the refraction texture on this material is in linear color space
  14756. * @hidden
  14757. */
  14758. IS_REFRACTION_LINEAR: boolean;
  14759. EXPOSURE: boolean;
  14760. constructor();
  14761. setReflectionMode(modeToEnable: string): void;
  14762. }
  14763. class StandardMaterial extends PushMaterial {
  14764. private _diffuseTexture;
  14765. diffuseTexture: Nullable<BaseTexture>;
  14766. private _ambientTexture;
  14767. ambientTexture: Nullable<BaseTexture>;
  14768. private _opacityTexture;
  14769. opacityTexture: Nullable<BaseTexture>;
  14770. private _reflectionTexture;
  14771. reflectionTexture: Nullable<BaseTexture>;
  14772. private _emissiveTexture;
  14773. emissiveTexture: Nullable<BaseTexture>;
  14774. private _specularTexture;
  14775. specularTexture: Nullable<BaseTexture>;
  14776. private _bumpTexture;
  14777. bumpTexture: Nullable<BaseTexture>;
  14778. private _lightmapTexture;
  14779. lightmapTexture: Nullable<BaseTexture>;
  14780. private _refractionTexture;
  14781. refractionTexture: Nullable<BaseTexture>;
  14782. ambientColor: Color3;
  14783. diffuseColor: Color3;
  14784. specularColor: Color3;
  14785. emissiveColor: Color3;
  14786. specularPower: number;
  14787. private _useAlphaFromDiffuseTexture;
  14788. useAlphaFromDiffuseTexture: boolean;
  14789. private _useEmissiveAsIllumination;
  14790. useEmissiveAsIllumination: boolean;
  14791. private _linkEmissiveWithDiffuse;
  14792. linkEmissiveWithDiffuse: boolean;
  14793. private _useSpecularOverAlpha;
  14794. useSpecularOverAlpha: boolean;
  14795. private _useReflectionOverAlpha;
  14796. useReflectionOverAlpha: boolean;
  14797. private _disableLighting;
  14798. disableLighting: boolean;
  14799. private _useObjectSpaceNormalMap;
  14800. /**
  14801. * Allows using an object space normal map (instead of tangent space).
  14802. */
  14803. useObjectSpaceNormalMap: boolean;
  14804. private _useParallax;
  14805. useParallax: boolean;
  14806. private _useParallaxOcclusion;
  14807. useParallaxOcclusion: boolean;
  14808. parallaxScaleBias: number;
  14809. private _roughness;
  14810. roughness: number;
  14811. indexOfRefraction: number;
  14812. invertRefractionY: boolean;
  14813. /**
  14814. * Defines the alpha limits in alpha test mode
  14815. */
  14816. alphaCutOff: number;
  14817. private _useLightmapAsShadowmap;
  14818. useLightmapAsShadowmap: boolean;
  14819. private _diffuseFresnelParameters;
  14820. diffuseFresnelParameters: FresnelParameters;
  14821. private _opacityFresnelParameters;
  14822. opacityFresnelParameters: FresnelParameters;
  14823. private _reflectionFresnelParameters;
  14824. reflectionFresnelParameters: FresnelParameters;
  14825. private _refractionFresnelParameters;
  14826. refractionFresnelParameters: FresnelParameters;
  14827. private _emissiveFresnelParameters;
  14828. emissiveFresnelParameters: FresnelParameters;
  14829. private _useReflectionFresnelFromSpecular;
  14830. useReflectionFresnelFromSpecular: boolean;
  14831. private _useGlossinessFromSpecularMapAlpha;
  14832. useGlossinessFromSpecularMapAlpha: boolean;
  14833. private _maxSimultaneousLights;
  14834. maxSimultaneousLights: number;
  14835. /**
  14836. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14837. */
  14838. private _invertNormalMapX;
  14839. invertNormalMapX: boolean;
  14840. /**
  14841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14842. */
  14843. private _invertNormalMapY;
  14844. invertNormalMapY: boolean;
  14845. /**
  14846. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14847. */
  14848. private _twoSidedLighting;
  14849. twoSidedLighting: boolean;
  14850. /**
  14851. * Default configuration related to image processing available in the standard Material.
  14852. */
  14853. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14854. /**
  14855. * Gets the image processing configuration used either in this material.
  14856. */
  14857. /**
  14858. * Sets the Default image processing configuration used either in the this material.
  14859. *
  14860. * If sets to null, the scene one is in use.
  14861. */
  14862. imageProcessingConfiguration: ImageProcessingConfiguration;
  14863. /**
  14864. * Keep track of the image processing observer to allow dispose and replace.
  14865. */
  14866. private _imageProcessingObserver;
  14867. /**
  14868. * Attaches a new image processing configuration to the Standard Material.
  14869. * @param configuration
  14870. */
  14871. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14872. /**
  14873. * Gets wether the color curves effect is enabled.
  14874. */
  14875. /**
  14876. * Sets wether the color curves effect is enabled.
  14877. */
  14878. cameraColorCurvesEnabled: boolean;
  14879. /**
  14880. * Gets wether the color grading effect is enabled.
  14881. */
  14882. /**
  14883. * Gets wether the color grading effect is enabled.
  14884. */
  14885. cameraColorGradingEnabled: boolean;
  14886. /**
  14887. * Gets wether tonemapping is enabled or not.
  14888. */
  14889. /**
  14890. * Sets wether tonemapping is enabled or not
  14891. */
  14892. cameraToneMappingEnabled: boolean;
  14893. /**
  14894. * The camera exposure used on this material.
  14895. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14896. * This corresponds to a photographic exposure.
  14897. */
  14898. /**
  14899. * The camera exposure used on this material.
  14900. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14901. * This corresponds to a photographic exposure.
  14902. */
  14903. cameraExposure: number;
  14904. /**
  14905. * Gets The camera contrast used on this material.
  14906. */
  14907. /**
  14908. * Sets The camera contrast used on this material.
  14909. */
  14910. cameraContrast: number;
  14911. /**
  14912. * Gets the Color Grading 2D Lookup Texture.
  14913. */
  14914. /**
  14915. * Sets the Color Grading 2D Lookup Texture.
  14916. */
  14917. cameraColorGradingTexture: Nullable<BaseTexture>;
  14918. /**
  14919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14921. * 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;
  14922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14923. */
  14924. /**
  14925. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14926. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14927. * 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;
  14928. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14929. */
  14930. cameraColorCurves: Nullable<ColorCurves>;
  14931. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14932. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14933. protected _worldViewProjectionMatrix: Matrix;
  14934. protected _globalAmbientColor: Color3;
  14935. protected _useLogarithmicDepth: boolean;
  14936. constructor(name: string, scene: Scene);
  14937. getClassName(): string;
  14938. useLogarithmicDepth: boolean;
  14939. needAlphaBlending(): boolean;
  14940. needAlphaTesting(): boolean;
  14941. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14942. getAlphaTestTexture(): Nullable<BaseTexture>;
  14943. /**
  14944. * Child classes can use it to update shaders
  14945. */
  14946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14947. buildUniformLayout(): void;
  14948. unbind(): void;
  14949. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14950. getAnimatables(): IAnimatable[];
  14951. getActiveTextures(): BaseTexture[];
  14952. hasTexture(texture: BaseTexture): boolean;
  14953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14954. clone(name: string): StandardMaterial;
  14955. serialize(): any;
  14956. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14957. static _DiffuseTextureEnabled: boolean;
  14958. static DiffuseTextureEnabled: boolean;
  14959. static _AmbientTextureEnabled: boolean;
  14960. static AmbientTextureEnabled: boolean;
  14961. static _OpacityTextureEnabled: boolean;
  14962. static OpacityTextureEnabled: boolean;
  14963. static _ReflectionTextureEnabled: boolean;
  14964. static ReflectionTextureEnabled: boolean;
  14965. static _EmissiveTextureEnabled: boolean;
  14966. static EmissiveTextureEnabled: boolean;
  14967. static _SpecularTextureEnabled: boolean;
  14968. static SpecularTextureEnabled: boolean;
  14969. static _BumpTextureEnabled: boolean;
  14970. static BumpTextureEnabled: boolean;
  14971. static _LightmapTextureEnabled: boolean;
  14972. static LightmapTextureEnabled: boolean;
  14973. static _RefractionTextureEnabled: boolean;
  14974. static RefractionTextureEnabled: boolean;
  14975. static _ColorGradingTextureEnabled: boolean;
  14976. static ColorGradingTextureEnabled: boolean;
  14977. static _FresnelEnabled: boolean;
  14978. static FresnelEnabled: boolean;
  14979. }
  14980. }
  14981. declare module BABYLON {
  14982. class UniformBuffer {
  14983. private _engine;
  14984. private _buffer;
  14985. private _data;
  14986. private _bufferData;
  14987. private _dynamic?;
  14988. private _uniformLocations;
  14989. private _uniformSizes;
  14990. private _uniformLocationPointer;
  14991. private _needSync;
  14992. private _noUBO;
  14993. private _currentEffect;
  14994. private static _MAX_UNIFORM_SIZE;
  14995. private static _tempBuffer;
  14996. /**
  14997. * Wrapper for updateUniform.
  14998. * @method updateMatrix3x3
  14999. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15000. * @param {Float32Array} matrix
  15001. */
  15002. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15003. /**
  15004. * Wrapper for updateUniform.
  15005. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15006. * @param {Float32Array} matrix
  15007. */
  15008. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15009. /**
  15010. * Wrapper for updateUniform.
  15011. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15012. * @param {number} x
  15013. */
  15014. updateFloat: (name: string, x: number) => void;
  15015. /**
  15016. * Wrapper for updateUniform.
  15017. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15018. * @param {number} x
  15019. * @param {number} y
  15020. * @param {string} [suffix] Suffix to add to the uniform name.
  15021. */
  15022. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15023. /**
  15024. * Wrapper for updateUniform.
  15025. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15026. * @param {number} x
  15027. * @param {number} y
  15028. * @param {number} z
  15029. * @param {string} [suffix] Suffix to add to the uniform name.
  15030. */
  15031. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15032. /**
  15033. * Wrapper for updateUniform.
  15034. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15035. * @param {number} x
  15036. * @param {number} y
  15037. * @param {number} z
  15038. * @param {number} w
  15039. * @param {string} [suffix] Suffix to add to the uniform name.
  15040. */
  15041. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15042. /**
  15043. * Wrapper for updateUniform.
  15044. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15045. * @param {Matrix} A 4x4 matrix.
  15046. */
  15047. updateMatrix: (name: string, mat: Matrix) => void;
  15048. /**
  15049. * Wrapper for updateUniform.
  15050. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15051. * @param {Vector3} vector
  15052. */
  15053. updateVector3: (name: string, vector: Vector3) => void;
  15054. /**
  15055. * Wrapper for updateUniform.
  15056. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15057. * @param {Vector4} vector
  15058. */
  15059. updateVector4: (name: string, vector: Vector4) => void;
  15060. /**
  15061. * Wrapper for updateUniform.
  15062. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15063. * @param {Color3} color
  15064. * @param {string} [suffix] Suffix to add to the uniform name.
  15065. */
  15066. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15067. /**
  15068. * Wrapper for updateUniform.
  15069. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15070. * @param {Color3} color
  15071. * @param {number} alpha
  15072. * @param {string} [suffix] Suffix to add to the uniform name.
  15073. */
  15074. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15075. /**
  15076. * Uniform buffer objects.
  15077. *
  15078. * Handles blocks of uniform on the GPU.
  15079. *
  15080. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15081. *
  15082. * For more information, please refer to :
  15083. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15084. */
  15085. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15086. /**
  15087. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15088. * or just falling back on setUniformXXX calls.
  15089. */
  15090. readonly useUbo: boolean;
  15091. /**
  15092. * Indicates if the WebGL underlying uniform buffer is in sync
  15093. * with the javascript cache data.
  15094. */
  15095. readonly isSync: boolean;
  15096. /**
  15097. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15098. * Also, a dynamic UniformBuffer will disable cache verification and always
  15099. * update the underlying WebGL uniform buffer to the GPU.
  15100. */
  15101. isDynamic(): boolean;
  15102. /**
  15103. * The data cache on JS side.
  15104. */
  15105. getData(): Float32Array;
  15106. /**
  15107. * The underlying WebGL Uniform buffer.
  15108. */
  15109. getBuffer(): Nullable<WebGLBuffer>;
  15110. /**
  15111. * std140 layout specifies how to align data within an UBO structure.
  15112. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15113. * for specs.
  15114. */
  15115. private _fillAlignment(size);
  15116. /**
  15117. * Adds an uniform in the buffer.
  15118. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15119. * for the layout to be correct !
  15120. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15121. * @param {number|number[]} size Data size, or data directly.
  15122. */
  15123. addUniform(name: string, size: number | number[]): void;
  15124. /**
  15125. * Wrapper for addUniform.
  15126. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15127. * @param {Matrix} mat A 4x4 matrix.
  15128. */
  15129. addMatrix(name: string, mat: Matrix): void;
  15130. /**
  15131. * Wrapper for addUniform.
  15132. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15133. * @param {number} x
  15134. * @param {number} y
  15135. */
  15136. addFloat2(name: string, x: number, y: number): void;
  15137. /**
  15138. * Wrapper for addUniform.
  15139. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15140. * @param {number} x
  15141. * @param {number} y
  15142. * @param {number} z
  15143. */
  15144. addFloat3(name: string, x: number, y: number, z: number): void;
  15145. /**
  15146. * Wrapper for addUniform.
  15147. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15148. * @param {Color3} color
  15149. */
  15150. addColor3(name: string, color: Color3): void;
  15151. /**
  15152. * Wrapper for addUniform.
  15153. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15154. * @param {Color3} color
  15155. * @param {number} alpha
  15156. */
  15157. addColor4(name: string, color: Color3, alpha: number): void;
  15158. /**
  15159. * Wrapper for addUniform.
  15160. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15161. * @param {Vector3} vector
  15162. */
  15163. addVector3(name: string, vector: Vector3): void;
  15164. /**
  15165. * Wrapper for addUniform.
  15166. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15167. */
  15168. addMatrix3x3(name: string): void;
  15169. /**
  15170. * Wrapper for addUniform.
  15171. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15172. */
  15173. addMatrix2x2(name: string): void;
  15174. /**
  15175. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15176. */
  15177. create(): void;
  15178. _rebuild(): void;
  15179. /**
  15180. * Updates the WebGL Uniform Buffer on the GPU.
  15181. * If the `dynamic` flag is set to true, no cache comparison is done.
  15182. * Otherwise, the buffer will be updated only if the cache differs.
  15183. */
  15184. update(): void;
  15185. /**
  15186. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15187. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15188. * @param {number[]|Float32Array} data Flattened data
  15189. * @param {number} size Size of the data.
  15190. */
  15191. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15192. private _updateMatrix3x3ForUniform(name, matrix);
  15193. private _updateMatrix3x3ForEffect(name, matrix);
  15194. private _updateMatrix2x2ForEffect(name, matrix);
  15195. private _updateMatrix2x2ForUniform(name, matrix);
  15196. private _updateFloatForEffect(name, x);
  15197. private _updateFloatForUniform(name, x);
  15198. private _updateFloat2ForEffect(name, x, y, suffix?);
  15199. private _updateFloat2ForUniform(name, x, y, suffix?);
  15200. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  15201. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  15202. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  15203. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  15204. private _updateMatrixForEffect(name, mat);
  15205. private _updateMatrixForUniform(name, mat);
  15206. private _updateVector3ForEffect(name, vector);
  15207. private _updateVector3ForUniform(name, vector);
  15208. private _updateVector4ForEffect(name, vector);
  15209. private _updateVector4ForUniform(name, vector);
  15210. private _updateColor3ForEffect(name, color, suffix?);
  15211. private _updateColor3ForUniform(name, color, suffix?);
  15212. private _updateColor4ForEffect(name, color, alpha, suffix?);
  15213. private _updateColor4ForUniform(name, color, alpha, suffix?);
  15214. /**
  15215. * Sets a sampler uniform on the effect.
  15216. * @param {string} name Name of the sampler.
  15217. * @param {Texture} texture
  15218. */
  15219. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15220. /**
  15221. * Directly updates the value of the uniform in the cache AND on the GPU.
  15222. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15223. * @param {number[]|Float32Array} data Flattened data
  15224. */
  15225. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15226. /**
  15227. * Binds this uniform buffer to an effect.
  15228. * @param {Effect} effect
  15229. * @param {string} name Name of the uniform block in the shader.
  15230. */
  15231. bindToEffect(effect: Effect, name: string): void;
  15232. /**
  15233. * Disposes the uniform buffer.
  15234. */
  15235. dispose(): void;
  15236. }
  15237. }
  15238. declare module BABYLON {
  15239. class Scalar {
  15240. /**
  15241. * Two pi constants convenient for computation.
  15242. */
  15243. static TwoPi: number;
  15244. /**
  15245. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15246. */
  15247. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15248. /**
  15249. * Returns a string : the upper case translation of the number i to hexadecimal.
  15250. */
  15251. static ToHex(i: number): string;
  15252. /**
  15253. * Returns -1 if value is negative and +1 is value is positive.
  15254. * Returns the value itself if it's equal to zero.
  15255. */
  15256. static Sign(value: number): number;
  15257. /**
  15258. * Returns the value itself if it's between min and max.
  15259. * Returns min if the value is lower than min.
  15260. * Returns max if the value is greater than max.
  15261. */
  15262. static Clamp(value: number, min?: number, max?: number): number;
  15263. /**
  15264. * Returns the log2 of value.
  15265. */
  15266. static Log2(value: number): number;
  15267. /**
  15268. * Loops the value, so that it is never larger than length and never smaller than 0.
  15269. *
  15270. * This is similar to the modulo operator but it works with floating point numbers.
  15271. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15272. * With t = 5 and length = 2.5, the result would be 0.0.
  15273. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15274. */
  15275. static Repeat(value: number, length: number): number;
  15276. /**
  15277. * Normalize the value between 0.0 and 1.0 using min and max values
  15278. */
  15279. static Normalize(value: number, min: number, max: number): number;
  15280. /**
  15281. * Denormalize the value from 0.0 and 1.0 using min and max values
  15282. */
  15283. static Denormalize(normalized: number, min: number, max: number): number;
  15284. /**
  15285. * Calculates the shortest difference between two given angles given in degrees.
  15286. */
  15287. static DeltaAngle(current: number, target: number): number;
  15288. /**
  15289. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15290. *
  15291. * The returned value will move back and forth between 0 and length
  15292. */
  15293. static PingPong(tx: number, length: number): number;
  15294. /**
  15295. * Interpolates between min and max with smoothing at the limits.
  15296. *
  15297. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15298. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15299. */
  15300. static SmoothStep(from: number, to: number, tx: number): number;
  15301. /**
  15302. * Moves a value current towards target.
  15303. *
  15304. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15305. * Negative values of maxDelta pushes the value away from target.
  15306. */
  15307. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15308. /**
  15309. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15310. *
  15311. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15312. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15313. */
  15314. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15315. /**
  15316. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15317. */
  15318. static Lerp(start: number, end: number, amount: number): number;
  15319. /**
  15320. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15321. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15322. */
  15323. static LerpAngle(start: number, end: number, amount: number): number;
  15324. /**
  15325. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15326. */
  15327. static InverseLerp(a: number, b: number, value: number): number;
  15328. /**
  15329. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15330. */
  15331. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15332. /**
  15333. * Returns a random float number between and min and max values
  15334. */
  15335. static RandomRange(min: number, max: number): number;
  15336. /**
  15337. * This function returns percentage of a number in a given range.
  15338. *
  15339. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15340. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15341. */
  15342. static RangeToPercent(number: number, min: number, max: number): number;
  15343. /**
  15344. * This function returns number that corresponds to the percentage in a given range.
  15345. *
  15346. * PercentToRange(0.34,0,100) will return 34.
  15347. */
  15348. static PercentToRange(percent: number, min: number, max: number): number;
  15349. /**
  15350. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15351. * @param angle The angle to normalize in radian.
  15352. * @return The converted angle.
  15353. */
  15354. static NormalizeRadians(angle: number): number;
  15355. }
  15356. }
  15357. declare module BABYLON {
  15358. const ToGammaSpace: number;
  15359. const ToLinearSpace = 2.2;
  15360. const Epsilon = 0.001;
  15361. /**
  15362. * Class used to hold a RBG color
  15363. */
  15364. class Color3 {
  15365. /**
  15366. * Defines the red component (between 0 and 1, default is 0)
  15367. */
  15368. r: number;
  15369. /**
  15370. * Defines the green component (between 0 and 1, default is 0)
  15371. */
  15372. g: number;
  15373. /**
  15374. * Defines the blue component (between 0 and 1, default is 0)
  15375. */
  15376. b: number;
  15377. /**
  15378. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15379. * @param r defines the red component (between 0 and 1, default is 0)
  15380. * @param g defines the green component (between 0 and 1, default is 0)
  15381. * @param b defines the blue component (between 0 and 1, default is 0)
  15382. */
  15383. constructor(
  15384. /**
  15385. * Defines the red component (between 0 and 1, default is 0)
  15386. */
  15387. r?: number,
  15388. /**
  15389. * Defines the green component (between 0 and 1, default is 0)
  15390. */
  15391. g?: number,
  15392. /**
  15393. * Defines the blue component (between 0 and 1, default is 0)
  15394. */
  15395. b?: number);
  15396. /**
  15397. * Creates a string with the Color3 current values
  15398. * @returns the string representation of the Color3 object
  15399. */
  15400. toString(): string;
  15401. /**
  15402. * Returns the string "Color3"
  15403. * @returns "Color3"
  15404. */
  15405. getClassName(): string;
  15406. /**
  15407. * Compute the Color3 hash code
  15408. * @returns an unique number that can be used to hash Color3 objects
  15409. */
  15410. getHashCode(): number;
  15411. /**
  15412. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15413. * @param array defines the array where to store the r,g,b components
  15414. * @param index defines an optional index in the target array to define where to start storing values
  15415. * @returns the current Color3 object
  15416. */
  15417. toArray(array: FloatArray, index?: number): Color3;
  15418. /**
  15419. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15420. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15421. * @returns a new {BABYLON.Color4} object
  15422. */
  15423. toColor4(alpha?: number): Color4;
  15424. /**
  15425. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15426. * @returns the new array
  15427. */
  15428. asArray(): number[];
  15429. /**
  15430. * Returns the luminance value
  15431. * @returns a float value
  15432. */
  15433. toLuminance(): number;
  15434. /**
  15435. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15436. * @param otherColor defines the second operand
  15437. * @returns the new Color3 object
  15438. */
  15439. multiply(otherColor: Color3): Color3;
  15440. /**
  15441. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15442. * @param otherColor defines the second operand
  15443. * @param result defines the Color3 object where to store the result
  15444. * @returns the current Color3
  15445. */
  15446. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15447. /**
  15448. * Determines equality between Color3 objects
  15449. * @param otherColor defines the second operand
  15450. * @returns true if the rgb values are equal to the given ones
  15451. */
  15452. equals(otherColor: Color3): boolean;
  15453. /**
  15454. * Determines equality between the current Color3 object and a set of r,b,g values
  15455. * @param r defines the red component to check
  15456. * @param g defines the green component to check
  15457. * @param b defines the blue component to check
  15458. * @returns true if the rgb values are equal to the given ones
  15459. */
  15460. equalsFloats(r: number, g: number, b: number): boolean;
  15461. /**
  15462. * Multiplies in place each rgb value by scale
  15463. * @param scale defines the scaling factor
  15464. * @returns the updated Color3
  15465. */
  15466. scale(scale: number): Color3;
  15467. /**
  15468. * Multiplies the rgb values by scale and stores the result into "result"
  15469. * @param scale defines the scaling factor
  15470. * @param result defines the Color3 object where to store the result
  15471. * @returns the unmodified current Color3
  15472. */
  15473. scaleToRef(scale: number, result: Color3): Color3;
  15474. /**
  15475. * Scale the current Color3 values by a factor and add the result to a given Color3
  15476. * @param scale defines the scale factor
  15477. * @param result defines color to store the result into
  15478. * @returns the unmodified current Color3
  15479. */
  15480. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15481. /**
  15482. * Clamps the rgb values by the min and max values and stores the result into "result"
  15483. * @param min defines minimum clamping value (default is 0)
  15484. * @param max defines maximum clamping value (default is 1)
  15485. * @param result defines color to store the result into
  15486. * @returns the original Color3
  15487. */
  15488. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15489. /**
  15490. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15491. * @param otherColor defines the second operand
  15492. * @returns the new Color3
  15493. */
  15494. add(otherColor: Color3): Color3;
  15495. /**
  15496. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15497. * @param otherColor defines the second operand
  15498. * @param result defines Color3 object to store the result into
  15499. * @returns the unmodified current Color3
  15500. */
  15501. addToRef(otherColor: Color3, result: Color3): Color3;
  15502. /**
  15503. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15504. * @param otherColor defines the second operand
  15505. * @returns the new Color3
  15506. */
  15507. subtract(otherColor: Color3): Color3;
  15508. /**
  15509. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15510. * @param otherColor defines the second operand
  15511. * @param result defines Color3 object to store the result into
  15512. * @returns the unmodified current Color3
  15513. */
  15514. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15515. /**
  15516. * Copy the current object
  15517. * @returns a new Color3 copied the current one
  15518. */
  15519. clone(): Color3;
  15520. /**
  15521. * Copies the rgb values from the source in the current Color3
  15522. * @param source defines the source Color3 object
  15523. * @returns the updated Color3 object
  15524. */
  15525. copyFrom(source: Color3): Color3;
  15526. /**
  15527. * Updates the Color3 rgb values from the given floats
  15528. * @param r defines the red component to read from
  15529. * @param g defines the green component to read from
  15530. * @param b defines the blue component to read from
  15531. * @returns the current Color3 object
  15532. */
  15533. copyFromFloats(r: number, g: number, b: number): Color3;
  15534. /**
  15535. * Updates the Color3 rgb values from the given floats
  15536. * @param r defines the red component to read from
  15537. * @param g defines the green component to read from
  15538. * @param b defines the blue component to read from
  15539. * @returns the current Color3 object
  15540. */
  15541. set(r: number, g: number, b: number): Color3;
  15542. /**
  15543. * Compute the Color3 hexadecimal code as a string
  15544. * @returns a string containing the hexadecimal representation of the Color3 object
  15545. */
  15546. toHexString(): string;
  15547. /**
  15548. * Computes a new Color3 converted from the current one to linear space
  15549. * @returns a new Color3 object
  15550. */
  15551. toLinearSpace(): Color3;
  15552. /**
  15553. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15554. * @param convertedColor defines the Color3 object where to store the linear space version
  15555. * @returns the unmodified Color3
  15556. */
  15557. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15558. /**
  15559. * Computes a new Color3 converted from the current one to gamma space
  15560. * @returns a new Color3 object
  15561. */
  15562. toGammaSpace(): Color3;
  15563. /**
  15564. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15565. * @param convertedColor defines the Color3 object where to store the gamma space version
  15566. * @returns the unmodified Color3
  15567. */
  15568. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15569. /**
  15570. * Creates a new Color3 from the string containing valid hexadecimal values
  15571. * @param hex defines a string containing valid hexadecimal values
  15572. * @returns a new Color3 object
  15573. */
  15574. static FromHexString(hex: string): Color3;
  15575. /**
  15576. * Creates a new Vector3 from the starting index of the given array
  15577. * @param array defines the source array
  15578. * @param offset defines an offset in the source array
  15579. * @returns a new Color3 object
  15580. */
  15581. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15582. /**
  15583. * Creates a new Color3 from integer values (< 256)
  15584. * @param r defines the red component to read from (value between 0 and 255)
  15585. * @param g defines the green component to read from (value between 0 and 255)
  15586. * @param b defines the blue component to read from (value between 0 and 255)
  15587. * @returns a new Color3 object
  15588. */
  15589. static FromInts(r: number, g: number, b: number): Color3;
  15590. /**
  15591. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15592. * @param start defines the start Color3 value
  15593. * @param end defines the end Color3 value
  15594. * @param amount defines the gradient value between start and end
  15595. * @returns a new Color3 object
  15596. */
  15597. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15598. /**
  15599. * Returns a Color3 value containing a red color
  15600. * @returns a new Color3 object
  15601. */
  15602. static Red(): Color3;
  15603. /**
  15604. * Returns a Color3 value containing a green color
  15605. * @returns a new Color3 object
  15606. */
  15607. static Green(): Color3;
  15608. /**
  15609. * Returns a Color3 value containing a blue color
  15610. * @returns a new Color3 object
  15611. */
  15612. static Blue(): Color3;
  15613. /**
  15614. * Returns a Color3 value containing a black color
  15615. * @returns a new Color3 object
  15616. */
  15617. static Black(): Color3;
  15618. /**
  15619. * Returns a Color3 value containing a white color
  15620. * @returns a new Color3 object
  15621. */
  15622. static White(): Color3;
  15623. /**
  15624. * Returns a Color3 value containing a purple color
  15625. * @returns a new Color3 object
  15626. */
  15627. static Purple(): Color3;
  15628. /**
  15629. * Returns a Color3 value containing a magenta color
  15630. * @returns a new Color3 object
  15631. */
  15632. static Magenta(): Color3;
  15633. /**
  15634. * Returns a Color3 value containing a yellow color
  15635. * @returns a new Color3 object
  15636. */
  15637. static Yellow(): Color3;
  15638. /**
  15639. * Returns a Color3 value containing a gray color
  15640. * @returns a new Color3 object
  15641. */
  15642. static Gray(): Color3;
  15643. /**
  15644. * Returns a Color3 value containing a teal color
  15645. * @returns a new Color3 object
  15646. */
  15647. static Teal(): Color3;
  15648. /**
  15649. * Returns a Color3 value containing a random color
  15650. * @returns a new Color3 object
  15651. */
  15652. static Random(): Color3;
  15653. }
  15654. /**
  15655. * Class used to hold a RBGA color
  15656. */
  15657. class Color4 {
  15658. /**
  15659. * Defines the red component (between 0 and 1, default is 0)
  15660. */
  15661. r: number;
  15662. /**
  15663. * Defines the green component (between 0 and 1, default is 0)
  15664. */
  15665. g: number;
  15666. /**
  15667. * Defines the blue component (between 0 and 1, default is 0)
  15668. */
  15669. b: number;
  15670. /**
  15671. * Defines the alpha component (between 0 and 1, default is 1)
  15672. */
  15673. a: number;
  15674. /**
  15675. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15676. * @param r defines the red component (between 0 and 1, default is 0)
  15677. * @param g defines the green component (between 0 and 1, default is 0)
  15678. * @param b defines the blue component (between 0 and 1, default is 0)
  15679. * @param a defines the alpha component (between 0 and 1, default is 1)
  15680. */
  15681. constructor(
  15682. /**
  15683. * Defines the red component (between 0 and 1, default is 0)
  15684. */
  15685. r?: number,
  15686. /**
  15687. * Defines the green component (between 0 and 1, default is 0)
  15688. */
  15689. g?: number,
  15690. /**
  15691. * Defines the blue component (between 0 and 1, default is 0)
  15692. */
  15693. b?: number,
  15694. /**
  15695. * Defines the alpha component (between 0 and 1, default is 1)
  15696. */
  15697. a?: number);
  15698. /**
  15699. * Adds in place the given Color4 values to the current Color4 object
  15700. * @param right defines the second operand
  15701. * @returns the current updated Color4 object
  15702. */
  15703. addInPlace(right: Color4): Color4;
  15704. /**
  15705. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15706. * @returns the new array
  15707. */
  15708. asArray(): number[];
  15709. /**
  15710. * Stores from the starting index in the given array the Color4 successive values
  15711. * @param array defines the array where to store the r,g,b components
  15712. * @param index defines an optional index in the target array to define where to start storing values
  15713. * @returns the current Color4 object
  15714. */
  15715. toArray(array: number[], index?: number): Color4;
  15716. /**
  15717. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15718. * @param right defines the second operand
  15719. * @returns a new Color4 object
  15720. */
  15721. add(right: Color4): Color4;
  15722. /**
  15723. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15724. * @param right defines the second operand
  15725. * @returns a new Color4 object
  15726. */
  15727. subtract(right: Color4): Color4;
  15728. /**
  15729. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15730. * @param right defines the second operand
  15731. * @param result defines the Color4 object where to store the result
  15732. * @returns the current Color4 object
  15733. */
  15734. subtractToRef(right: Color4, result: Color4): Color4;
  15735. /**
  15736. * Creates a new Color4 with the current Color4 values multiplied by scale
  15737. * @param scale defines the scaling factor to apply
  15738. * @returns a new Color4 object
  15739. */
  15740. scale(scale: number): Color4;
  15741. /**
  15742. * Multiplies the current Color4 values by scale and stores the result in "result"
  15743. * @param scale defines the scaling factor to apply
  15744. * @param result defines the Color4 object where to store the result
  15745. * @returns the current unmodified Color4
  15746. */
  15747. scaleToRef(scale: number, result: Color4): Color4;
  15748. /**
  15749. * Scale the current Color4 values by a factor and add the result to a given Color4
  15750. * @param scale defines the scale factor
  15751. * @param result defines the Color4 object where to store the result
  15752. * @returns the unmodified current Color4
  15753. */
  15754. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15755. /**
  15756. * Clamps the rgb values by the min and max values and stores the result into "result"
  15757. * @param min defines minimum clamping value (default is 0)
  15758. * @param max defines maximum clamping value (default is 1)
  15759. * @param result defines color to store the result into.
  15760. * @returns the cuurent Color4
  15761. */
  15762. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15763. /**
  15764. * Multipy an Color4 value by another and return a new Color4 object
  15765. * @param color defines the Color4 value to multiply by
  15766. * @returns a new Color4 object
  15767. */
  15768. multiply(color: Color4): Color4;
  15769. /**
  15770. * Multipy a Color4 value by another and push the result in a reference value
  15771. * @param color defines the Color4 value to multiply by
  15772. * @param result defines the Color4 to fill the result in
  15773. * @returns the result Color4
  15774. */
  15775. multiplyToRef(color: Color4, result: Color4): Color4;
  15776. /**
  15777. * Creates a string with the Color4 current values
  15778. * @returns the string representation of the Color4 object
  15779. */
  15780. toString(): string;
  15781. /**
  15782. * Returns the string "Color4"
  15783. * @returns "Color4"
  15784. */
  15785. getClassName(): string;
  15786. /**
  15787. * Compute the Color4 hash code
  15788. * @returns an unique number that can be used to hash Color4 objects
  15789. */
  15790. getHashCode(): number;
  15791. /**
  15792. * Creates a new Color4 copied from the current one
  15793. * @returns a new Color4 object
  15794. */
  15795. clone(): Color4;
  15796. /**
  15797. * Copies the given Color4 values into the current one
  15798. * @param source defines the source Color4 object
  15799. * @returns the current updated Color4 object
  15800. */
  15801. copyFrom(source: Color4): Color4;
  15802. /**
  15803. * Copies the given float values into the current one
  15804. * @param r defines the red component to read from
  15805. * @param g defines the green component to read from
  15806. * @param b defines the blue component to read from
  15807. * @param a defines the alpha component to read from
  15808. * @returns the current updated Color4 object
  15809. */
  15810. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15811. /**
  15812. * Copies the given float values into the current one
  15813. * @param r defines the red component to read from
  15814. * @param g defines the green component to read from
  15815. * @param b defines the blue component to read from
  15816. * @param a defines the alpha component to read from
  15817. * @returns the current updated Color4 object
  15818. */
  15819. set(r: number, g: number, b: number, a: number): Color4;
  15820. /**
  15821. * Compute the Color4 hexadecimal code as a string
  15822. * @returns a string containing the hexadecimal representation of the Color4 object
  15823. */
  15824. toHexString(): string;
  15825. /**
  15826. * Computes a new Color4 converted from the current one to linear space
  15827. * @returns a new Color4 object
  15828. */
  15829. toLinearSpace(): Color4;
  15830. /**
  15831. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15832. * @param convertedColor defines the Color4 object where to store the linear space version
  15833. * @returns the unmodified Color4
  15834. */
  15835. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15836. /**
  15837. * Computes a new Color4 converted from the current one to gamma space
  15838. * @returns a new Color4 object
  15839. */
  15840. toGammaSpace(): Color4;
  15841. /**
  15842. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15843. * @param convertedColor defines the Color4 object where to store the gamma space version
  15844. * @returns the unmodified Color4
  15845. */
  15846. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15847. /**
  15848. * Creates a new Color4 from the string containing valid hexadecimal values
  15849. * @param hex defines a string containing valid hexadecimal values
  15850. * @returns a new Color4 object
  15851. */
  15852. static FromHexString(hex: string): Color4;
  15853. /**
  15854. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15855. * @param left defines the start value
  15856. * @param right defines the end value
  15857. * @param amount defines the gradient factor
  15858. * @returns a new Color4 object
  15859. */
  15860. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15861. /**
  15862. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15863. * @param left defines the start value
  15864. * @param right defines the end value
  15865. * @param amount defines the gradient factor
  15866. * @param result defines the Color4 object where to store data
  15867. */
  15868. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15869. /**
  15870. * Creates a new Color4 from the starting index element of the given array
  15871. * @param array defines the source array to read from
  15872. * @param offset defines the offset in the source array
  15873. * @returns a new Color4 object
  15874. */
  15875. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15876. /**
  15877. * Creates a new Color3 from integer values (< 256)
  15878. * @param r defines the red component to read from (value between 0 and 255)
  15879. * @param g defines the green component to read from (value between 0 and 255)
  15880. * @param b defines the blue component to read from (value between 0 and 255)
  15881. * @param a defines the alpha component to read from (value between 0 and 255)
  15882. * @returns a new Color3 object
  15883. */
  15884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15885. /**
  15886. * Check the content of a given array and convert it to an array containing RGBA data
  15887. * If the original array was already containing count * 4 values then it is returned directly
  15888. * @param colors defines the array to check
  15889. * @param count defines the number of RGBA data to expect
  15890. * @returns an array containing count * 4 values (RGBA)
  15891. */
  15892. static CheckColors4(colors: number[], count: number): number[];
  15893. }
  15894. /**
  15895. * Class representing a vector containing 2 coordinates
  15896. */
  15897. class Vector2 {
  15898. /** defines the first coordinate */
  15899. x: number;
  15900. /** defines the second coordinate */
  15901. y: number;
  15902. /**
  15903. * Creates a new Vector2 from the given x and y coordinates
  15904. * @param x defines the first coordinate
  15905. * @param y defines the second coordinate
  15906. */
  15907. constructor(
  15908. /** defines the first coordinate */
  15909. x?: number,
  15910. /** defines the second coordinate */
  15911. y?: number);
  15912. /**
  15913. * Gets a string with the Vector2 coordinates
  15914. * @returns a string with the Vector2 coordinates
  15915. */
  15916. toString(): string;
  15917. /**
  15918. * Gets class name
  15919. * @returns the string "Vector2"
  15920. */
  15921. getClassName(): string;
  15922. /**
  15923. * Gets current vector hash code
  15924. * @returns the Vector2 hash code as a number
  15925. */
  15926. getHashCode(): number;
  15927. /**
  15928. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15929. * @param array defines the source array
  15930. * @param index defines the offset in source array
  15931. * @returns the current Vector2
  15932. */
  15933. toArray(array: FloatArray, index?: number): Vector2;
  15934. /**
  15935. * Copy the current vector to an array
  15936. * @returns a new array with 2 elements: the Vector2 coordinates.
  15937. */
  15938. asArray(): number[];
  15939. /**
  15940. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15941. * @param source defines the source Vector2
  15942. * @returns the current updated Vector2
  15943. */
  15944. copyFrom(source: Vector2): Vector2;
  15945. /**
  15946. * Sets the Vector2 coordinates with the given floats
  15947. * @param x defines the first coordinate
  15948. * @param y defines the second coordinate
  15949. * @returns the current updated Vector2
  15950. */
  15951. copyFromFloats(x: number, y: number): Vector2;
  15952. /**
  15953. * Sets the Vector2 coordinates with the given floats
  15954. * @param x defines the first coordinate
  15955. * @param y defines the second coordinate
  15956. * @returns the current updated Vector2
  15957. */
  15958. set(x: number, y: number): Vector2;
  15959. /**
  15960. * Add another vector with the current one
  15961. * @param otherVector defines the other vector
  15962. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15963. */
  15964. add(otherVector: Vector2): Vector2;
  15965. /**
  15966. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15967. * @param otherVector defines the other vector
  15968. * @param result defines the target vector
  15969. * @returns the unmodified current Vector2
  15970. */
  15971. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15972. /**
  15973. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15974. * @param otherVector defines the other vector
  15975. * @returns the current updated Vector2
  15976. */
  15977. addInPlace(otherVector: Vector2): Vector2;
  15978. /**
  15979. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15980. * @param otherVector defines the other vector
  15981. * @returns a new Vector2
  15982. */
  15983. addVector3(otherVector: Vector3): Vector2;
  15984. /**
  15985. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15986. * @param otherVector defines the other vector
  15987. * @returns a new Vector2
  15988. */
  15989. subtract(otherVector: Vector2): Vector2;
  15990. /**
  15991. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15992. * @param otherVector defines the other vector
  15993. * @param result defines the target vector
  15994. * @returns the unmodified current Vector2
  15995. */
  15996. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15997. /**
  15998. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15999. * @param otherVector defines the other vector
  16000. * @returns the current updated Vector2
  16001. */
  16002. subtractInPlace(otherVector: Vector2): Vector2;
  16003. /**
  16004. * Multiplies in place the current Vector2 coordinates by the given ones
  16005. * @param otherVector defines the other vector
  16006. * @returns the current updated Vector2
  16007. */
  16008. multiplyInPlace(otherVector: Vector2): Vector2;
  16009. /**
  16010. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16011. * @param otherVector defines the other vector
  16012. * @returns a new Vector2
  16013. */
  16014. multiply(otherVector: Vector2): Vector2;
  16015. /**
  16016. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16017. * @param otherVector defines the other vector
  16018. * @param result defines the target vector
  16019. * @returns the unmodified current Vector2
  16020. */
  16021. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16022. /**
  16023. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16024. * @param x defines the first coordinate
  16025. * @param y defines the second coordinate
  16026. * @returns a new Vector2
  16027. */
  16028. multiplyByFloats(x: number, y: number): Vector2;
  16029. /**
  16030. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16031. * @param otherVector defines the other vector
  16032. * @returns a new Vector2
  16033. */
  16034. divide(otherVector: Vector2): Vector2;
  16035. /**
  16036. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16037. * @param otherVector defines the other vector
  16038. * @param result defines the target vector
  16039. * @returns the unmodified current Vector2
  16040. */
  16041. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16042. /**
  16043. * Divides the current Vector3 coordinates by the given ones
  16044. * @param otherVector defines the other vector
  16045. * @returns the current updated Vector2
  16046. */
  16047. divideInPlace(otherVector: Vector2): Vector2;
  16048. /**
  16049. * Gets a new Vector2 with current Vector2 negated coordinates
  16050. * @returns a new Vector2
  16051. */
  16052. negate(): Vector2;
  16053. /**
  16054. * Multiply the Vector2 coordinates by scale
  16055. * @param scale defines the scaling factor
  16056. * @returns the current updated Vector2
  16057. */
  16058. scaleInPlace(scale: number): Vector2;
  16059. /**
  16060. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16061. * @param scale defines the scaling factor
  16062. * @returns a new Vector2
  16063. */
  16064. scale(scale: number): Vector2;
  16065. /**
  16066. * Scale the current Vector2 values by a factor to a given Vector2
  16067. * @param scale defines the scale factor
  16068. * @param result defines the Vector2 object where to store the result
  16069. * @returns the unmodified current Vector2
  16070. */
  16071. scaleToRef(scale: number, result: Vector2): Vector2;
  16072. /**
  16073. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16074. * @param scale defines the scale factor
  16075. * @param result defines the Vector2 object where to store the result
  16076. * @returns the unmodified current Vector2
  16077. */
  16078. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16079. /**
  16080. * Gets a boolean if two vectors are equals
  16081. * @param otherVector defines the other vector
  16082. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16083. */
  16084. equals(otherVector: Vector2): boolean;
  16085. /**
  16086. * Gets a boolean if two vectors are equals (using an epsilon value)
  16087. * @param otherVector defines the other vector
  16088. * @param epsilon defines the minimal distance to consider equality
  16089. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16090. */
  16091. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16092. /**
  16093. * Gets the length of the vector
  16094. * @returns the vector length (float)
  16095. */
  16096. length(): number;
  16097. /**
  16098. * Gets the vector squared length
  16099. * @returns the vector squared length (float)
  16100. */
  16101. lengthSquared(): number;
  16102. /**
  16103. * Normalize the vector
  16104. * @returns the current updated Vector2
  16105. */
  16106. normalize(): Vector2;
  16107. /**
  16108. * Gets a new Vector2 copied from the Vector2
  16109. * @returns a new Vector2
  16110. */
  16111. clone(): Vector2;
  16112. /**
  16113. * Gets a new Vector2(0, 0)
  16114. * @returns a new Vector2
  16115. */
  16116. static Zero(): Vector2;
  16117. /**
  16118. * Gets a new Vector2(1, 1)
  16119. * @returns a new Vector2
  16120. */
  16121. static One(): Vector2;
  16122. /**
  16123. * Gets a new Vector2 set from the given index element of the given array
  16124. * @param array defines the data source
  16125. * @param offset defines the offset in the data source
  16126. * @returns a new Vector2
  16127. */
  16128. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16129. /**
  16130. * Sets "result" from the given index element of the given array
  16131. * @param array defines the data source
  16132. * @param offset defines the offset in the data source
  16133. * @param result defines the target vector
  16134. */
  16135. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16136. /**
  16137. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16138. * @param value1 defines 1st point of control
  16139. * @param value2 defines 2nd point of control
  16140. * @param value3 defines 3rd point of control
  16141. * @param value4 defines 4th point of control
  16142. * @param amount defines the interpolation factor
  16143. * @returns a new Vector2
  16144. */
  16145. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16146. /**
  16147. * 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".
  16148. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16149. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16150. * @param value defines the value to clamp
  16151. * @param min defines the lower limit
  16152. * @param max defines the upper limit
  16153. * @returns a new Vector2
  16154. */
  16155. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16156. /**
  16157. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16158. * @param value1 defines the 1st control point
  16159. * @param tangent1 defines the outgoing tangent
  16160. * @param value2 defines the 2nd control point
  16161. * @param tangent2 defines the incoming tangent
  16162. * @param amount defines the interpolation factor
  16163. * @returns a new Vector2
  16164. */
  16165. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16166. /**
  16167. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16168. * @param start defines the start vector
  16169. * @param end defines the end vector
  16170. * @param amount defines the interpolation factor
  16171. * @returns a new Vector2
  16172. */
  16173. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16174. /**
  16175. * Gets the dot product of the vector "left" and the vector "right"
  16176. * @param left defines first vector
  16177. * @param right defines second vector
  16178. * @returns the dot product (float)
  16179. */
  16180. static Dot(left: Vector2, right: Vector2): number;
  16181. /**
  16182. * Returns a new Vector2 equal to the normalized given vector
  16183. * @param vector defines the vector to normalize
  16184. * @returns a new Vector2
  16185. */
  16186. static Normalize(vector: Vector2): Vector2;
  16187. /**
  16188. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16189. * @param left defines 1st vector
  16190. * @param right defines 2nd vector
  16191. * @returns a new Vector2
  16192. */
  16193. static Minimize(left: Vector2, right: Vector2): Vector2;
  16194. /**
  16195. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16196. * @param left defines 1st vector
  16197. * @param right defines 2nd vector
  16198. * @returns a new Vector2
  16199. */
  16200. static Maximize(left: Vector2, right: Vector2): Vector2;
  16201. /**
  16202. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16203. * @param vector defines the vector to transform
  16204. * @param transformation defines the matrix to apply
  16205. * @returns a new Vector2
  16206. */
  16207. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16208. /**
  16209. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16210. * @param vector defines the vector to transform
  16211. * @param transformation defines the matrix to apply
  16212. * @param result defines the target vector
  16213. */
  16214. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16215. /**
  16216. * Determines if a given vector is included in a triangle
  16217. * @param p defines the vector to test
  16218. * @param p0 defines 1st triangle point
  16219. * @param p1 defines 2nd triangle point
  16220. * @param p2 defines 3rd triangle point
  16221. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16222. */
  16223. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16224. /**
  16225. * Gets the distance between the vectors "value1" and "value2"
  16226. * @param value1 defines first vector
  16227. * @param value2 defines second vector
  16228. * @returns the distance between vectors
  16229. */
  16230. static Distance(value1: Vector2, value2: Vector2): number;
  16231. /**
  16232. * Returns the squared distance between the vectors "value1" and "value2"
  16233. * @param value1 defines first vector
  16234. * @param value2 defines second vector
  16235. * @returns the squared distance between vectors
  16236. */
  16237. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16238. /**
  16239. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16240. * @param value1 defines first vector
  16241. * @param value2 defines second vector
  16242. * @returns a new Vector2
  16243. */
  16244. static Center(value1: Vector2, value2: Vector2): Vector2;
  16245. /**
  16246. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16247. * @param p defines the middle point
  16248. * @param segA defines one point of the segment
  16249. * @param segB defines the other point of the segment
  16250. * @returns the shortest distance
  16251. */
  16252. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16253. }
  16254. /**
  16255. * Classed used to store (x,y,z) vector representation
  16256. * A Vector3 is the main object used in 3D geometry
  16257. * It can represent etiher the coordinates of a point the space, either a direction
  16258. * Reminder: Babylon.js uses a left handed forward facing system
  16259. */
  16260. class Vector3 {
  16261. /**
  16262. * Defines the first coordinates (on X axis)
  16263. */
  16264. x: number;
  16265. /**
  16266. * Defines the second coordinates (on Y axis)
  16267. */
  16268. y: number;
  16269. /**
  16270. * Defines the third coordinates (on Z axis)
  16271. */
  16272. z: number;
  16273. /**
  16274. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16275. * @param x defines the first coordinates (on X axis)
  16276. * @param y defines the second coordinates (on Y axis)
  16277. * @param z defines the third coordinates (on Z axis)
  16278. */
  16279. constructor(
  16280. /**
  16281. * Defines the first coordinates (on X axis)
  16282. */
  16283. x?: number,
  16284. /**
  16285. * Defines the second coordinates (on Y axis)
  16286. */
  16287. y?: number,
  16288. /**
  16289. * Defines the third coordinates (on Z axis)
  16290. */
  16291. z?: number);
  16292. /**
  16293. * Creates a string representation of the Vector3
  16294. * @returns a string with the Vector3 coordinates.
  16295. */
  16296. toString(): string;
  16297. /**
  16298. * Gets the class name
  16299. * @returns the string "Vector3"
  16300. */
  16301. getClassName(): string;
  16302. /**
  16303. * Creates the Vector3 hash code
  16304. * @returns a number which tends to be unique between Vector3 instances
  16305. */
  16306. getHashCode(): number;
  16307. /**
  16308. * Creates an array containing three elements : the coordinates of the Vector3
  16309. * @returns a new array of numbers
  16310. */
  16311. asArray(): number[];
  16312. /**
  16313. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16314. * @param array defines the destination array
  16315. * @param index defines the offset in the destination array
  16316. * @returns the current Vector3
  16317. */
  16318. toArray(array: FloatArray, index?: number): Vector3;
  16319. /**
  16320. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16321. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16322. */
  16323. toQuaternion(): Quaternion;
  16324. /**
  16325. * Adds the given vector to the current Vector3
  16326. * @param otherVector defines the second operand
  16327. * @returns the current updated Vector3
  16328. */
  16329. addInPlace(otherVector: Vector3): Vector3;
  16330. /**
  16331. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16332. * @param otherVector defines the second operand
  16333. * @returns the resulting Vector3
  16334. */
  16335. add(otherVector: Vector3): Vector3;
  16336. /**
  16337. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16338. * @param otherVector defines the second operand
  16339. * @param result defines the Vector3 object where to store the result
  16340. * @returns the current Vector3
  16341. */
  16342. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16343. /**
  16344. * Subtract the given vector from the current Vector3
  16345. * @param otherVector defines the second operand
  16346. * @returns the current updated Vector3
  16347. */
  16348. subtractInPlace(otherVector: Vector3): Vector3;
  16349. /**
  16350. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16351. * @param otherVector defines the second operand
  16352. * @returns the resulting Vector3
  16353. */
  16354. subtract(otherVector: Vector3): Vector3;
  16355. /**
  16356. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16357. * @param otherVector defines the second operand
  16358. * @param result defines the Vector3 object where to store the result
  16359. * @returns the current Vector3
  16360. */
  16361. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16362. /**
  16363. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16364. * @param x defines the x coordinate of the operand
  16365. * @param y defines the y coordinate of the operand
  16366. * @param z defines the z coordinate of the operand
  16367. * @returns the resulting Vector3
  16368. */
  16369. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16370. /**
  16371. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16372. * @param x defines the x coordinate of the operand
  16373. * @param y defines the y coordinate of the operand
  16374. * @param z defines the z coordinate of the operand
  16375. * @param result defines the Vector3 object where to store the result
  16376. * @returns the current Vector3
  16377. */
  16378. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16379. /**
  16380. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16381. * @returns a new Vector3
  16382. */
  16383. negate(): Vector3;
  16384. /**
  16385. * Multiplies the Vector3 coordinates by the float "scale"
  16386. * @param scale defines the multiplier factor
  16387. * @returns the current updated Vector3
  16388. */
  16389. scaleInPlace(scale: number): Vector3;
  16390. /**
  16391. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16392. * @param scale defines the multiplier factor
  16393. * @returns a new Vector3
  16394. */
  16395. scale(scale: number): Vector3;
  16396. /**
  16397. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16398. * @param scale defines the multiplier factor
  16399. * @param result defines the Vector3 object where to store the result
  16400. * @returns the current Vector3
  16401. */
  16402. scaleToRef(scale: number, result: Vector3): Vector3;
  16403. /**
  16404. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16405. * @param scale defines the scale factor
  16406. * @param result defines the Vector3 object where to store the result
  16407. * @returns the unmodified current Vector3
  16408. */
  16409. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16410. /**
  16411. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16412. * @param otherVector defines the second operand
  16413. * @returns true if both vectors are equals
  16414. */
  16415. equals(otherVector: Vector3): boolean;
  16416. /**
  16417. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16418. * @param otherVector defines the second operand
  16419. * @param epsilon defines the minimal distance to define values as equals
  16420. * @returns true if both vectors are distant less than epsilon
  16421. */
  16422. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16423. /**
  16424. * Returns true if the current Vector3 coordinates equals the given floats
  16425. * @param x defines the x coordinate of the operand
  16426. * @param y defines the y coordinate of the operand
  16427. * @param z defines the z coordinate of the operand
  16428. * @returns true if both vectors are equals
  16429. */
  16430. equalsToFloats(x: number, y: number, z: number): boolean;
  16431. /**
  16432. * Multiplies the current Vector3 coordinates by the given ones
  16433. * @param otherVector defines the second operand
  16434. * @returns the current updated Vector3
  16435. */
  16436. multiplyInPlace(otherVector: Vector3): Vector3;
  16437. /**
  16438. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16439. * @param otherVector defines the second operand
  16440. * @returns the new Vector3
  16441. */
  16442. multiply(otherVector: Vector3): Vector3;
  16443. /**
  16444. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16445. * @param otherVector defines the second operand
  16446. * @param result defines the Vector3 object where to store the result
  16447. * @returns the current Vector3
  16448. */
  16449. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16450. /**
  16451. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16452. * @param x defines the x coordinate of the operand
  16453. * @param y defines the y coordinate of the operand
  16454. * @param z defines the z coordinate of the operand
  16455. * @returns the new Vector3
  16456. */
  16457. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16458. /**
  16459. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16460. * @param otherVector defines the second operand
  16461. * @returns the new Vector3
  16462. */
  16463. divide(otherVector: Vector3): Vector3;
  16464. /**
  16465. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16466. * @param otherVector defines the second operand
  16467. * @param result defines the Vector3 object where to store the result
  16468. * @returns the current Vector3
  16469. */
  16470. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16471. /**
  16472. * Divides the current Vector3 coordinates by the given ones.
  16473. * @param otherVector defines the second operand
  16474. * @returns the current updated Vector3
  16475. */
  16476. divideInPlace(otherVector: Vector3): Vector3;
  16477. /**
  16478. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16479. * @param other defines the second operand
  16480. * @returns the current updated Vector3
  16481. */
  16482. minimizeInPlace(other: Vector3): Vector3;
  16483. /**
  16484. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16485. * @param other defines the second operand
  16486. * @returns the current updated Vector3
  16487. */
  16488. maximizeInPlace(other: Vector3): Vector3;
  16489. /**
  16490. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16491. */
  16492. readonly isNonUniform: boolean;
  16493. /**
  16494. * Gets the length of the Vector3
  16495. * @returns the length of the Vecto3
  16496. */
  16497. length(): number;
  16498. /**
  16499. * Gets the squared length of the Vector3
  16500. * @returns squared length of the Vector3
  16501. */
  16502. lengthSquared(): number;
  16503. /**
  16504. * Normalize the current Vector3.
  16505. * Please note that this is an in place operation.
  16506. * @returns the current updated Vector3
  16507. */
  16508. normalize(): Vector3;
  16509. /**
  16510. * Normalize the current Vector3 to a new vector
  16511. * @returns the new Vector3
  16512. */
  16513. normalizeToNew(): Vector3;
  16514. /**
  16515. * Normalize the current Vector3 to the reference
  16516. * @param reference define the Vector3 to update
  16517. * @returns the updated Vector3
  16518. */
  16519. normalizeToRef(reference: Vector3): Vector3;
  16520. /**
  16521. * Creates a new Vector3 copied from the current Vector3
  16522. * @returns the new Vector3
  16523. */
  16524. clone(): Vector3;
  16525. /**
  16526. * Copies the given vector coordinates to the current Vector3 ones
  16527. * @param source defines the source Vector3
  16528. * @returns the current updated Vector3
  16529. */
  16530. copyFrom(source: Vector3): Vector3;
  16531. /**
  16532. * Copies the given floats to the current Vector3 coordinates
  16533. * @param x defines the x coordinate of the operand
  16534. * @param y defines the y coordinate of the operand
  16535. * @param z defines the z coordinate of the operand
  16536. * @returns the current updated Vector3
  16537. */
  16538. copyFromFloats(x: number, y: number, z: number): Vector3;
  16539. /**
  16540. * Copies the given floats to the current Vector3 coordinates
  16541. * @param x defines the x coordinate of the operand
  16542. * @param y defines the y coordinate of the operand
  16543. * @param z defines the z coordinate of the operand
  16544. * @returns the current updated Vector3
  16545. */
  16546. set(x: number, y: number, z: number): Vector3;
  16547. /**
  16548. * Get the clip factor between two vectors
  16549. * @param vector0 defines the first operand
  16550. * @param vector1 defines the second operand
  16551. * @param axis defines the axis to use
  16552. * @param size defines the size along the axis
  16553. * @returns the clip factor
  16554. */
  16555. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16556. /**
  16557. * Get angle between two vectors
  16558. * @param vector0 angle between vector0 and vector1
  16559. * @param vector1 angle between vector0 and vector1
  16560. * @param normal direction of the normal
  16561. * @return the angle between vector0 and vector1
  16562. */
  16563. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16564. /**
  16565. * Returns a new Vector3 set from the index "offset" of the given array
  16566. * @param array defines the source array
  16567. * @param offset defines the offset in the source array
  16568. * @returns the new Vector3
  16569. */
  16570. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16571. /**
  16572. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16573. * This function is deprecated. Use FromArray instead
  16574. * @param array defines the source array
  16575. * @param offset defines the offset in the source array
  16576. * @returns the new Vector3
  16577. */
  16578. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16579. /**
  16580. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16581. * @param array defines the source array
  16582. * @param offset defines the offset in the source array
  16583. * @param result defines the Vector3 where to store the result
  16584. */
  16585. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16586. /**
  16587. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16588. * This function is deprecated. Use FromArrayToRef instead.
  16589. * @param array defines the source array
  16590. * @param offset defines the offset in the source array
  16591. * @param result defines the Vector3 where to store the result
  16592. */
  16593. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16594. /**
  16595. * Sets the given vector "result" with the given floats.
  16596. * @param x defines the x coordinate of the source
  16597. * @param y defines the y coordinate of the source
  16598. * @param z defines the z coordinate of the source
  16599. * @param result defines the Vector3 where to store the result
  16600. */
  16601. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16602. /**
  16603. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16604. * @returns a new empty Vector3
  16605. */
  16606. static Zero(): Vector3;
  16607. /**
  16608. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16609. * @returns a new unit Vector3
  16610. */
  16611. static One(): Vector3;
  16612. /**
  16613. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16614. * @returns a new up Vector3
  16615. */
  16616. static Up(): Vector3;
  16617. /**
  16618. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16619. * @returns a new down Vector3
  16620. */
  16621. static Down(): Vector3;
  16622. /**
  16623. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16624. * @returns a new forward Vector3
  16625. */
  16626. static Forward(): Vector3;
  16627. /**
  16628. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16629. * @returns a new right Vector3
  16630. */
  16631. static Right(): Vector3;
  16632. /**
  16633. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16634. * @returns a new left Vector3
  16635. */
  16636. static Left(): Vector3;
  16637. /**
  16638. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16639. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16640. * @param vector defines the Vector3 to transform
  16641. * @param transformation defines the transformation matrix
  16642. * @returns the transformed Vector3
  16643. */
  16644. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16645. /**
  16646. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16647. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16648. * @param vector defines the Vector3 to transform
  16649. * @param transformation defines the transformation matrix
  16650. * @param result defines the Vector3 where to store the result
  16651. */
  16652. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16653. /**
  16654. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16655. * This method computes tranformed coordinates only, not transformed direction vectors
  16656. * @param x define the x coordinate of the source vector
  16657. * @param y define the y coordinate of the source vector
  16658. * @param z define the z coordinate of the source vector
  16659. * @param transformation defines the transformation matrix
  16660. * @param result defines the Vector3 where to store the result
  16661. */
  16662. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16663. /**
  16664. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16665. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16666. * @param vector defines the Vector3 to transform
  16667. * @param transformation defines the transformation matrix
  16668. * @returns the new Vector3
  16669. */
  16670. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16671. /**
  16672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16673. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16674. * @param vector defines the Vector3 to transform
  16675. * @param transformation defines the transformation matrix
  16676. * @param result defines the Vector3 where to store the result
  16677. */
  16678. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16679. /**
  16680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16681. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16682. * @param x define the x coordinate of the source vector
  16683. * @param y define the y coordinate of the source vector
  16684. * @param z define the z coordinate of the source vector
  16685. * @param transformation defines the transformation matrix
  16686. * @param result defines the Vector3 where to store the result
  16687. */
  16688. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16689. /**
  16690. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16691. * @param value1 defines the first control point
  16692. * @param value2 defines the second control point
  16693. * @param value3 defines the third control point
  16694. * @param value4 defines the fourth control point
  16695. * @param amount defines the amount on the spline to use
  16696. * @returns the new Vector3
  16697. */
  16698. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16699. /**
  16700. * 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"
  16701. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16702. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16703. * @param value defines the current value
  16704. * @param min defines the lower range value
  16705. * @param max defines the upper range value
  16706. * @returns the new Vector3
  16707. */
  16708. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16709. /**
  16710. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16711. * @param value1 defines the first control point
  16712. * @param tangent1 defines the first tangent vector
  16713. * @param value2 defines the second control point
  16714. * @param tangent2 defines the second tangent vector
  16715. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16716. * @returns the new Vector3
  16717. */
  16718. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16719. /**
  16720. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16721. * @param start defines the start value
  16722. * @param end defines the end value
  16723. * @param amount max defines amount between both (between 0 and 1)
  16724. * @returns the new Vector3
  16725. */
  16726. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16727. /**
  16728. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16729. * @param start defines the start value
  16730. * @param end defines the end value
  16731. * @param amount max defines amount between both (between 0 and 1)
  16732. * @param result defines the Vector3 where to store the result
  16733. */
  16734. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16735. /**
  16736. * Returns the dot product (float) between the vectors "left" and "right"
  16737. * @param left defines the left operand
  16738. * @param right defines the right operand
  16739. * @returns the dot product
  16740. */
  16741. static Dot(left: Vector3, right: Vector3): number;
  16742. /**
  16743. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16744. * The cross product is then orthogonal to both "left" and "right"
  16745. * @param left defines the left operand
  16746. * @param right defines the right operand
  16747. * @returns the cross product
  16748. */
  16749. static Cross(left: Vector3, right: Vector3): Vector3;
  16750. /**
  16751. * Sets the given vector "result" with the cross product of "left" and "right"
  16752. * The cross product is then orthogonal to both "left" and "right"
  16753. * @param left defines the left operand
  16754. * @param right defines the right operand
  16755. * @param result defines the Vector3 where to store the result
  16756. */
  16757. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16758. /**
  16759. * Returns a new Vector3 as the normalization of the given vector
  16760. * @param vector defines the Vector3 to normalize
  16761. * @returns the new Vector3
  16762. */
  16763. static Normalize(vector: Vector3): Vector3;
  16764. /**
  16765. * Sets the given vector "result" with the normalization of the given first vector
  16766. * @param vector defines the Vector3 to normalize
  16767. * @param result defines the Vector3 where to store the result
  16768. */
  16769. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16770. private static _viewportMatrixCache;
  16771. /**
  16772. * Project a Vector3 onto screen space
  16773. * @param vector defines the Vector3 to project
  16774. * @param world defines the world matrix to use
  16775. * @param transform defines the transform (view x projection) matrix to use
  16776. * @param viewport defines the screen viewport to use
  16777. * @returns the new Vector3
  16778. */
  16779. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16780. /**
  16781. * Unproject from screen space to object space
  16782. * @param source defines the screen space Vector3 to use
  16783. * @param viewportWidth defines the current width of the viewport
  16784. * @param viewportHeight defines the current height of the viewport
  16785. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16786. * @param transform defines the transform (view x projection) matrix to use
  16787. * @returns the new Vector3
  16788. */
  16789. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16790. /**
  16791. * Unproject from screen space to object space
  16792. * @param source defines the screen space Vector3 to use
  16793. * @param viewportWidth defines the current width of the viewport
  16794. * @param viewportHeight defines the current height of the viewport
  16795. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16796. * @param view defines the view matrix to use
  16797. * @param projection defines the projection matrix to use
  16798. * @returns the new Vector3
  16799. */
  16800. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16801. /**
  16802. * Unproject from screen space to object space
  16803. * @param source defines the screen space Vector3 to use
  16804. * @param viewportWidth defines the current width of the viewport
  16805. * @param viewportHeight defines the current height of the viewport
  16806. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16807. * @param view defines the view matrix to use
  16808. * @param projection defines the projection matrix to use
  16809. * @param result defines the Vector3 where to store the result
  16810. */
  16811. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16812. /**
  16813. * Unproject from screen space to object space
  16814. * @param sourceX defines the screen space x coordinate to use
  16815. * @param sourceY defines the screen space y coordinate to use
  16816. * @param sourceZ defines the screen space z coordinate to use
  16817. * @param viewportWidth defines the current width of the viewport
  16818. * @param viewportHeight defines the current height of the viewport
  16819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16820. * @param view defines the view matrix to use
  16821. * @param projection defines the projection matrix to use
  16822. * @param result defines the Vector3 where to store the result
  16823. */
  16824. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16825. /**
  16826. * Gets the minimal coordinate values between two Vector3
  16827. * @param left defines the first operand
  16828. * @param right defines the second operand
  16829. * @returns the new Vector3
  16830. */
  16831. static Minimize(left: Vector3, right: Vector3): Vector3;
  16832. /**
  16833. * Gets the maximal coordinate values between two Vector3
  16834. * @param left defines the first operand
  16835. * @param right defines the second operand
  16836. * @returns the new Vector3
  16837. */
  16838. static Maximize(left: Vector3, right: Vector3): Vector3;
  16839. /**
  16840. * Returns the distance between the vectors "value1" and "value2"
  16841. * @param value1 defines the first operand
  16842. * @param value2 defines the second operand
  16843. * @returns the distance
  16844. */
  16845. static Distance(value1: Vector3, value2: Vector3): number;
  16846. /**
  16847. * Returns the squared distance between the vectors "value1" and "value2"
  16848. * @param value1 defines the first operand
  16849. * @param value2 defines the second operand
  16850. * @returns the squared distance
  16851. */
  16852. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16853. /**
  16854. * Returns a new Vector3 located at the center between "value1" and "value2"
  16855. * @param value1 defines the first operand
  16856. * @param value2 defines the second operand
  16857. * @returns the new Vector3
  16858. */
  16859. static Center(value1: Vector3, value2: Vector3): Vector3;
  16860. /**
  16861. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16862. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16863. * to something in order to rotate it from its local system to the given target system
  16864. * Note: axis1, axis2 and axis3 are normalized during this operation
  16865. * @param axis1 defines the first axis
  16866. * @param axis2 defines the second axis
  16867. * @param axis3 defines the third axis
  16868. * @returns a new Vector3
  16869. */
  16870. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16871. /**
  16872. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16873. * @param axis1 defines the first axis
  16874. * @param axis2 defines the second axis
  16875. * @param axis3 defines the third axis
  16876. * @param ref defines the Vector3 where to store the result
  16877. */
  16878. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16879. }
  16880. class Vector4 {
  16881. x: number;
  16882. y: number;
  16883. z: number;
  16884. w: number;
  16885. /**
  16886. * Creates a Vector4 object from the given floats.
  16887. */
  16888. constructor(x: number, y: number, z: number, w: number);
  16889. /**
  16890. * Returns the string with the Vector4 coordinates.
  16891. */
  16892. toString(): string;
  16893. /**
  16894. * Returns the string "Vector4".
  16895. */
  16896. getClassName(): string;
  16897. /**
  16898. * Returns the Vector4 hash code.
  16899. */
  16900. getHashCode(): number;
  16901. /**
  16902. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16903. */
  16904. asArray(): number[];
  16905. /**
  16906. * Populates the given array from the given index with the Vector4 coordinates.
  16907. * Returns the Vector4.
  16908. */
  16909. toArray(array: FloatArray, index?: number): Vector4;
  16910. /**
  16911. * Adds the given vector to the current Vector4.
  16912. * Returns the updated Vector4.
  16913. */
  16914. addInPlace(otherVector: Vector4): Vector4;
  16915. /**
  16916. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16917. */
  16918. add(otherVector: Vector4): Vector4;
  16919. /**
  16920. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16921. * Returns the current Vector4.
  16922. */
  16923. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16924. /**
  16925. * Subtract in place the given vector from the current Vector4.
  16926. * Returns the updated Vector4.
  16927. */
  16928. subtractInPlace(otherVector: Vector4): Vector4;
  16929. /**
  16930. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16931. */
  16932. subtract(otherVector: Vector4): Vector4;
  16933. /**
  16934. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16935. * Returns the current Vector4.
  16936. */
  16937. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16938. /**
  16939. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16940. */
  16941. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16942. /**
  16943. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16944. * Returns the current Vector4.
  16945. */
  16946. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16947. /**
  16948. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16949. */
  16950. negate(): Vector4;
  16951. /**
  16952. * Multiplies the current Vector4 coordinates by scale (float).
  16953. * Returns the updated Vector4.
  16954. */
  16955. scaleInPlace(scale: number): Vector4;
  16956. /**
  16957. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16958. */
  16959. scale(scale: number): Vector4;
  16960. /**
  16961. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16962. * Returns the current Vector4.
  16963. */
  16964. scaleToRef(scale: number, result: Vector4): Vector4;
  16965. /**
  16966. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16967. * @param scale defines the scale factor
  16968. * @param result defines the Vector4 object where to store the result
  16969. * @returns the unmodified current Vector4
  16970. */
  16971. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16972. /**
  16973. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16974. */
  16975. equals(otherVector: Vector4): boolean;
  16976. /**
  16977. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16978. */
  16979. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16980. /**
  16981. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16982. */
  16983. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16984. /**
  16985. * Multiplies in place the current Vector4 by the given one.
  16986. * Returns the updated Vector4.
  16987. */
  16988. multiplyInPlace(otherVector: Vector4): Vector4;
  16989. /**
  16990. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16991. */
  16992. multiply(otherVector: Vector4): Vector4;
  16993. /**
  16994. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16995. * Returns the current Vector4.
  16996. */
  16997. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16998. /**
  16999. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17000. */
  17001. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17002. /**
  17003. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17004. */
  17005. divide(otherVector: Vector4): Vector4;
  17006. /**
  17007. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17008. * Returns the current Vector4.
  17009. */
  17010. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17011. /**
  17012. * Divides the current Vector3 coordinates by the given ones.
  17013. * @returns the updated Vector3.
  17014. */
  17015. divideInPlace(otherVector: Vector4): Vector4;
  17016. /**
  17017. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17018. * @param other defines the second operand
  17019. * @returns the current updated Vector4
  17020. */
  17021. minimizeInPlace(other: Vector4): Vector4;
  17022. /**
  17023. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17024. * @param other defines the second operand
  17025. * @returns the current updated Vector4
  17026. */
  17027. maximizeInPlace(other: Vector4): Vector4;
  17028. /**
  17029. * Returns the Vector4 length (float).
  17030. */
  17031. length(): number;
  17032. /**
  17033. * Returns the Vector4 squared length (float).
  17034. */
  17035. lengthSquared(): number;
  17036. /**
  17037. * Normalizes in place the Vector4.
  17038. * Returns the updated Vector4.
  17039. */
  17040. normalize(): Vector4;
  17041. /**
  17042. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17043. */
  17044. toVector3(): Vector3;
  17045. /**
  17046. * Returns a new Vector4 copied from the current one.
  17047. */
  17048. clone(): Vector4;
  17049. /**
  17050. * Updates the current Vector4 with the given one coordinates.
  17051. * Returns the updated Vector4.
  17052. */
  17053. copyFrom(source: Vector4): Vector4;
  17054. /**
  17055. * Updates the current Vector4 coordinates with the given floats.
  17056. * Returns the updated Vector4.
  17057. */
  17058. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17059. /**
  17060. * Updates the current Vector4 coordinates with the given floats.
  17061. * Returns the updated Vector4.
  17062. */
  17063. set(x: number, y: number, z: number, w: number): Vector4;
  17064. /**
  17065. * Returns a new Vector4 set from the starting index of the given array.
  17066. */
  17067. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17068. /**
  17069. * Updates the given vector "result" from the starting index of the given array.
  17070. */
  17071. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17072. /**
  17073. * Updates the given vector "result" from the starting index of the given Float32Array.
  17074. */
  17075. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17076. /**
  17077. * Updates the given vector "result" coordinates from the given floats.
  17078. */
  17079. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17080. /**
  17081. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17082. */
  17083. static Zero(): Vector4;
  17084. /**
  17085. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17086. */
  17087. static One(): Vector4;
  17088. /**
  17089. * Returns a new normalized Vector4 from the given one.
  17090. */
  17091. static Normalize(vector: Vector4): Vector4;
  17092. /**
  17093. * Updates the given vector "result" from the normalization of the given one.
  17094. */
  17095. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17096. static Minimize(left: Vector4, right: Vector4): Vector4;
  17097. static Maximize(left: Vector4, right: Vector4): Vector4;
  17098. /**
  17099. * Returns the distance (float) between the vectors "value1" and "value2".
  17100. */
  17101. static Distance(value1: Vector4, value2: Vector4): number;
  17102. /**
  17103. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17104. */
  17105. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17106. /**
  17107. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17108. */
  17109. static Center(value1: Vector4, value2: Vector4): Vector4;
  17110. /**
  17111. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17112. * This methods computes transformed normalized direction vectors only.
  17113. */
  17114. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17115. /**
  17116. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17117. * This methods computes transformed normalized direction vectors only.
  17118. */
  17119. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17120. /**
  17121. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17122. * This methods computes transformed normalized direction vectors only.
  17123. */
  17124. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17125. }
  17126. interface ISize {
  17127. width: number;
  17128. height: number;
  17129. }
  17130. class Size implements ISize {
  17131. width: number;
  17132. height: number;
  17133. /**
  17134. * Creates a Size object from the given width and height (floats).
  17135. */
  17136. constructor(width: number, height: number);
  17137. toString(): string;
  17138. /**
  17139. * Returns the string "Size"
  17140. */
  17141. getClassName(): string;
  17142. /**
  17143. * Returns the Size hash code.
  17144. */
  17145. getHashCode(): number;
  17146. /**
  17147. * Updates the current size from the given one.
  17148. * Returns the updated Size.
  17149. */
  17150. copyFrom(src: Size): void;
  17151. /**
  17152. * Updates in place the current Size from the given floats.
  17153. * Returns the updated Size.
  17154. */
  17155. copyFromFloats(width: number, height: number): Size;
  17156. /**
  17157. * Updates in place the current Size from the given floats.
  17158. * Returns the updated Size.
  17159. */
  17160. set(width: number, height: number): Size;
  17161. /**
  17162. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17163. */
  17164. multiplyByFloats(w: number, h: number): Size;
  17165. /**
  17166. * Returns a new Size copied from the given one.
  17167. */
  17168. clone(): Size;
  17169. /**
  17170. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17171. */
  17172. equals(other: Size): boolean;
  17173. /**
  17174. * Returns the surface of the Size : width * height (float).
  17175. */
  17176. readonly surface: number;
  17177. /**
  17178. * Returns a new Size set to (0.0, 0.0)
  17179. */
  17180. static Zero(): Size;
  17181. /**
  17182. * Returns a new Size set as the addition result of the current Size and the given one.
  17183. */
  17184. add(otherSize: Size): Size;
  17185. /**
  17186. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17187. */
  17188. subtract(otherSize: Size): Size;
  17189. /**
  17190. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17191. */
  17192. static Lerp(start: Size, end: Size, amount: number): Size;
  17193. }
  17194. /**
  17195. * Class used to store quaternion data
  17196. * @see https://en.wikipedia.org/wiki/Quaternion
  17197. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17198. */
  17199. class Quaternion {
  17200. /** defines the first component (0 by default) */
  17201. x: number;
  17202. /** defines the second component (0 by default) */
  17203. y: number;
  17204. /** defines the third component (0 by default) */
  17205. z: number;
  17206. /** defines the fourth component (1.0 by default) */
  17207. w: number;
  17208. /**
  17209. * Creates a new Quaternion from the given floats
  17210. * @param x defines the first component (0 by default)
  17211. * @param y defines the second component (0 by default)
  17212. * @param z defines the third component (0 by default)
  17213. * @param w defines the fourth component (1.0 by default)
  17214. */
  17215. constructor(
  17216. /** defines the first component (0 by default) */
  17217. x?: number,
  17218. /** defines the second component (0 by default) */
  17219. y?: number,
  17220. /** defines the third component (0 by default) */
  17221. z?: number,
  17222. /** defines the fourth component (1.0 by default) */
  17223. w?: number);
  17224. /**
  17225. * Gets a string representation for the current quaternion
  17226. * @returns a string with the Quaternion coordinates
  17227. */
  17228. toString(): string;
  17229. /**
  17230. * Gets the class name of the quaternion
  17231. * @returns the string "Quaternion"
  17232. */
  17233. getClassName(): string;
  17234. /**
  17235. * Gets a hash code for this quaternion
  17236. * @returns the quaternion hash code
  17237. */
  17238. getHashCode(): number;
  17239. /**
  17240. * Copy the quaternion to an array
  17241. * @returns a new array populated with 4 elements from the quaternion coordinates
  17242. */
  17243. asArray(): number[];
  17244. /**
  17245. * Check if two quaternions are equals
  17246. * @param otherQuaternion defines the second operand
  17247. * @return true if the current quaternion and the given one coordinates are strictly equals
  17248. */
  17249. equals(otherQuaternion: Quaternion): boolean;
  17250. /**
  17251. * Clone the current quaternion
  17252. * @returns a new quaternion copied from the current one
  17253. */
  17254. clone(): Quaternion;
  17255. /**
  17256. * Copy a quaternion to the current one
  17257. * @param other defines the other quaternion
  17258. * @returns the updated current quaternion
  17259. */
  17260. copyFrom(other: Quaternion): Quaternion;
  17261. /**
  17262. * Updates the current quaternion with the given float coordinates
  17263. * @param x defines the x coordinate
  17264. * @param y defines the y coordinate
  17265. * @param z defines the z coordinate
  17266. * @param w defines the w coordinate
  17267. * @returns the updated current quaternion
  17268. */
  17269. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17270. /**
  17271. * Updates the current quaternion from the given float coordinates
  17272. * @param x defines the x coordinate
  17273. * @param y defines the y coordinate
  17274. * @param z defines the z coordinate
  17275. * @param w defines the w coordinate
  17276. * @returns the updated current quaternion
  17277. */
  17278. set(x: number, y: number, z: number, w: number): Quaternion;
  17279. /**
  17280. * Adds two quaternions
  17281. * @param other defines the second operand
  17282. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17283. */
  17284. add(other: Quaternion): Quaternion;
  17285. /**
  17286. * Add a quaternion to the current one
  17287. * @param other defines the quaternion to add
  17288. * @returns the current quaternion
  17289. */
  17290. addInPlace(other: Quaternion): Quaternion;
  17291. /**
  17292. * Subtract two quaternions
  17293. * @param other defines the second operand
  17294. * @returns a new quaternion as the subtraction result of the given one from the current one
  17295. */
  17296. subtract(other: Quaternion): Quaternion;
  17297. /**
  17298. * Multiplies the current quaternion by a scale factor
  17299. * @param value defines the scale factor
  17300. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17301. */
  17302. scale(value: number): Quaternion;
  17303. /**
  17304. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17305. * @param scale defines the scale factor
  17306. * @param result defines the Quaternion object where to store the result
  17307. * @returns the unmodified current quaternion
  17308. */
  17309. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17310. /**
  17311. * Multiplies in place the current quaternion by a scale factor
  17312. * @param value defines the scale factor
  17313. * @returns the current modified quaternion
  17314. */
  17315. scaleInPlace(value: number): Quaternion;
  17316. /**
  17317. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17318. * @param scale defines the scale factor
  17319. * @param result defines the Quaternion object where to store the result
  17320. * @returns the unmodified current quaternion
  17321. */
  17322. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17323. /**
  17324. * Multiplies two quaternions
  17325. * @param q1 defines the second operand
  17326. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17327. */
  17328. multiply(q1: Quaternion): Quaternion;
  17329. /**
  17330. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17331. * @param q1 defines the second operand
  17332. * @param result defines the target quaternion
  17333. * @returns the current quaternion
  17334. */
  17335. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17336. /**
  17337. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17338. * @param q1 defines the second operand
  17339. * @returns the currentupdated quaternion
  17340. */
  17341. multiplyInPlace(q1: Quaternion): Quaternion;
  17342. /**
  17343. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17344. * @param ref defines the target quaternion
  17345. * @returns the current quaternion
  17346. */
  17347. conjugateToRef(ref: Quaternion): Quaternion;
  17348. /**
  17349. * Conjugates in place (1-q) the current quaternion
  17350. * @returns the current updated quaternion
  17351. */
  17352. conjugateInPlace(): Quaternion;
  17353. /**
  17354. * Conjugates in place (1-q) the current quaternion
  17355. * @returns a new quaternion
  17356. */
  17357. conjugate(): Quaternion;
  17358. /**
  17359. * Gets length of current quaternion
  17360. * @returns the quaternion length (float)
  17361. */
  17362. length(): number;
  17363. /**
  17364. * Normalize in place the current quaternion
  17365. * @returns the current updated quaternion
  17366. */
  17367. normalize(): Quaternion;
  17368. /**
  17369. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17370. * @param order is a reserved parameter and is ignore for now
  17371. * @returns a new Vector3 containing the Euler angles
  17372. */
  17373. toEulerAngles(order?: string): Vector3;
  17374. /**
  17375. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17376. * @param result defines the vector which will be filled with the Euler angles
  17377. * @param order is a reserved parameter and is ignore for now
  17378. * @returns the current unchanged quaternion
  17379. */
  17380. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17381. /**
  17382. * Updates the given rotation matrix with the current quaternion values
  17383. * @param result defines the target matrix
  17384. * @returns the current unchanged quaternion
  17385. */
  17386. toRotationMatrix(result: Matrix): Quaternion;
  17387. /**
  17388. * Updates the current quaternion from the given rotation matrix values
  17389. * @param matrix defines the source matrix
  17390. * @returns the current updated quaternion
  17391. */
  17392. fromRotationMatrix(matrix: Matrix): Quaternion;
  17393. /**
  17394. * Creates a new quaternion from a rotation matrix
  17395. * @param matrix defines the source matrix
  17396. * @returns a new quaternion created from the given rotation matrix values
  17397. */
  17398. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17399. /**
  17400. * Updates the given quaternion with the given rotation matrix values
  17401. * @param matrix defines the source matrix
  17402. * @param result defines the target quaternion
  17403. */
  17404. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17405. /**
  17406. * Returns the dot product (float) between the quaternions "left" and "right"
  17407. * @param left defines the left operand
  17408. * @param right defines the right operand
  17409. * @returns the dot product
  17410. */
  17411. static Dot(left: Quaternion, right: Quaternion): number;
  17412. /**
  17413. * Checks if the two quaternions are close to each other
  17414. * @param quat0 defines the first quaternion to check
  17415. * @param quat1 defines the second quaternion to check
  17416. * @returns true if the two quaternions are close to each other
  17417. */
  17418. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17419. /**
  17420. * Creates an empty quaternion
  17421. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17422. */
  17423. static Zero(): Quaternion;
  17424. /**
  17425. * Inverse a given quaternion
  17426. * @param q defines the source quaternion
  17427. * @returns a new quaternion as the inverted current quaternion
  17428. */
  17429. static Inverse(q: Quaternion): Quaternion;
  17430. /**
  17431. * Creates an identity quaternion
  17432. * @returns the identity quaternion
  17433. */
  17434. static Identity(): Quaternion;
  17435. /**
  17436. * Gets a boolean indicating if the given quaternion is identity
  17437. * @param quaternion defines the quaternion to check
  17438. * @returns true if the quaternion is identity
  17439. */
  17440. static IsIdentity(quaternion: Quaternion): boolean;
  17441. /**
  17442. * Creates a quaternion from a rotation around an axis
  17443. * @param axis defines the axis to use
  17444. * @param angle defines the angle to use
  17445. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17446. */
  17447. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17448. /**
  17449. * Creates a rotation around an axis and stores it into the given quaternion
  17450. * @param axis defines the axis to use
  17451. * @param angle defines the angle to use
  17452. * @param result defines the target quaternion
  17453. * @returns the target quaternion
  17454. */
  17455. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17456. /**
  17457. * Creates a new quaternion from data stored into an array
  17458. * @param array defines the data source
  17459. * @param offset defines the offset in the source array where the data starts
  17460. * @returns a new quaternion
  17461. */
  17462. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17463. /**
  17464. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17465. * @param yaw defines the rotation around Y axis
  17466. * @param pitch defines the rotation around X axis
  17467. * @param roll defines the rotation around Z axis
  17468. * @returns the new quaternion
  17469. */
  17470. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17471. /**
  17472. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17473. * @param yaw defines the rotation around Y axis
  17474. * @param pitch defines the rotation around X axis
  17475. * @param roll defines the rotation around Z axis
  17476. * @param result defines the target quaternion
  17477. */
  17478. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17479. /**
  17480. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17481. * @param alpha defines the rotation around first axis
  17482. * @param beta defines the rotation around second axis
  17483. * @param gamma defines the rotation around third axis
  17484. * @returns the new quaternion
  17485. */
  17486. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17487. /**
  17488. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17489. * @param alpha defines the rotation around first axis
  17490. * @param beta defines the rotation around second axis
  17491. * @param gamma defines the rotation around third axis
  17492. * @param result defines the target quaternion
  17493. */
  17494. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17495. /**
  17496. * 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)
  17497. * @param axis1 defines the first axis
  17498. * @param axis2 defines the second axis
  17499. * @param axis3 defines the third axis
  17500. * @returns the new quaternion
  17501. */
  17502. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17503. /**
  17504. * 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
  17505. * @param axis1 defines the first axis
  17506. * @param axis2 defines the second axis
  17507. * @param axis3 defines the third axis
  17508. * @param ref defines the target quaternion
  17509. */
  17510. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17511. /**
  17512. * Interpolates between two quaternions
  17513. * @param left defines first quaternion
  17514. * @param right defines second quaternion
  17515. * @param amount defines the gradient to use
  17516. * @returns the new interpolated quaternion
  17517. */
  17518. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17519. /**
  17520. * Interpolates between two quaternions and stores it into a target quaternion
  17521. * @param left defines first quaternion
  17522. * @param right defines second quaternion
  17523. * @param amount defines the gradient to use
  17524. * @param result defines the target quaternion
  17525. */
  17526. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17527. /**
  17528. * Interpolate between two quaternions using Hermite interpolation
  17529. * @param value1 defines first quaternion
  17530. * @param tangent1 defines the incoming tangent
  17531. * @param value2 defines second quaternion
  17532. * @param tangent2 defines the outgoing tangent
  17533. * @param amount defines the target quaternion
  17534. * @returns the new interpolated quaternion
  17535. */
  17536. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17537. }
  17538. /**
  17539. * Class used to store matrix data (4x4)
  17540. */
  17541. class Matrix {
  17542. private static _tempQuaternion;
  17543. private static _xAxis;
  17544. private static _yAxis;
  17545. private static _zAxis;
  17546. private static _updateFlagSeed;
  17547. private static _identityReadOnly;
  17548. private _isIdentity;
  17549. private _isIdentityDirty;
  17550. /**
  17551. * Gets the update flag of the matrix which is an unique number for the matrix.
  17552. * It will be incremented every time the matrix data change.
  17553. * You can use it to speed the comparison between two versions of the same matrix.
  17554. */
  17555. updateFlag: number;
  17556. /**
  17557. * Gets or sets the internal data of the matrix
  17558. */
  17559. m: Float32Array;
  17560. /** @hidden */
  17561. _markAsUpdated(): void;
  17562. /**
  17563. * Creates an empty matrix (filled with zeros)
  17564. */
  17565. constructor();
  17566. /**
  17567. * Check if the current matrix is indentity
  17568. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17569. * @returns true is the matrix is the identity matrix
  17570. */
  17571. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17572. /**
  17573. * Gets the determinant of the matrix
  17574. * @returns the matrix determinant
  17575. */
  17576. determinant(): number;
  17577. /**
  17578. * Returns the matrix as a Float32Array
  17579. * @returns the matrix underlying array
  17580. */
  17581. toArray(): Float32Array;
  17582. /**
  17583. * Returns the matrix as a Float32Array
  17584. * @returns the matrix underlying array.
  17585. */
  17586. asArray(): Float32Array;
  17587. /**
  17588. * Inverts the current matrix in place
  17589. * @returns the current inverted matrix
  17590. */
  17591. invert(): Matrix;
  17592. /**
  17593. * Sets all the matrix elements to zero
  17594. * @returns the current matrix
  17595. */
  17596. reset(): Matrix;
  17597. /**
  17598. * Adds the current matrix with a second one
  17599. * @param other defines the matrix to add
  17600. * @returns a new matrix as the addition of the current matrix and the given one
  17601. */
  17602. add(other: Matrix): Matrix;
  17603. /**
  17604. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17605. * @param other defines the matrix to add
  17606. * @param result defines the target matrix
  17607. * @returns the current matrix
  17608. */
  17609. addToRef(other: Matrix, result: Matrix): Matrix;
  17610. /**
  17611. * Adds in place the given matrix to the current matrix
  17612. * @param other defines the second operand
  17613. * @returns the current updated matrix
  17614. */
  17615. addToSelf(other: Matrix): Matrix;
  17616. /**
  17617. * Sets the given matrix to the current inverted Matrix
  17618. * @param other defines the target matrix
  17619. * @returns the unmodified current matrix
  17620. */
  17621. invertToRef(other: Matrix): Matrix;
  17622. /**
  17623. * Inserts the translation vector (using 3 floats) in the current matrix
  17624. * @param x defines the 1st component of the translation
  17625. * @param y defines the 2nd component of the translation
  17626. * @param z defines the 3rd component of the translation
  17627. * @returns the current updated matrix
  17628. */
  17629. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17630. /**
  17631. * Inserts the translation vector in the current matrix
  17632. * @param vector3 defines the translation to insert
  17633. * @returns the current updated matrix
  17634. */
  17635. setTranslation(vector3: Vector3): Matrix;
  17636. /**
  17637. * Gets the translation value of the current matrix
  17638. * @returns a new Vector3 as the extracted translation from the matrix
  17639. */
  17640. getTranslation(): Vector3;
  17641. /**
  17642. * Fill a Vector3 with the extracted translation from the matrix
  17643. * @param result defines the Vector3 where to store the translation
  17644. * @returns the current matrix
  17645. */
  17646. getTranslationToRef(result: Vector3): Matrix;
  17647. /**
  17648. * Remove rotation and scaling part from the matrix
  17649. * @returns the updated matrix
  17650. */
  17651. removeRotationAndScaling(): Matrix;
  17652. /**
  17653. * Multiply two matrices
  17654. * @param other defines the second operand
  17655. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17656. */
  17657. multiply(other: Matrix): Matrix;
  17658. /**
  17659. * Copy the current matrix from the given one
  17660. * @param other defines the source matrix
  17661. * @returns the current updated matrix
  17662. */
  17663. copyFrom(other: Matrix): Matrix;
  17664. /**
  17665. * Populates the given array from the starting index with the current matrix values
  17666. * @param array defines the target array
  17667. * @param offset defines the offset in the target array where to start storing values
  17668. * @returns the current matrix
  17669. */
  17670. copyToArray(array: Float32Array, offset?: number): Matrix;
  17671. /**
  17672. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17673. * @param other defines the second operand
  17674. * @param result defines the matrix where to store the multiplication
  17675. * @returns the current matrix
  17676. */
  17677. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17678. /**
  17679. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17680. * @param other defines the second operand
  17681. * @param result defines the array where to store the multiplication
  17682. * @param offset defines the offset in the target array where to start storing values
  17683. * @returns the current matrix
  17684. */
  17685. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17686. /**
  17687. * Check equality between this matrix and a second one
  17688. * @param value defines the second matrix to compare
  17689. * @returns true is the current matrix and the given one values are strictly equal
  17690. */
  17691. equals(value: Matrix): boolean;
  17692. /**
  17693. * Clone the current matrix
  17694. * @returns a new matrix from the current matrix
  17695. */
  17696. clone(): Matrix;
  17697. /**
  17698. * Returns the name of the current matrix class
  17699. * @returns the string "Matrix"
  17700. */
  17701. getClassName(): string;
  17702. /**
  17703. * Gets the hash code of the current matrix
  17704. * @returns the hash code
  17705. */
  17706. getHashCode(): number;
  17707. /**
  17708. * Decomposes the current Matrix into a translation, rotation and scaling components
  17709. * @param scale defines the scale vector3 given as a reference to update
  17710. * @param rotation defines the rotation quaternion given as a reference to update
  17711. * @param translation defines the translation vector3 given as a reference to update
  17712. * @returns true if operation was successful
  17713. */
  17714. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17715. /**
  17716. * Gets specific row of the matrix
  17717. * @param index defines the number of the row to get
  17718. * @returns the index-th row of the current matrix as a new Vector4
  17719. */
  17720. getRow(index: number): Nullable<Vector4>;
  17721. /**
  17722. * Sets the index-th row of the current matrix to the vector4 values
  17723. * @param index defines the number of the row to set
  17724. * @param row defines the target vector4
  17725. * @returns the updated current matrix
  17726. */
  17727. setRow(index: number, row: Vector4): Matrix;
  17728. /**
  17729. * Compute the transpose of the matrix
  17730. * @returns the new transposed matrix
  17731. */
  17732. transpose(): Matrix;
  17733. /**
  17734. * Compute the transpose of the matrix and store it in a given matrix
  17735. * @param result defines the target matrix
  17736. * @returns the current matrix
  17737. */
  17738. transposeToRef(result: Matrix): Matrix;
  17739. /**
  17740. * Sets the index-th row of the current matrix with the given 4 x float values
  17741. * @param index defines the row index
  17742. * @param x defines the x component to set
  17743. * @param y defines the y component to set
  17744. * @param z defines the z component to set
  17745. * @param w defines the w component to set
  17746. * @returns the updated current matrix
  17747. */
  17748. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17749. /**
  17750. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17751. * @param scale defines the scale factor
  17752. * @returns a new matrix
  17753. */
  17754. scale(scale: number): Matrix;
  17755. /**
  17756. * Scale the current matrix values by a factor to a given result matrix
  17757. * @param scale defines the scale factor
  17758. * @param result defines the matrix to store the result
  17759. * @returns the current matrix
  17760. */
  17761. scaleToRef(scale: number, result: Matrix): Matrix;
  17762. /**
  17763. * Scale the current matrix values by a factor and add the result to a given matrix
  17764. * @param scale defines the scale factor
  17765. * @param result defines the Matrix to store the result
  17766. * @returns the current matrix
  17767. */
  17768. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17769. /**
  17770. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17771. * @param ref matrix to store the result
  17772. */
  17773. toNormalMatrix(ref: Matrix): void;
  17774. /**
  17775. * Gets only rotation part of the current matrix
  17776. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17777. */
  17778. getRotationMatrix(): Matrix;
  17779. /**
  17780. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17781. * @param result defines the target matrix to store data to
  17782. * @returns the current matrix
  17783. */
  17784. getRotationMatrixToRef(result: Matrix): Matrix;
  17785. /**
  17786. * Creates a matrix from an array
  17787. * @param array defines the source array
  17788. * @param offset defines an offset in the source array
  17789. * @returns a new Matrix set from the starting index of the given array
  17790. */
  17791. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17792. /**
  17793. * Copy the content of an array into a given matrix
  17794. * @param array defines the source array
  17795. * @param offset defines an offset in the source array
  17796. * @param result defines the target matrix
  17797. */
  17798. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17799. /**
  17800. * Stores an array into a matrix after having multiplied each component by a given factor
  17801. * @param array defines the source array
  17802. * @param offset defines the offset in the source array
  17803. * @param scale defines the scaling factor
  17804. * @param result defines the target matrix
  17805. */
  17806. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17807. /**
  17808. * Stores a list of values (16) inside a given matrix
  17809. * @param initialM11 defines 1st value of 1st row
  17810. * @param initialM12 defines 2nd value of 1st row
  17811. * @param initialM13 defines 3rd value of 1st row
  17812. * @param initialM14 defines 4th value of 1st row
  17813. * @param initialM21 defines 1st value of 2nd row
  17814. * @param initialM22 defines 2nd value of 2nd row
  17815. * @param initialM23 defines 3rd value of 2nd row
  17816. * @param initialM24 defines 4th value of 2nd row
  17817. * @param initialM31 defines 1st value of 3rd row
  17818. * @param initialM32 defines 2nd value of 3rd row
  17819. * @param initialM33 defines 3rd value of 3rd row
  17820. * @param initialM34 defines 4th value of 3rd row
  17821. * @param initialM41 defines 1st value of 4th row
  17822. * @param initialM42 defines 2nd value of 4th row
  17823. * @param initialM43 defines 3rd value of 4th row
  17824. * @param initialM44 defines 4th value of 4th row
  17825. * @param result defines the target matrix
  17826. */
  17827. 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;
  17828. /**
  17829. * Gets an identity matrix that must not be updated
  17830. */
  17831. static readonly IdentityReadOnly: Matrix;
  17832. /**
  17833. * Creates new matrix from a list of values (16)
  17834. * @param initialM11 defines 1st value of 1st row
  17835. * @param initialM12 defines 2nd value of 1st row
  17836. * @param initialM13 defines 3rd value of 1st row
  17837. * @param initialM14 defines 4th value of 1st row
  17838. * @param initialM21 defines 1st value of 2nd row
  17839. * @param initialM22 defines 2nd value of 2nd row
  17840. * @param initialM23 defines 3rd value of 2nd row
  17841. * @param initialM24 defines 4th value of 2nd row
  17842. * @param initialM31 defines 1st value of 3rd row
  17843. * @param initialM32 defines 2nd value of 3rd row
  17844. * @param initialM33 defines 3rd value of 3rd row
  17845. * @param initialM34 defines 4th value of 3rd row
  17846. * @param initialM41 defines 1st value of 4th row
  17847. * @param initialM42 defines 2nd value of 4th row
  17848. * @param initialM43 defines 3rd value of 4th row
  17849. * @param initialM44 defines 4th value of 4th row
  17850. * @returns the new matrix
  17851. */
  17852. 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;
  17853. /**
  17854. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17855. * @param scale defines the scale vector3
  17856. * @param rotation defines the rotation quaternion
  17857. * @param translation defines the translation vector3
  17858. * @returns a new matrix
  17859. */
  17860. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17861. /**
  17862. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17863. * @param scale defines the scale vector3
  17864. * @param rotation defines the rotation quaternion
  17865. * @param translation defines the translation vector3
  17866. * @param result defines the target matrix
  17867. */
  17868. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17869. /**
  17870. * Creates a new identity matrix
  17871. * @returns a new identity matrix
  17872. */
  17873. static Identity(): Matrix;
  17874. /**
  17875. * Creates a new identity matrix and stores the result in a given matrix
  17876. * @param result defines the target matrix
  17877. */
  17878. static IdentityToRef(result: Matrix): void;
  17879. /**
  17880. * Creates a new zero matrix
  17881. * @returns a new zero matrix
  17882. */
  17883. static Zero(): Matrix;
  17884. /**
  17885. * Creates a new rotation matrix for "angle" radians around the X axis
  17886. * @param angle defines the angle (in radians) to use
  17887. * @return the new matrix
  17888. */
  17889. static RotationX(angle: number): Matrix;
  17890. /**
  17891. * Creates a new matrix as the invert of a given matrix
  17892. * @param source defines the source matrix
  17893. * @returns the new matrix
  17894. */
  17895. static Invert(source: Matrix): Matrix;
  17896. /**
  17897. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17898. * @param angle defines the angle (in radians) to use
  17899. * @param result defines the target matrix
  17900. */
  17901. static RotationXToRef(angle: number, result: Matrix): void;
  17902. /**
  17903. * Creates a new rotation matrix for "angle" radians around the Y axis
  17904. * @param angle defines the angle (in radians) to use
  17905. * @return the new matrix
  17906. */
  17907. static RotationY(angle: number): Matrix;
  17908. /**
  17909. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17910. * @param angle defines the angle (in radians) to use
  17911. * @param result defines the target matrix
  17912. */
  17913. static RotationYToRef(angle: number, result: Matrix): void;
  17914. /**
  17915. * Creates a new rotation matrix for "angle" radians around the Z axis
  17916. * @param angle defines the angle (in radians) to use
  17917. * @return the new matrix
  17918. */
  17919. static RotationZ(angle: number): Matrix;
  17920. /**
  17921. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17922. * @param angle defines the angle (in radians) to use
  17923. * @param result defines the target matrix
  17924. */
  17925. static RotationZToRef(angle: number, result: Matrix): void;
  17926. /**
  17927. * Creates a new rotation matrix for "angle" radians around the given axis
  17928. * @param axis defines the axis to use
  17929. * @param angle defines the angle (in radians) to use
  17930. * @return the new matrix
  17931. */
  17932. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17933. /**
  17934. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17935. * @param axis defines the axis to use
  17936. * @param angle defines the angle (in radians) to use
  17937. * @param result defines the target matrix
  17938. */
  17939. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17940. /**
  17941. * Creates a rotation matrix
  17942. * @param yaw defines the yaw angle in radians (Y axis)
  17943. * @param pitch defines the pitch angle in radians (X axis)
  17944. * @param roll defines the roll angle in radians (X axis)
  17945. * @returns the new rotation matrix
  17946. */
  17947. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17948. /**
  17949. * Creates a rotation matrix and stores it in a given matrix
  17950. * @param yaw defines the yaw angle in radians (Y axis)
  17951. * @param pitch defines the pitch angle in radians (X axis)
  17952. * @param roll defines the roll angle in radians (X axis)
  17953. * @param result defines the target matrix
  17954. */
  17955. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17956. /**
  17957. * Creates a scaling matrix
  17958. * @param x defines the scale factor on X axis
  17959. * @param y defines the scale factor on Y axis
  17960. * @param z defines the scale factor on Z axis
  17961. * @returns the new matrix
  17962. */
  17963. static Scaling(x: number, y: number, z: number): Matrix;
  17964. /**
  17965. * Creates a scaling matrix and stores it in a given matrix
  17966. * @param x defines the scale factor on X axis
  17967. * @param y defines the scale factor on Y axis
  17968. * @param z defines the scale factor on Z axis
  17969. * @param result defines the target matrix
  17970. */
  17971. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17972. /**
  17973. * Creates a translation matrix
  17974. * @param x defines the translation on X axis
  17975. * @param y defines the translation on Y axis
  17976. * @param z defines the translationon Z axis
  17977. * @returns the new matrix
  17978. */
  17979. static Translation(x: number, y: number, z: number): Matrix;
  17980. /**
  17981. * Creates a translation matrix and stores it in a given matrix
  17982. * @param x defines the translation on X axis
  17983. * @param y defines the translation on Y axis
  17984. * @param z defines the translationon Z axis
  17985. * @param result defines the target matrix
  17986. */
  17987. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17988. /**
  17989. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17990. * @param startValue defines the start value
  17991. * @param endValue defines the end value
  17992. * @param gradient defines the gradient factor
  17993. * @returns the new matrix
  17994. */
  17995. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17996. /**
  17997. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17998. * @param startValue defines the start value
  17999. * @param endValue defines the end value
  18000. * @param gradient defines the gradient factor
  18001. * @param result defines the Matrix object where to store data
  18002. */
  18003. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18004. /**
  18005. * Builds a new matrix whose values are computed by:
  18006. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18007. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18008. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18009. * @param startValue defines the first matrix
  18010. * @param endValue defines the second matrix
  18011. * @param gradient defines the gradient between the two matrices
  18012. * @returns the new matrix
  18013. */
  18014. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18015. /**
  18016. * Update a matrix to values which are computed by:
  18017. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18018. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18019. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18020. * @param startValue defines the first matrix
  18021. * @param endValue defines the second matrix
  18022. * @param gradient defines the gradient between the two matrices
  18023. * @param result defines the target matrix
  18024. */
  18025. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18026. /**
  18027. * 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"
  18028. * This function works in left handed mode
  18029. * @param eye defines the final position of the entity
  18030. * @param target defines where the entity should look at
  18031. * @param up defines the up vector for the entity
  18032. * @returns the new matrix
  18033. */
  18034. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18035. /**
  18036. * 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".
  18037. * This function works in left handed mode
  18038. * @param eye defines the final position of the entity
  18039. * @param target defines where the entity should look at
  18040. * @param up defines the up vector for the entity
  18041. * @param result defines the target matrix
  18042. */
  18043. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18044. /**
  18045. * 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"
  18046. * This function works in right handed mode
  18047. * @param eye defines the final position of the entity
  18048. * @param target defines where the entity should look at
  18049. * @param up defines the up vector for the entity
  18050. * @returns the new matrix
  18051. */
  18052. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18053. /**
  18054. * 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".
  18055. * This function works in right handed mode
  18056. * @param eye defines the final position of the entity
  18057. * @param target defines where the entity should look at
  18058. * @param up defines the up vector for the entity
  18059. * @param result defines the target matrix
  18060. */
  18061. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18062. /**
  18063. * Create a left-handed orthographic projection matrix
  18064. * @param width defines the viewport width
  18065. * @param height defines the viewport height
  18066. * @param znear defines the near clip plane
  18067. * @param zfar defines the far clip plane
  18068. * @returns a new matrix as a left-handed orthographic projection matrix
  18069. */
  18070. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18071. /**
  18072. * Store a left-handed orthographic projection to a given matrix
  18073. * @param width defines the viewport width
  18074. * @param height defines the viewport height
  18075. * @param znear defines the near clip plane
  18076. * @param zfar defines the far clip plane
  18077. * @param result defines the target matrix
  18078. */
  18079. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18080. /**
  18081. * Create a left-handed orthographic projection matrix
  18082. * @param left defines the viewport left coordinate
  18083. * @param right defines the viewport right coordinate
  18084. * @param bottom defines the viewport bottom coordinate
  18085. * @param top defines the viewport top coordinate
  18086. * @param znear defines the near clip plane
  18087. * @param zfar defines the far clip plane
  18088. * @returns a new matrix as a left-handed orthographic projection matrix
  18089. */
  18090. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18091. /**
  18092. * Stores a left-handed orthographic projection into a given matrix
  18093. * @param left defines the viewport left coordinate
  18094. * @param right defines the viewport right coordinate
  18095. * @param bottom defines the viewport bottom coordinate
  18096. * @param top defines the viewport top coordinate
  18097. * @param znear defines the near clip plane
  18098. * @param zfar defines the far clip plane
  18099. * @param result defines the target matrix
  18100. */
  18101. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18102. /**
  18103. * Creates a right-handed orthographic projection matrix
  18104. * @param left defines the viewport left coordinate
  18105. * @param right defines the viewport right coordinate
  18106. * @param bottom defines the viewport bottom coordinate
  18107. * @param top defines the viewport top coordinate
  18108. * @param znear defines the near clip plane
  18109. * @param zfar defines the far clip plane
  18110. * @returns a new matrix as a right-handed orthographic projection matrix
  18111. */
  18112. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18113. /**
  18114. * Stores a right-handed orthographic projection into a given matrix
  18115. * @param left defines the viewport left coordinate
  18116. * @param right defines the viewport right coordinate
  18117. * @param bottom defines the viewport bottom coordinate
  18118. * @param top defines the viewport top coordinate
  18119. * @param znear defines the near clip plane
  18120. * @param zfar defines the far clip plane
  18121. * @param result defines the target matrix
  18122. */
  18123. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18124. /**
  18125. * Creates a left-handed perspective projection matrix
  18126. * @param width defines the viewport width
  18127. * @param height defines the viewport height
  18128. * @param znear defines the near clip plane
  18129. * @param zfar defines the far clip plane
  18130. * @returns a new matrix as a left-handed perspective projection matrix
  18131. */
  18132. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18133. /**
  18134. * Creates a left-handed perspective projection matrix
  18135. * @param fov defines the horizontal field of view
  18136. * @param aspect defines the aspect ratio
  18137. * @param znear defines the near clip plane
  18138. * @param zfar defines the far clip plane
  18139. * @returns a new matrix as a left-handed perspective projection matrix
  18140. */
  18141. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18142. /**
  18143. * Stores a left-handed perspective projection into a given matrix
  18144. * @param fov defines the horizontal field of view
  18145. * @param aspect defines the aspect ratio
  18146. * @param znear defines the near clip plane
  18147. * @param zfar defines the far clip plane
  18148. * @param result defines the target matrix
  18149. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18150. */
  18151. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18152. /**
  18153. * Creates a right-handed perspective projection matrix
  18154. * @param fov defines the horizontal field of view
  18155. * @param aspect defines the aspect ratio
  18156. * @param znear defines the near clip plane
  18157. * @param zfar defines the far clip plane
  18158. * @returns a new matrix as a right-handed perspective projection matrix
  18159. */
  18160. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18161. /**
  18162. * Stores a right-handed perspective projection into a given matrix
  18163. * @param fov defines the horizontal field of view
  18164. * @param aspect defines the aspect ratio
  18165. * @param znear defines the near clip plane
  18166. * @param zfar defines the far clip plane
  18167. * @param result defines the target matrix
  18168. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18169. */
  18170. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18171. /**
  18172. * Stores a perspective projection for WebVR info a given matrix
  18173. * @param fov defines the field of view
  18174. * @param znear defines the near clip plane
  18175. * @param zfar defines the far clip plane
  18176. * @param result defines the target matrix
  18177. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18178. */
  18179. static PerspectiveFovWebVRToRef(fov: {
  18180. upDegrees: number;
  18181. downDegrees: number;
  18182. leftDegrees: number;
  18183. rightDegrees: number;
  18184. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18185. /**
  18186. * Computes a complete transformation matrix
  18187. * @param viewport defines the viewport to use
  18188. * @param world defines the world matrix
  18189. * @param view defines the view matrix
  18190. * @param projection defines the projection matrix
  18191. * @param zmin defines the near clip plane
  18192. * @param zmax defines the far clip plane
  18193. * @returns the transformation matrix
  18194. */
  18195. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18196. /**
  18197. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18198. * @param matrix defines the matrix to use
  18199. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18200. */
  18201. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18202. /**
  18203. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18204. * @param matrix defines the matrix to use
  18205. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18206. */
  18207. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18208. /**
  18209. * Compute the transpose of a given matrix
  18210. * @param matrix defines the matrix to transpose
  18211. * @returns the new matrix
  18212. */
  18213. static Transpose(matrix: Matrix): Matrix;
  18214. /**
  18215. * Compute the transpose of a matrix and store it in a target matrix
  18216. * @param matrix defines the matrix to transpose
  18217. * @param result defines the target matrix
  18218. */
  18219. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18220. /**
  18221. * Computes a reflection matrix from a plane
  18222. * @param plane defines the reflection plane
  18223. * @returns a new matrix
  18224. */
  18225. static Reflection(plane: Plane): Matrix;
  18226. /**
  18227. * Computes a reflection matrix from a plane
  18228. * @param plane defines the reflection plane
  18229. * @param result defines the target matrix
  18230. */
  18231. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18232. /**
  18233. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18234. * @param xaxis defines the value of the 1st axis
  18235. * @param yaxis defines the value of the 2nd axis
  18236. * @param zaxis defines the value of the 3rd axis
  18237. * @param result defines the target matrix
  18238. */
  18239. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18240. /**
  18241. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18242. * @param quat defines the quaternion to use
  18243. * @param result defines the target matrix
  18244. */
  18245. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18246. }
  18247. class Plane {
  18248. normal: Vector3;
  18249. d: number;
  18250. /**
  18251. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18252. */
  18253. constructor(a: number, b: number, c: number, d: number);
  18254. /**
  18255. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18256. */
  18257. asArray(): number[];
  18258. /**
  18259. * Returns a new plane copied from the current Plane.
  18260. */
  18261. clone(): Plane;
  18262. /**
  18263. * Returns the string "Plane".
  18264. */
  18265. getClassName(): string;
  18266. /**
  18267. * Returns the Plane hash code.
  18268. */
  18269. getHashCode(): number;
  18270. /**
  18271. * Normalize the current Plane in place.
  18272. * Returns the updated Plane.
  18273. */
  18274. normalize(): Plane;
  18275. /**
  18276. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18277. */
  18278. transform(transformation: Matrix): Plane;
  18279. /**
  18280. * Returns the dot product (float) of the point coordinates and the plane normal.
  18281. */
  18282. dotCoordinate(point: Vector3): number;
  18283. /**
  18284. * Updates the current Plane from the plane defined by the three given points.
  18285. * Returns the updated Plane.
  18286. */
  18287. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18288. /**
  18289. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18290. */
  18291. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18292. /**
  18293. * Returns the signed distance (float) from the given point to the Plane.
  18294. */
  18295. signedDistanceTo(point: Vector3): number;
  18296. /**
  18297. * Returns a new Plane from the given array.
  18298. */
  18299. static FromArray(array: ArrayLike<number>): Plane;
  18300. /**
  18301. * Returns a new Plane defined by the three given points.
  18302. */
  18303. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18304. /**
  18305. * Returns a new Plane the normal vector to this plane at the given origin point.
  18306. * Note : the vector "normal" is updated because normalized.
  18307. */
  18308. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18309. /**
  18310. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18311. */
  18312. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18313. }
  18314. class Viewport {
  18315. x: number;
  18316. y: number;
  18317. width: number;
  18318. height: number;
  18319. /**
  18320. * Creates a Viewport object located at (x, y) and sized (width, height).
  18321. */
  18322. constructor(x: number, y: number, width: number, height: number);
  18323. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18324. /**
  18325. * Returns a new Viewport copied from the current one.
  18326. */
  18327. clone(): Viewport;
  18328. }
  18329. class Frustum {
  18330. /**
  18331. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18332. */
  18333. static GetPlanes(transform: Matrix): Plane[];
  18334. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18335. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18336. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18337. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18338. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18339. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18340. /**
  18341. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18342. */
  18343. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18344. }
  18345. /** Defines supported spaces */
  18346. enum Space {
  18347. /** Local (object) space */
  18348. LOCAL = 0,
  18349. /** World space */
  18350. WORLD = 1,
  18351. /** Bone space */
  18352. BONE = 2,
  18353. }
  18354. /** Defines the 3 main axes */
  18355. class Axis {
  18356. /** X axis */
  18357. static X: Vector3;
  18358. /** Y axis */
  18359. static Y: Vector3;
  18360. /** Z axis */
  18361. static Z: Vector3;
  18362. }
  18363. class BezierCurve {
  18364. /**
  18365. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18366. */
  18367. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18368. }
  18369. /**
  18370. * Defines potential orientation for back face culling
  18371. */
  18372. enum Orientation {
  18373. /**
  18374. * Clockwise
  18375. */
  18376. CW = 0,
  18377. /** Counter clockwise */
  18378. CCW = 1,
  18379. }
  18380. /**
  18381. * Defines angle representation
  18382. */
  18383. class Angle {
  18384. private _radians;
  18385. /**
  18386. * Creates an Angle object of "radians" radians (float).
  18387. */
  18388. constructor(radians: number);
  18389. /**
  18390. * Get value in degrees
  18391. * @returns the Angle value in degrees (float)
  18392. */
  18393. degrees(): number;
  18394. /**
  18395. * Get value in radians
  18396. * @returns the Angle value in radians (float)
  18397. */
  18398. radians(): number;
  18399. /**
  18400. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18401. * @param a defines first vector
  18402. * @param b defines second vector
  18403. * @returns a new Angle
  18404. */
  18405. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18406. /**
  18407. * Gets a new Angle object from the given float in radians
  18408. * @param radians defines the angle value in radians
  18409. * @returns a new Angle
  18410. */
  18411. static FromRadians(radians: number): Angle;
  18412. /**
  18413. * Gets a new Angle object from the given float in degrees
  18414. * @param degrees defines the angle value in degrees
  18415. * @returns a new Angle
  18416. */
  18417. static FromDegrees(degrees: number): Angle;
  18418. }
  18419. class Arc2 {
  18420. startPoint: Vector2;
  18421. midPoint: Vector2;
  18422. endPoint: Vector2;
  18423. centerPoint: Vector2;
  18424. radius: number;
  18425. angle: Angle;
  18426. startAngle: Angle;
  18427. orientation: Orientation;
  18428. /**
  18429. * Creates an Arc object from the three given points : start, middle and end.
  18430. */
  18431. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18432. }
  18433. class Path2 {
  18434. private _points;
  18435. private _length;
  18436. closed: boolean;
  18437. /**
  18438. * Creates a Path2 object from the starting 2D coordinates x and y.
  18439. */
  18440. constructor(x: number, y: number);
  18441. /**
  18442. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18443. * Returns the updated Path2.
  18444. */
  18445. addLineTo(x: number, y: number): Path2;
  18446. /**
  18447. * 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.
  18448. * Returns the updated Path2.
  18449. */
  18450. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18451. /**
  18452. * Closes the Path2.
  18453. * Returns the Path2.
  18454. */
  18455. close(): Path2;
  18456. /**
  18457. * Returns the Path2 total length (float).
  18458. */
  18459. length(): number;
  18460. /**
  18461. * Returns the Path2 internal array of points.
  18462. */
  18463. getPoints(): Vector2[];
  18464. /**
  18465. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18466. */
  18467. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18468. /**
  18469. * Returns a new Path2 starting at the coordinates (x, y).
  18470. */
  18471. static StartingAt(x: number, y: number): Path2;
  18472. }
  18473. class Path3D {
  18474. path: Vector3[];
  18475. private _curve;
  18476. private _distances;
  18477. private _tangents;
  18478. private _normals;
  18479. private _binormals;
  18480. private _raw;
  18481. /**
  18482. * new Path3D(path, normal, raw)
  18483. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18484. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18485. * path : an array of Vector3, the curve axis of the Path3D
  18486. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18487. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18488. */
  18489. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18490. /**
  18491. * Returns the Path3D array of successive Vector3 designing its curve.
  18492. */
  18493. getCurve(): Vector3[];
  18494. /**
  18495. * Returns an array populated with tangent vectors on each Path3D curve point.
  18496. */
  18497. getTangents(): Vector3[];
  18498. /**
  18499. * Returns an array populated with normal vectors on each Path3D curve point.
  18500. */
  18501. getNormals(): Vector3[];
  18502. /**
  18503. * Returns an array populated with binormal vectors on each Path3D curve point.
  18504. */
  18505. getBinormals(): Vector3[];
  18506. /**
  18507. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18508. */
  18509. getDistances(): number[];
  18510. /**
  18511. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18512. * Returns the same object updated.
  18513. */
  18514. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18515. private _compute(firstNormal);
  18516. private _getFirstNonNullVector(index);
  18517. private _getLastNonNullVector(index);
  18518. private _normalVector(v0, vt, va);
  18519. }
  18520. class Curve3 {
  18521. private _points;
  18522. private _length;
  18523. /**
  18524. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18526. * @param v1 (Vector3) the control point
  18527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18528. * @param nbPoints (integer) the wanted number of points in the curve
  18529. */
  18530. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18531. /**
  18532. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18533. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18534. * @param v1 (Vector3) the first control point
  18535. * @param v2 (Vector3) the second control point
  18536. * @param v3 (Vector3) the end point of the Cubic Bezier
  18537. * @param nbPoints (integer) the wanted number of points in the curve
  18538. */
  18539. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18540. /**
  18541. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18542. * @param p1 (Vector3) the origin point of the Hermite Spline
  18543. * @param t1 (Vector3) the tangent vector at the origin point
  18544. * @param p2 (Vector3) the end point of the Hermite Spline
  18545. * @param t2 (Vector3) the tangent vector at the end point
  18546. * @param nbPoints (integer) the wanted number of points in the curve
  18547. */
  18548. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18549. /**
  18550. * Returns a Curve3 object along a CatmullRom Spline curve :
  18551. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18552. * @param nbPoints (integer) the wanted number of points between each curve control points
  18553. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18554. */
  18555. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18556. /**
  18557. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18558. * A Curve3 is designed from a series of successive Vector3.
  18559. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18560. */
  18561. constructor(points: Vector3[]);
  18562. /**
  18563. * Returns the Curve3 stored array of successive Vector3
  18564. */
  18565. getPoints(): Vector3[];
  18566. /**
  18567. * Returns the computed length (float) of the curve.
  18568. */
  18569. length(): number;
  18570. /**
  18571. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18572. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18573. * curveA and curveB keep unchanged.
  18574. */
  18575. continue(curve: Curve3): Curve3;
  18576. private _computeLength(path);
  18577. }
  18578. class PositionNormalVertex {
  18579. position: Vector3;
  18580. normal: Vector3;
  18581. constructor(position?: Vector3, normal?: Vector3);
  18582. clone(): PositionNormalVertex;
  18583. }
  18584. class PositionNormalTextureVertex {
  18585. position: Vector3;
  18586. normal: Vector3;
  18587. uv: Vector2;
  18588. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18589. clone(): PositionNormalTextureVertex;
  18590. }
  18591. class Tmp {
  18592. static Color3: Color3[];
  18593. static Color4: Color4[];
  18594. static Vector2: Vector2[];
  18595. static Vector3: Vector3[];
  18596. static Vector4: Vector4[];
  18597. static Quaternion: Quaternion[];
  18598. static Matrix: Matrix[];
  18599. }
  18600. }
  18601. declare module BABYLON {
  18602. /**
  18603. * Class representing spherical polynomial coefficients to the 3rd degree
  18604. */
  18605. class SphericalPolynomial {
  18606. /**
  18607. * The x coefficients of the spherical polynomial
  18608. */
  18609. x: Vector3;
  18610. /**
  18611. * The y coefficients of the spherical polynomial
  18612. */
  18613. y: Vector3;
  18614. /**
  18615. * The z coefficients of the spherical polynomial
  18616. */
  18617. z: Vector3;
  18618. /**
  18619. * The xx coefficients of the spherical polynomial
  18620. */
  18621. xx: Vector3;
  18622. /**
  18623. * The yy coefficients of the spherical polynomial
  18624. */
  18625. yy: Vector3;
  18626. /**
  18627. * The zz coefficients of the spherical polynomial
  18628. */
  18629. zz: Vector3;
  18630. /**
  18631. * The xy coefficients of the spherical polynomial
  18632. */
  18633. xy: Vector3;
  18634. /**
  18635. * The yz coefficients of the spherical polynomial
  18636. */
  18637. yz: Vector3;
  18638. /**
  18639. * The zx coefficients of the spherical polynomial
  18640. */
  18641. zx: Vector3;
  18642. /**
  18643. * Adds an ambient color to the spherical polynomial
  18644. * @param color the color to add
  18645. */
  18646. addAmbient(color: Color3): void;
  18647. /**
  18648. * Scales the spherical polynomial by the given amount
  18649. * @param scale the amount to scale
  18650. */
  18651. scale(scale: number): void;
  18652. /**
  18653. * Gets the spherical polynomial from harmonics
  18654. * @param harmonics the spherical harmonics
  18655. * @returns the spherical polynomial
  18656. */
  18657. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18658. /**
  18659. * Constructs a spherical polynomial from an array.
  18660. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  18661. * @returns the spherical polynomial
  18662. */
  18663. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  18664. }
  18665. /**
  18666. * Class representing spherical harmonics coefficients to the 3rd degree
  18667. */
  18668. class SphericalHarmonics {
  18669. /**
  18670. * The l0,0 coefficients of the spherical harmonics
  18671. */
  18672. l00: Vector3;
  18673. /**
  18674. * The l1,-1 coefficients of the spherical harmonics
  18675. */
  18676. l1_1: Vector3;
  18677. /**
  18678. * The l1,0 coefficients of the spherical harmonics
  18679. */
  18680. l10: Vector3;
  18681. /**
  18682. * The l1,1 coefficients of the spherical harmonics
  18683. */
  18684. l11: Vector3;
  18685. /**
  18686. * The l2,-2 coefficients of the spherical harmonics
  18687. */
  18688. l2_2: Vector3;
  18689. /**
  18690. * The l2,-1 coefficients of the spherical harmonics
  18691. */
  18692. l2_1: Vector3;
  18693. /**
  18694. * The l2,0 coefficients of the spherical harmonics
  18695. */
  18696. l20: Vector3;
  18697. /**
  18698. * The l2,1 coefficients of the spherical harmonics
  18699. */
  18700. l21: Vector3;
  18701. /**
  18702. * The l2,2 coefficients of the spherical harmonics
  18703. */
  18704. lL22: Vector3;
  18705. /**
  18706. * Adds a light to the spherical harmonics
  18707. * @param direction the direction of the light
  18708. * @param color the color of the light
  18709. * @param deltaSolidAngle the delta solid angle of the light
  18710. */
  18711. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18712. /**
  18713. * Scales the spherical harmonics by the given amount
  18714. * @param scale the amount to scale
  18715. */
  18716. scale(scale: number): void;
  18717. /**
  18718. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  18719. *
  18720. * ```
  18721. * E_lm = A_l * L_lm
  18722. * ```
  18723. *
  18724. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  18725. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  18726. * the scaling factors are given in equation 9.
  18727. */
  18728. convertIncidentRadianceToIrradiance(): void;
  18729. /**
  18730. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  18731. *
  18732. * ```
  18733. * L = (1/pi) * E * rho
  18734. * ```
  18735. *
  18736. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  18737. */
  18738. convertIrradianceToLambertianRadiance(): void;
  18739. /**
  18740. * Gets the spherical harmonics from polynomial
  18741. * @param polynomial the spherical polynomial
  18742. * @returns the spherical harmonics
  18743. */
  18744. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18745. /**
  18746. * Constructs a spherical harmonics from an array.
  18747. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  18748. * @returns the spherical harmonics
  18749. */
  18750. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  18751. }
  18752. }
  18753. declare module BABYLON {
  18754. /**
  18755. * Defines a target to use with MorphTargetManager
  18756. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18757. */
  18758. class MorphTarget implements IAnimatable {
  18759. /** defines the name of the target */
  18760. name: string;
  18761. /**
  18762. * Gets or sets the list of animations
  18763. */
  18764. animations: Animation[];
  18765. private _scene;
  18766. private _positions;
  18767. private _normals;
  18768. private _tangents;
  18769. private _influence;
  18770. /**
  18771. * Observable raised when the influence changes
  18772. */
  18773. onInfluenceChanged: Observable<boolean>;
  18774. /**
  18775. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18776. */
  18777. influence: number;
  18778. private _animationPropertiesOverride;
  18779. /**
  18780. * Gets or sets the animation properties override
  18781. */
  18782. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18783. /**
  18784. * Creates a new MorphTarget
  18785. * @param name defines the name of the target
  18786. * @param influence defines the influence to use
  18787. */
  18788. constructor(
  18789. /** defines the name of the target */
  18790. name: string, influence?: number, scene?: Nullable<Scene>);
  18791. /**
  18792. * Gets a boolean defining if the target contains position data
  18793. */
  18794. readonly hasPositions: boolean;
  18795. /**
  18796. * Gets a boolean defining if the target contains normal data
  18797. */
  18798. readonly hasNormals: boolean;
  18799. /**
  18800. * Gets a boolean defining if the target contains tangent data
  18801. */
  18802. readonly hasTangents: boolean;
  18803. /**
  18804. * Affects position data to this target
  18805. * @param data defines the position data to use
  18806. */
  18807. setPositions(data: Nullable<FloatArray>): void;
  18808. /**
  18809. * Gets the position data stored in this target
  18810. * @returns a FloatArray containing the position data (or null if not present)
  18811. */
  18812. getPositions(): Nullable<FloatArray>;
  18813. /**
  18814. * Affects normal data to this target
  18815. * @param data defines the normal data to use
  18816. */
  18817. setNormals(data: Nullable<FloatArray>): void;
  18818. /**
  18819. * Gets the normal data stored in this target
  18820. * @returns a FloatArray containing the normal data (or null if not present)
  18821. */
  18822. getNormals(): Nullable<FloatArray>;
  18823. /**
  18824. * Affects tangent data to this target
  18825. * @param data defines the tangent data to use
  18826. */
  18827. setTangents(data: Nullable<FloatArray>): void;
  18828. /**
  18829. * Gets the tangent data stored in this target
  18830. * @returns a FloatArray containing the tangent data (or null if not present)
  18831. */
  18832. getTangents(): Nullable<FloatArray>;
  18833. /**
  18834. * Serializes the current target into a Serialization object
  18835. * @returns the serialized object
  18836. */
  18837. serialize(): any;
  18838. /**
  18839. * Creates a new target from serialized data
  18840. * @param serializationObject defines the serialized data to use
  18841. * @returns a new MorphTarget
  18842. */
  18843. static Parse(serializationObject: any): MorphTarget;
  18844. /**
  18845. * Creates a MorphTarget from mesh data
  18846. * @param mesh defines the source mesh
  18847. * @param name defines the name to use for the new target
  18848. * @param influence defines the influence to attach to the target
  18849. * @returns a new MorphTarget
  18850. */
  18851. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18852. }
  18853. }
  18854. declare module BABYLON {
  18855. /**
  18856. * This class is used to deform meshes using morphing between different targets
  18857. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18858. */
  18859. class MorphTargetManager {
  18860. private _targets;
  18861. private _targetObservable;
  18862. private _activeTargets;
  18863. private _scene;
  18864. private _influences;
  18865. private _supportsNormals;
  18866. private _supportsTangents;
  18867. private _vertexCount;
  18868. private _uniqueId;
  18869. private _tempInfluences;
  18870. /**
  18871. * Creates a new MorphTargetManager
  18872. * @param scene defines the current scene
  18873. */
  18874. constructor(scene?: Nullable<Scene>);
  18875. /**
  18876. * Gets the unique ID of this manager
  18877. */
  18878. readonly uniqueId: number;
  18879. /**
  18880. * Gets the number of vertices handled by this manager
  18881. */
  18882. readonly vertexCount: number;
  18883. /**
  18884. * Gets a boolean indicating if this manager supports morphing of normals
  18885. */
  18886. readonly supportsNormals: boolean;
  18887. /**
  18888. * Gets a boolean indicating if this manager supports morphing of tangents
  18889. */
  18890. readonly supportsTangents: boolean;
  18891. /**
  18892. * Gets the number of targets stored in this manager
  18893. */
  18894. readonly numTargets: number;
  18895. /**
  18896. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18897. */
  18898. readonly numInfluencers: number;
  18899. /**
  18900. * Gets the list of influences (one per target)
  18901. */
  18902. readonly influences: Float32Array;
  18903. /**
  18904. * Gets the active target at specified index. An active target is a target with an influence > 0
  18905. * @param index defines the index to check
  18906. * @returns the requested target
  18907. */
  18908. getActiveTarget(index: number): MorphTarget;
  18909. /**
  18910. * Gets the target at specified index
  18911. * @param index defines the index to check
  18912. * @returns the requested target
  18913. */
  18914. getTarget(index: number): MorphTarget;
  18915. /**
  18916. * Add a new target to this manager
  18917. * @param target defines the target to add
  18918. */
  18919. addTarget(target: MorphTarget): void;
  18920. /**
  18921. * Removes a target from the manager
  18922. * @param target defines the target to remove
  18923. */
  18924. removeTarget(target: MorphTarget): void;
  18925. /**
  18926. * Serializes the current manager into a Serialization object
  18927. * @returns the serialized object
  18928. */
  18929. serialize(): any;
  18930. private _syncActiveTargets(needUpdate);
  18931. /**
  18932. * Syncrhonize the targets with all the meshes using this morph target manager
  18933. */
  18934. synchronize(): void;
  18935. /**
  18936. * Creates a new MorphTargetManager from serialized data
  18937. * @param serializationObject defines the serialized data
  18938. * @param scene defines the hosting scene
  18939. * @returns the new MorphTargetManager
  18940. */
  18941. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18942. }
  18943. }
  18944. declare module BABYLON {
  18945. /**
  18946. * This represents a GPU particle system in Babylon
  18947. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  18948. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  18949. */
  18950. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  18951. /**
  18952. * The id of the Particle system.
  18953. */
  18954. id: string;
  18955. /**
  18956. * The friendly name of the Particle system.
  18957. */
  18958. name: string;
  18959. /**
  18960. * The emitter represents the Mesh or position we are attaching the particle system to.
  18961. */
  18962. emitter: Nullable<AbstractMesh | Vector3>;
  18963. /**
  18964. * The rendering group used by the Particle system to chose when to render.
  18965. */
  18966. renderingGroupId: number;
  18967. /**
  18968. * The layer mask we are rendering the particles through.
  18969. */
  18970. layerMask: number;
  18971. private _capacity;
  18972. private _activeCount;
  18973. private _currentActiveCount;
  18974. private _accumulatedCount;
  18975. private _renderEffect;
  18976. private _updateEffect;
  18977. private _buffer0;
  18978. private _buffer1;
  18979. private _spriteBuffer;
  18980. private _updateVAO;
  18981. private _renderVAO;
  18982. private _targetIndex;
  18983. private _sourceBuffer;
  18984. private _targetBuffer;
  18985. private _scene;
  18986. private _engine;
  18987. private _currentRenderId;
  18988. private _started;
  18989. private _stopped;
  18990. private _timeDelta;
  18991. private _randomTexture;
  18992. private _randomTexture2;
  18993. private _attributesStrideSize;
  18994. private _updateEffectOptions;
  18995. private _randomTextureSize;
  18996. private _actualFrame;
  18997. private readonly _rawTextureWidth;
  18998. /**
  18999. * List of animations used by the particle system.
  19000. */
  19001. animations: Animation[];
  19002. /**
  19003. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  19004. */
  19005. static readonly IsSupported: boolean;
  19006. /**
  19007. * An event triggered when the system is disposed.
  19008. */
  19009. onDisposeObservable: Observable<GPUParticleSystem>;
  19010. /**
  19011. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19012. */
  19013. updateSpeed: number;
  19014. /**
  19015. * The amount of time the particle system is running (depends of the overall update speed).
  19016. */
  19017. targetStopDuration: number;
  19018. /**
  19019. * The texture used to render each particle. (this can be a spritesheet)
  19020. */
  19021. particleTexture: Nullable<Texture>;
  19022. /**
  19023. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19024. */
  19025. blendMode: number;
  19026. /**
  19027. * Minimum life time of emitting particles.
  19028. */
  19029. minLifeTime: number;
  19030. /**
  19031. * Maximum life time of emitting particles.
  19032. */
  19033. maxLifeTime: number;
  19034. /**
  19035. * Minimum Size of emitting particles.
  19036. */
  19037. minSize: number;
  19038. /**
  19039. * Maximum Size of emitting particles.
  19040. */
  19041. maxSize: number;
  19042. /**
  19043. * Minimum scale of emitting particles on X axis.
  19044. */
  19045. minScaleX: number;
  19046. /**
  19047. * Maximum scale of emitting particles on X axis.
  19048. */
  19049. maxScaleX: number;
  19050. /**
  19051. * Minimum scale of emitting particles on Y axis.
  19052. */
  19053. minScaleY: number;
  19054. /**
  19055. * Maximum scale of emitting particles on Y axis.
  19056. */
  19057. maxScaleY: number;
  19058. /**
  19059. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19060. */
  19061. color1: Color4;
  19062. /**
  19063. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19064. */
  19065. color2: Color4;
  19066. /**
  19067. * Color the particle will have at the end of its lifetime.
  19068. */
  19069. colorDead: Color4;
  19070. /**
  19071. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19072. */
  19073. emitRate: number;
  19074. /**
  19075. * You can use gravity if you want to give an orientation to your particles.
  19076. */
  19077. gravity: Vector3;
  19078. /**
  19079. * Minimum power of emitting particles.
  19080. */
  19081. minEmitPower: number;
  19082. /**
  19083. * Maximum power of emitting particles.
  19084. */
  19085. maxEmitPower: number;
  19086. /**
  19087. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19088. */
  19089. minAngularSpeed: number;
  19090. /**
  19091. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19092. */
  19093. maxAngularSpeed: number;
  19094. /**
  19095. * The particle emitter type defines the emitter used by the particle system.
  19096. * It can be for example box, sphere, or cone...
  19097. */
  19098. particleEmitterType: Nullable<IParticleEmitterType>;
  19099. /**
  19100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19102. */
  19103. direction1: Vector3;
  19104. /**
  19105. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19107. */
  19108. direction2: Vector3;
  19109. /**
  19110. * 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.
  19111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19112. */
  19113. minEmitBox: Vector3;
  19114. /**
  19115. * 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.
  19116. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19117. */
  19118. maxEmitBox: Vector3;
  19119. /**
  19120. * Gets the maximum number of particles active at the same time.
  19121. * @returns The max number of active particles.
  19122. */
  19123. getCapacity(): number;
  19124. /**
  19125. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19126. * to override the particles.
  19127. */
  19128. forceDepthWrite: boolean;
  19129. /**
  19130. * Gets or set the number of active particles
  19131. */
  19132. activeParticleCount: number;
  19133. private _preWarmDone;
  19134. /** 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 */
  19135. preWarmCycles: number;
  19136. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19137. preWarmStepOffset: number;
  19138. /**
  19139. * Gets or sets the minimal initial rotation in radians.
  19140. */
  19141. minInitialRotation: number;
  19142. /**
  19143. * Gets or sets the maximal initial rotation in radians.
  19144. */
  19145. maxInitialRotation: number;
  19146. /**
  19147. * 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)
  19148. */
  19149. spriteCellChangeSpeed: number;
  19150. /**
  19151. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19152. */
  19153. startSpriteCellID: number;
  19154. /**
  19155. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19156. */
  19157. endSpriteCellID: number;
  19158. /**
  19159. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19160. */
  19161. spriteCellWidth: number;
  19162. /**
  19163. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19164. */
  19165. spriteCellHeight: number;
  19166. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19167. translationPivot: Vector2;
  19168. /**
  19169. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19170. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  19171. */
  19172. billboardMode: number;
  19173. private _isAnimationSheetEnabled;
  19174. /**
  19175. * Gets whether an animation sprite sheet is enabled or not on the particle system
  19176. */
  19177. readonly isAnimationSheetEnabled: boolean;
  19178. /**
  19179. * Is this system ready to be used/rendered
  19180. * @return true if the system is ready
  19181. */
  19182. isReady(): boolean;
  19183. /**
  19184. * Gets Wether the system has been started.
  19185. * @returns True if it has been started, otherwise false.
  19186. */
  19187. isStarted(): boolean;
  19188. /**
  19189. * Starts the particle system and begins to emit.
  19190. */
  19191. start(): void;
  19192. /**
  19193. * Stops the particle system.
  19194. */
  19195. stop(): void;
  19196. /**
  19197. * Remove all active particles
  19198. */
  19199. reset(): void;
  19200. /**
  19201. * Returns the string "GPUParticleSystem"
  19202. * @returns a string containing the class name
  19203. */
  19204. getClassName(): string;
  19205. private _isBillboardBased;
  19206. /**
  19207. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19208. */
  19209. isBillboardBased: boolean;
  19210. private _colorGradients;
  19211. private _colorGradientsTexture;
  19212. /**
  19213. * Gets the current list of color gradients.
  19214. * You must use addColorGradient and removeColorGradient to udpate this list
  19215. * @returns the list of color gradients
  19216. */
  19217. getColorGradients(): Nullable<Array<ColorGradient>>;
  19218. /**
  19219. * Gets the current list of size gradients.
  19220. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19221. * @returns the list of size gradients
  19222. */
  19223. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19224. /**
  19225. * Gets the current list of angular speed gradients.
  19226. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19227. * @returns the list of angular speed gradients
  19228. */
  19229. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19230. /**
  19231. * Gets the current list of velocity gradients.
  19232. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19233. * @returns the list of angular speed gradients
  19234. */
  19235. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19236. private _removeGradient(gradient, gradients, texture);
  19237. /**
  19238. * Adds a new color gradient
  19239. * @param gradient defines the gradient to use (between 0 and 1)
  19240. * @param color defines the color to affect to the specified gradient
  19241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19242. * @returns the current particle system
  19243. */
  19244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  19245. /**
  19246. * Remove a specific color gradient
  19247. * @param gradient defines the gradient to remove
  19248. * @returns the current particle system
  19249. */
  19250. removeColorGradient(gradient: number): GPUParticleSystem;
  19251. private _angularSpeedGradients;
  19252. private _angularSpeedGradientsTexture;
  19253. private _sizeGradients;
  19254. private _sizeGradientsTexture;
  19255. private _velocityGradients;
  19256. private _velocityGradientsTexture;
  19257. private _addFactorGradient(factorGradients, gradient, factor);
  19258. /**
  19259. * Adds a new size gradient
  19260. * @param gradient defines the gradient to use (between 0 and 1)
  19261. * @param factor defines the size factor to affect to the specified gradient
  19262. * @returns the current particle system
  19263. */
  19264. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  19265. /**
  19266. * Remove a specific size gradient
  19267. * @param gradient defines the gradient to remove
  19268. * @returns the current particle system
  19269. */
  19270. removeSizeGradient(gradient: number): GPUParticleSystem;
  19271. /**
  19272. * Adds a new angular speed gradient
  19273. * @param gradient defines the gradient to use (between 0 and 1)
  19274. * @param factor defines the size factor to affect to the specified gradient
  19275. * @returns the current particle system
  19276. */
  19277. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  19278. /**
  19279. * Remove a specific angular speed gradient
  19280. * @param gradient defines the gradient to remove
  19281. * @returns the current particle system
  19282. */
  19283. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  19284. /**
  19285. * Adds a new velocity gradient
  19286. * @param gradient defines the gradient to use (between 0 and 1)
  19287. * @param factor defines the size factor to affect to the specified gradient
  19288. * @returns the current particle system
  19289. */
  19290. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  19291. /**
  19292. * Remove a specific velocity gradient
  19293. * @param gradient defines the gradient to remove
  19294. * @returns the current particle system
  19295. */
  19296. removeVelocityGradient(gradient: number): GPUParticleSystem;
  19297. /**
  19298. * Instantiates a GPU particle system.
  19299. * 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.
  19300. * @param name The name of the particle system
  19301. * @param options The options used to create the system
  19302. * @param scene The scene the particle system belongs to
  19303. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19304. */
  19305. constructor(name: string, options: Partial<{
  19306. capacity: number;
  19307. randomTextureSize: number;
  19308. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  19309. private _createUpdateVAO(source);
  19310. private _createRenderVAO(source, spriteSource);
  19311. private _initialize(force?);
  19312. /** @hidden */
  19313. _recreateUpdateEffect(): void;
  19314. /** @hidden */
  19315. _recreateRenderEffect(): void;
  19316. /**
  19317. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19318. * @param preWarm defines if we are in the pre-warmimg phase
  19319. */
  19320. animate(preWarm?: boolean): void;
  19321. private _createFactorGradientTexture(factorGradients, textureName);
  19322. private _createSizeGradientTexture();
  19323. private _createAngularSpeedGradientTexture();
  19324. private _createVelocityGradientTexture();
  19325. private _createColorGradientTexture();
  19326. /**
  19327. * Renders the particle system in its current state
  19328. * @param preWarm defines if the system should only update the particles but not render them
  19329. * @returns the current number of particles
  19330. */
  19331. render(preWarm?: boolean): number;
  19332. /**
  19333. * Rebuilds the particle system
  19334. */
  19335. rebuild(): void;
  19336. private _releaseBuffers();
  19337. private _releaseVAOs();
  19338. /**
  19339. * Disposes the particle system and free the associated resources
  19340. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19341. */
  19342. dispose(disposeTexture?: boolean): void;
  19343. /**
  19344. * Clones the particle system.
  19345. * @param name The name of the cloned object
  19346. * @param newEmitter The new emitter to use
  19347. * @returns the cloned particle system
  19348. */
  19349. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  19350. /**
  19351. * Serializes the particle system to a JSON object.
  19352. * @returns the JSON object
  19353. */
  19354. serialize(): any;
  19355. /**
  19356. * Parses a JSON object to create a GPU particle system.
  19357. * @param parsedParticleSystem The JSON object to parse
  19358. * @param scene The scene to create the particle system in
  19359. * @param rootUrl The root url to use to load external dependencies like texture
  19360. * @returns the parsed GPU particle system
  19361. */
  19362. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  19363. }
  19364. }
  19365. declare module BABYLON {
  19366. /**
  19367. * Interface representing a particle system in Babylon.js.
  19368. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19369. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19370. */
  19371. interface IParticleSystem {
  19372. /**
  19373. * List of animations used by the particle system.
  19374. */
  19375. animations: Animation[];
  19376. /**
  19377. * The id of the Particle system.
  19378. */
  19379. id: string;
  19380. /**
  19381. * The name of the Particle system.
  19382. */
  19383. name: string;
  19384. /**
  19385. * The emitter represents the Mesh or position we are attaching the particle system to.
  19386. */
  19387. emitter: Nullable<AbstractMesh | Vector3>;
  19388. /**
  19389. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19390. */
  19391. isBillboardBased: boolean;
  19392. /**
  19393. * The rendering group used by the Particle system to chose when to render.
  19394. */
  19395. renderingGroupId: number;
  19396. /**
  19397. * The layer mask we are rendering the particles through.
  19398. */
  19399. layerMask: number;
  19400. /**
  19401. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19402. */
  19403. updateSpeed: number;
  19404. /**
  19405. * The amount of time the particle system is running (depends of the overall update speed).
  19406. */
  19407. targetStopDuration: number;
  19408. /**
  19409. * The texture used to render each particle. (this can be a spritesheet)
  19410. */
  19411. particleTexture: Nullable<Texture>;
  19412. /**
  19413. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19414. */
  19415. blendMode: number;
  19416. /**
  19417. * Minimum life time of emitting particles.
  19418. */
  19419. minLifeTime: number;
  19420. /**
  19421. * Maximum life time of emitting particles.
  19422. */
  19423. maxLifeTime: number;
  19424. /**
  19425. * Minimum Size of emitting particles.
  19426. */
  19427. minSize: number;
  19428. /**
  19429. * Maximum Size of emitting particles.
  19430. */
  19431. maxSize: number;
  19432. /**
  19433. * Minimum scale of emitting particles on X axis.
  19434. */
  19435. minScaleX: number;
  19436. /**
  19437. * Maximum scale of emitting particles on X axis.
  19438. */
  19439. maxScaleX: number;
  19440. /**
  19441. * Minimum scale of emitting particles on Y axis.
  19442. */
  19443. minScaleY: number;
  19444. /**
  19445. * Maximum scale of emitting particles on Y axis.
  19446. */
  19447. maxScaleY: number;
  19448. /**
  19449. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19450. */
  19451. color1: Color4;
  19452. /**
  19453. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19454. */
  19455. color2: Color4;
  19456. /**
  19457. * Color the particle will have at the end of its lifetime.
  19458. */
  19459. colorDead: Color4;
  19460. /**
  19461. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19462. */
  19463. emitRate: number;
  19464. /**
  19465. * You can use gravity if you want to give an orientation to your particles.
  19466. */
  19467. gravity: Vector3;
  19468. /**
  19469. * Minimum power of emitting particles.
  19470. */
  19471. minEmitPower: number;
  19472. /**
  19473. * Maximum power of emitting particles.
  19474. */
  19475. maxEmitPower: number;
  19476. /**
  19477. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19478. */
  19479. minAngularSpeed: number;
  19480. /**
  19481. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19482. */
  19483. maxAngularSpeed: number;
  19484. /**
  19485. * Gets or sets the minimal initial rotation in radians.
  19486. */
  19487. minInitialRotation: number;
  19488. /**
  19489. * Gets or sets the maximal initial rotation in radians.
  19490. */
  19491. maxInitialRotation: number;
  19492. /**
  19493. * The particle emitter type defines the emitter used by the particle system.
  19494. * It can be for example box, sphere, or cone...
  19495. */
  19496. particleEmitterType: Nullable<IParticleEmitterType>;
  19497. /**
  19498. * 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
  19499. */
  19500. preWarmCycles: number;
  19501. /**
  19502. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19503. */
  19504. preWarmStepOffset: number;
  19505. /**
  19506. * 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)
  19507. */
  19508. spriteCellChangeSpeed: number;
  19509. /**
  19510. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19511. */
  19512. startSpriteCellID: number;
  19513. /**
  19514. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19515. */
  19516. endSpriteCellID: number;
  19517. /**
  19518. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19519. */
  19520. spriteCellWidth: number;
  19521. /**
  19522. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19523. */
  19524. spriteCellHeight: number;
  19525. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19526. translationPivot: Vector2;
  19527. /**
  19528. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19529. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  19530. */
  19531. billboardMode: number;
  19532. /**
  19533. * Gets the maximum number of particles active at the same time.
  19534. * @returns The max number of active particles.
  19535. */
  19536. getCapacity(): number;
  19537. /**
  19538. * Gets Wether the system has been started.
  19539. * @returns True if it has been started, otherwise false.
  19540. */
  19541. isStarted(): boolean;
  19542. /**
  19543. * Gets if the particle system has been started.
  19544. * @return true if the system has been started, otherwise false.
  19545. */
  19546. isStarted(): boolean;
  19547. /**
  19548. * Animates the particle system for this frame.
  19549. */
  19550. animate(): void;
  19551. /**
  19552. * Renders the particle system in its current state.
  19553. * @returns the current number of particles
  19554. */
  19555. render(): number;
  19556. /**
  19557. * Dispose the particle system and frees its associated resources.
  19558. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19559. */
  19560. dispose(disposeTexture?: boolean): void;
  19561. /**
  19562. * Clones the particle system.
  19563. * @param name The name of the cloned object
  19564. * @param newEmitter The new emitter to use
  19565. * @returns the cloned particle system
  19566. */
  19567. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19568. /**
  19569. * Serializes the particle system to a JSON object.
  19570. * @returns the JSON object
  19571. */
  19572. serialize(): any;
  19573. /**
  19574. * Rebuild the particle system
  19575. */
  19576. rebuild(): void;
  19577. /**
  19578. * Starts the particle system and begins to emit.
  19579. */
  19580. start(): void;
  19581. /**
  19582. * Stops the particle system.
  19583. */
  19584. stop(): void;
  19585. /**
  19586. * Remove all active particles
  19587. */
  19588. reset(): void;
  19589. /**
  19590. * Is this system ready to be used/rendered
  19591. * @return true if the system is ready
  19592. */
  19593. isReady(): boolean;
  19594. /**
  19595. * Adds a new color gradient
  19596. * @param gradient defines the gradient to use (between 0 and 1)
  19597. * @param color defines the color to affect to the specified gradient
  19598. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19599. * @returns the current particle system
  19600. */
  19601. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19602. /**
  19603. * Remove a specific color gradient
  19604. * @param gradient defines the gradient to remove
  19605. * @returns the current particle system
  19606. */
  19607. removeColorGradient(gradient: number): IParticleSystem;
  19608. /**
  19609. * Adds a new size gradient
  19610. * @param gradient defines the gradient to use (between 0 and 1)
  19611. * @param factor defines the size factor to affect to the specified gradient
  19612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19613. * @returns the current particle system
  19614. */
  19615. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19616. /**
  19617. * Remove a specific size gradient
  19618. * @param gradient defines the gradient to remove
  19619. * @returns the current particle system
  19620. */
  19621. removeSizeGradient(gradient: number): IParticleSystem;
  19622. /**
  19623. * Gets the current list of color gradients.
  19624. * You must use addColorGradient and removeColorGradient to udpate this list
  19625. * @returns the list of color gradients
  19626. */
  19627. getColorGradients(): Nullable<Array<ColorGradient>>;
  19628. /**
  19629. * Gets the current list of size gradients.
  19630. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19631. * @returns the list of size gradients
  19632. */
  19633. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19634. /**
  19635. * Gets the current list of angular speed gradients.
  19636. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19637. * @returns the list of angular speed gradients
  19638. */
  19639. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19640. /**
  19641. * Adds a new angular speed gradient
  19642. * @param gradient defines the gradient to use (between 0 and 1)
  19643. * @param factor defines the size factor to affect to the specified gradient
  19644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19645. * @returns the current particle system
  19646. */
  19647. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19648. /**
  19649. * Remove a specific angular speed gradient
  19650. * @param gradient defines the gradient to remove
  19651. * @returns the current particle system
  19652. */
  19653. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19654. /**
  19655. * Gets the current list of velocity gradients.
  19656. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19657. * @returns the list of velocity gradients
  19658. */
  19659. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19660. /**
  19661. * Adds a new velocity gradient
  19662. * @param gradient defines the gradient to use (between 0 and 1)
  19663. * @param factor defines the size factor to affect to the specified gradient
  19664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19665. * @returns the current particle system
  19666. */
  19667. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19668. /**
  19669. * Remove a specific velocity gradient
  19670. * @param gradient defines the gradient to remove
  19671. * @returns the current particle system
  19672. */
  19673. removeVelocityGradient(gradient: number): IParticleSystem;
  19674. }
  19675. }
  19676. declare module BABYLON {
  19677. /**
  19678. * A particle represents one of the element emitted by a particle system.
  19679. * This is mainly define by its coordinates, direction, velocity and age.
  19680. */
  19681. class Particle {
  19682. /**
  19683. * particleSystem the particle system the particle belongs to.
  19684. */
  19685. particleSystem: ParticleSystem;
  19686. /**
  19687. * The world position of the particle in the scene.
  19688. */
  19689. position: Vector3;
  19690. /**
  19691. * The world direction of the particle in the scene.
  19692. */
  19693. direction: Vector3;
  19694. /**
  19695. * The color of the particle.
  19696. */
  19697. color: Color4;
  19698. /**
  19699. * The color change of the particle per step.
  19700. */
  19701. colorStep: Color4;
  19702. /**
  19703. * Defines how long will the life of the particle be.
  19704. */
  19705. lifeTime: number;
  19706. /**
  19707. * The current age of the particle.
  19708. */
  19709. age: number;
  19710. /**
  19711. * The current size of the particle.
  19712. */
  19713. size: number;
  19714. /**
  19715. * The current scale of the particle.
  19716. */
  19717. scale: Vector2;
  19718. /**
  19719. * The current angle of the particle.
  19720. */
  19721. angle: number;
  19722. /**
  19723. * Defines how fast is the angle changing.
  19724. */
  19725. angularSpeed: number;
  19726. /**
  19727. * Defines the cell index used by the particle to be rendered from a sprite.
  19728. */
  19729. cellIndex: number;
  19730. /** @hidden */
  19731. _initialDirection: Nullable<Vector3>;
  19732. /** @hidden */
  19733. _initialStartSpriteCellID: number;
  19734. _initialEndSpriteCellID: number;
  19735. /** @hidden */
  19736. _currentColorGradient: Nullable<ColorGradient>;
  19737. /** @hidden */
  19738. _currentColor1: Color4;
  19739. /** @hidden */
  19740. _currentColor2: Color4;
  19741. /** @hidden */
  19742. _currentSizeGradient: Nullable<FactorGradient>;
  19743. /** @hidden */
  19744. _currentSize1: number;
  19745. /** @hidden */
  19746. _currentSize2: number;
  19747. /** @hidden */
  19748. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  19749. /** @hidden */
  19750. _currentAngularSpeed1: number;
  19751. /** @hidden */
  19752. _currentAngularSpeed2: number;
  19753. /** @hidden */
  19754. _currentVelocityGradient: Nullable<FactorGradient>;
  19755. /** @hidden */
  19756. _currentVelocity1: number;
  19757. /** @hidden */
  19758. _currentVelocity2: number;
  19759. /**
  19760. * Creates a new instance Particle
  19761. * @param particleSystem the particle system the particle belongs to
  19762. */
  19763. constructor(
  19764. /**
  19765. * particleSystem the particle system the particle belongs to.
  19766. */
  19767. particleSystem: ParticleSystem);
  19768. private updateCellInfoFromSystem();
  19769. /**
  19770. * Defines how the sprite cell index is updated for the particle
  19771. */
  19772. updateCellIndex(): void;
  19773. /**
  19774. * Copy the properties of particle to another one.
  19775. * @param other the particle to copy the information to.
  19776. */
  19777. copyTo(other: Particle): void;
  19778. }
  19779. }
  19780. declare module BABYLON {
  19781. /**
  19782. * This class is made for on one-liner static method to help creating particle system set.
  19783. */
  19784. class ParticleHelper {
  19785. /**
  19786. * Gets or sets base Assets URL
  19787. */
  19788. static BaseAssetsUrl: string;
  19789. /**
  19790. * This is the main static method (one-liner) of this helper to create different particle systems
  19791. * @param type This string represents the type to the particle system to create
  19792. * @param scene The scene where the particle system should live
  19793. * @param gpu If the system will use gpu
  19794. * @returns the ParticleSystemSet created
  19795. */
  19796. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  19797. /**
  19798. * Static function used to export a particle system to a ParticleSystemSet variable.
  19799. * Please note that the emitter shape is not exported
  19800. * @param system defines the particle systems to export
  19801. */
  19802. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  19803. }
  19804. }
  19805. declare module BABYLON {
  19806. /**
  19807. * This represents a particle system in Babylon.
  19808. * 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.
  19809. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19810. * @example https://doc.babylonjs.com/babylon101/particles
  19811. */
  19812. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19813. /**
  19814. * Source color is added to the destination color without alpha affecting the result.
  19815. */
  19816. static BLENDMODE_ONEONE: number;
  19817. /**
  19818. * Blend current color and particle color using particle’s alpha.
  19819. */
  19820. static BLENDMODE_STANDARD: number;
  19821. /**
  19822. * Add current color and particle color multiplied by particle’s alpha.
  19823. */
  19824. static BLENDMODE_ADD: number;
  19825. /**
  19826. * List of animations used by the particle system.
  19827. */
  19828. animations: Animation[];
  19829. /**
  19830. * The id of the Particle system.
  19831. */
  19832. id: string;
  19833. /**
  19834. * The friendly name of the Particle system.
  19835. */
  19836. name: string;
  19837. /**
  19838. * The rendering group used by the Particle system to chose when to render.
  19839. */
  19840. renderingGroupId: number;
  19841. /**
  19842. * The emitter represents the Mesh or position we are attaching the particle system to.
  19843. */
  19844. emitter: Nullable<AbstractMesh | Vector3>;
  19845. /**
  19846. * The maximum number of particles to emit per frame
  19847. */
  19848. emitRate: number;
  19849. /**
  19850. * If you want to launch only a few particles at once, that can be done, as well.
  19851. */
  19852. manualEmitCount: number;
  19853. /**
  19854. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19855. */
  19856. updateSpeed: number;
  19857. /**
  19858. * The amount of time the particle system is running (depends of the overall update speed).
  19859. */
  19860. targetStopDuration: number;
  19861. /**
  19862. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19863. */
  19864. disposeOnStop: boolean;
  19865. /**
  19866. * Minimum power of emitting particles.
  19867. */
  19868. minEmitPower: number;
  19869. /**
  19870. * Maximum power of emitting particles.
  19871. */
  19872. maxEmitPower: number;
  19873. /**
  19874. * Minimum life time of emitting particles.
  19875. */
  19876. minLifeTime: number;
  19877. /**
  19878. * Maximum life time of emitting particles.
  19879. */
  19880. maxLifeTime: number;
  19881. /**
  19882. * Minimum Size of emitting particles.
  19883. */
  19884. minSize: number;
  19885. /**
  19886. * Maximum Size of emitting particles.
  19887. */
  19888. maxSize: number;
  19889. /**
  19890. * Minimum scale of emitting particles on X axis.
  19891. */
  19892. minScaleX: number;
  19893. /**
  19894. * Maximum scale of emitting particles on X axis.
  19895. */
  19896. maxScaleX: number;
  19897. /**
  19898. * Minimum scale of emitting particles on Y axis.
  19899. */
  19900. minScaleY: number;
  19901. /**
  19902. * Maximum scale of emitting particles on Y axis.
  19903. */
  19904. maxScaleY: number;
  19905. /**
  19906. * Gets or sets the minimal initial rotation in radians.
  19907. */
  19908. minInitialRotation: number;
  19909. /**
  19910. * Gets or sets the maximal initial rotation in radians.
  19911. */
  19912. maxInitialRotation: number;
  19913. /**
  19914. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19915. */
  19916. minAngularSpeed: number;
  19917. /**
  19918. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19919. */
  19920. maxAngularSpeed: number;
  19921. /**
  19922. * The texture used to render each particle. (this can be a spritesheet)
  19923. */
  19924. particleTexture: Nullable<Texture>;
  19925. /**
  19926. * The layer mask we are rendering the particles through.
  19927. */
  19928. layerMask: number;
  19929. /**
  19930. * This can help using your own shader to render the particle system.
  19931. * The according effect will be created
  19932. */
  19933. customShader: any;
  19934. /**
  19935. * By default particle system starts as soon as they are created. This prevents the
  19936. * automatic start to happen and let you decide when to start emitting particles.
  19937. */
  19938. preventAutoStart: boolean;
  19939. /**
  19940. * This function can be defined to provide custom update for active particles.
  19941. * This function will be called instead of regular update (age, position, color, etc.).
  19942. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19943. */
  19944. updateFunction: (particles: Particle[]) => void;
  19945. /**
  19946. * Callback triggered when the particle animation is ending.
  19947. */
  19948. onAnimationEnd: Nullable<() => void>;
  19949. /**
  19950. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19951. */
  19952. blendMode: number;
  19953. /**
  19954. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19955. * to override the particles.
  19956. */
  19957. forceDepthWrite: boolean;
  19958. /**
  19959. * You can use gravity if you want to give an orientation to your particles.
  19960. */
  19961. gravity: Vector3;
  19962. private _colorGradients;
  19963. private _sizeGradients;
  19964. private _lifeTimeGradients;
  19965. private _angularSpeedGradients;
  19966. private _velocityGradients;
  19967. /**
  19968. * Gets the current list of color gradients.
  19969. * You must use addColorGradient and removeColorGradient to udpate this list
  19970. * @returns the list of color gradients
  19971. */
  19972. getColorGradients(): Nullable<Array<ColorGradient>>;
  19973. /**
  19974. * Gets the current list of size gradients.
  19975. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19976. * @returns the list of size gradients
  19977. */
  19978. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19979. /**
  19980. * Gets the current list of life time gradients.
  19981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19982. * @returns the list of life time gradients
  19983. */
  19984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19985. /**
  19986. * Gets the current list of angular speed gradients.
  19987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19988. * @returns the list of angular speed gradients
  19989. */
  19990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19991. /**
  19992. * Gets the current list of velocity gradients.
  19993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19994. * @returns the list of velocity gradients
  19995. */
  19996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19997. /**
  19998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19999. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20000. */
  20001. direction1: Vector3;
  20002. /**
  20003. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20004. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20005. */
  20006. direction2: Vector3;
  20007. /**
  20008. * 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.
  20009. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20010. */
  20011. minEmitBox: Vector3;
  20012. /**
  20013. * 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.
  20014. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20015. */
  20016. maxEmitBox: Vector3;
  20017. /**
  20018. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  20019. */
  20020. color1: Color4;
  20021. /**
  20022. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  20023. */
  20024. color2: Color4;
  20025. /**
  20026. * Color the particle will have at the end of its lifetime
  20027. */
  20028. colorDead: Color4;
  20029. /**
  20030. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  20031. */
  20032. textureMask: Color4;
  20033. /**
  20034. * The particle emitter type defines the emitter used by the particle system.
  20035. * It can be for example box, sphere, or cone...
  20036. */
  20037. particleEmitterType: IParticleEmitterType;
  20038. /**
  20039. * This function can be defined to specify initial direction for every new particle.
  20040. * It by default use the emitterType defined function
  20041. */
  20042. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20043. /**
  20044. * This function can be defined to specify initial position for every new particle.
  20045. * It by default use the emitterType defined function
  20046. */
  20047. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20048. /**
  20049. * 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)
  20050. */
  20051. spriteCellChangeSpeed: number;
  20052. /**
  20053. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20054. */
  20055. startSpriteCellID: number;
  20056. /**
  20057. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20058. */
  20059. endSpriteCellID: number;
  20060. /**
  20061. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20062. */
  20063. spriteCellWidth: number;
  20064. /**
  20065. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20066. */
  20067. spriteCellHeight: number;
  20068. /** 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 */
  20069. preWarmCycles: number;
  20070. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  20071. preWarmStepOffset: number;
  20072. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20073. translationPivot: Vector2;
  20074. /**
  20075. * An event triggered when the system is disposed
  20076. */
  20077. onDisposeObservable: Observable<ParticleSystem>;
  20078. private _onDisposeObserver;
  20079. /**
  20080. * Sets a callback that will be triggered when the system is disposed
  20081. */
  20082. onDispose: () => void;
  20083. /**
  20084. * Gets whether an animation sprite sheet is enabled or not on the particle system
  20085. */
  20086. readonly isAnimationSheetEnabled: boolean;
  20087. /**
  20088. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20089. */
  20090. isBillboardBased: boolean;
  20091. /**
  20092. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20093. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  20094. */
  20095. billboardMode: number;
  20096. private _particles;
  20097. private _epsilon;
  20098. private _capacity;
  20099. private _scene;
  20100. private _stockParticles;
  20101. private _newPartsExcess;
  20102. private _vertexData;
  20103. private _vertexBuffer;
  20104. private _vertexBuffers;
  20105. private _spriteBuffer;
  20106. private _indexBuffer;
  20107. private _effect;
  20108. private _customEffect;
  20109. private _cachedDefines;
  20110. private _scaledColorStep;
  20111. private _colorDiff;
  20112. private _scaledDirection;
  20113. private _scaledGravity;
  20114. private _currentRenderId;
  20115. private _alive;
  20116. private _useInstancing;
  20117. private _started;
  20118. private _stopped;
  20119. private _actualFrame;
  20120. private _scaledUpdateSpeed;
  20121. private _vertexBufferSize;
  20122. private _isAnimationSheetEnabled;
  20123. private _isBillboardBased;
  20124. /**
  20125. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  20126. */
  20127. subEmitters: ParticleSystem[];
  20128. /**
  20129. * The current active Sub-systems, this property is used by the root particle system only.
  20130. */
  20131. activeSubSystems: Array<ParticleSystem>;
  20132. private _rootParticleSystem;
  20133. /**
  20134. * Gets the current list of active particles
  20135. */
  20136. readonly particles: Particle[];
  20137. /**
  20138. * Returns the string "ParticleSystem"
  20139. * @returns a string containing the class name
  20140. */
  20141. getClassName(): string;
  20142. /**
  20143. * Instantiates a particle system.
  20144. * 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.
  20145. * @param name The name of the particle system
  20146. * @param capacity The max number of particles alive at the same time
  20147. * @param scene The scene the particle system belongs to
  20148. * @param customEffect a custom effect used to change the way particles are rendered by default
  20149. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20150. * @param epsilon Offset used to render the particles
  20151. */
  20152. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20153. private _addFactorGradient(factorGradients, gradient, factor, factor2?);
  20154. private _removeFactorGradient(factorGradients, gradient);
  20155. /**
  20156. * Adds a new life time gradient
  20157. * @param gradient defines the gradient to use (between 0 and 1)
  20158. * @param factor defines the life time factor to affect to the specified gradient
  20159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20160. * @returns the current particle system
  20161. */
  20162. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  20163. /**
  20164. * Remove a specific life time gradient
  20165. * @param gradient defines the gradient to remove
  20166. * @returns the current particle system
  20167. */
  20168. removeLifeTimeGradient(gradient: number): ParticleSystem;
  20169. /**
  20170. * Adds a new size gradient
  20171. * @param gradient defines the gradient to use (between 0 and 1)
  20172. * @param factor defines the size factor to affect to the specified gradient
  20173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20174. * @returns the current particle system
  20175. */
  20176. addSizeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  20177. /**
  20178. * Remove a specific size gradient
  20179. * @param gradient defines the gradient to remove
  20180. * @returns the current particle system
  20181. */
  20182. removeSizeGradient(gradient: number): ParticleSystem;
  20183. /**
  20184. * Adds a new angular speed gradient
  20185. * @param gradient defines the gradient to use (between 0 and 1)
  20186. * @param factor defines the size factor to affect to the specified gradient
  20187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20188. * @returns the current particle system
  20189. */
  20190. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  20191. /**
  20192. * Remove a specific angular speed gradient
  20193. * @param gradient defines the gradient to remove
  20194. * @returns the current particle system
  20195. */
  20196. removeAngularSpeedGradient(gradient: number): ParticleSystem;
  20197. /**
  20198. * Adds a new velocity gradient
  20199. * @param gradient defines the gradient to use (between 0 and 1)
  20200. * @param factor defines the size factor to affect to the specified gradient
  20201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20202. * @returns the current particle system
  20203. */
  20204. addVelocityGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  20205. /**
  20206. * Remove a specific velocity gradient
  20207. * @param gradient defines the gradient to remove
  20208. * @returns the current particle system
  20209. */
  20210. removeVelocityGradient(gradient: number): ParticleSystem;
  20211. /**
  20212. * Adds a new color gradient
  20213. * @param gradient defines the gradient to use (between 0 and 1)
  20214. * @param color defines the color to affect to the specified gradient
  20215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20216. */
  20217. addColorGradient(gradient: number, color: Color4, color2?: Color4): ParticleSystem;
  20218. /**
  20219. * Remove a specific color gradient
  20220. * @param gradient defines the gradient to remove
  20221. */
  20222. removeColorGradient(gradient: number): ParticleSystem;
  20223. private _resetEffect();
  20224. private _createVertexBuffers();
  20225. private _createIndexBuffer();
  20226. /**
  20227. * Gets the maximum number of particles active at the same time.
  20228. * @returns The max number of active particles.
  20229. */
  20230. getCapacity(): number;
  20231. /**
  20232. * Gets Wether there are still active particles in the system.
  20233. * @returns True if it is alive, otherwise false.
  20234. */
  20235. isAlive(): boolean;
  20236. /**
  20237. * Gets Wether the system has been started.
  20238. * @returns True if it has been started, otherwise false.
  20239. */
  20240. isStarted(): boolean;
  20241. /**
  20242. * Starts the particle system and begins to emit.
  20243. */
  20244. start(): void;
  20245. /**
  20246. * Stops the particle system.
  20247. * @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.
  20248. */
  20249. stop(stopSubEmitters?: boolean): void;
  20250. /**
  20251. * Remove all active particles
  20252. */
  20253. reset(): void;
  20254. /**
  20255. * @hidden (for internal use only)
  20256. */
  20257. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20258. /**
  20259. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20260. * Its lifetime will start back at 0.
  20261. */
  20262. recycleParticle: (particle: Particle) => void;
  20263. private _stopSubEmitters();
  20264. private _createParticle;
  20265. private _removeFromRoot();
  20266. private _emitFromParticle;
  20267. private _update(newParticles);
  20268. /** @hidden */
  20269. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  20270. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20271. private _getEffect();
  20272. /**
  20273. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20274. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20275. */
  20276. animate(preWarmOnly?: boolean): void;
  20277. private _appendParticleVertices(offset, particle);
  20278. /**
  20279. * Rebuilds the particle system.
  20280. */
  20281. rebuild(): void;
  20282. /**
  20283. * Is this system ready to be used/rendered
  20284. * @return true if the system is ready
  20285. */
  20286. isReady(): boolean;
  20287. /**
  20288. * Renders the particle system in its current state.
  20289. * @returns the current number of particles
  20290. */
  20291. render(): number;
  20292. /**
  20293. * Disposes the particle system and free the associated resources
  20294. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20295. */
  20296. dispose(disposeTexture?: boolean): void;
  20297. /**
  20298. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  20299. * @param radius The radius of the sphere to emit from
  20300. * @returns the emitter
  20301. */
  20302. createSphereEmitter(radius?: number): SphereParticleEmitter;
  20303. /**
  20304. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  20305. * @param radius The radius of the sphere to emit from
  20306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  20307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  20308. * @returns the emitter
  20309. */
  20310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  20311. /**
  20312. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  20313. * @param radius The radius of the cone to emit from
  20314. * @param angle The base angle of the cone
  20315. * @returns the emitter
  20316. */
  20317. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  20318. /**
  20319. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  20320. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  20321. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  20322. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  20323. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  20324. * @returns the emitter
  20325. */
  20326. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  20327. /**
  20328. * Clones the particle system.
  20329. * @param name The name of the cloned object
  20330. * @param newEmitter The new emitter to use
  20331. * @returns the cloned particle system
  20332. */
  20333. clone(name: string, newEmitter: any): ParticleSystem;
  20334. /**
  20335. * Serializes the particle system to a JSON object.
  20336. * @returns the JSON object
  20337. */
  20338. serialize(): any;
  20339. /** @hidden */
  20340. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20341. /** @hidden */
  20342. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20343. /**
  20344. * Parses a JSON object to create a particle system.
  20345. * @param parsedParticleSystem The JSON object to parse
  20346. * @param scene The scene to create the particle system in
  20347. * @param rootUrl The root url to use to load external dependencies like texture
  20348. * @returns the Parsed particle system
  20349. */
  20350. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  20351. }
  20352. }
  20353. declare module BABYLON {
  20354. interface Engine {
  20355. /**
  20356. * Create an effect to use with particle systems.
  20357. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  20358. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  20359. * @param uniformsNames defines a list of attribute names
  20360. * @param samplers defines an array of string used to represent textures
  20361. * @param defines defines the string containing the defines to use to compile the shaders
  20362. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  20363. * @param onCompiled defines a function to call when the effect creation is successful
  20364. * @param onError defines a function to call when the effect creation has failed
  20365. * @returns the new Effect
  20366. */
  20367. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  20368. }
  20369. }
  20370. declare module BABYLON {
  20371. /**
  20372. * Represents a set of particle systems working together to create a specific effect
  20373. */
  20374. class ParticleSystemSet implements IDisposable {
  20375. private _emitterCreationOptions;
  20376. private _emitterNode;
  20377. /**
  20378. * Gets the particle system list
  20379. */
  20380. systems: IParticleSystem[];
  20381. /**
  20382. * Gets the emitter node used with this set
  20383. */
  20384. readonly emitterNode: Nullable<TransformNode>;
  20385. /**
  20386. * Creates a new emitter mesh as a sphere
  20387. * @param options defines the options used to create the sphere
  20388. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  20389. * @param scene defines the hosting scene
  20390. */
  20391. setEmitterAsSphere(options: {
  20392. diameter: number;
  20393. segments: number;
  20394. color: Color3;
  20395. }, renderingGroupId: number, scene: Scene): void;
  20396. /**
  20397. * Starts all particle systems of the set
  20398. * @param emitter defines an optional mesh to use as emitter for the particle systems
  20399. */
  20400. start(emitter?: AbstractMesh): void;
  20401. /**
  20402. * Release all associated resources
  20403. */
  20404. dispose(): void;
  20405. /**
  20406. * Serialize the set into a JSON compatible object
  20407. * @returns a JSON compatible representation of the set
  20408. */
  20409. serialize(): any;
  20410. /**
  20411. * Parse a new ParticleSystemSet from a serialized source
  20412. * @param data defines a JSON compatible representation of the set
  20413. * @param scene defines the hosting scene
  20414. * @param gpu defines if we want GPU particles or CPU particles
  20415. * @returns a new ParticleSystemSet
  20416. */
  20417. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  20418. }
  20419. }
  20420. declare module BABYLON {
  20421. /**
  20422. * Represents one particle of a solid particle system.
  20423. */
  20424. class SolidParticle {
  20425. /**
  20426. * particle global index
  20427. */
  20428. idx: number;
  20429. /**
  20430. * The color of the particle
  20431. */
  20432. color: Nullable<Color4>;
  20433. /**
  20434. * The world space position of the particle.
  20435. */
  20436. position: Vector3;
  20437. /**
  20438. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  20439. */
  20440. rotation: Vector3;
  20441. /**
  20442. * The world space rotation quaternion of the particle.
  20443. */
  20444. rotationQuaternion: Nullable<Quaternion>;
  20445. /**
  20446. * The scaling of the particle.
  20447. */
  20448. scaling: Vector3;
  20449. /**
  20450. * The uvs of the particle.
  20451. */
  20452. uvs: Vector4;
  20453. /**
  20454. * The current speed of the particle.
  20455. */
  20456. velocity: Vector3;
  20457. /**
  20458. * The pivot point in the particle local space.
  20459. */
  20460. pivot: Vector3;
  20461. /**
  20462. * Must the particle be translated from its pivot point in its local space ?
  20463. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  20464. * Default : false
  20465. */
  20466. translateFromPivot: boolean;
  20467. /**
  20468. * Is the particle active or not ?
  20469. */
  20470. alive: boolean;
  20471. /**
  20472. * Is the particle visible or not ?
  20473. */
  20474. isVisible: boolean;
  20475. /**
  20476. * Index of this particle in the global "positions" array (Internal use)
  20477. */
  20478. _pos: number;
  20479. /**
  20480. * Index of this particle in the global "indices" array (Internal use)
  20481. */
  20482. _ind: number;
  20483. /**
  20484. * ModelShape of this particle (Internal use)
  20485. */
  20486. _model: ModelShape;
  20487. /**
  20488. * ModelShape id of this particle
  20489. */
  20490. shapeId: number;
  20491. /**
  20492. * Index of the particle in its shape id (Internal use)
  20493. */
  20494. idxInShape: number;
  20495. /**
  20496. * Reference to the shape model BoundingInfo object (Internal use)
  20497. */
  20498. _modelBoundingInfo: BoundingInfo;
  20499. /**
  20500. * Particle BoundingInfo object (Internal use)
  20501. */
  20502. _boundingInfo: BoundingInfo;
  20503. /**
  20504. * Reference to the SPS what the particle belongs to (Internal use)
  20505. */
  20506. _sps: SolidParticleSystem;
  20507. /**
  20508. * Still set as invisible in order to skip useless computations (Internal use)
  20509. */
  20510. _stillInvisible: boolean;
  20511. /**
  20512. * Last computed particle rotation matrix
  20513. */
  20514. _rotationMatrix: number[];
  20515. /**
  20516. * Parent particle Id, if any.
  20517. * Default null.
  20518. */
  20519. parentId: Nullable<number>;
  20520. /**
  20521. * Internal global position in the SPS.
  20522. */
  20523. _globalPosition: Vector3;
  20524. /**
  20525. * Creates a Solid Particle object.
  20526. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  20527. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  20528. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  20529. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  20530. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  20531. * @param shapeId (integer) is the model shape identifier in the SPS.
  20532. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  20533. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  20534. */
  20535. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  20536. /**
  20537. * Legacy support, changed scale to scaling
  20538. */
  20539. /**
  20540. * Legacy support, changed scale to scaling
  20541. */
  20542. scale: Vector3;
  20543. /**
  20544. * Legacy support, changed quaternion to rotationQuaternion
  20545. */
  20546. /**
  20547. * Legacy support, changed quaternion to rotationQuaternion
  20548. */
  20549. quaternion: Nullable<Quaternion>;
  20550. /**
  20551. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  20552. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  20553. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  20554. * @returns true if it intersects
  20555. */
  20556. intersectsMesh(target: Mesh | SolidParticle): boolean;
  20557. }
  20558. /**
  20559. * Represents the shape of the model used by one particle of a solid particle system.
  20560. * SPS internal tool, don't use it manually.
  20561. */
  20562. class ModelShape {
  20563. /**
  20564. * The shape id.
  20565. */
  20566. shapeID: number;
  20567. /**
  20568. * flat array of model positions (internal use)
  20569. */
  20570. _shape: Vector3[];
  20571. /**
  20572. * flat array of model UVs (internal use)
  20573. */
  20574. _shapeUV: number[];
  20575. /**
  20576. * length of the shape in the model indices array (internal use)
  20577. */
  20578. _indicesLength: number;
  20579. /**
  20580. * Custom position function (internal use)
  20581. */
  20582. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  20583. /**
  20584. * Custom vertex function (internal use)
  20585. */
  20586. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  20587. /**
  20588. * 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.
  20589. * SPS internal tool, don't use it manually.
  20590. * @hidden
  20591. */
  20592. 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>);
  20593. }
  20594. /**
  20595. * Represents a Depth Sorted Particle in the solid particle system.
  20596. */
  20597. class DepthSortedParticle {
  20598. /**
  20599. * Index of the particle in the "indices" array
  20600. */
  20601. ind: number;
  20602. /**
  20603. * Length of the particle shape in the "indices" array
  20604. */
  20605. indicesLength: number;
  20606. /**
  20607. * Squared distance from the particle to the camera
  20608. */
  20609. sqDistance: number;
  20610. }
  20611. }
  20612. declare module BABYLON {
  20613. /**
  20614. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  20615. *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.
  20616. * The SPS is also a particle system. It provides some methods to manage the particles.
  20617. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  20618. *
  20619. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  20620. */
  20621. class SolidParticleSystem implements IDisposable {
  20622. /**
  20623. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  20624. * Example : var p = SPS.particles[i];
  20625. */
  20626. particles: SolidParticle[];
  20627. /**
  20628. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  20629. */
  20630. nbParticles: number;
  20631. /**
  20632. * If the particles must ever face the camera (default false). Useful for planar particles.
  20633. */
  20634. billboard: boolean;
  20635. /**
  20636. * Recompute normals when adding a shape
  20637. */
  20638. recomputeNormals: boolean;
  20639. /**
  20640. * This a counter ofr your own usage. It's not set by any SPS functions.
  20641. */
  20642. counter: number;
  20643. /**
  20644. * The SPS name. This name is also given to the underlying mesh.
  20645. */
  20646. name: string;
  20647. /**
  20648. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  20649. */
  20650. mesh: Mesh;
  20651. /**
  20652. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  20653. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  20654. */
  20655. vars: any;
  20656. /**
  20657. * This array is populated when the SPS is set as 'pickable'.
  20658. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  20659. * Each element of this array is an object `{idx: int, faceId: int}`.
  20660. * `idx` is the picked particle index in the `SPS.particles` array
  20661. * `faceId` is the picked face index counted within this particle.
  20662. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  20663. */
  20664. pickedParticles: {
  20665. idx: number;
  20666. faceId: number;
  20667. }[];
  20668. /**
  20669. * This array is populated when `enableDepthSort` is set to true.
  20670. * Each element of this array is an instance of the class DepthSortedParticle.
  20671. */
  20672. depthSortedParticles: DepthSortedParticle[];
  20673. /**
  20674. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  20675. */
  20676. _bSphereOnly: boolean;
  20677. /**
  20678. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  20679. */
  20680. _bSphereRadiusFactor: number;
  20681. private _scene;
  20682. private _positions;
  20683. private _indices;
  20684. private _normals;
  20685. private _colors;
  20686. private _uvs;
  20687. private _indices32;
  20688. private _positions32;
  20689. private _normals32;
  20690. private _fixedNormal32;
  20691. private _colors32;
  20692. private _uvs32;
  20693. private _index;
  20694. private _updatable;
  20695. private _pickable;
  20696. private _isVisibilityBoxLocked;
  20697. private _alwaysVisible;
  20698. private _depthSort;
  20699. private _shapeCounter;
  20700. private _copy;
  20701. private _shape;
  20702. private _shapeUV;
  20703. private _color;
  20704. private _computeParticleColor;
  20705. private _computeParticleTexture;
  20706. private _computeParticleRotation;
  20707. private _computeParticleVertex;
  20708. private _computeBoundingBox;
  20709. private _depthSortParticles;
  20710. private _cam_axisZ;
  20711. private _cam_axisY;
  20712. private _cam_axisX;
  20713. private _axisZ;
  20714. private _camera;
  20715. private _particle;
  20716. private _camDir;
  20717. private _camInvertedPosition;
  20718. private _rotMatrix;
  20719. private _invertMatrix;
  20720. private _rotated;
  20721. private _quaternion;
  20722. private _vertex;
  20723. private _normal;
  20724. private _yaw;
  20725. private _pitch;
  20726. private _roll;
  20727. private _halfroll;
  20728. private _halfpitch;
  20729. private _halfyaw;
  20730. private _sinRoll;
  20731. private _cosRoll;
  20732. private _sinPitch;
  20733. private _cosPitch;
  20734. private _sinYaw;
  20735. private _cosYaw;
  20736. private _mustUnrotateFixedNormals;
  20737. private _minimum;
  20738. private _maximum;
  20739. private _minBbox;
  20740. private _maxBbox;
  20741. private _particlesIntersect;
  20742. private _depthSortFunction;
  20743. private _needs32Bits;
  20744. private _pivotBackTranslation;
  20745. private _scaledPivot;
  20746. private _particleHasParent;
  20747. private _parent;
  20748. /**
  20749. * Creates a SPS (Solid Particle System) object.
  20750. * @param name (String) is the SPS name, this will be the underlying mesh name.
  20751. * @param scene (Scene) is the scene in which the SPS is added.
  20752. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  20753. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  20754. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  20755. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  20756. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  20757. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  20758. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  20759. */
  20760. constructor(name: string, scene: Scene, options?: {
  20761. updatable?: boolean;
  20762. isPickable?: boolean;
  20763. enableDepthSort?: boolean;
  20764. particleIntersection?: boolean;
  20765. boundingSphereOnly?: boolean;
  20766. bSphereRadiusFactor?: number;
  20767. });
  20768. /**
  20769. * Builds the SPS underlying mesh. Returns a standard Mesh.
  20770. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  20771. * @returns the created mesh
  20772. */
  20773. buildMesh(): Mesh;
  20774. /**
  20775. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  20776. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  20777. * Thus the particles generated from `digest()` have their property `position` set yet.
  20778. * @param mesh ( Mesh ) is the mesh to be digested
  20779. * @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
  20780. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  20781. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  20782. * @returns the current SPS
  20783. */
  20784. digest(mesh: Mesh, options?: {
  20785. facetNb?: number;
  20786. number?: number;
  20787. delta?: number;
  20788. }): SolidParticleSystem;
  20789. private _unrotateFixedNormals();
  20790. private _resetCopy();
  20791. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  20792. private _posToShape(positions);
  20793. private _uvsToShapeUV(uvs);
  20794. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  20795. /**
  20796. * Adds some particles to the SPS from the model shape. Returns the shape id.
  20797. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  20798. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  20799. * @param nb (positive integer) the number of particles to be created from this model
  20800. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  20801. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  20802. * @returns the number of shapes in the system
  20803. */
  20804. addShape(mesh: Mesh, nb: number, options?: {
  20805. positionFunction?: any;
  20806. vertexFunction?: any;
  20807. }): number;
  20808. private _rebuildParticle(particle);
  20809. /**
  20810. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  20811. * @returns the SPS.
  20812. */
  20813. rebuildMesh(): SolidParticleSystem;
  20814. /**
  20815. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  20816. * This method calls `updateParticle()` for each particle of the SPS.
  20817. * For an animated SPS, it is usually called within the render loop.
  20818. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  20819. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  20820. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  20821. * @returns the SPS.
  20822. */
  20823. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  20824. private _quaternionRotationYPR();
  20825. private _quaternionToRotationMatrix();
  20826. /**
  20827. * Disposes the SPS.
  20828. */
  20829. dispose(): void;
  20830. /**
  20831. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  20832. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20833. * @returns the SPS.
  20834. */
  20835. refreshVisibleSize(): SolidParticleSystem;
  20836. /**
  20837. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  20838. * @param size the size (float) of the visibility box
  20839. * note : this doesn't lock the SPS mesh bounding box.
  20840. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20841. */
  20842. setVisibilityBox(size: number): void;
  20843. /**
  20844. * Gets whether the SPS as always visible or not
  20845. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20846. */
  20847. /**
  20848. * Sets the SPS as always visible or not
  20849. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20850. */
  20851. isAlwaysVisible: boolean;
  20852. /**
  20853. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  20854. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20855. */
  20856. /**
  20857. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  20858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  20859. */
  20860. isVisibilityBoxLocked: boolean;
  20861. /**
  20862. * Gets if `setParticles()` computes the particle rotations or not.
  20863. * Default value : true. The SPS is faster when it's set to false.
  20864. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  20865. */
  20866. /**
  20867. * Tells to `setParticles()` to compute the particle rotations or not.
  20868. * Default value : true. The SPS is faster when it's set to false.
  20869. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  20870. */
  20871. computeParticleRotation: boolean;
  20872. /**
  20873. * Gets if `setParticles()` computes the particle colors or not.
  20874. * Default value : true. The SPS is faster when it's set to false.
  20875. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  20876. */
  20877. /**
  20878. * Tells to `setParticles()` to compute the particle colors or not.
  20879. * Default value : true. The SPS is faster when it's set to false.
  20880. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  20881. */
  20882. computeParticleColor: boolean;
  20883. /**
  20884. * Gets if `setParticles()` computes the particle textures or not.
  20885. * Default value : true. The SPS is faster when it's set to false.
  20886. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  20887. */
  20888. computeParticleTexture: boolean;
  20889. /**
  20890. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  20891. * Default value : false. The SPS is faster when it's set to false.
  20892. * Note : the particle custom vertex positions aren't stored values.
  20893. */
  20894. /**
  20895. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  20896. * Default value : false. The SPS is faster when it's set to false.
  20897. * Note : the particle custom vertex positions aren't stored values.
  20898. */
  20899. computeParticleVertex: boolean;
  20900. /**
  20901. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  20902. */
  20903. /**
  20904. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  20905. */
  20906. computeBoundingBox: boolean;
  20907. /**
  20908. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  20909. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  20910. * Default : `true`
  20911. */
  20912. /**
  20913. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  20914. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  20915. * Default : `true`
  20916. */
  20917. depthSortParticles: boolean;
  20918. /**
  20919. * This function does nothing. It may be overwritten to set all the particle first values.
  20920. * The SPS doesn't call this function, you may have to call it by your own.
  20921. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20922. */
  20923. initParticles(): void;
  20924. /**
  20925. * This function does nothing. It may be overwritten to recycle a particle.
  20926. * The SPS doesn't call this function, you may have to call it by your own.
  20927. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20928. * @param particle The particle to recycle
  20929. * @returns the recycled particle
  20930. */
  20931. recycleParticle(particle: SolidParticle): SolidParticle;
  20932. /**
  20933. * Updates a particle : this function should be overwritten by the user.
  20934. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  20935. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20936. * @example : just set a particle position or velocity and recycle conditions
  20937. * @param particle The particle to update
  20938. * @returns the updated particle
  20939. */
  20940. updateParticle(particle: SolidParticle): SolidParticle;
  20941. /**
  20942. * Updates a vertex of a particle : it can be overwritten by the user.
  20943. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  20944. * @param particle the current particle
  20945. * @param vertex the current index of the current particle
  20946. * @param pt the index of the current vertex in the particle shape
  20947. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  20948. * @example : just set a vertex particle position
  20949. * @returns the updated vertex
  20950. */
  20951. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  20952. /**
  20953. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  20954. * This does nothing and may be overwritten by the user.
  20955. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20956. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20957. * @param update the boolean update value actually passed to setParticles()
  20958. */
  20959. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  20960. /**
  20961. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  20962. * This will be passed three parameters.
  20963. * This does nothing and may be overwritten by the user.
  20964. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20965. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20966. * @param update the boolean update value actually passed to setParticles()
  20967. */
  20968. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  20969. }
  20970. }
  20971. declare module BABYLON {
  20972. /**
  20973. * Class used to store all common mesh properties
  20974. */
  20975. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  20976. /** No occlusion */
  20977. static OCCLUSION_TYPE_NONE: number;
  20978. /** Occlusion set to optimisitic */
  20979. static OCCLUSION_TYPE_OPTIMISTIC: number;
  20980. /** Occlusion set to strict */
  20981. static OCCLUSION_TYPE_STRICT: number;
  20982. /** Use an accurante occlusion algorithm */
  20983. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  20984. /** Use a conservative occlusion algorithm */
  20985. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  20986. /**
  20987. * No billboard
  20988. */
  20989. static readonly BILLBOARDMODE_NONE: number;
  20990. /** Billboard on X axis */
  20991. static readonly BILLBOARDMODE_X: number;
  20992. /** Billboard on Y axis */
  20993. static readonly BILLBOARDMODE_Y: number;
  20994. /** Billboard on Z axis */
  20995. static readonly BILLBOARDMODE_Z: number;
  20996. /** Billboard on all axes */
  20997. static readonly BILLBOARDMODE_ALL: number;
  20998. private _facetPositions;
  20999. private _facetNormals;
  21000. private _facetPartitioning;
  21001. private _facetNb;
  21002. private _partitioningSubdivisions;
  21003. private _partitioningBBoxRatio;
  21004. private _facetDataEnabled;
  21005. private _facetParameters;
  21006. private _bbSize;
  21007. private _subDiv;
  21008. private _facetDepthSort;
  21009. private _facetDepthSortEnabled;
  21010. private _depthSortedIndices;
  21011. private _depthSortedFacets;
  21012. private _facetDepthSortFunction;
  21013. private _facetDepthSortFrom;
  21014. private _facetDepthSortOrigin;
  21015. private _invertedMatrix;
  21016. /**
  21017. * Gets the number of facets in the mesh
  21018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  21019. */
  21020. readonly facetNb: number;
  21021. /**
  21022. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  21023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  21024. */
  21025. partitioningSubdivisions: number;
  21026. /**
  21027. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  21028. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  21029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  21030. */
  21031. partitioningBBoxRatio: number;
  21032. /**
  21033. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  21034. * Works only for updatable meshes.
  21035. * Doesn't work with multi-materials
  21036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  21037. */
  21038. mustDepthSortFacets: boolean;
  21039. /**
  21040. * The location (Vector3) where the facet depth sort must be computed from.
  21041. * By default, the active camera position.
  21042. * Used only when facet depth sort is enabled
  21043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  21044. */
  21045. facetDepthSortFrom: Vector3;
  21046. /**
  21047. * gets a boolean indicating if facetData is enabled
  21048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  21049. */
  21050. readonly isFacetDataEnabled: boolean;
  21051. /** @hidden */
  21052. _updateNonUniformScalingState(value: boolean): boolean;
  21053. /**
  21054. * An event triggered when this mesh collides with another one
  21055. */
  21056. onCollideObservable: Observable<AbstractMesh>;
  21057. private _onCollideObserver;
  21058. /** Set a function to call when this mesh collides with another one */
  21059. onCollide: () => void;
  21060. /**
  21061. * An event triggered when the collision's position changes
  21062. */
  21063. onCollisionPositionChangeObservable: Observable<Vector3>;
  21064. private _onCollisionPositionChangeObserver;
  21065. /** Set a function to call when the collision's position changes */
  21066. onCollisionPositionChange: () => void;
  21067. /**
  21068. * An event triggered when material is changed
  21069. */
  21070. onMaterialChangedObservable: Observable<AbstractMesh>;
  21071. /**
  21072. * Gets or sets the orientation for POV movement & rotation
  21073. */
  21074. definedFacingForward: boolean;
  21075. /**
  21076. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  21077. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  21078. * * 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.
  21079. * @see http://doc.babylonjs.com/features/occlusionquery
  21080. */
  21081. occlusionQueryAlgorithmType: number;
  21082. /**
  21083. * 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:
  21084. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  21085. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  21086. * * 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.
  21087. * @see http://doc.babylonjs.com/features/occlusionquery
  21088. */
  21089. occlusionType: number;
  21090. /**
  21091. * 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.
  21092. * The default value is -1 which means don't break the query and wait till the result
  21093. * @see http://doc.babylonjs.com/features/occlusionquery
  21094. */
  21095. occlusionRetryCount: number;
  21096. /** @hidden */
  21097. _occlusionInternalRetryCounter: number;
  21098. /** @hidden */
  21099. _isOccluded: boolean;
  21100. /**
  21101. * 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
  21102. * @see http://doc.babylonjs.com/features/occlusionquery
  21103. */
  21104. isOccluded: boolean;
  21105. /** @hidden */
  21106. _isOcclusionQueryInProgress: boolean;
  21107. /**
  21108. * Flag to check the progress status of the query
  21109. * @see http://doc.babylonjs.com/features/occlusionquery
  21110. */
  21111. readonly isOcclusionQueryInProgress: boolean;
  21112. /** @hidden */
  21113. _occlusionQuery: Nullable<WebGLQuery>;
  21114. private _visibility;
  21115. /**
  21116. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  21117. */
  21118. /**
  21119. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  21120. */
  21121. visibility: number;
  21122. /** Gets or sets the alpha index used to sort transparent meshes
  21123. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  21124. */
  21125. alphaIndex: number;
  21126. /**
  21127. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  21128. */
  21129. isVisible: boolean;
  21130. /**
  21131. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  21132. */
  21133. isPickable: boolean;
  21134. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  21135. showSubMeshesBoundingBox: boolean;
  21136. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  21137. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  21138. */
  21139. isBlocker: boolean;
  21140. /**
  21141. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  21142. */
  21143. enablePointerMoveEvents: boolean;
  21144. /**
  21145. * Specifies the rendering group id for this mesh (0 by default)
  21146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  21147. */
  21148. renderingGroupId: number;
  21149. private _material;
  21150. /** Gets or sets current material */
  21151. material: Nullable<Material>;
  21152. private _receiveShadows;
  21153. /**
  21154. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  21155. * @see http://doc.babylonjs.com/babylon101/shadows
  21156. */
  21157. receiveShadows: boolean;
  21158. /**
  21159. * Gets or sets a boolean indicating if the outline must be rendered as well
  21160. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  21161. */
  21162. renderOutline: boolean;
  21163. /** Defines color to use when rendering outline */
  21164. outlineColor: Color3;
  21165. /** Define width to use when rendering outline */
  21166. outlineWidth: number;
  21167. /**
  21168. * Gets or sets a boolean indicating if the overlay must be rendered as well
  21169. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  21170. */
  21171. renderOverlay: boolean;
  21172. /** Defines color to use when rendering overlay */
  21173. overlayColor: Color3;
  21174. /** Defines alpha to use when rendering overlay */
  21175. overlayAlpha: number;
  21176. private _hasVertexAlpha;
  21177. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  21178. hasVertexAlpha: boolean;
  21179. private _useVertexColors;
  21180. /** 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) */
  21181. useVertexColors: boolean;
  21182. private _computeBonesUsingShaders;
  21183. /**
  21184. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  21185. */
  21186. computeBonesUsingShaders: boolean;
  21187. private _numBoneInfluencers;
  21188. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  21189. numBoneInfluencers: number;
  21190. private _applyFog;
  21191. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  21192. applyFog: boolean;
  21193. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  21194. useOctreeForRenderingSelection: boolean;
  21195. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  21196. useOctreeForPicking: boolean;
  21197. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  21198. useOctreeForCollisions: boolean;
  21199. private _layerMask;
  21200. /**
  21201. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  21202. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  21203. */
  21204. layerMask: number;
  21205. /**
  21206. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  21207. */
  21208. alwaysSelectAsActiveMesh: boolean;
  21209. /**
  21210. * Gets or sets the current action manager
  21211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21212. */
  21213. actionManager: Nullable<ActionManager>;
  21214. /**
  21215. * Gets or sets impostor used for physic simulation
  21216. * @see http://doc.babylonjs.com/features/physics_engine
  21217. */
  21218. physicsImpostor: Nullable<PhysicsImpostor>;
  21219. private _checkCollisions;
  21220. private _collisionMask;
  21221. private _collisionGroup;
  21222. /**
  21223. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  21224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21225. */
  21226. ellipsoid: Vector3;
  21227. /**
  21228. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  21229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21230. */
  21231. ellipsoidOffset: Vector3;
  21232. private _collider;
  21233. private _oldPositionForCollisions;
  21234. private _diffPositionForCollisions;
  21235. /**
  21236. * Gets or sets a collision mask used to mask collisions (default is -1).
  21237. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  21238. */
  21239. collisionMask: number;
  21240. /**
  21241. * Gets or sets the current collision group mask (-1 by default).
  21242. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  21243. */
  21244. collisionGroup: number;
  21245. /**
  21246. * Defines edge width used when edgesRenderer is enabled
  21247. * @see https://www.babylonjs-playground.com/#10OJSG#13
  21248. */
  21249. edgesWidth: number;
  21250. /**
  21251. * Defines edge color used when edgesRenderer is enabled
  21252. * @see https://www.babylonjs-playground.com/#10OJSG#13
  21253. */
  21254. edgesColor: Color4;
  21255. /** @hidden */
  21256. _edgesRenderer: Nullable<EdgesRenderer>;
  21257. private _collisionsTransformMatrix;
  21258. private _collisionsScalingMatrix;
  21259. /** @hidden */
  21260. _masterMesh: Nullable<AbstractMesh>;
  21261. /** @hidden */
  21262. _boundingInfo: Nullable<BoundingInfo>;
  21263. /** @hidden */
  21264. _renderId: number;
  21265. /**
  21266. * Gets or sets the list of subMeshes
  21267. * @see http://doc.babylonjs.com/how_to/multi_materials
  21268. */
  21269. subMeshes: SubMesh[];
  21270. /** @hidden */
  21271. _submeshesOctree: Octree<SubMesh>;
  21272. /** @hidden */
  21273. _intersectionsInProgress: AbstractMesh[];
  21274. /** @hidden */
  21275. _unIndexed: boolean;
  21276. /** @hidden */
  21277. _lightSources: Light[];
  21278. /** @hidden */
  21279. readonly _positions: Nullable<Vector3[]>;
  21280. /** @hidden */
  21281. _waitingActions: any;
  21282. /** @hidden */
  21283. _waitingFreezeWorldMatrix: Nullable<boolean>;
  21284. private _skeleton;
  21285. /** @hidden */
  21286. _bonesTransformMatrices: Nullable<Float32Array>;
  21287. /**
  21288. * Gets or sets a skeleton to apply skining transformations
  21289. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  21290. */
  21291. skeleton: Nullable<Skeleton>;
  21292. /**
  21293. * Creates a new AbstractMesh
  21294. * @param name defines the name of the mesh
  21295. * @param scene defines the hosting scene
  21296. */
  21297. constructor(name: string, scene?: Nullable<Scene>);
  21298. /**
  21299. * Returns the string "AbstractMesh"
  21300. * @returns "AbstractMesh"
  21301. */
  21302. getClassName(): string;
  21303. /**
  21304. * Gets a string representation of the current mesh
  21305. * @param fullDetails defines a boolean indicating if full details must be included
  21306. * @returns a string representation of the current mesh
  21307. */
  21308. toString(fullDetails?: boolean): string;
  21309. /** @hidden */
  21310. _rebuild(): void;
  21311. /** @hidden */
  21312. _resyncLightSources(): void;
  21313. /** @hidden */
  21314. _resyncLighSource(light: Light): void;
  21315. /** @hidden */
  21316. _unBindEffect(): void;
  21317. /** @hidden */
  21318. _removeLightSource(light: Light): void;
  21319. private _markSubMeshesAsDirty(func);
  21320. /** @hidden */
  21321. _markSubMeshesAsLightDirty(): void;
  21322. /** @hidden */
  21323. _markSubMeshesAsAttributesDirty(): void;
  21324. /** @hidden */
  21325. _markSubMeshesAsMiscDirty(): void;
  21326. /**
  21327. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  21328. */
  21329. scaling: Vector3;
  21330. /**
  21331. * Disables the mesh edge rendering mode
  21332. * @returns the currentAbstractMesh
  21333. */
  21334. disableEdgesRendering(): AbstractMesh;
  21335. /**
  21336. * Enables the edge rendering mode on the mesh.
  21337. * This mode makes the mesh edges visible
  21338. * @param epsilon defines the maximal distance between two angles to detect a face
  21339. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21340. * @returns the currentAbstractMesh
  21341. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21342. */
  21343. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21344. /**
  21345. * Gets the edgesRenderer associated with the mesh
  21346. */
  21347. readonly edgesRenderer: Nullable<EdgesRenderer>;
  21348. /**
  21349. * Returns true if the mesh is blocked. Implemented by child classes
  21350. */
  21351. readonly isBlocked: boolean;
  21352. /**
  21353. * Returns the mesh itself by default. Implemented by child classes
  21354. * @param camera defines the camera to use to pick the right LOD level
  21355. * @returns the currentAbstractMesh
  21356. */
  21357. getLOD(camera: Camera): Nullable<AbstractMesh>;
  21358. /**
  21359. * Returns 0 by default. Implemented by child classes
  21360. * @returns an integer
  21361. */
  21362. getTotalVertices(): number;
  21363. /**
  21364. * Returns null by default. Implemented by child classes
  21365. * @returns null
  21366. */
  21367. getIndices(): Nullable<IndicesArray>;
  21368. /**
  21369. * Returns the array of the requested vertex data kind. Implemented by child classes
  21370. * @param kind defines the vertex data kind to use
  21371. * @returns null
  21372. */
  21373. getVerticesData(kind: string): Nullable<FloatArray>;
  21374. /**
  21375. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21376. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21377. * Note that a new underlying VertexBuffer object is created each call.
  21378. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21379. * @param kind defines vertex data kind:
  21380. * * BABYLON.VertexBuffer.PositionKind
  21381. * * BABYLON.VertexBuffer.UVKind
  21382. * * BABYLON.VertexBuffer.UV2Kind
  21383. * * BABYLON.VertexBuffer.UV3Kind
  21384. * * BABYLON.VertexBuffer.UV4Kind
  21385. * * BABYLON.VertexBuffer.UV5Kind
  21386. * * BABYLON.VertexBuffer.UV6Kind
  21387. * * BABYLON.VertexBuffer.ColorKind
  21388. * * BABYLON.VertexBuffer.MatricesIndicesKind
  21389. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21390. * * BABYLON.VertexBuffer.MatricesWeightsKind
  21391. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21392. * @param data defines the data source
  21393. * @param updatable defines if the data must be flagged as updatable (or static)
  21394. * @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
  21395. * @returns the current mesh
  21396. */
  21397. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  21398. /**
  21399. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21400. * If the mesh has no geometry, it is simply returned as it is.
  21401. * @param kind defines vertex data kind:
  21402. * * BABYLON.VertexBuffer.PositionKind
  21403. * * BABYLON.VertexBuffer.UVKind
  21404. * * BABYLON.VertexBuffer.UV2Kind
  21405. * * BABYLON.VertexBuffer.UV3Kind
  21406. * * BABYLON.VertexBuffer.UV4Kind
  21407. * * BABYLON.VertexBuffer.UV5Kind
  21408. * * BABYLON.VertexBuffer.UV6Kind
  21409. * * BABYLON.VertexBuffer.ColorKind
  21410. * * BABYLON.VertexBuffer.MatricesIndicesKind
  21411. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21412. * * BABYLON.VertexBuffer.MatricesWeightsKind
  21413. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21414. * @param data defines the data source
  21415. * @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
  21416. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  21417. * @returns the current mesh
  21418. */
  21419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  21420. /**
  21421. * Sets the mesh indices,
  21422. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21423. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21424. * @param totalVertices Defines the total number of vertices
  21425. * @returns the current mesh
  21426. */
  21427. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  21428. /**
  21429. * Gets a boolean indicating if specific vertex data is present
  21430. * @param kind defines the vertex data kind to use
  21431. * @returns true is data kind is present
  21432. */
  21433. isVerticesDataPresent(kind: string): boolean;
  21434. /**
  21435. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  21436. * @returns a BoundingInfo
  21437. */
  21438. getBoundingInfo(): BoundingInfo;
  21439. /**
  21440. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  21441. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  21442. * @returns the current mesh
  21443. */
  21444. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  21445. /**
  21446. * Overwrite the current bounding info
  21447. * @param boundingInfo defines the new bounding info
  21448. * @returns the current mesh
  21449. */
  21450. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  21451. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  21452. readonly useBones: boolean;
  21453. /** @hidden */
  21454. _preActivate(): void;
  21455. /** @hidden */
  21456. _preActivateForIntermediateRendering(renderId: number): void;
  21457. /** @hidden */
  21458. _activate(renderId: number): void;
  21459. /**
  21460. * Gets the current world matrix
  21461. * @returns a Matrix
  21462. */
  21463. getWorldMatrix(): Matrix;
  21464. /** @hidden */
  21465. _getWorldMatrixDeterminant(): number;
  21466. /**
  21467. * Perform relative position change from the point of view of behind the front of the mesh.
  21468. * This is performed taking into account the meshes current rotation, so you do not have to care.
  21469. * Supports definition of mesh facing forward or backward
  21470. * @param amountRight defines the distance on the right axis
  21471. * @param amountUp defines the distance on the up axis
  21472. * @param amountForward defines the distance on the forward axis
  21473. * @returns the current mesh
  21474. */
  21475. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  21476. /**
  21477. * Calculate relative position change from the point of view of behind the front of the mesh.
  21478. * This is performed taking into account the meshes current rotation, so you do not have to care.
  21479. * Supports definition of mesh facing forward or backward
  21480. * @param amountRight defines the distance on the right axis
  21481. * @param amountUp defines the distance on the up axis
  21482. * @param amountForward defines the distance on the forward axis
  21483. * @returns the new displacement vector
  21484. */
  21485. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  21486. /**
  21487. * Perform relative rotation change from the point of view of behind the front of the mesh.
  21488. * Supports definition of mesh facing forward or backward
  21489. * @param flipBack defines the flip
  21490. * @param twirlClockwise defines the twirl
  21491. * @param tiltRight defines the tilt
  21492. * @returns the current mesh
  21493. */
  21494. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  21495. /**
  21496. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  21497. * Supports definition of mesh facing forward or backward.
  21498. * @param flipBack defines the flip
  21499. * @param twirlClockwise defines the twirl
  21500. * @param tiltRight defines the tilt
  21501. * @returns the new rotation vector
  21502. */
  21503. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  21504. /**
  21505. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  21506. * @param includeDescendants Include bounding info from descendants as well (true by default)
  21507. * @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
  21508. * @returns the new bounding vectors
  21509. */
  21510. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  21511. min: Vector3;
  21512. max: Vector3;
  21513. };
  21514. /** @hidden */
  21515. _updateBoundingInfo(): AbstractMesh;
  21516. /** @hidden */
  21517. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  21518. /** @hidden */
  21519. protected _afterComputeWorldMatrix(): void;
  21520. /**
  21521. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21522. * A mesh is in the frustum if its bounding box intersects the frustum
  21523. * @param frustumPlanes defines the frustum to test
  21524. * @returns true if the mesh is in the frustum planes
  21525. */
  21526. isInFrustum(frustumPlanes: Plane[]): boolean;
  21527. /**
  21528. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  21529. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  21530. * @param frustumPlanes defines the frustum to test
  21531. * @returns true if the mesh is completely in the frustum planes
  21532. */
  21533. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21534. /**
  21535. * True if the mesh intersects another mesh or a SolidParticle object
  21536. * @param mesh defines a target mesh or SolidParticle to test
  21537. * @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)
  21538. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  21539. * @returns true if there is an intersection
  21540. */
  21541. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  21542. /**
  21543. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  21544. * @param point defines the point to test
  21545. * @returns true if there is an intersection
  21546. */
  21547. intersectsPoint(point: Vector3): boolean;
  21548. /**
  21549. * Gets the current physics impostor
  21550. * @see http://doc.babylonjs.com/features/physics_engine
  21551. * @returns a physics impostor or null
  21552. */
  21553. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  21554. /**
  21555. * Gets the position of the current mesh in camera space
  21556. * @param camera defines the camera to use
  21557. * @returns a position
  21558. */
  21559. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  21560. /**
  21561. * Returns the distance from the mesh to the active camera
  21562. * @param camera defines the camera to use
  21563. * @returns the distance
  21564. */
  21565. getDistanceToCamera(camera?: Nullable<Camera>): number;
  21566. /**
  21567. * Apply a physic impulse to the mesh
  21568. * @param force defines the force to apply
  21569. * @param contactPoint defines where to apply the force
  21570. * @returns the current mesh
  21571. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  21572. */
  21573. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  21574. /**
  21575. * Creates a physic joint between two meshes
  21576. * @param otherMesh defines the other mesh to use
  21577. * @param pivot1 defines the pivot to use on this mesh
  21578. * @param pivot2 defines the pivot to use on the other mesh
  21579. * @param options defines additional options (can be plugin dependent)
  21580. * @returns the current mesh
  21581. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  21582. */
  21583. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  21584. /**
  21585. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  21586. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21587. */
  21588. checkCollisions: boolean;
  21589. /**
  21590. * Gets Collider object used to compute collisions (not physics)
  21591. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21592. */
  21593. readonly collider: Collider;
  21594. /**
  21595. * Move the mesh using collision engine
  21596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21597. * @param displacement defines the requested displacement vector
  21598. * @returns the current mesh
  21599. */
  21600. moveWithCollisions(displacement: Vector3): AbstractMesh;
  21601. private _onCollisionPositionChange;
  21602. /**
  21603. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  21604. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21605. * @param maxCapacity defines the maximum size of each block (64 by default)
  21606. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  21607. * @returns the new octree
  21608. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  21609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  21610. */
  21611. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  21612. /** @hidden */
  21613. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  21614. /** @hidden */
  21615. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  21616. /** @hidden */
  21617. _checkCollision(collider: Collider): AbstractMesh;
  21618. /** @hidden */
  21619. _generatePointsArray(): boolean;
  21620. /**
  21621. * Checks if the passed Ray intersects with the mesh
  21622. * @param ray defines the ray to use
  21623. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  21624. * @returns the picking info
  21625. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  21626. */
  21627. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  21628. /**
  21629. * Clones the current mesh
  21630. * @param name defines the mesh name
  21631. * @param newParent defines the new mesh parent
  21632. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  21633. * @returns the new mesh
  21634. */
  21635. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  21636. /**
  21637. * Disposes all the submeshes of the current meshnp
  21638. * @returns the current mesh
  21639. */
  21640. releaseSubMeshes(): AbstractMesh;
  21641. /**
  21642. * Releases resources associated with this abstract mesh.
  21643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21645. */
  21646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21647. /**
  21648. * Adds the passed mesh as a child to the current mesh
  21649. * @param mesh defines the child mesh
  21650. * @returns the current mesh
  21651. */
  21652. addChild(mesh: AbstractMesh): AbstractMesh;
  21653. /**
  21654. * Removes the passed mesh from the current mesh children list
  21655. * @param mesh defines the child mesh
  21656. * @returns the current mesh
  21657. */
  21658. removeChild(mesh: AbstractMesh): AbstractMesh;
  21659. /** @hidden */
  21660. private _initFacetData();
  21661. /**
  21662. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  21663. * This method can be called within the render loop.
  21664. * 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
  21665. * @returns the current mesh
  21666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21667. */
  21668. updateFacetData(): AbstractMesh;
  21669. /**
  21670. * Returns the facetLocalNormals array.
  21671. * The normals are expressed in the mesh local spac
  21672. * @returns an array of Vector3
  21673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21674. */
  21675. getFacetLocalNormals(): Vector3[];
  21676. /**
  21677. * Returns the facetLocalPositions array.
  21678. * The facet positions are expressed in the mesh local space
  21679. * @returns an array of Vector3
  21680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21681. */
  21682. getFacetLocalPositions(): Vector3[];
  21683. /**
  21684. * Returns the facetLocalPartioning array
  21685. * @returns an array of array of numbers
  21686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21687. */
  21688. getFacetLocalPartitioning(): number[][];
  21689. /**
  21690. * Returns the i-th facet position in the world system.
  21691. * This method allocates a new Vector3 per call
  21692. * @param i defines the facet index
  21693. * @returns a new Vector3
  21694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21695. */
  21696. getFacetPosition(i: number): Vector3;
  21697. /**
  21698. * Sets the reference Vector3 with the i-th facet position in the world system
  21699. * @param i defines the facet index
  21700. * @param ref defines the target vector
  21701. * @returns the current mesh
  21702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21703. */
  21704. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  21705. /**
  21706. * Returns the i-th facet normal in the world system.
  21707. * This method allocates a new Vector3 per call
  21708. * @param i defines the facet index
  21709. * @returns a new Vector3
  21710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21711. */
  21712. getFacetNormal(i: number): Vector3;
  21713. /**
  21714. * Sets the reference Vector3 with the i-th facet normal in the world system
  21715. * @param i defines the facet index
  21716. * @param ref defines the target vector
  21717. * @returns the current mesh
  21718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21719. */
  21720. getFacetNormalToRef(i: number, ref: Vector3): this;
  21721. /**
  21722. * 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)
  21723. * @param x defines x coordinate
  21724. * @param y defines y coordinate
  21725. * @param z defines z coordinate
  21726. * @returns the array of facet indexes
  21727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21728. */
  21729. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  21730. /**
  21731. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  21732. * @param projected sets as the (x,y,z) world projection on the facet
  21733. * @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
  21734. * @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
  21735. * @param x defines x coordinate
  21736. * @param y defines y coordinate
  21737. * @param z defines z coordinate
  21738. * @returns the face index if found (or null instead)
  21739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21740. */
  21741. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  21742. /**
  21743. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  21744. * @param projected sets as the (x,y,z) local projection on the facet
  21745. * @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
  21746. * @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
  21747. * @param x defines x coordinate
  21748. * @param y defines y coordinate
  21749. * @param z defines z coordinate
  21750. * @returns the face index if found (or null instead)
  21751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21752. */
  21753. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  21754. /**
  21755. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  21756. * @returns the parameters
  21757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21758. */
  21759. getFacetDataParameters(): any;
  21760. /**
  21761. * Disables the feature FacetData and frees the related memory
  21762. * @returns the current mesh
  21763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21764. */
  21765. disableFacetData(): AbstractMesh;
  21766. /**
  21767. * Updates the AbstractMesh indices array
  21768. * @param indices defines the data source
  21769. * @returns the current mesh
  21770. */
  21771. updateIndices(indices: IndicesArray): AbstractMesh;
  21772. /**
  21773. * Creates new normals data for the mesh
  21774. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  21775. * @returns the current mesh
  21776. */
  21777. createNormals(updatable: boolean): AbstractMesh;
  21778. /**
  21779. * Align the mesh with a normal
  21780. * @param normal defines the normal to use
  21781. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  21782. * @returns the current mesh
  21783. */
  21784. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  21785. /** @hidden */
  21786. _checkOcclusionQuery(): void;
  21787. }
  21788. }
  21789. declare module BABYLON {
  21790. class Buffer {
  21791. private _engine;
  21792. private _buffer;
  21793. /** @hidden */
  21794. _data: Nullable<DataArray>;
  21795. private _updatable;
  21796. private _instanced;
  21797. /**
  21798. * Gets the byte stride.
  21799. */
  21800. readonly byteStride: number;
  21801. /**
  21802. * Constructor
  21803. * @param engine the engine
  21804. * @param data the data to use for this buffer
  21805. * @param updatable whether the data is updatable
  21806. * @param stride the stride (optional)
  21807. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  21808. * @param instanced whether the buffer is instanced (optional)
  21809. * @param useBytes set to true if the stride in in bytes (optional)
  21810. */
  21811. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  21812. /**
  21813. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  21814. * @param kind defines the vertex buffer kind (position, normal, etc.)
  21815. * @param offset defines offset in the buffer (0 by default)
  21816. * @param size defines the size in floats of attributes (position is 3 for instance)
  21817. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  21818. * @param instanced defines if the vertex buffer contains indexed data
  21819. * @param useBytes defines if the offset and stride are in bytes
  21820. * @returns the new vertex buffer
  21821. */
  21822. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  21823. isUpdatable(): boolean;
  21824. getData(): Nullable<DataArray>;
  21825. getBuffer(): Nullable<WebGLBuffer>;
  21826. /**
  21827. * Gets the stride in float32 units (i.e. byte stride / 4).
  21828. * May not be an integer if the byte stride is not divisible by 4.
  21829. * DEPRECATED. Use byteStride instead.
  21830. * @returns the stride in float32 units
  21831. */
  21832. getStrideSize(): number;
  21833. create(data?: Nullable<DataArray>): void;
  21834. _rebuild(): void;
  21835. update(data: DataArray): void;
  21836. /**
  21837. * Updates the data directly.
  21838. * @param data the new data
  21839. * @param offset the new offset
  21840. * @param vertexCount the vertex count (optional)
  21841. * @param useBytes set to true if the offset is in bytes
  21842. */
  21843. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  21844. dispose(): void;
  21845. }
  21846. }
  21847. declare module BABYLON {
  21848. class CSG {
  21849. private polygons;
  21850. matrix: Matrix;
  21851. position: Vector3;
  21852. rotation: Vector3;
  21853. rotationQuaternion: Nullable<Quaternion>;
  21854. scaling: Vector3;
  21855. static FromMesh(mesh: Mesh): CSG;
  21856. private static FromPolygons(polygons);
  21857. clone(): CSG;
  21858. union(csg: CSG): CSG;
  21859. unionInPlace(csg: CSG): void;
  21860. subtract(csg: CSG): CSG;
  21861. subtractInPlace(csg: CSG): void;
  21862. intersect(csg: CSG): CSG;
  21863. intersectInPlace(csg: CSG): void;
  21864. inverse(): CSG;
  21865. inverseInPlace(): void;
  21866. copyTransformAttributes(csg: CSG): CSG;
  21867. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  21868. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  21869. }
  21870. }
  21871. declare module BABYLON {
  21872. /**
  21873. * Class used to store geometry data (vertex buffers + index buffer)
  21874. */
  21875. class Geometry implements IGetSetVerticesData {
  21876. /**
  21877. * Gets or sets the unique ID of the geometry
  21878. */
  21879. id: string;
  21880. /**
  21881. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21882. */
  21883. delayLoadState: number;
  21884. /**
  21885. * Gets the file containing the data to load when running in delay load state
  21886. */
  21887. delayLoadingFile: Nullable<string>;
  21888. /**
  21889. * Callback called when the geometry is updated
  21890. */
  21891. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21892. private _scene;
  21893. private _engine;
  21894. private _meshes;
  21895. private _totalVertices;
  21896. /** @hidden */
  21897. _indices: IndicesArray;
  21898. /** @hidden */
  21899. _vertexBuffers: {
  21900. [key: string]: VertexBuffer;
  21901. };
  21902. private _isDisposed;
  21903. private _extend;
  21904. private _boundingBias;
  21905. /** @hidden */
  21906. _delayInfo: Array<string>;
  21907. private _indexBuffer;
  21908. private _indexBufferIsUpdatable;
  21909. /** @hidden */
  21910. _boundingInfo: Nullable<BoundingInfo>;
  21911. /** @hidden */
  21912. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21913. /** @hidden */
  21914. _softwareSkinningRenderId: number;
  21915. private _vertexArrayObjects;
  21916. private _updatable;
  21917. /** @hidden */
  21918. _positions: Nullable<Vector3[]>;
  21919. /**
  21920. * 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
  21921. */
  21922. /**
  21923. * 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
  21924. */
  21925. boundingBias: Vector2;
  21926. /**
  21927. * Static function used to attach a new empty geometry to a mesh
  21928. * @param mesh defines the mesh to attach the geometry to
  21929. * @returns the new {BABYLON.Geometry}
  21930. */
  21931. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21932. /**
  21933. * Creates a new geometry
  21934. * @param id defines the unique ID
  21935. * @param scene defines the hosting scene
  21936. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  21937. * @param updatable defines if geometry must be updatable (false by default)
  21938. * @param mesh defines the mesh that will be associated with the geometry
  21939. */
  21940. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21941. /**
  21942. * Gets the current extend of the geometry
  21943. */
  21944. readonly extend: {
  21945. minimum: Vector3;
  21946. maximum: Vector3;
  21947. };
  21948. /**
  21949. * Gets the hosting scene
  21950. * @returns the hosting {BABYLON.Scene}
  21951. */
  21952. getScene(): Scene;
  21953. /**
  21954. * Gets the hosting engine
  21955. * @returns the hosting {BABYLON.Engine}
  21956. */
  21957. getEngine(): Engine;
  21958. /**
  21959. * Defines if the geometry is ready to use
  21960. * @returns true if the geometry is ready to be used
  21961. */
  21962. isReady(): boolean;
  21963. /**
  21964. * Gets a value indicating that the geometry should not be serialized
  21965. */
  21966. readonly doNotSerialize: boolean;
  21967. /** @hidden */
  21968. _rebuild(): void;
  21969. /**
  21970. * Affects all geometry data in one call
  21971. * @param vertexData defines the geometry data
  21972. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21973. */
  21974. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21975. /**
  21976. * Set specific vertex data
  21977. * @param kind defines the data kind (Position, normal, etc...)
  21978. * @param data defines the vertex data to use
  21979. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21980. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21981. */
  21982. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21983. /**
  21984. * Removes a specific vertex data
  21985. * @param kind defines the data kind (Position, normal, etc...)
  21986. */
  21987. removeVerticesData(kind: string): void;
  21988. /**
  21989. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21990. * @param buffer defines the vertex buffer to use
  21991. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21992. */
  21993. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21994. /**
  21995. * Update a specific vertex buffer
  21996. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21997. * It will do nothing if the buffer is not updatable
  21998. * @param kind defines the data kind (Position, normal, etc...)
  21999. * @param data defines the data to use
  22000. * @param offset defines the offset in the target buffer where to store the data
  22001. * @param useBytes set to true if the offset is in bytes
  22002. */
  22003. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22004. /**
  22005. * Update a specific vertex buffer
  22006. * This function will create a new buffer if the current one is not updatable
  22007. * @param kind defines the data kind (Position, normal, etc...)
  22008. * @param data defines the data to use
  22009. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22010. */
  22011. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22012. private _updateBoundingInfo(updateExtends, data);
  22013. /** @hidden */
  22014. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22015. /**
  22016. * Gets total number of vertices
  22017. * @returns the total number of vertices
  22018. */
  22019. getTotalVertices(): number;
  22020. /**
  22021. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22022. * @param kind defines the data kind (Position, normal, etc...)
  22023. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22025. * @returns a float array containing vertex data
  22026. */
  22027. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22028. /**
  22029. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22030. * @param kind defines the data kind (Position, normal, etc...)
  22031. * @returns true if the vertex buffer with the specified kind is updatable
  22032. */
  22033. isVertexBufferUpdatable(kind: string): boolean;
  22034. /**
  22035. * Gets a specific vertex buffer
  22036. * @param kind defines the data kind (Position, normal, etc...)
  22037. * @returns a {BABYLON.VertexBuffer}
  22038. */
  22039. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22040. /**
  22041. * Returns all vertex buffers
  22042. * @return an object holding all vertex buffers indexed by kind
  22043. */
  22044. getVertexBuffers(): Nullable<{
  22045. [key: string]: VertexBuffer;
  22046. }>;
  22047. /**
  22048. * Gets a boolean indicating if specific vertex buffer is present
  22049. * @param kind defines the data kind (Position, normal, etc...)
  22050. * @returns true if data is present
  22051. */
  22052. isVerticesDataPresent(kind: string): boolean;
  22053. /**
  22054. * Gets a list of all attached data kinds (Position, normal, etc...)
  22055. * @returns a list of string containing all kinds
  22056. */
  22057. getVerticesDataKinds(): string[];
  22058. /**
  22059. * Update index buffer
  22060. * @param indices defines the indices to store in the index buffer
  22061. * @param offset defines the offset in the target buffer where to store the data
  22062. */
  22063. updateIndices(indices: IndicesArray, offset?: number): void;
  22064. /**
  22065. * Creates a new index buffer
  22066. * @param indices defines the indices to store in the index buffer
  22067. * @param totalVertices defines the total number of vertices (could be null)
  22068. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22069. */
  22070. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22071. /**
  22072. * Return the total number of indices
  22073. * @returns the total number of indices
  22074. */
  22075. getTotalIndices(): number;
  22076. /**
  22077. * Gets the index buffer array
  22078. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22079. * @returns the index buffer array
  22080. */
  22081. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22082. /**
  22083. * Gets the index buffer
  22084. * @return the index buffer
  22085. */
  22086. getIndexBuffer(): Nullable<WebGLBuffer>;
  22087. /** @hidden */
  22088. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22089. /**
  22090. * Release the associated resources for a specific mesh
  22091. * @param mesh defines the source mesh
  22092. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22093. */
  22094. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22095. /**
  22096. * Apply current geometry to a given mesh
  22097. * @param mesh defines the mesh to apply geometry to
  22098. */
  22099. applyToMesh(mesh: Mesh): void;
  22100. private _updateExtend(data?);
  22101. private _applyToMesh(mesh);
  22102. private notifyUpdate(kind?);
  22103. /**
  22104. * Load the geometry if it was flagged as delay loaded
  22105. * @param scene defines the hosting scene
  22106. * @param onLoaded defines a callback called when the geometry is loaded
  22107. */
  22108. load(scene: Scene, onLoaded?: () => void): void;
  22109. private _queueLoad(scene, onLoaded?);
  22110. /**
  22111. * Invert the geometry to move from a right handed system to a left handed one.
  22112. */
  22113. toLeftHanded(): void;
  22114. /** @hidden */
  22115. _resetPointsArrayCache(): void;
  22116. /** @hidden */
  22117. _generatePointsArray(): boolean;
  22118. /**
  22119. * Gets a value indicating if the geometry is disposed
  22120. * @returns true if the geometry was disposed
  22121. */
  22122. isDisposed(): boolean;
  22123. private _disposeVertexArrayObjects();
  22124. /**
  22125. * Free all associated resources
  22126. */
  22127. dispose(): void;
  22128. /**
  22129. * Clone the current geometry into a new geometry
  22130. * @param id defines the unique ID of the new geometry
  22131. * @returns a new geometry object
  22132. */
  22133. copy(id: string): Geometry;
  22134. /**
  22135. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22136. * @return a JSON representation of the current geometry data (without the vertices data)
  22137. */
  22138. serialize(): any;
  22139. private toNumberArray(origin);
  22140. /**
  22141. * Serialize all vertices data into a JSON oject
  22142. * @returns a JSON representation of the current geometry data
  22143. */
  22144. serializeVerticeData(): any;
  22145. /**
  22146. * Extracts a clone of a mesh geometry
  22147. * @param mesh defines the source mesh
  22148. * @param id defines the unique ID of the new geometry object
  22149. * @returns the new geometry object
  22150. */
  22151. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22152. /**
  22153. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22154. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22155. * Be aware Math.random() could cause collisions, but:
  22156. * "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"
  22157. * @returns a string containing a new GUID
  22158. */
  22159. static RandomId(): string;
  22160. /** @hidden */
  22161. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22162. private static _CleanMatricesWeights(parsedGeometry, mesh);
  22163. /**
  22164. * Create a new geometry from persisted data (Using .babylon file format)
  22165. * @param parsedVertexData defines the persisted data
  22166. * @param scene defines the hosting scene
  22167. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22168. * @returns the new geometry object
  22169. */
  22170. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22171. }
  22172. /**
  22173. * Abstract class used to provide common services for all typed geometries
  22174. * @hidden
  22175. */
  22176. class _PrimitiveGeometry extends Geometry {
  22177. private _canBeRegenerated;
  22178. private _beingRegenerated;
  22179. /**
  22180. * Creates a new typed geometry
  22181. * @param id defines the unique ID of the geometry
  22182. * @param scene defines the hosting scene
  22183. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22184. * @param mesh defines the hosting mesh (can be null)
  22185. */
  22186. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22187. /**
  22188. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  22189. * @returns true if the geometry can be regenerated
  22190. */
  22191. canBeRegenerated(): boolean;
  22192. /**
  22193. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  22194. */
  22195. regenerate(): void;
  22196. /**
  22197. * Clone the geometry
  22198. * @param id defines the unique ID of the new geometry
  22199. * @returns the new geometry
  22200. */
  22201. asNewGeometry(id: string): Geometry;
  22202. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22203. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  22204. /** @hidden */
  22205. _regenerateVertexData(): VertexData;
  22206. copy(id: string): Geometry;
  22207. serialize(): any;
  22208. }
  22209. /**
  22210. * Creates a ribbon geometry
  22211. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  22212. */
  22213. class RibbonGeometry extends _PrimitiveGeometry {
  22214. /**
  22215. * Defines the array of paths to use
  22216. */
  22217. pathArray: Vector3[][];
  22218. /**
  22219. * Defines if the last and first points of each path in your pathArray must be joined
  22220. */
  22221. closeArray: boolean;
  22222. /**
  22223. * Defines if the last and first points of each path in your pathArray must be joined
  22224. */
  22225. closePath: boolean;
  22226. /**
  22227. * Defines the offset between points
  22228. */
  22229. offset: number;
  22230. /**
  22231. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22232. */
  22233. side: number;
  22234. /**
  22235. * Creates a ribbon geometry
  22236. * @param id defines the unique ID of the geometry
  22237. * @param scene defines the hosting scene
  22238. * @param pathArray defines the array of paths to use
  22239. * @param closeArray defines if the last path and the first path must be joined
  22240. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  22241. * @param offset defines the offset between points
  22242. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22243. * @param mesh defines the hosting mesh (can be null)
  22244. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22245. */
  22246. constructor(id: string, scene: Scene,
  22247. /**
  22248. * Defines the array of paths to use
  22249. */
  22250. pathArray: Vector3[][],
  22251. /**
  22252. * Defines if the last and first points of each path in your pathArray must be joined
  22253. */
  22254. closeArray: boolean,
  22255. /**
  22256. * Defines if the last and first points of each path in your pathArray must be joined
  22257. */
  22258. closePath: boolean,
  22259. /**
  22260. * Defines the offset between points
  22261. */
  22262. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  22263. /**
  22264. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22265. */
  22266. side?: number);
  22267. /** @hidden */
  22268. _regenerateVertexData(): VertexData;
  22269. copy(id: string): Geometry;
  22270. }
  22271. /**
  22272. * Creates a box geometry
  22273. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  22274. */
  22275. class BoxGeometry extends _PrimitiveGeometry {
  22276. /**
  22277. * Defines the zise of the box (width, height and depth are the same)
  22278. */
  22279. size: number;
  22280. /**
  22281. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22282. */
  22283. side: number;
  22284. /**
  22285. * Creates a box geometry
  22286. * @param id defines the unique ID of the geometry
  22287. * @param scene defines the hosting scene
  22288. * @param size defines the zise of the box (width, height and depth are the same)
  22289. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22290. * @param mesh defines the hosting mesh (can be null)
  22291. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22292. */
  22293. constructor(id: string, scene: Scene,
  22294. /**
  22295. * Defines the zise of the box (width, height and depth are the same)
  22296. */
  22297. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22298. /**
  22299. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22300. */
  22301. side?: number);
  22302. _regenerateVertexData(): VertexData;
  22303. copy(id: string): Geometry;
  22304. serialize(): any;
  22305. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  22306. }
  22307. /**
  22308. * Creates a sphere geometry
  22309. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  22310. */
  22311. class SphereGeometry extends _PrimitiveGeometry {
  22312. /**
  22313. * Defines the number of segments to use to create the sphere
  22314. */
  22315. segments: number;
  22316. /**
  22317. * Defines the diameter of the sphere
  22318. */
  22319. diameter: number;
  22320. /**
  22321. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22322. */
  22323. side: number;
  22324. /**
  22325. * Create a new sphere geometry
  22326. * @param id defines the unique ID of the geometry
  22327. * @param scene defines the hosting scene
  22328. * @param segments defines the number of segments to use to create the sphere
  22329. * @param diameter defines the diameter of the sphere
  22330. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22331. * @param mesh defines the hosting mesh (can be null)
  22332. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22333. */
  22334. constructor(id: string, scene: Scene,
  22335. /**
  22336. * Defines the number of segments to use to create the sphere
  22337. */
  22338. segments: number,
  22339. /**
  22340. * Defines the diameter of the sphere
  22341. */
  22342. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22343. /**
  22344. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22345. */
  22346. side?: number);
  22347. _regenerateVertexData(): VertexData;
  22348. copy(id: string): Geometry;
  22349. serialize(): any;
  22350. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  22351. }
  22352. /**
  22353. * Creates a disc geometry
  22354. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22355. */
  22356. class DiscGeometry extends _PrimitiveGeometry {
  22357. /**
  22358. * Defines the radius of the disc
  22359. */
  22360. radius: number;
  22361. /**
  22362. * Defines the tesselation factor to apply to the disc
  22363. */
  22364. tessellation: number;
  22365. /**
  22366. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22367. */
  22368. side: number;
  22369. /**
  22370. * Creates a new disc geometry
  22371. * @param id defines the unique ID of the geometry
  22372. * @param scene defines the hosting scene
  22373. * @param radius defines the radius of the disc
  22374. * @param tessellation defines the tesselation factor to apply to the disc
  22375. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22376. * @param mesh defines the hosting mesh (can be null)
  22377. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22378. */
  22379. constructor(id: string, scene: Scene,
  22380. /**
  22381. * Defines the radius of the disc
  22382. */
  22383. radius: number,
  22384. /**
  22385. * Defines the tesselation factor to apply to the disc
  22386. */
  22387. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22388. /**
  22389. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22390. */
  22391. side?: number);
  22392. _regenerateVertexData(): VertexData;
  22393. copy(id: string): Geometry;
  22394. }
  22395. /**
  22396. * Creates a new cylinder geometry
  22397. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22398. */
  22399. class CylinderGeometry extends _PrimitiveGeometry {
  22400. /**
  22401. * Defines the height of the cylinder
  22402. */
  22403. height: number;
  22404. /**
  22405. * Defines the diameter of the cylinder's top cap
  22406. */
  22407. diameterTop: number;
  22408. /**
  22409. * Defines the diameter of the cylinder's bottom cap
  22410. */
  22411. diameterBottom: number;
  22412. /**
  22413. * Defines the tessellation factor to apply to the cylinder
  22414. */
  22415. tessellation: number;
  22416. /**
  22417. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22418. */
  22419. subdivisions: number;
  22420. /**
  22421. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22422. */
  22423. side: number;
  22424. /**
  22425. * Creates a new cylinder geometry
  22426. * @param id defines the unique ID of the geometry
  22427. * @param scene defines the hosting scene
  22428. * @param height defines the height of the cylinder
  22429. * @param diameterTop defines the diameter of the cylinder's top cap
  22430. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22431. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22432. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22433. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22434. * @param mesh defines the hosting mesh (can be null)
  22435. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22436. */
  22437. constructor(id: string, scene: Scene,
  22438. /**
  22439. * Defines the height of the cylinder
  22440. */
  22441. height: number,
  22442. /**
  22443. * Defines the diameter of the cylinder's top cap
  22444. */
  22445. diameterTop: number,
  22446. /**
  22447. * Defines the diameter of the cylinder's bottom cap
  22448. */
  22449. diameterBottom: number,
  22450. /**
  22451. * Defines the tessellation factor to apply to the cylinder
  22452. */
  22453. tessellation: number,
  22454. /**
  22455. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22456. */
  22457. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22458. /**
  22459. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22460. */
  22461. side?: number);
  22462. _regenerateVertexData(): VertexData;
  22463. copy(id: string): Geometry;
  22464. serialize(): any;
  22465. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22466. }
  22467. /**
  22468. * Creates a new torus geometry
  22469. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22470. */
  22471. class TorusGeometry extends _PrimitiveGeometry {
  22472. /**
  22473. * Defines the diameter of the torus
  22474. */
  22475. diameter: number;
  22476. /**
  22477. * Defines the thickness of the torus (ie. internal diameter)
  22478. */
  22479. thickness: number;
  22480. /**
  22481. * Defines the tesselation factor to apply to the torus
  22482. */
  22483. tessellation: number;
  22484. /**
  22485. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22486. */
  22487. side: number;
  22488. /**
  22489. * Creates a new torus geometry
  22490. * @param id defines the unique ID of the geometry
  22491. * @param scene defines the hosting scene
  22492. * @param diameter defines the diameter of the torus
  22493. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22494. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22495. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22496. * @param mesh defines the hosting mesh (can be null)
  22497. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22498. */
  22499. constructor(id: string, scene: Scene,
  22500. /**
  22501. * Defines the diameter of the torus
  22502. */
  22503. diameter: number,
  22504. /**
  22505. * Defines the thickness of the torus (ie. internal diameter)
  22506. */
  22507. thickness: number,
  22508. /**
  22509. * Defines the tesselation factor to apply to the torus
  22510. */
  22511. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22512. /**
  22513. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22514. */
  22515. side?: number);
  22516. _regenerateVertexData(): VertexData;
  22517. copy(id: string): Geometry;
  22518. serialize(): any;
  22519. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22520. }
  22521. /**
  22522. * Creates a new ground geometry
  22523. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22524. */
  22525. class GroundGeometry extends _PrimitiveGeometry {
  22526. /**
  22527. * Defines the width of the ground
  22528. */
  22529. width: number;
  22530. /**
  22531. * Defines the height of the ground
  22532. */
  22533. height: number;
  22534. /**
  22535. * Defines the subdivisions to apply to the ground
  22536. */
  22537. subdivisions: number;
  22538. /**
  22539. * Creates a new ground geometry
  22540. * @param id defines the unique ID of the geometry
  22541. * @param scene defines the hosting scene
  22542. * @param width defines the width of the ground
  22543. * @param height defines the height of the ground
  22544. * @param subdivisions defines the subdivisions to apply to the ground
  22545. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22546. * @param mesh defines the hosting mesh (can be null)
  22547. */
  22548. constructor(id: string, scene: Scene,
  22549. /**
  22550. * Defines the width of the ground
  22551. */
  22552. width: number,
  22553. /**
  22554. * Defines the height of the ground
  22555. */
  22556. height: number,
  22557. /**
  22558. * Defines the subdivisions to apply to the ground
  22559. */
  22560. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22561. _regenerateVertexData(): VertexData;
  22562. copy(id: string): Geometry;
  22563. serialize(): any;
  22564. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22565. }
  22566. /**
  22567. * Creates a tiled ground geometry
  22568. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22569. */
  22570. class TiledGroundGeometry extends _PrimitiveGeometry {
  22571. /**
  22572. * Defines the minimum value on X axis
  22573. */
  22574. xmin: number;
  22575. /**
  22576. * Defines the minimum value on Z axis
  22577. */
  22578. zmin: number;
  22579. /**
  22580. * Defines the maximum value on X axis
  22581. */
  22582. xmax: number;
  22583. /**
  22584. * Defines the maximum value on Z axis
  22585. */
  22586. zmax: number;
  22587. /**
  22588. * Defines the subdivisions to apply to the ground
  22589. */
  22590. subdivisions: {
  22591. w: number;
  22592. h: number;
  22593. };
  22594. /**
  22595. * Defines the precision to use when computing the tiles
  22596. */
  22597. precision: {
  22598. w: number;
  22599. h: number;
  22600. };
  22601. /**
  22602. * Creates a tiled ground geometry
  22603. * @param id defines the unique ID of the geometry
  22604. * @param scene defines the hosting scene
  22605. * @param xmin defines the minimum value on X axis
  22606. * @param zmin defines the minimum value on Z axis
  22607. * @param xmax defines the maximum value on X axis
  22608. * @param zmax defines the maximum value on Z axis
  22609. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22610. * @param precision defines the precision to use when computing the tiles
  22611. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22612. * @param mesh defines the hosting mesh (can be null)
  22613. */
  22614. constructor(id: string, scene: Scene,
  22615. /**
  22616. * Defines the minimum value on X axis
  22617. */
  22618. xmin: number,
  22619. /**
  22620. * Defines the minimum value on Z axis
  22621. */
  22622. zmin: number,
  22623. /**
  22624. * Defines the maximum value on X axis
  22625. */
  22626. xmax: number,
  22627. /**
  22628. * Defines the maximum value on Z axis
  22629. */
  22630. zmax: number,
  22631. /**
  22632. * Defines the subdivisions to apply to the ground
  22633. */
  22634. subdivisions: {
  22635. w: number;
  22636. h: number;
  22637. },
  22638. /**
  22639. * Defines the precision to use when computing the tiles
  22640. */
  22641. precision: {
  22642. w: number;
  22643. h: number;
  22644. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22645. _regenerateVertexData(): VertexData;
  22646. copy(id: string): Geometry;
  22647. }
  22648. /**
  22649. * Creates a plane geometry
  22650. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22651. */
  22652. class PlaneGeometry extends _PrimitiveGeometry {
  22653. /**
  22654. * Defines the size of the plane (width === height)
  22655. */
  22656. size: number;
  22657. /**
  22658. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22659. */
  22660. side: number;
  22661. /**
  22662. * Creates a plane geometry
  22663. * @param id defines the unique ID of the geometry
  22664. * @param scene defines the hosting scene
  22665. * @param size defines the size of the plane (width === height)
  22666. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22667. * @param mesh defines the hosting mesh (can be null)
  22668. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22669. */
  22670. constructor(id: string, scene: Scene,
  22671. /**
  22672. * Defines the size of the plane (width === height)
  22673. */
  22674. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22675. /**
  22676. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22677. */
  22678. side?: number);
  22679. _regenerateVertexData(): VertexData;
  22680. copy(id: string): Geometry;
  22681. serialize(): any;
  22682. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  22683. }
  22684. /**
  22685. * Creates a torus knot geometry
  22686. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  22687. */
  22688. class TorusKnotGeometry extends _PrimitiveGeometry {
  22689. /**
  22690. * Defines the radius of the torus knot
  22691. */
  22692. radius: number;
  22693. /**
  22694. * Defines the thickness of the torus knot tube
  22695. */
  22696. tube: number;
  22697. /**
  22698. * Defines the number of radial segments
  22699. */
  22700. radialSegments: number;
  22701. /**
  22702. * Defines the number of tubular segments
  22703. */
  22704. tubularSegments: number;
  22705. /**
  22706. * Defines the first number of windings
  22707. */
  22708. p: number;
  22709. /**
  22710. * Defines the second number of windings
  22711. */
  22712. q: number;
  22713. /**
  22714. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22715. */
  22716. side: number;
  22717. /**
  22718. * Creates a torus knot geometry
  22719. * @param id defines the unique ID of the geometry
  22720. * @param scene defines the hosting scene
  22721. * @param radius defines the radius of the torus knot
  22722. * @param tube defines the thickness of the torus knot tube
  22723. * @param radialSegments defines the number of radial segments
  22724. * @param tubularSegments defines the number of tubular segments
  22725. * @param p defines the first number of windings
  22726. * @param q defines the second number of windings
  22727. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22728. * @param mesh defines the hosting mesh (can be null)
  22729. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22730. */
  22731. constructor(id: string, scene: Scene,
  22732. /**
  22733. * Defines the radius of the torus knot
  22734. */
  22735. radius: number,
  22736. /**
  22737. * Defines the thickness of the torus knot tube
  22738. */
  22739. tube: number,
  22740. /**
  22741. * Defines the number of radial segments
  22742. */
  22743. radialSegments: number,
  22744. /**
  22745. * Defines the number of tubular segments
  22746. */
  22747. tubularSegments: number,
  22748. /**
  22749. * Defines the first number of windings
  22750. */
  22751. p: number,
  22752. /**
  22753. * Defines the second number of windings
  22754. */
  22755. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22756. /**
  22757. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22758. */
  22759. side?: number);
  22760. _regenerateVertexData(): VertexData;
  22761. copy(id: string): Geometry;
  22762. serialize(): any;
  22763. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  22764. }
  22765. }
  22766. declare module BABYLON {
  22767. class GroundMesh extends Mesh {
  22768. generateOctree: boolean;
  22769. private _heightQuads;
  22770. _subdivisionsX: number;
  22771. _subdivisionsY: number;
  22772. _width: number;
  22773. _height: number;
  22774. _minX: number;
  22775. _maxX: number;
  22776. _minZ: number;
  22777. _maxZ: number;
  22778. constructor(name: string, scene: Scene);
  22779. getClassName(): string;
  22780. readonly subdivisions: number;
  22781. readonly subdivisionsX: number;
  22782. readonly subdivisionsY: number;
  22783. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22784. /**
  22785. * Returns a height (y) value in the Worl system :
  22786. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22787. * Returns the ground y position if (x, z) are outside the ground surface.
  22788. */
  22789. getHeightAtCoordinates(x: number, z: number): number;
  22790. /**
  22791. * Returns a normalized vector (Vector3) orthogonal to the ground
  22792. * at the ground coordinates (x, z) expressed in the World system.
  22793. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22794. */
  22795. getNormalAtCoordinates(x: number, z: number): Vector3;
  22796. /**
  22797. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22798. * at the ground coordinates (x, z) expressed in the World system.
  22799. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22800. * Returns the GroundMesh.
  22801. */
  22802. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22803. /**
  22804. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22805. * if the ground has been updated.
  22806. * This can be used in the render loop.
  22807. * Returns the GroundMesh.
  22808. */
  22809. updateCoordinateHeights(): GroundMesh;
  22810. private _getFacetAt(x, z);
  22811. private _initHeightQuads();
  22812. private _computeHeightQuads();
  22813. serialize(serializationObject: any): void;
  22814. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22815. }
  22816. }
  22817. declare module BABYLON {
  22818. /**
  22819. * Creates an instance based on a source mesh.
  22820. */
  22821. class InstancedMesh extends AbstractMesh {
  22822. private _sourceMesh;
  22823. private _currentLOD;
  22824. constructor(name: string, source: Mesh);
  22825. /**
  22826. * Returns the string "InstancedMesh".
  22827. */
  22828. getClassName(): string;
  22829. readonly receiveShadows: boolean;
  22830. readonly material: Nullable<Material>;
  22831. readonly visibility: number;
  22832. readonly skeleton: Nullable<Skeleton>;
  22833. renderingGroupId: number;
  22834. /**
  22835. * Returns the total number of vertices (integer).
  22836. */
  22837. getTotalVertices(): number;
  22838. readonly sourceMesh: Mesh;
  22839. /**
  22840. * Is this node ready to be used/rendered
  22841. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  22842. * @return {boolean} is it ready
  22843. */
  22844. isReady(completeCheck?: boolean): boolean;
  22845. /**
  22846. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  22847. */
  22848. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  22849. /**
  22850. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22851. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22852. * The `data` are either a numeric array either a Float32Array.
  22853. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  22854. * 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).
  22855. * Note that a new underlying VertexBuffer object is created each call.
  22856. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22857. *
  22858. * Possible `kind` values :
  22859. * - BABYLON.VertexBuffer.PositionKind
  22860. * - BABYLON.VertexBuffer.UVKind
  22861. * - BABYLON.VertexBuffer.UV2Kind
  22862. * - BABYLON.VertexBuffer.UV3Kind
  22863. * - BABYLON.VertexBuffer.UV4Kind
  22864. * - BABYLON.VertexBuffer.UV5Kind
  22865. * - BABYLON.VertexBuffer.UV6Kind
  22866. * - BABYLON.VertexBuffer.ColorKind
  22867. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22868. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22869. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22870. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22871. *
  22872. * Returns the Mesh.
  22873. */
  22874. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  22875. /**
  22876. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22877. * If the mesh has no geometry, it is simply returned as it is.
  22878. * The `data` are either a numeric array either a Float32Array.
  22879. * No new underlying VertexBuffer object is created.
  22880. * 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.
  22881. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  22882. *
  22883. * Possible `kind` values :
  22884. * - BABYLON.VertexBuffer.PositionKind
  22885. * - BABYLON.VertexBuffer.UVKind
  22886. * - BABYLON.VertexBuffer.UV2Kind
  22887. * - BABYLON.VertexBuffer.UV3Kind
  22888. * - BABYLON.VertexBuffer.UV4Kind
  22889. * - BABYLON.VertexBuffer.UV5Kind
  22890. * - BABYLON.VertexBuffer.UV6Kind
  22891. * - BABYLON.VertexBuffer.ColorKind
  22892. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22893. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22894. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22895. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22896. *
  22897. * Returns the Mesh.
  22898. */
  22899. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  22900. /**
  22901. * Sets the mesh indices.
  22902. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  22903. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22904. * This method creates a new index buffer each call.
  22905. * Returns the Mesh.
  22906. */
  22907. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  22908. /**
  22909. * Boolean : True if the mesh owns the requested kind of data.
  22910. */
  22911. isVerticesDataPresent(kind: string): boolean;
  22912. /**
  22913. * Returns an array of indices (IndicesArray).
  22914. */
  22915. getIndices(): Nullable<IndicesArray>;
  22916. readonly _positions: Nullable<Vector3[]>;
  22917. /**
  22918. * Sets a new updated BoundingInfo to the mesh.
  22919. * Returns the mesh.
  22920. */
  22921. refreshBoundingInfo(): InstancedMesh;
  22922. _preActivate(): InstancedMesh;
  22923. _activate(renderId: number): InstancedMesh;
  22924. /**
  22925. * Returns the current associated LOD AbstractMesh.
  22926. */
  22927. getLOD(camera: Camera): AbstractMesh;
  22928. _syncSubMeshes(): InstancedMesh;
  22929. _generatePointsArray(): boolean;
  22930. /**
  22931. * Creates a new InstancedMesh from the current mesh.
  22932. * - name (string) : the cloned mesh name
  22933. * - newParent (optional Node) : the optional Node to parent the clone to.
  22934. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  22935. *
  22936. * Returns the clone.
  22937. */
  22938. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  22939. /**
  22940. * Disposes the InstancedMesh.
  22941. * Returns nothing.
  22942. */
  22943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22944. }
  22945. }
  22946. declare module BABYLON {
  22947. class LinesMesh extends Mesh {
  22948. useVertexColor: boolean | undefined;
  22949. useVertexAlpha: boolean | undefined;
  22950. color: Color3;
  22951. alpha: number;
  22952. /**
  22953. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  22954. * This margin is expressed in world space coordinates, so its value may vary.
  22955. * Default value is 0.1
  22956. * @returns the intersection Threshold value.
  22957. */
  22958. /**
  22959. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  22960. * This margin is expressed in world space coordinates, so its value may vary.
  22961. * @param value the new threshold to apply
  22962. */
  22963. intersectionThreshold: number;
  22964. private _intersectionThreshold;
  22965. private _colorShader;
  22966. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  22967. /**
  22968. * Returns the string "LineMesh"
  22969. */
  22970. getClassName(): string;
  22971. material: Material;
  22972. readonly checkCollisions: boolean;
  22973. createInstance(name: string): InstancedMesh;
  22974. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  22975. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  22976. dispose(doNotRecurse?: boolean): void;
  22977. /**
  22978. * Returns a new LineMesh object cloned from the current one.
  22979. */
  22980. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  22981. }
  22982. }
  22983. declare module BABYLON {
  22984. /**
  22985. * @hidden
  22986. **/
  22987. class _InstancesBatch {
  22988. mustReturn: boolean;
  22989. visibleInstances: Nullable<InstancedMesh[]>[];
  22990. renderSelf: boolean[];
  22991. }
  22992. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22993. static _FRONTSIDE: number;
  22994. static _BACKSIDE: number;
  22995. static _DOUBLESIDE: number;
  22996. static _DEFAULTSIDE: number;
  22997. static _NO_CAP: number;
  22998. static _CAP_START: number;
  22999. static _CAP_END: number;
  23000. static _CAP_ALL: number;
  23001. /**
  23002. * Mesh side orientation : usually the external or front surface
  23003. */
  23004. static readonly FRONTSIDE: number;
  23005. /**
  23006. * Mesh side orientation : usually the internal or back surface
  23007. */
  23008. static readonly BACKSIDE: number;
  23009. /**
  23010. * Mesh side orientation : both internal and external or front and back surfaces
  23011. */
  23012. static readonly DOUBLESIDE: number;
  23013. /**
  23014. * Mesh side orientation : by default, `FRONTSIDE`
  23015. */
  23016. static readonly DEFAULTSIDE: number;
  23017. /**
  23018. * Mesh cap setting : no cap
  23019. */
  23020. static readonly NO_CAP: number;
  23021. /**
  23022. * Mesh cap setting : one cap at the beginning of the mesh
  23023. */
  23024. static readonly CAP_START: number;
  23025. /**
  23026. * Mesh cap setting : one cap at the end of the mesh
  23027. */
  23028. static readonly CAP_END: number;
  23029. /**
  23030. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23031. */
  23032. static readonly CAP_ALL: number;
  23033. /**
  23034. * An event triggered before rendering the mesh
  23035. */
  23036. onBeforeRenderObservable: Observable<Mesh>;
  23037. /**
  23038. * An event triggered after rendering the mesh
  23039. */
  23040. onAfterRenderObservable: Observable<Mesh>;
  23041. /**
  23042. * An event triggered before drawing the mesh
  23043. */
  23044. onBeforeDrawObservable: Observable<Mesh>;
  23045. private _onBeforeDrawObserver;
  23046. onBeforeDraw: () => void;
  23047. delayLoadState: number;
  23048. instances: InstancedMesh[];
  23049. delayLoadingFile: string;
  23050. _binaryInfo: any;
  23051. private _LODLevels;
  23052. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23053. private _morphTargetManager;
  23054. morphTargetManager: Nullable<MorphTargetManager>;
  23055. _geometry: Nullable<Geometry>;
  23056. _delayInfo: Array<string>;
  23057. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23058. _visibleInstances: any;
  23059. private _renderIdForInstances;
  23060. private _batchCache;
  23061. private _instancesBufferSize;
  23062. private _instancesBuffer;
  23063. private _instancesData;
  23064. private _overridenInstanceCount;
  23065. private _effectiveMaterial;
  23066. _shouldGenerateFlatShading: boolean;
  23067. private _preActivateId;
  23068. _originalBuilderSideOrientation: number;
  23069. overrideMaterialSideOrientation: Nullable<number>;
  23070. private _areNormalsFrozen;
  23071. private _sourcePositions;
  23072. private _sourceNormals;
  23073. private _source;
  23074. readonly source: Nullable<Mesh>;
  23075. isUnIndexed: boolean;
  23076. /**
  23077. * @constructor
  23078. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  23079. * @param {Scene} scene The scene to add this mesh to.
  23080. * @param {Node} parent The parent of this mesh, if it has one
  23081. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  23082. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23083. * When false, achieved by calling a clone(), also passing False.
  23084. * This will make creation of children, recursive.
  23085. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23086. */
  23087. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23088. /**
  23089. * Returns the string "Mesh".
  23090. */
  23091. getClassName(): string;
  23092. /**
  23093. * Returns a string.
  23094. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  23095. */
  23096. toString(fullDetails?: boolean): string;
  23097. _unBindEffect(): void;
  23098. /**
  23099. * True if the mesh has some Levels Of Details (LOD).
  23100. * Returns a boolean.
  23101. */
  23102. readonly hasLODLevels: boolean;
  23103. /**
  23104. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  23105. * @returns an array of {BABYLON.MeshLODLevel}
  23106. */
  23107. getLODLevels(): MeshLODLevel[];
  23108. private _sortLODLevels();
  23109. /**
  23110. * Add a mesh as LOD level triggered at the given distance.
  23111. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  23112. * @param distance The distance from the center of the object to show this level
  23113. * @param mesh The mesh to be added as LOD level (can be null)
  23114. * @return This mesh (for chaining)
  23115. */
  23116. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23117. /**
  23118. * Returns the LOD level mesh at the passed distance or null if not found.
  23119. * It is related to the method `addLODLevel(distance, mesh)`.
  23120. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  23121. * Returns an object Mesh or `null`.
  23122. */
  23123. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23124. /**
  23125. * Remove a mesh from the LOD array
  23126. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  23127. * @param {Mesh} mesh The mesh to be removed.
  23128. * @return {Mesh} This mesh (for chaining)
  23129. */
  23130. removeLODLevel(mesh: Mesh): Mesh;
  23131. /**
  23132. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23133. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  23134. */
  23135. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23136. /**
  23137. * Returns the mesh internal Geometry object.
  23138. */
  23139. readonly geometry: Nullable<Geometry>;
  23140. /**
  23141. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23142. */
  23143. getTotalVertices(): number;
  23144. /**
  23145. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  23146. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  23147. * You can force the copy with forceCopy === true
  23148. * Returns null if the mesh has no geometry or no vertex buffer.
  23149. * Possible `kind` values :
  23150. * - BABYLON.VertexBuffer.PositionKind
  23151. * - BABYLON.VertexBuffer.UVKind
  23152. * - BABYLON.VertexBuffer.UV2Kind
  23153. * - BABYLON.VertexBuffer.UV3Kind
  23154. * - BABYLON.VertexBuffer.UV4Kind
  23155. * - BABYLON.VertexBuffer.UV5Kind
  23156. * - BABYLON.VertexBuffer.UV6Kind
  23157. * - BABYLON.VertexBuffer.ColorKind
  23158. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23159. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23160. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23161. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23162. */
  23163. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23164. /**
  23165. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  23166. * Returns `null` if the mesh has no geometry.
  23167. * Possible `kind` values :
  23168. * - BABYLON.VertexBuffer.PositionKind
  23169. * - BABYLON.VertexBuffer.UVKind
  23170. * - BABYLON.VertexBuffer.UV2Kind
  23171. * - BABYLON.VertexBuffer.UV3Kind
  23172. * - BABYLON.VertexBuffer.UV4Kind
  23173. * - BABYLON.VertexBuffer.UV5Kind
  23174. * - BABYLON.VertexBuffer.UV6Kind
  23175. * - BABYLON.VertexBuffer.ColorKind
  23176. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23177. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23178. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23179. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23180. */
  23181. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23182. isVerticesDataPresent(kind: string): boolean;
  23183. /**
  23184. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23185. * Possible `kind` values :
  23186. * - BABYLON.VertexBuffer.PositionKind
  23187. * - BABYLON.VertexBuffer.UVKind
  23188. * - BABYLON.VertexBuffer.UV2Kind
  23189. * - BABYLON.VertexBuffer.UV3Kind
  23190. * - BABYLON.VertexBuffer.UV4Kind
  23191. * - BABYLON.VertexBuffer.UV5Kind
  23192. * - BABYLON.VertexBuffer.UV6Kind
  23193. * - BABYLON.VertexBuffer.ColorKind
  23194. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23195. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23196. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23197. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23198. */
  23199. isVertexBufferUpdatable(kind: string): boolean;
  23200. /**
  23201. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  23202. * Possible `kind` values :
  23203. * - BABYLON.VertexBuffer.PositionKind
  23204. * - BABYLON.VertexBuffer.UVKind
  23205. * - BABYLON.VertexBuffer.UV2Kind
  23206. * - BABYLON.VertexBuffer.UV3Kind
  23207. * - BABYLON.VertexBuffer.UV4Kind
  23208. * - BABYLON.VertexBuffer.UV5Kind
  23209. * - BABYLON.VertexBuffer.UV6Kind
  23210. * - BABYLON.VertexBuffer.ColorKind
  23211. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23212. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23213. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23214. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23215. */
  23216. getVerticesDataKinds(): string[];
  23217. /**
  23218. * Returns a positive integer : the total number of indices in this mesh geometry.
  23219. * Returns zero if the mesh has no geometry.
  23220. */
  23221. getTotalIndices(): number;
  23222. /**
  23223. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23224. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  23225. * Returns an empty array if the mesh has no geometry.
  23226. */
  23227. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  23228. readonly isBlocked: boolean;
  23229. /**
  23230. * Determine if the current mesh is ready to be rendered
  23231. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23232. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23233. * @returns true if all associated assets are ready (material, textures, shaders)
  23234. */
  23235. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23236. /**
  23237. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  23238. * This property is pertinent only for updatable parametric shapes.
  23239. */
  23240. readonly areNormalsFrozen: boolean;
  23241. /**
  23242. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  23243. * It has no effect at all on other shapes.
  23244. * It prevents the mesh normals from being recomputed on next `positions` array update.
  23245. * Returns the Mesh.
  23246. */
  23247. freezeNormals(): Mesh;
  23248. /**
  23249. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  23250. * It has no effect at all on other shapes.
  23251. * It reactivates the mesh normals computation if it was previously frozen.
  23252. * Returns the Mesh.
  23253. */
  23254. unfreezeNormals(): Mesh;
  23255. /**
  23256. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23257. */
  23258. overridenInstanceCount: number;
  23259. _preActivate(): Mesh;
  23260. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23261. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23262. /**
  23263. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23264. * This means the mesh underlying bounding box and sphere are recomputed.
  23265. * Returns the Mesh.
  23266. */
  23267. refreshBoundingInfo(): Mesh;
  23268. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  23269. private _getPositionData(applySkeleton);
  23270. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23271. subdivide(count: number): void;
  23272. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23273. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23274. /**
  23275. * Sets the mesh VertexBuffer.
  23276. * Returns the Mesh.
  23277. */
  23278. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23280. /**
  23281. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23282. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23283. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  23284. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  23285. * Returns the Mesh.
  23286. */
  23287. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23288. /**
  23289. * Creates a un-shared specific occurence of the geometry for the mesh.
  23290. * Returns the Mesh.
  23291. */
  23292. makeGeometryUnique(): Mesh;
  23293. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23294. /**
  23295. * Update the current index buffer
  23296. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23297. * Returns the Mesh.
  23298. */
  23299. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  23300. /**
  23301. * Invert the geometry to move from a right handed system to a left handed one.
  23302. * Returns the Mesh.
  23303. */
  23304. toLeftHanded(): Mesh;
  23305. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23306. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  23307. /**
  23308. * Registers for this mesh a javascript function called just before the rendering process.
  23309. * This function is passed the current mesh.
  23310. * Return the Mesh.
  23311. */
  23312. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23313. /**
  23314. * Disposes a previously registered javascript function called before the rendering.
  23315. * This function is passed the current mesh.
  23316. * Returns the Mesh.
  23317. */
  23318. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23319. /**
  23320. * Registers for this mesh a javascript function called just after the rendering is complete.
  23321. * This function is passed the current mesh.
  23322. * Returns the Mesh.
  23323. */
  23324. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23325. /**
  23326. * Disposes a previously registered javascript function called after the rendering.
  23327. * This function is passed the current mesh.
  23328. * Return the Mesh.
  23329. */
  23330. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23331. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23332. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23333. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23334. /**
  23335. * 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
  23336. * @param subMesh defines the subMesh to render
  23337. * @param enableAlphaMode defines if alpha mode can be changed
  23338. * @returns the current mesh
  23339. */
  23340. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23341. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  23342. /**
  23343. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  23344. */
  23345. getEmittedParticleSystems(): IParticleSystem[];
  23346. /**
  23347. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  23348. */
  23349. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  23350. /**
  23351. * Normalize matrix weights so that all vertices have a total weight set to 1
  23352. */
  23353. cleanMatrixWeights(): void;
  23354. _checkDelayState(): Mesh;
  23355. private _queueLoad(scene);
  23356. /**
  23357. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  23358. */
  23359. isInFrustum(frustumPlanes: Plane[]): boolean;
  23360. /**
  23361. * Sets the mesh material by the material or multiMaterial `id` property.
  23362. * The material `id` is a string identifying the material or the multiMaterial.
  23363. * This method returns the Mesh.
  23364. */
  23365. setMaterialByID(id: string): Mesh;
  23366. /**
  23367. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23368. */
  23369. getAnimatables(): IAnimatable[];
  23370. /**
  23371. * Modifies the mesh geometry according to the passed transformation matrix.
  23372. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23373. * The mesh normals are modified accordingly the same transformation.
  23374. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  23375. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23376. * Returns the Mesh.
  23377. */
  23378. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23379. /**
  23380. * Modifies the mesh geometry according to its own current World Matrix.
  23381. * The mesh World Matrix is then reset.
  23382. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23383. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  23384. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23385. * Returns the Mesh.
  23386. */
  23387. bakeCurrentTransformIntoVertices(): Mesh;
  23388. readonly _positions: Nullable<Vector3[]>;
  23389. _resetPointsArrayCache(): Mesh;
  23390. _generatePointsArray(): boolean;
  23391. /**
  23392. * Returns a new Mesh object generated from the current mesh properties.
  23393. * This method must not get confused with createInstance().
  23394. * The parameter `name` is a string, the name given to the new mesh.
  23395. * The optional parameter `newParent` can be any Node object (default `null`).
  23396. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  23397. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  23398. */
  23399. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23400. /**
  23401. * Releases resources associated with this mesh.
  23402. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23403. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23404. */
  23405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23406. /**
  23407. * Modifies the mesh geometry according to a displacement map.
  23408. * 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.
  23409. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23410. * This method returns nothing.
  23411. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  23412. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  23413. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  23414. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  23415. * The parameter `uvScale` is an optional vector2 used to scale UV.
  23416. *
  23417. * Returns the Mesh.
  23418. */
  23419. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  23420. /**
  23421. * Modifies the mesh geometry according to a displacementMap buffer.
  23422. * 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.
  23423. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23424. * This method returns nothing.
  23425. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23426. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  23427. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  23428. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  23429. * The parameter `uvScale` is an optional vector2 used to scale UV.
  23430. *
  23431. * Returns the Mesh.
  23432. */
  23433. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  23434. /**
  23435. * Modify the mesh to get a flat shading rendering.
  23436. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23437. * This method returns the Mesh.
  23438. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23439. */
  23440. convertToFlatShadedMesh(): Mesh;
  23441. /**
  23442. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23443. * In other words, more vertices, no more indices and a single bigger VBO.
  23444. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23445. * Returns the Mesh.
  23446. */
  23447. convertToUnIndexedMesh(): Mesh;
  23448. /**
  23449. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  23450. * This method returns the Mesh.
  23451. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23452. */
  23453. flipFaces(flipNormals?: boolean): Mesh;
  23454. /**
  23455. * Creates a new InstancedMesh object from the mesh model.
  23456. * An instance shares the same properties and the same material than its model.
  23457. * Only these properties of each instance can then be set individually :
  23458. * - position
  23459. * - rotation
  23460. * - rotationQuaternion
  23461. * - setPivotMatrix
  23462. * - scaling
  23463. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  23464. * Warning : this method is not supported for Line mesh and LineSystem
  23465. */
  23466. createInstance(name: string): InstancedMesh;
  23467. /**
  23468. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23469. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23470. * This method returns the Mesh.
  23471. */
  23472. synchronizeInstances(): Mesh;
  23473. /**
  23474. * Simplify the mesh according to the given array of settings.
  23475. * Function will return immediately and will simplify async. It returns the Mesh.
  23476. * @param settings a collection of simplification settings.
  23477. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23478. * @param type the type of simplification to run.
  23479. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23480. */
  23481. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23482. /**
  23483. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23484. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23485. * This should be used together with the simplification to avoid disappearing triangles.
  23486. * Returns the Mesh.
  23487. * @param successCallback an optional success callback to be called after the optimization finished.
  23488. */
  23489. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23490. serialize(serializationObject: any): void;
  23491. _syncGeometryWithMorphTargetManager(): void;
  23492. /**
  23493. * Returns a new Mesh object parsed from the source provided.
  23494. * The parameter `parsedMesh` is the source.
  23495. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23496. */
  23497. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23498. /**
  23499. * Creates a ribbon mesh.
  23500. * Please consider using the same method from the MeshBuilder class instead.
  23501. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  23502. *
  23503. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23504. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23505. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  23506. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  23507. * 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.
  23508. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  23509. * 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
  23510. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23511. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23512. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23513. */
  23514. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23515. /**
  23516. * Creates a plane polygonal mesh. By default, this is a disc.
  23517. * Please consider using the same method from the MeshBuilder class instead.
  23518. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  23519. * 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.
  23520. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23521. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23522. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23523. */
  23524. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23525. /**
  23526. * Creates a box mesh.
  23527. * Please consider using the same method from the MeshBuilder class instead.
  23528. * The parameter `size` sets the size (float) of each box side (default 1).
  23529. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23530. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23532. */
  23533. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23534. /**
  23535. * Creates a sphere mesh.
  23536. * Please consider using the same method from the MeshBuilder class instead.
  23537. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  23538. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  23539. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23540. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23541. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23542. */
  23543. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23544. /**
  23545. * Creates a cylinder or a cone mesh.
  23546. * Please consider using the same method from the MeshBuilder class instead.
  23547. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23548. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23549. * 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.
  23550. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23551. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23552. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23553. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23554. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23555. */
  23556. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23557. /**
  23558. * Creates a torus mesh.
  23559. * Please consider using the same method from the MeshBuilder class instead.
  23560. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  23561. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  23562. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  23563. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23564. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23565. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23566. */
  23567. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23568. /**
  23569. * Creates a torus knot mesh.
  23570. * Please consider using the same method from the MeshBuilder class instead.
  23571. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  23572. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  23573. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  23574. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  23575. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23576. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23577. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23578. */
  23579. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23580. /**
  23581. * Creates a line mesh.
  23582. * Please consider using the same method from the MeshBuilder class instead.
  23583. * 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.
  23584. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  23585. * The parameter `points` is an array successive Vector3.
  23586. * 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
  23587. * When updating an instance, remember that only point positions can change, not the number of points.
  23588. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23589. */
  23590. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23591. /**
  23592. * Creates a dashed line mesh.
  23593. * Please consider using the same method from the MeshBuilder class instead.
  23594. * 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.
  23595. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  23596. * The parameter `points` is an array successive Vector3.
  23597. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  23598. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  23599. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  23600. * 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
  23601. * When updating an instance, remember that only point positions can change, not the number of points.
  23602. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23603. */
  23604. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23605. /**
  23606. * Creates a polygon mesh.
  23607. * Please consider using the same method from the MeshBuilder class instead.
  23608. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23609. * 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.
  23610. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23611. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23612. * Remember you can only change the shape positions, not their number when updating a polygon.
  23613. */
  23614. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  23615. /**
  23616. * Creates an extruded polygon mesh, with depth in the Y direction.
  23617. * Please consider using the same method from the MeshBuilder class instead.
  23618. */
  23619. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  23620. /**
  23621. * Creates an extruded shape mesh.
  23622. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  23623. * Please consider using the same method from the MeshBuilder class instead.
  23624. *
  23625. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23626. * 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
  23627. * extruded along the Z axis.
  23628. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23629. * 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.
  23630. * The parameter `scale` (float, default 1) is the value to scale the shape.
  23631. * 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
  23632. * 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
  23633. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23634. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23635. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23636. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23637. */
  23638. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23639. /**
  23640. * Creates an custom extruded shape mesh.
  23641. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  23642. * Please consider using the same method from the MeshBuilder class instead.
  23643. *
  23644. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23645. * 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
  23646. * extruded along the Z axis.
  23647. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23648. * 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
  23649. * and the distance of this point from the begining of the path :
  23650. * ```javascript
  23651. * var rotationFunction = function(i, distance) {
  23652. * // do things
  23653. * return rotationValue; }
  23654. * ```
  23655. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23656. * 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
  23657. * and the distance of this point from the begining of the path :
  23658. * ```javascript
  23659. * var scaleFunction = function(i, distance) {
  23660. * // do things
  23661. * return scaleValue;}
  23662. * ```
  23663. * It must returns a float value that will be the scale value applied to the shape on each path point.
  23664. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  23665. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  23666. * 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
  23667. * 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
  23668. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23669. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23670. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23671. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23672. */
  23673. 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;
  23674. /**
  23675. * Creates lathe mesh.
  23676. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23677. * Please consider using the same method from the MeshBuilder class instead.
  23678. * 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
  23679. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  23680. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  23681. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  23682. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23683. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23684. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23685. */
  23686. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23687. /**
  23688. * Creates a plane mesh.
  23689. * Please consider using the same method from the MeshBuilder class instead.
  23690. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  23691. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23692. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23693. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23694. */
  23695. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23696. /**
  23697. * Creates a ground mesh.
  23698. * Please consider using the same method from the MeshBuilder class instead.
  23699. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  23700. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  23701. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23702. */
  23703. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23704. /**
  23705. * Creates a tiled ground mesh.
  23706. * Please consider using the same method from the MeshBuilder class instead.
  23707. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  23708. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  23709. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  23710. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  23711. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  23712. * numbers of subdivisions on the ground width and height of each tile.
  23713. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23714. */
  23715. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23716. w: number;
  23717. h: number;
  23718. }, precision: {
  23719. w: number;
  23720. h: number;
  23721. }, scene: Scene, updatable?: boolean): Mesh;
  23722. /**
  23723. * Creates a ground mesh from a height map.
  23724. * tuto : http://doc.babylonjs.com/babylon101/height_map
  23725. * Please consider using the same method from the MeshBuilder class instead.
  23726. * The parameter `url` sets the URL of the height map image resource.
  23727. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23728. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23729. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23730. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23731. * 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).
  23732. * This function is passed the newly built mesh :
  23733. * ```javascript
  23734. * function(mesh) { // do things
  23735. * return; }
  23736. * ```
  23737. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23738. */
  23739. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  23740. /**
  23741. * Creates a tube mesh.
  23742. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  23743. * Please consider using the same method from the MeshBuilder class instead.
  23744. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  23745. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  23746. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  23747. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  23748. * 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.
  23749. * It must return a radius value (positive float) :
  23750. * ```javascript
  23751. * var radiusFunction = function(i, distance) {
  23752. * // do things
  23753. * return radius; }
  23754. * ```
  23755. * 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
  23756. * 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
  23757. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23758. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23759. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23760. */
  23761. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23762. (i: number, distance: number): number;
  23763. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23764. /**
  23765. * Creates a polyhedron mesh.
  23766. * Please consider using the same method from the MeshBuilder class instead.
  23767. * 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
  23768. * to choose the wanted type.
  23769. * The parameter `size` (positive float, default 1) sets the polygon size.
  23770. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  23771. * 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`.
  23772. * 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
  23773. * 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)`).
  23774. * 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
  23775. * 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.
  23776. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23777. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23778. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23779. */
  23780. static CreatePolyhedron(name: string, options: {
  23781. type?: number;
  23782. size?: number;
  23783. sizeX?: number;
  23784. sizeY?: number;
  23785. sizeZ?: number;
  23786. custom?: any;
  23787. faceUV?: Vector4[];
  23788. faceColors?: Color4[];
  23789. updatable?: boolean;
  23790. sideOrientation?: number;
  23791. }, scene: Scene): Mesh;
  23792. /**
  23793. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  23794. * Please consider using the same method from the MeshBuilder class instead.
  23795. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  23796. * 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`).
  23797. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  23798. * 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.
  23799. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23800. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23801. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23802. */
  23803. static CreateIcoSphere(name: string, options: {
  23804. radius?: number;
  23805. flat?: boolean;
  23806. subdivisions?: number;
  23807. sideOrientation?: number;
  23808. updatable?: boolean;
  23809. }, scene: Scene): Mesh;
  23810. /**
  23811. * Creates a decal mesh.
  23812. * Please consider using the same method from the MeshBuilder class instead.
  23813. * 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.
  23814. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  23815. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  23816. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  23817. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  23818. */
  23819. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  23820. /**
  23821. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  23822. */
  23823. setPositionsForCPUSkinning(): Float32Array;
  23824. /**
  23825. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  23826. */
  23827. setNormalsForCPUSkinning(): Float32Array;
  23828. /**
  23829. * Updates the vertex buffer by applying transformation from the bones.
  23830. * Returns the Mesh.
  23831. *
  23832. * @param {skeleton} skeleton to apply
  23833. */
  23834. applySkeleton(skeleton: Skeleton): Mesh;
  23835. /**
  23836. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  23837. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  23838. */
  23839. static MinMax(meshes: AbstractMesh[]): {
  23840. min: Vector3;
  23841. max: Vector3;
  23842. };
  23843. /**
  23844. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  23845. */
  23846. static Center(meshesOrMinMaxVector: {
  23847. min: Vector3;
  23848. max: Vector3;
  23849. } | AbstractMesh[]): Vector3;
  23850. /**
  23851. * Merge the array of meshes into a single mesh for performance reasons.
  23852. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  23853. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  23854. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  23855. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  23856. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  23857. */
  23858. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  23859. }
  23860. }
  23861. declare module BABYLON {
  23862. /**
  23863. * Define an interface for all classes that will get and set the data on vertices
  23864. */
  23865. interface IGetSetVerticesData {
  23866. isVerticesDataPresent(kind: string): boolean;
  23867. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23868. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  23869. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23870. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23871. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23872. }
  23873. /**
  23874. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23875. */
  23876. class VertexData {
  23877. /**
  23878. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23879. */
  23880. positions: Nullable<FloatArray>;
  23881. /**
  23882. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23883. */
  23884. normals: Nullable<FloatArray>;
  23885. /**
  23886. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23887. */
  23888. tangents: Nullable<FloatArray>;
  23889. /**
  23890. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23891. */
  23892. uvs: Nullable<FloatArray>;
  23893. /**
  23894. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23895. */
  23896. uvs2: Nullable<FloatArray>;
  23897. /**
  23898. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23899. */
  23900. uvs3: Nullable<FloatArray>;
  23901. /**
  23902. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23903. */
  23904. uvs4: Nullable<FloatArray>;
  23905. /**
  23906. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23907. */
  23908. uvs5: Nullable<FloatArray>;
  23909. /**
  23910. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23911. */
  23912. uvs6: Nullable<FloatArray>;
  23913. /**
  23914. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23915. */
  23916. colors: Nullable<FloatArray>;
  23917. /**
  23918. * 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).
  23919. */
  23920. matricesIndices: Nullable<FloatArray>;
  23921. /**
  23922. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23923. */
  23924. matricesWeights: Nullable<FloatArray>;
  23925. /**
  23926. * An array extending the number of possible indices
  23927. */
  23928. matricesIndicesExtra: Nullable<FloatArray>;
  23929. /**
  23930. * An array extending the number of possible weights when the number of indices is extended
  23931. */
  23932. matricesWeightsExtra: Nullable<FloatArray>;
  23933. /**
  23934. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23935. */
  23936. indices: Nullable<IndicesArray>;
  23937. /**
  23938. * Uses the passed data array to set the set the values for the specified kind of data
  23939. * @param data a linear array of floating numbers
  23940. * @param kind the type of data that is being set, eg positions, colors etc
  23941. */
  23942. set(data: FloatArray, kind: string): void;
  23943. /**
  23944. * Associates the vertexData to the passed Mesh.
  23945. * Sets it as updatable or not (default `false`)
  23946. * @param mesh the mesh the vertexData is applied to
  23947. * @param updatable when used and having the value true allows new data to update the vertexData
  23948. * @returns the VertexData
  23949. */
  23950. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23951. /**
  23952. * Associates the vertexData to the passed Geometry.
  23953. * Sets it as updatable or not (default `false`)
  23954. * @param geometry the geometry the vertexData is applied to
  23955. * @param updatable when used and having the value true allows new data to update the vertexData
  23956. * @returns VertexData
  23957. */
  23958. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23959. /**
  23960. * Updates the associated mesh
  23961. * @param mesh the mesh to be updated
  23962. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23963. * @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
  23964. * @returns VertexData
  23965. */
  23966. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  23967. /**
  23968. * Updates the associated geometry
  23969. * @param geometry the geometry to be updated
  23970. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23971. * @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
  23972. * @returns VertexData.
  23973. */
  23974. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  23975. private _applyTo(meshOrGeometry, updatable?);
  23976. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  23977. /**
  23978. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23979. * @param matrix the transforming matrix
  23980. * @returns the VertexData
  23981. */
  23982. transform(matrix: Matrix): VertexData;
  23983. /**
  23984. * Merges the passed VertexData into the current one
  23985. * @param other the VertexData to be merged into the current one
  23986. * @returns the modified VertexData
  23987. */
  23988. merge(other: VertexData): VertexData;
  23989. private _mergeElement(source, other);
  23990. private _validate();
  23991. /**
  23992. * Serializes the VertexData
  23993. * @returns a serialized object
  23994. */
  23995. serialize(): any;
  23996. /**
  23997. * Extracts the vertexData from a mesh
  23998. * @param mesh the mesh from which to extract the VertexData
  23999. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24000. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24001. * @returns the object VertexData associated to the passed mesh
  24002. */
  24003. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24004. /**
  24005. * Extracts the vertexData from the geometry
  24006. * @param geometry the geometry from which to extract the VertexData
  24007. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24008. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24009. * @returns the object VertexData associated to the passed mesh
  24010. */
  24011. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24012. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  24013. /**
  24014. * Creates the VertexData for a Ribbon
  24015. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24016. * * pathArray array of paths, each of which an array of successive Vector3
  24017. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24018. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24019. * * 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
  24020. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24021. * * 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)
  24022. * * 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)
  24023. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24024. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24025. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24026. * @returns the VertexData of the ribbon
  24027. */
  24028. static CreateRibbon(options: {
  24029. pathArray: Vector3[][];
  24030. closeArray?: boolean;
  24031. closePath?: boolean;
  24032. offset?: number;
  24033. sideOrientation?: number;
  24034. frontUVs?: Vector4;
  24035. backUVs?: Vector4;
  24036. invertUV?: boolean;
  24037. uvs?: Vector2[];
  24038. colors?: Color4[];
  24039. }): VertexData;
  24040. /**
  24041. * Creates the VertexData for a box
  24042. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24043. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24044. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24045. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24046. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24047. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24048. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24049. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24050. * * 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)
  24051. * * 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)
  24052. * @returns the VertexData of the box
  24053. */
  24054. static CreateBox(options: {
  24055. size?: number;
  24056. width?: number;
  24057. height?: number;
  24058. depth?: number;
  24059. faceUV?: Vector4[];
  24060. faceColors?: Color4[];
  24061. sideOrientation?: number;
  24062. frontUVs?: Vector4;
  24063. backUVs?: Vector4;
  24064. }): VertexData;
  24065. /**
  24066. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24067. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24068. * * segments sets the number of horizontal strips optional, default 32
  24069. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24070. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24071. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24072. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24073. * * 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
  24074. * * 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
  24075. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24076. * * 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)
  24077. * * 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)
  24078. * @returns the VertexData of the ellipsoid
  24079. */
  24080. static CreateSphere(options: {
  24081. segments?: number;
  24082. diameter?: number;
  24083. diameterX?: number;
  24084. diameterY?: number;
  24085. diameterZ?: number;
  24086. arc?: number;
  24087. slice?: number;
  24088. sideOrientation?: number;
  24089. frontUVs?: Vector4;
  24090. backUVs?: Vector4;
  24091. }): VertexData;
  24092. /**
  24093. * Creates the VertexData for a cylinder, cone or prism
  24094. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24095. * * height sets the height (y direction) of the cylinder, optional, default 2
  24096. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24097. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24098. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24099. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24100. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24101. * * 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
  24102. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24103. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24104. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24105. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24106. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24107. * * 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)
  24108. * * 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)
  24109. * @returns the VertexData of the cylinder, cone or prism
  24110. */
  24111. static CreateCylinder(options: {
  24112. height?: number;
  24113. diameterTop?: number;
  24114. diameterBottom?: number;
  24115. diameter?: number;
  24116. tessellation?: number;
  24117. subdivisions?: number;
  24118. arc?: number;
  24119. faceColors?: Color4[];
  24120. faceUV?: Vector4[];
  24121. hasRings?: boolean;
  24122. enclose?: boolean;
  24123. sideOrientation?: number;
  24124. frontUVs?: Vector4;
  24125. backUVs?: Vector4;
  24126. }): VertexData;
  24127. /**
  24128. * Creates the VertexData for a torus
  24129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24130. * * diameter the diameter of the torus, optional default 1
  24131. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24132. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24133. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24134. * * 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)
  24135. * * 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)
  24136. * @returns the VertexData of the torus
  24137. */
  24138. static CreateTorus(options: {
  24139. diameter?: number;
  24140. thickness?: number;
  24141. tessellation?: number;
  24142. sideOrientation?: number;
  24143. frontUVs?: Vector4;
  24144. backUVs?: Vector4;
  24145. }): VertexData;
  24146. /**
  24147. * Creates the VertexData of the LineSystem
  24148. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24149. * - lines an array of lines, each line being an array of successive Vector3
  24150. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24151. * @returns the VertexData of the LineSystem
  24152. */
  24153. static CreateLineSystem(options: {
  24154. lines: Vector3[][];
  24155. colors?: Nullable<Color4[][]>;
  24156. }): VertexData;
  24157. /**
  24158. * Create the VertexData for a DashedLines
  24159. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24160. * - points an array successive Vector3
  24161. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24162. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24163. * - dashNb the intended total number of dashes, optional, default 200
  24164. * @returns the VertexData for the DashedLines
  24165. */
  24166. static CreateDashedLines(options: {
  24167. points: Vector3[];
  24168. dashSize?: number;
  24169. gapSize?: number;
  24170. dashNb?: number;
  24171. }): VertexData;
  24172. /**
  24173. * Creates the VertexData for a Ground
  24174. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24175. * - width the width (x direction) of the ground, optional, default 1
  24176. * - height the height (z direction) of the ground, optional, default 1
  24177. * - subdivisions the number of subdivisions per side, optional, default 1
  24178. * @returns the VertexData of the Ground
  24179. */
  24180. static CreateGround(options: {
  24181. width?: number;
  24182. height?: number;
  24183. subdivisions?: number;
  24184. subdivisionsX?: number;
  24185. subdivisionsY?: number;
  24186. }): VertexData;
  24187. /**
  24188. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24189. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24190. * * xmin the ground minimum X coordinate, optional, default -1
  24191. * * zmin the ground minimum Z coordinate, optional, default -1
  24192. * * xmax the ground maximum X coordinate, optional, default 1
  24193. * * zmax the ground maximum Z coordinate, optional, default 1
  24194. * * 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}
  24195. * * 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}
  24196. * @returns the VertexData of the TiledGround
  24197. */
  24198. static CreateTiledGround(options: {
  24199. xmin: number;
  24200. zmin: number;
  24201. xmax: number;
  24202. zmax: number;
  24203. subdivisions?: {
  24204. w: number;
  24205. h: number;
  24206. };
  24207. precision?: {
  24208. w: number;
  24209. h: number;
  24210. };
  24211. }): VertexData;
  24212. /**
  24213. * Creates the VertexData of the Ground designed from a heightmap
  24214. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24215. * * width the width (x direction) of the ground
  24216. * * height the height (z direction) of the ground
  24217. * * subdivisions the number of subdivisions per side
  24218. * * minHeight the minimum altitude on the ground, optional, default 0
  24219. * * maxHeight the maximum altitude on the ground, optional default 1
  24220. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24221. * * buffer the array holding the image color data
  24222. * * bufferWidth the width of image
  24223. * * bufferHeight the height of image
  24224. * @returns the VertexData of the Ground designed from a heightmap
  24225. */
  24226. static CreateGroundFromHeightMap(options: {
  24227. width: number;
  24228. height: number;
  24229. subdivisions: number;
  24230. minHeight: number;
  24231. maxHeight: number;
  24232. colorFilter: Color3;
  24233. buffer: Uint8Array;
  24234. bufferWidth: number;
  24235. bufferHeight: number;
  24236. }): VertexData;
  24237. /**
  24238. * Creates the VertexData for a Plane
  24239. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24240. * * size sets the width and height of the plane to the value of size, optional default 1
  24241. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24242. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24243. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24244. * * 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)
  24245. * * 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)
  24246. * @returns the VertexData of the box
  24247. */
  24248. static CreatePlane(options: {
  24249. size?: number;
  24250. width?: number;
  24251. height?: number;
  24252. sideOrientation?: number;
  24253. frontUVs?: Vector4;
  24254. backUVs?: Vector4;
  24255. }): VertexData;
  24256. /**
  24257. * Creates the VertexData of the Disc or regular Polygon
  24258. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24259. * * radius the radius of the disc, optional default 0.5
  24260. * * tessellation the number of polygon sides, optional, default 64
  24261. * * 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
  24262. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24263. * * 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)
  24264. * * 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)
  24265. * @returns the VertexData of the box
  24266. */
  24267. static CreateDisc(options: {
  24268. radius?: number;
  24269. tessellation?: number;
  24270. arc?: number;
  24271. sideOrientation?: number;
  24272. frontUVs?: Vector4;
  24273. backUVs?: Vector4;
  24274. }): VertexData;
  24275. /**
  24276. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24277. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24278. * @param polygon a mesh built from polygonTriangulation.build()
  24279. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24280. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24281. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24282. * @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)
  24283. * @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)
  24284. * @returns the VertexData of the Polygon
  24285. */
  24286. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24287. /**
  24288. * Creates the VertexData of the IcoSphere
  24289. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24290. * * radius the radius of the IcoSphere, optional default 1
  24291. * * radiusX allows stretching in the x direction, optional, default radius
  24292. * * radiusY allows stretching in the y direction, optional, default radius
  24293. * * radiusZ allows stretching in the z direction, optional, default radius
  24294. * * flat when true creates a flat shaded mesh, optional, default true
  24295. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24296. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24297. * * 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)
  24298. * * 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)
  24299. * @returns the VertexData of the IcoSphere
  24300. */
  24301. static CreateIcoSphere(options: {
  24302. radius?: number;
  24303. radiusX?: number;
  24304. radiusY?: number;
  24305. radiusZ?: number;
  24306. flat?: boolean;
  24307. subdivisions?: number;
  24308. sideOrientation?: number;
  24309. frontUVs?: Vector4;
  24310. backUVs?: Vector4;
  24311. }): VertexData;
  24312. /**
  24313. * Creates the VertexData for a Polyhedron
  24314. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24315. * * type provided types are:
  24316. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24317. * * 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)
  24318. * * size the size of the IcoSphere, optional default 1
  24319. * * sizeX allows stretching in the x direction, optional, default size
  24320. * * sizeY allows stretching in the y direction, optional, default size
  24321. * * sizeZ allows stretching in the z direction, optional, default size
  24322. * * 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
  24323. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24325. * * flat when true creates a flat shaded mesh, optional, default true
  24326. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24327. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24328. * * 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)
  24329. * * 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)
  24330. * @returns the VertexData of the Polyhedron
  24331. */
  24332. static CreatePolyhedron(options: {
  24333. type?: number;
  24334. size?: number;
  24335. sizeX?: number;
  24336. sizeY?: number;
  24337. sizeZ?: number;
  24338. custom?: any;
  24339. faceUV?: Vector4[];
  24340. faceColors?: Color4[];
  24341. flat?: boolean;
  24342. sideOrientation?: number;
  24343. frontUVs?: Vector4;
  24344. backUVs?: Vector4;
  24345. }): VertexData;
  24346. /**
  24347. * Creates the VertexData for a TorusKnot
  24348. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24349. * * radius the radius of the torus knot, optional, default 2
  24350. * * tube the thickness of the tube, optional, default 0.5
  24351. * * radialSegments the number of sides on each tube segments, optional, default 32
  24352. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24353. * * p the number of windings around the z axis, optional, default 2
  24354. * * q the number of windings around the x axis, optional, default 3
  24355. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24356. * * 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)
  24357. * * 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)
  24358. * @returns the VertexData of the Torus Knot
  24359. */
  24360. static CreateTorusKnot(options: {
  24361. radius?: number;
  24362. tube?: number;
  24363. radialSegments?: number;
  24364. tubularSegments?: number;
  24365. p?: number;
  24366. q?: number;
  24367. sideOrientation?: number;
  24368. frontUVs?: Vector4;
  24369. backUVs?: Vector4;
  24370. }): VertexData;
  24371. /**
  24372. * Compute normals for given positions and indices
  24373. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24374. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24375. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24376. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24377. * * facetNormals : optional array of facet normals (vector3)
  24378. * * facetPositions : optional array of facet positions (vector3)
  24379. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24380. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24381. * * bInfo : optional bounding info, required for facetPartitioning computation
  24382. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24383. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24384. * * useRightHandedSystem: optional boolean to for right handed system computation
  24385. * * depthSort : optional boolean to enable the facet depth sort computation
  24386. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24387. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24388. */
  24389. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24390. facetNormals?: any;
  24391. facetPositions?: any;
  24392. facetPartitioning?: any;
  24393. ratio?: number;
  24394. bInfo?: any;
  24395. bbSize?: Vector3;
  24396. subDiv?: any;
  24397. useRightHandedSystem?: boolean;
  24398. depthSort?: boolean;
  24399. distanceTo?: Vector3;
  24400. depthSortedFacets?: any;
  24401. }): void;
  24402. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  24403. /**
  24404. * Applies VertexData created from the imported parameters to the geometry
  24405. * @param parsedVertexData the parsed data from an imported file
  24406. * @param geometry the geometry to apply the VertexData to
  24407. */
  24408. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24409. }
  24410. }
  24411. declare module BABYLON {
  24412. /**
  24413. * Class containing static functions to help procedurally build meshes
  24414. */
  24415. class MeshBuilder {
  24416. private static updateSideOrientation(orientation?);
  24417. /**
  24418. * Creates a box mesh
  24419. * * The parameter `size` sets the size (float) of each box side (default 1)
  24420. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  24421. * * 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)
  24422. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  24423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24424. * * 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
  24425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24426. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  24427. * @param name defines the name of the mesh
  24428. * @param options defines the options used to create the mesh
  24429. * @param scene defines the hosting scene
  24430. * @returns the box mesh
  24431. */
  24432. static CreateBox(name: string, options: {
  24433. size?: number;
  24434. width?: number;
  24435. height?: number;
  24436. depth?: number;
  24437. faceUV?: Vector4[];
  24438. faceColors?: Color4[];
  24439. sideOrientation?: number;
  24440. frontUVs?: Vector4;
  24441. backUVs?: Vector4;
  24442. updatable?: boolean;
  24443. }, scene?: Nullable<Scene>): Mesh;
  24444. /**
  24445. * Creates a sphere mesh
  24446. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  24447. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value than `diameter`)
  24448. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  24449. * * 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
  24450. * * 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)
  24451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24452. * * 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
  24453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24454. * @param name defines the name of the mesh
  24455. * @param options defines the options used to create the mesh
  24456. * @param scene defines the hosting scene
  24457. * @returns the sphere mesh
  24458. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  24459. */
  24460. static CreateSphere(name: string, options: {
  24461. segments?: number;
  24462. diameter?: number;
  24463. diameterX?: number;
  24464. diameterY?: number;
  24465. diameterZ?: number;
  24466. arc?: number;
  24467. slice?: number;
  24468. sideOrientation?: number;
  24469. frontUVs?: Vector4;
  24470. backUVs?: Vector4;
  24471. updatable?: boolean;
  24472. }, scene: any): Mesh;
  24473. /**
  24474. * Creates a plane polygonal mesh. By default, this is a disc
  24475. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24476. * * 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
  24477. * * 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
  24478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24479. * * 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
  24480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24481. * @param name defines the name of the mesh
  24482. * @param options defines the options used to create the mesh
  24483. * @param scene defines the hosting scene
  24484. * @returns the plane polygonal mesh
  24485. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24486. */
  24487. static CreateDisc(name: string, options: {
  24488. radius?: number;
  24489. tessellation?: number;
  24490. arc?: number;
  24491. updatable?: boolean;
  24492. sideOrientation?: number;
  24493. frontUVs?: Vector4;
  24494. backUVs?: Vector4;
  24495. }, scene?: Nullable<Scene>): Mesh;
  24496. /**
  24497. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24498. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24499. * * 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`)
  24500. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24501. * * 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
  24502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24503. * * 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
  24504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24505. * @param name defines the name of the mesh
  24506. * @param options defines the options used to create the mesh
  24507. * @param scene defines the hosting scene
  24508. * @returns the icosahedron mesh
  24509. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24510. */
  24511. static CreateIcoSphere(name: string, options: {
  24512. radius?: number;
  24513. radiusX?: number;
  24514. radiusY?: number;
  24515. radiusZ?: number;
  24516. flat?: boolean;
  24517. subdivisions?: number;
  24518. sideOrientation?: number;
  24519. frontUVs?: Vector4;
  24520. backUVs?: Vector4;
  24521. updatable?: boolean;
  24522. }, scene: Scene): Mesh;
  24523. /**
  24524. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24525. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  24526. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  24527. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  24528. * * 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
  24529. * * 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
  24530. * * 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
  24531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24532. * * 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
  24533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24534. * * 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
  24535. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  24536. * * 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
  24537. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  24538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24539. * @param name defines the name of the mesh
  24540. * @param options defines the options used to create the mesh
  24541. * @param scene defines the hosting scene
  24542. * @returns the ribbon mesh
  24543. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  24544. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24545. */
  24546. static CreateRibbon(name: string, options: {
  24547. pathArray: Vector3[][];
  24548. closeArray?: boolean;
  24549. closePath?: boolean;
  24550. offset?: number;
  24551. updatable?: boolean;
  24552. sideOrientation?: number;
  24553. frontUVs?: Vector4;
  24554. backUVs?: Vector4;
  24555. instance?: Mesh;
  24556. invertUV?: boolean;
  24557. uvs?: Vector2[];
  24558. colors?: Color4[];
  24559. }, scene?: Nullable<Scene>): Mesh;
  24560. /**
  24561. * Creates a cylinder or a cone mesh
  24562. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  24563. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  24564. * * 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.
  24565. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  24566. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  24567. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  24568. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  24569. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  24570. * * 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).
  24571. * * 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
  24572. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  24573. * * 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
  24574. * * 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.
  24575. * * If `enclose` is false, a ring surface is one element.
  24576. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  24577. * * 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
  24578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24579. * * 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
  24580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24581. * @param name defines the name of the mesh
  24582. * @param options defines the options used to create the mesh
  24583. * @param scene defines the hosting scene
  24584. * @returns the cylinder mesh
  24585. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  24586. */
  24587. static CreateCylinder(name: string, options: {
  24588. height?: number;
  24589. diameterTop?: number;
  24590. diameterBottom?: number;
  24591. diameter?: number;
  24592. tessellation?: number;
  24593. subdivisions?: number;
  24594. arc?: number;
  24595. faceColors?: Color4[];
  24596. faceUV?: Vector4[];
  24597. updatable?: boolean;
  24598. hasRings?: boolean;
  24599. enclose?: boolean;
  24600. sideOrientation?: number;
  24601. frontUVs?: Vector4;
  24602. backUVs?: Vector4;
  24603. }, scene: any): Mesh;
  24604. /**
  24605. * Creates a torus mesh
  24606. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  24607. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  24608. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  24609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24610. * * 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
  24611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24612. * @param name defines the name of the mesh
  24613. * @param options defines the options used to create the mesh
  24614. * @param scene defines the hosting scene
  24615. * @returns the torus mesh
  24616. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  24617. */
  24618. static CreateTorus(name: string, options: {
  24619. diameter?: number;
  24620. thickness?: number;
  24621. tessellation?: number;
  24622. updatable?: boolean;
  24623. sideOrientation?: number;
  24624. frontUVs?: Vector4;
  24625. backUVs?: Vector4;
  24626. }, scene: any): Mesh;
  24627. /**
  24628. * Creates a torus knot mesh
  24629. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  24630. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  24631. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  24632. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  24633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24634. * * 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
  24635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24636. * @param name defines the name of the mesh
  24637. * @param options defines the options used to create the mesh
  24638. * @param scene defines the hosting scene
  24639. * @returns the torus knot mesh
  24640. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  24641. */
  24642. static CreateTorusKnot(name: string, options: {
  24643. radius?: number;
  24644. tube?: number;
  24645. radialSegments?: number;
  24646. tubularSegments?: number;
  24647. p?: number;
  24648. q?: number;
  24649. updatable?: boolean;
  24650. sideOrientation?: number;
  24651. frontUVs?: Vector4;
  24652. backUVs?: Vector4;
  24653. }, scene: any): Mesh;
  24654. /**
  24655. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  24656. * * 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
  24657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  24658. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  24659. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  24660. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  24661. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  24662. * * 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
  24663. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  24664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24665. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  24666. * @param name defines the name of the new line system
  24667. * @param options defines the options used to create the line system
  24668. * @param scene defines the hosting scene
  24669. * @returns a new line system mesh
  24670. */
  24671. static CreateLineSystem(name: string, options: {
  24672. lines: Vector3[][];
  24673. updatable?: boolean;
  24674. instance?: Nullable<LinesMesh>;
  24675. colors?: Nullable<Color4[][]>;
  24676. useVertexAlpha?: boolean;
  24677. }, scene: Nullable<Scene>): LinesMesh;
  24678. /**
  24679. * Creates a line mesh
  24680. * 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
  24681. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24682. * * The parameter `points` is an array successive Vector3
  24683. * * 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
  24684. * * The optional parameter `colors` is an array of successive Color4, one per line point
  24685. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  24686. * * When updating an instance, remember that only point positions can change, not the number of points
  24687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24688. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  24689. * @param name defines the name of the new line system
  24690. * @param options defines the options used to create the line system
  24691. * @param scene defines the hosting scene
  24692. * @returns a new line mesh
  24693. */
  24694. static CreateLines(name: string, options: {
  24695. points: Vector3[];
  24696. updatable?: boolean;
  24697. instance?: Nullable<LinesMesh>;
  24698. colors?: Color4[];
  24699. useVertexAlpha?: boolean;
  24700. }, scene?: Nullable<Scene>): LinesMesh;
  24701. /**
  24702. * Creates a dashed line mesh
  24703. * * 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
  24704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24705. * * The parameter `points` is an array successive Vector3
  24706. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  24707. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  24708. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24709. * * 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
  24710. * * When updating an instance, remember that only point positions can change, not the number of points
  24711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24712. * @param name defines the name of the mesh
  24713. * @param options defines the options used to create the mesh
  24714. * @param scene defines the hosting scene
  24715. * @returns the dashed line mesh
  24716. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  24717. */
  24718. static CreateDashedLines(name: string, options: {
  24719. points: Vector3[];
  24720. dashSize?: number;
  24721. gapSize?: number;
  24722. dashNb?: number;
  24723. updatable?: boolean;
  24724. instance?: LinesMesh;
  24725. }, scene?: Nullable<Scene>): LinesMesh;
  24726. /**
  24727. * 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.
  24728. * * 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.
  24729. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24730. * * 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.
  24731. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  24732. * * 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
  24733. * * 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
  24734. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  24735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24736. * * 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
  24737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  24738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24739. * @param name defines the name of the mesh
  24740. * @param options defines the options used to create the mesh
  24741. * @param scene defines the hosting scene
  24742. * @returns the extruded shape mesh
  24743. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24744. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24745. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24746. */
  24747. static ExtrudeShape(name: string, options: {
  24748. shape: Vector3[];
  24749. path: Vector3[];
  24750. scale?: number;
  24751. rotation?: number;
  24752. cap?: number;
  24753. updatable?: boolean;
  24754. sideOrientation?: number;
  24755. frontUVs?: Vector4;
  24756. backUVs?: Vector4;
  24757. instance?: Mesh;
  24758. invertUV?: boolean;
  24759. }, scene?: Nullable<Scene>): Mesh;
  24760. /**
  24761. * Creates an custom extruded shape mesh.
  24762. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24763. * * 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.
  24764. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24765. * * 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
  24766. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  24767. * * 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
  24768. * * It must returns a float value that will be the scale value applied to the shape on each path point
  24769. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24770. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  24771. * * 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
  24772. * * 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
  24773. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  24774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24775. * * 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
  24776. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24778. * @param name defines the name of the mesh
  24779. * @param options defines the options used to create the mesh
  24780. * @param scene defines the hosting scene
  24781. * @returns the custom extruded shape mesh
  24782. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  24783. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24784. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24785. */
  24786. static ExtrudeShapeCustom(name: string, options: {
  24787. shape: Vector3[];
  24788. path: Vector3[];
  24789. scaleFunction?: any;
  24790. rotationFunction?: any;
  24791. ribbonCloseArray?: boolean;
  24792. ribbonClosePath?: boolean;
  24793. cap?: number;
  24794. updatable?: boolean;
  24795. sideOrientation?: number;
  24796. frontUVs?: Vector4;
  24797. backUVs?: Vector4;
  24798. instance?: Mesh;
  24799. invertUV?: boolean;
  24800. }, scene: Scene): Mesh;
  24801. /**
  24802. * Creates lathe mesh.
  24803. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  24804. * * 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
  24805. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  24806. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  24807. * * 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
  24808. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  24809. * * 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
  24810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24811. * * 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
  24812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24814. * @param name defines the name of the mesh
  24815. * @param options defines the options used to create the mesh
  24816. * @param scene defines the hosting scene
  24817. * @returns the lathe mesh
  24818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  24819. */
  24820. static CreateLathe(name: string, options: {
  24821. shape: Vector3[];
  24822. radius?: number;
  24823. tessellation?: number;
  24824. arc?: number;
  24825. closed?: boolean;
  24826. updatable?: boolean;
  24827. sideOrientation?: number;
  24828. frontUVs?: Vector4;
  24829. backUVs?: Vector4;
  24830. cap?: number;
  24831. invertUV?: boolean;
  24832. }, scene: Scene): Mesh;
  24833. /**
  24834. * Creates a plane mesh
  24835. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  24836. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  24837. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  24838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24839. * * 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
  24840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24841. * @param name defines the name of the mesh
  24842. * @param options defines the options used to create the mesh
  24843. * @param scene defines the hosting scene
  24844. * @returns the plane mesh
  24845. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  24846. */
  24847. static CreatePlane(name: string, options: {
  24848. size?: number;
  24849. width?: number;
  24850. height?: number;
  24851. sideOrientation?: number;
  24852. frontUVs?: Vector4;
  24853. backUVs?: Vector4;
  24854. updatable?: boolean;
  24855. sourcePlane?: Plane;
  24856. }, scene: Scene): Mesh;
  24857. /**
  24858. * Creates a ground mesh
  24859. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  24860. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  24861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24862. * @param name defines the name of the mesh
  24863. * @param options defines the options used to create the mesh
  24864. * @param scene defines the hosting scene
  24865. * @returns the ground mesh
  24866. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  24867. */
  24868. static CreateGround(name: string, options: {
  24869. width?: number;
  24870. height?: number;
  24871. subdivisions?: number;
  24872. subdivisionsX?: number;
  24873. subdivisionsY?: number;
  24874. updatable?: boolean;
  24875. }, scene: any): Mesh;
  24876. /**
  24877. * Creates a tiled ground mesh
  24878. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  24879. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  24880. * * 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
  24881. * * 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
  24882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24883. * @param name defines the name of the mesh
  24884. * @param options defines the options used to create the mesh
  24885. * @param scene defines the hosting scene
  24886. * @returns the tiled ground mesh
  24887. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  24888. */
  24889. static CreateTiledGround(name: string, options: {
  24890. xmin: number;
  24891. zmin: number;
  24892. xmax: number;
  24893. zmax: number;
  24894. subdivisions?: {
  24895. w: number;
  24896. h: number;
  24897. };
  24898. precision?: {
  24899. w: number;
  24900. h: number;
  24901. };
  24902. updatable?: boolean;
  24903. }, scene: Scene): Mesh;
  24904. /**
  24905. * Creates a ground mesh from a height map
  24906. * * The parameter `url` sets the URL of the height map image resource.
  24907. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  24908. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  24909. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  24910. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  24911. * * 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.
  24912. * * 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).
  24913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24914. * @param name defines the name of the mesh
  24915. * @param url defines the url to the height map
  24916. * @param options defines the options used to create the mesh
  24917. * @param scene defines the hosting scene
  24918. * @returns the ground mesh
  24919. * @see http://doc.babylonjs.com/babylon101/height_map
  24920. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  24921. */
  24922. static CreateGroundFromHeightMap(name: string, url: string, options: {
  24923. width?: number;
  24924. height?: number;
  24925. subdivisions?: number;
  24926. minHeight?: number;
  24927. maxHeight?: number;
  24928. colorFilter?: Color3;
  24929. updatable?: boolean;
  24930. onReady?: (mesh: GroundMesh) => void;
  24931. }, scene: Scene): GroundMesh;
  24932. /**
  24933. * Creates a polygon mesh
  24934. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24935. * * 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
  24936. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24938. * * 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)
  24939. * * Remember you can only change the shape positions, not their number when updating a polygon
  24940. * @param name defines the name of the mesh
  24941. * @param options defines the options used to create the mesh
  24942. * @param scene defines the hosting scene
  24943. * @returns the polygon mesh
  24944. */
  24945. static CreatePolygon(name: string, options: {
  24946. shape: Vector3[];
  24947. holes?: Vector3[][];
  24948. depth?: number;
  24949. faceUV?: Vector4[];
  24950. faceColors?: Color4[];
  24951. updatable?: boolean;
  24952. sideOrientation?: number;
  24953. frontUVs?: Vector4;
  24954. backUVs?: Vector4;
  24955. }, scene: Scene): Mesh;
  24956. /**
  24957. * Creates an extruded polygon mesh, with depth in the Y direction.
  24958. * * 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)
  24959. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  24960. * @param name defines the name of the mesh
  24961. * @param options defines the options used to create the mesh
  24962. * @param scene defines the hosting scene
  24963. * @returns the polygon mesh
  24964. */
  24965. static ExtrudePolygon(name: string, options: {
  24966. shape: Vector3[];
  24967. holes?: Vector3[][];
  24968. depth?: number;
  24969. faceUV?: Vector4[];
  24970. faceColors?: Color4[];
  24971. updatable?: boolean;
  24972. sideOrientation?: number;
  24973. frontUVs?: Vector4;
  24974. backUVs?: Vector4;
  24975. }, scene: Scene): Mesh;
  24976. /**
  24977. * Creates a tube mesh.
  24978. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24979. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  24980. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  24981. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  24982. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  24983. * * 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)
  24984. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  24985. * * 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
  24986. * * 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
  24987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24988. * * 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
  24989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24991. * @param name defines the name of the mesh
  24992. * @param options defines the options used to create the mesh
  24993. * @param scene defines the hosting scene
  24994. * @returns the tube mesh
  24995. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24996. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  24997. */
  24998. static CreateTube(name: string, options: {
  24999. path: Vector3[];
  25000. radius?: number;
  25001. tessellation?: number;
  25002. radiusFunction?: {
  25003. (i: number, distance: number): number;
  25004. };
  25005. cap?: number;
  25006. arc?: number;
  25007. updatable?: boolean;
  25008. sideOrientation?: number;
  25009. frontUVs?: Vector4;
  25010. backUVs?: Vector4;
  25011. instance?: Mesh;
  25012. invertUV?: boolean;
  25013. }, scene: Scene): Mesh;
  25014. /**
  25015. * Creates a polyhedron mesh
  25016. * * 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
  25017. * * The parameter `size` (positive float, default 1) sets the polygon size
  25018. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25019. * * 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`
  25020. * * 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
  25021. * * 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)`)
  25022. * * 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
  25023. * * 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
  25024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25025. * * 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
  25026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25027. * @param name defines the name of the mesh
  25028. * @param options defines the options used to create the mesh
  25029. * @param scene defines the hosting scene
  25030. * @returns the polyhedron mesh
  25031. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  25032. */
  25033. static CreatePolyhedron(name: string, options: {
  25034. type?: number;
  25035. size?: number;
  25036. sizeX?: number;
  25037. sizeY?: number;
  25038. sizeZ?: number;
  25039. custom?: any;
  25040. faceUV?: Vector4[];
  25041. faceColors?: Color4[];
  25042. flat?: boolean;
  25043. updatable?: boolean;
  25044. sideOrientation?: number;
  25045. frontUVs?: Vector4;
  25046. backUVs?: Vector4;
  25047. }, scene: Scene): Mesh;
  25048. /**
  25049. * Creates a decal mesh.
  25050. * 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
  25051. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  25052. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  25053. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  25054. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  25055. * @param name defines the name of the mesh
  25056. * @param sourceMesh defines the mesh where the decal must be applied
  25057. * @param options defines the options used to create the mesh
  25058. * @param scene defines the hosting scene
  25059. * @returns the decal mesh
  25060. * @see http://doc.babylonjs.com/how_to/decals
  25061. */
  25062. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  25063. position?: Vector3;
  25064. normal?: Vector3;
  25065. size?: Vector3;
  25066. angle?: number;
  25067. }): Mesh;
  25068. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  25069. }
  25070. }
  25071. declare module BABYLON {
  25072. class MeshLODLevel {
  25073. distance: number;
  25074. mesh: Nullable<Mesh>;
  25075. constructor(distance: number, mesh: Nullable<Mesh>);
  25076. }
  25077. }
  25078. declare module BABYLON {
  25079. /**
  25080. * A simplifier interface for future simplification implementations.
  25081. */
  25082. interface ISimplifier {
  25083. /**
  25084. * Simplification of a given mesh according to the given settings.
  25085. * Since this requires computation, it is assumed that the function runs async.
  25086. * @param settings The settings of the simplification, including quality and distance
  25087. * @param successCallback A callback that will be called after the mesh was simplified.
  25088. * @param errorCallback in case of an error, this callback will be called. optional.
  25089. */
  25090. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  25091. }
  25092. /**
  25093. * Expected simplification settings.
  25094. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  25095. */
  25096. interface ISimplificationSettings {
  25097. quality: number;
  25098. distance: number;
  25099. optimizeMesh?: boolean;
  25100. }
  25101. class SimplificationSettings implements ISimplificationSettings {
  25102. quality: number;
  25103. distance: number;
  25104. optimizeMesh: boolean | undefined;
  25105. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  25106. }
  25107. interface ISimplificationTask {
  25108. settings: Array<ISimplificationSettings>;
  25109. simplificationType: SimplificationType;
  25110. mesh: Mesh;
  25111. successCallback?: () => void;
  25112. parallelProcessing: boolean;
  25113. }
  25114. class SimplificationQueue {
  25115. private _simplificationArray;
  25116. running: boolean;
  25117. constructor();
  25118. addTask(task: ISimplificationTask): void;
  25119. executeNext(): void;
  25120. runSimplification(task: ISimplificationTask): void;
  25121. private getSimplifier(task);
  25122. }
  25123. /**
  25124. * The implemented types of simplification
  25125. * At the moment only Quadratic Error Decimation is implemented
  25126. */
  25127. enum SimplificationType {
  25128. /** Quadratic error decimation */
  25129. QUADRATIC = 0,
  25130. }
  25131. class DecimationTriangle {
  25132. vertices: Array<DecimationVertex>;
  25133. normal: Vector3;
  25134. error: Array<number>;
  25135. deleted: boolean;
  25136. isDirty: boolean;
  25137. borderFactor: number;
  25138. deletePending: boolean;
  25139. originalOffset: number;
  25140. constructor(vertices: Array<DecimationVertex>);
  25141. }
  25142. class DecimationVertex {
  25143. position: Vector3;
  25144. id: number;
  25145. q: QuadraticMatrix;
  25146. isBorder: boolean;
  25147. triangleStart: number;
  25148. triangleCount: number;
  25149. originalOffsets: Array<number>;
  25150. constructor(position: Vector3, id: number);
  25151. updatePosition(newPosition: Vector3): void;
  25152. }
  25153. class QuadraticMatrix {
  25154. data: Array<number>;
  25155. constructor(data?: Array<number>);
  25156. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  25157. addInPlace(matrix: QuadraticMatrix): void;
  25158. addArrayInPlace(data: Array<number>): void;
  25159. add(matrix: QuadraticMatrix): QuadraticMatrix;
  25160. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  25161. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  25162. }
  25163. class Reference {
  25164. vertexId: number;
  25165. triangleId: number;
  25166. constructor(vertexId: number, triangleId: number);
  25167. }
  25168. /**
  25169. * An implementation of the Quadratic Error simplification algorithm.
  25170. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  25171. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  25172. * @author RaananW
  25173. */
  25174. class QuadraticErrorSimplification implements ISimplifier {
  25175. private _mesh;
  25176. private triangles;
  25177. private vertices;
  25178. private references;
  25179. private _reconstructedMesh;
  25180. syncIterations: number;
  25181. aggressiveness: number;
  25182. decimationIterations: number;
  25183. boundingBoxEpsilon: number;
  25184. constructor(_mesh: Mesh);
  25185. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  25186. private runDecimation(settings, submeshIndex, successCallback);
  25187. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  25188. private init(callback);
  25189. private reconstructMesh(submeshIndex);
  25190. private initDecimatedMesh();
  25191. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  25192. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  25193. private identifyBorder();
  25194. private updateMesh(identifyBorders?);
  25195. private vertexError(q, point);
  25196. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  25197. }
  25198. }
  25199. declare module BABYLON {
  25200. class Polygon {
  25201. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  25202. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  25203. static Parse(input: string): Vector2[];
  25204. static StartingAt(x: number, y: number): Path2;
  25205. }
  25206. class PolygonMeshBuilder {
  25207. private _points;
  25208. private _outlinepoints;
  25209. private _holes;
  25210. private _name;
  25211. private _scene;
  25212. private _epoints;
  25213. private _eholes;
  25214. private _addToepoint(points);
  25215. constructor(name: string, contours: Path2, scene: Scene);
  25216. constructor(name: string, contours: Vector2[], scene: Scene);
  25217. addHole(hole: Vector2[]): PolygonMeshBuilder;
  25218. build(updatable?: boolean, depth?: number): Mesh;
  25219. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  25220. }
  25221. }
  25222. declare module BABYLON {
  25223. class BaseSubMesh {
  25224. _materialDefines: Nullable<MaterialDefines>;
  25225. _materialEffect: Nullable<Effect>;
  25226. readonly effect: Nullable<Effect>;
  25227. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25228. }
  25229. class SubMesh extends BaseSubMesh implements ICullable {
  25230. materialIndex: number;
  25231. verticesStart: number;
  25232. verticesCount: number;
  25233. indexStart: number;
  25234. indexCount: number;
  25235. linesIndexCount: number;
  25236. private _mesh;
  25237. private _renderingMesh;
  25238. private _boundingInfo;
  25239. private _linesIndexBuffer;
  25240. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25241. _trianglePlanes: Plane[];
  25242. _lastColliderTransformMatrix: Matrix;
  25243. _renderId: number;
  25244. _alphaIndex: number;
  25245. _distanceToCamera: number;
  25246. _id: number;
  25247. private _currentMaterial;
  25248. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25249. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25250. readonly IsGlobal: boolean;
  25251. /**
  25252. * Returns the submesh BoudingInfo object.
  25253. */
  25254. getBoundingInfo(): BoundingInfo;
  25255. /**
  25256. * Sets the submesh BoundingInfo.
  25257. * Return the SubMesh.
  25258. */
  25259. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25260. /**
  25261. * Returns the mesh of the current submesh.
  25262. */
  25263. getMesh(): AbstractMesh;
  25264. /**
  25265. * Returns the rendering mesh of the submesh.
  25266. */
  25267. getRenderingMesh(): Mesh;
  25268. /**
  25269. * Returns the submesh material.
  25270. */
  25271. getMaterial(): Nullable<Material>;
  25272. /**
  25273. * Sets a new updated BoundingInfo object to the submesh.
  25274. * Returns the SubMesh.
  25275. */
  25276. refreshBoundingInfo(): SubMesh;
  25277. _checkCollision(collider: Collider): boolean;
  25278. /**
  25279. * Updates the submesh BoundingInfo.
  25280. * Returns the Submesh.
  25281. */
  25282. updateBoundingInfo(world: Matrix): SubMesh;
  25283. /**
  25284. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25285. * Boolean returned.
  25286. */
  25287. isInFrustum(frustumPlanes: Plane[]): boolean;
  25288. /**
  25289. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  25290. * Boolean returned.
  25291. */
  25292. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25293. /**
  25294. * Renders the submesh.
  25295. * Returns it.
  25296. */
  25297. render(enableAlphaMode: boolean): SubMesh;
  25298. /**
  25299. * Returns a new Index Buffer.
  25300. * Type returned : WebGLBuffer.
  25301. */
  25302. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  25303. /**
  25304. * True is the passed Ray intersects the submesh bounding box.
  25305. * Boolean returned.
  25306. */
  25307. canIntersects(ray: Ray): boolean;
  25308. /**
  25309. * Returns an object IntersectionInfo.
  25310. */
  25311. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  25312. _rebuild(): void;
  25313. /**
  25314. * Creates a new Submesh from the passed Mesh.
  25315. */
  25316. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25317. /**
  25318. * Disposes the Submesh.
  25319. * Returns nothing.
  25320. */
  25321. dispose(): void;
  25322. /**
  25323. * Creates a new Submesh from the passed parameters :
  25324. * - materialIndex (integer) : the index of the main mesh material.
  25325. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  25326. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  25327. * - mesh (Mesh) : the main mesh to create the submesh from.
  25328. * - renderingMesh (optional Mesh) : rendering mesh.
  25329. */
  25330. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25331. }
  25332. }
  25333. declare module BABYLON {
  25334. class TransformNode extends Node {
  25335. static BILLBOARDMODE_NONE: number;
  25336. static BILLBOARDMODE_X: number;
  25337. static BILLBOARDMODE_Y: number;
  25338. static BILLBOARDMODE_Z: number;
  25339. static BILLBOARDMODE_ALL: number;
  25340. private _forward;
  25341. private _forwardInverted;
  25342. private _up;
  25343. private _right;
  25344. private _rightInverted;
  25345. private _rotation;
  25346. private _rotationQuaternion;
  25347. protected _scaling: Vector3;
  25348. protected _isDirty: boolean;
  25349. private _transformToBoneReferal;
  25350. /**
  25351. * Set the billboard mode. Default is 0.
  25352. *
  25353. * | Value | Type | Description |
  25354. * | --- | --- | --- |
  25355. * | 0 | BILLBOARDMODE_NONE | |
  25356. * | 1 | BILLBOARDMODE_X | |
  25357. * | 2 | BILLBOARDMODE_Y | |
  25358. * | 4 | BILLBOARDMODE_Z | |
  25359. * | 7 | BILLBOARDMODE_ALL | |
  25360. *
  25361. */
  25362. billboardMode: number;
  25363. scalingDeterminant: number;
  25364. infiniteDistance: boolean;
  25365. /**
  25366. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25367. * By default the system will update normals to compensate
  25368. */
  25369. ignoreNonUniformScaling: boolean;
  25370. position: Vector3;
  25371. _poseMatrix: Matrix;
  25372. private _localWorld;
  25373. _worldMatrix: Matrix;
  25374. _worldMatrixDeterminant: number;
  25375. private _absolutePosition;
  25376. private _pivotMatrix;
  25377. private _pivotMatrixInverse;
  25378. private _postMultiplyPivotMatrix;
  25379. protected _isWorldMatrixFrozen: boolean;
  25380. /**
  25381. * An event triggered after the world matrix is updated
  25382. */
  25383. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25384. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25385. /**
  25386. * Gets a string idenfifying the name of the class
  25387. * @returns "TransformNode" string
  25388. */
  25389. getClassName(): string;
  25390. /**
  25391. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  25392. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  25393. * Default : (0.0, 0.0, 0.0)
  25394. */
  25395. rotation: Vector3;
  25396. /**
  25397. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  25398. * Default : (1.0, 1.0, 1.0)
  25399. */
  25400. /**
  25401. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  25402. * Default : (1.0, 1.0, 1.0)
  25403. */
  25404. scaling: Vector3;
  25405. /**
  25406. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  25407. * It's null by default.
  25408. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  25409. */
  25410. rotationQuaternion: Nullable<Quaternion>;
  25411. /**
  25412. * The forward direction of that transform in world space.
  25413. */
  25414. readonly forward: Vector3;
  25415. /**
  25416. * The up direction of that transform in world space.
  25417. */
  25418. readonly up: Vector3;
  25419. /**
  25420. * The right direction of that transform in world space.
  25421. */
  25422. readonly right: Vector3;
  25423. /**
  25424. * Returns the latest update of the World matrix
  25425. * Returns a Matrix.
  25426. */
  25427. getWorldMatrix(): Matrix;
  25428. /** @hidden */
  25429. _getWorldMatrixDeterminant(): number;
  25430. /**
  25431. * Returns directly the latest state of the mesh World matrix.
  25432. * A Matrix is returned.
  25433. */
  25434. readonly worldMatrixFromCache: Matrix;
  25435. /**
  25436. * Copies the paramater passed Matrix into the mesh Pose matrix.
  25437. * Returns the TransformNode.
  25438. */
  25439. updatePoseMatrix(matrix: Matrix): TransformNode;
  25440. /**
  25441. * Returns the mesh Pose matrix.
  25442. * Returned object : Matrix
  25443. */
  25444. getPoseMatrix(): Matrix;
  25445. _isSynchronized(): boolean;
  25446. _initCache(): void;
  25447. markAsDirty(property: string): TransformNode;
  25448. /**
  25449. * Returns the current mesh absolute position.
  25450. * Retuns a Vector3.
  25451. */
  25452. readonly absolutePosition: Vector3;
  25453. /**
  25454. * Sets a new matrix to apply before all other transformation
  25455. * @param matrix defines the transform matrix
  25456. * @returns the current TransformNode
  25457. */
  25458. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25459. /**
  25460. * Sets a new pivot matrix to the current node
  25461. * @param matrix defines the new pivot matrix to use
  25462. * @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
  25463. * @returns the current TransformNode
  25464. */
  25465. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  25466. /**
  25467. * Returns the mesh pivot matrix.
  25468. * Default : Identity.
  25469. * A Matrix is returned.
  25470. */
  25471. getPivotMatrix(): Matrix;
  25472. /**
  25473. * Prevents the World matrix to be computed any longer.
  25474. * Returns the TransformNode.
  25475. */
  25476. freezeWorldMatrix(): TransformNode;
  25477. /**
  25478. * Allows back the World matrix computation.
  25479. * Returns the TransformNode.
  25480. */
  25481. unfreezeWorldMatrix(): this;
  25482. /**
  25483. * True if the World matrix has been frozen.
  25484. * Returns a boolean.
  25485. */
  25486. readonly isWorldMatrixFrozen: boolean;
  25487. /**
  25488. * Retuns the mesh absolute position in the World.
  25489. * Returns a Vector3.
  25490. */
  25491. getAbsolutePosition(): Vector3;
  25492. /**
  25493. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  25494. * Returns the TransformNode.
  25495. */
  25496. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25497. /**
  25498. * Sets the mesh position in its local space.
  25499. * Returns the TransformNode.
  25500. */
  25501. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  25502. /**
  25503. * Returns the mesh position in the local space from the current World matrix values.
  25504. * Returns a new Vector3.
  25505. */
  25506. getPositionExpressedInLocalSpace(): Vector3;
  25507. /**
  25508. * Translates the mesh along the passed Vector3 in its local space.
  25509. * Returns the TransformNode.
  25510. */
  25511. locallyTranslate(vector3: Vector3): TransformNode;
  25512. private static _lookAtVectorCache;
  25513. /**
  25514. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  25515. * @param targetPoint the position (must be in same space as current mesh) to look at
  25516. * @param yawCor optional yaw (y-axis) correction in radians
  25517. * @param pitchCor optional pitch (x-axis) correction in radians
  25518. * @param rollCor optional roll (z-axis) correction in radians
  25519. * @param space the choosen space of the target
  25520. * @returns the TransformNode.
  25521. */
  25522. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  25523. /**
  25524. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  25525. * This Vector3 is expressed in the World space.
  25526. */
  25527. getDirection(localAxis: Vector3): Vector3;
  25528. /**
  25529. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  25530. * localAxis is expressed in the mesh local space.
  25531. * result is computed in the Wordl space from the mesh World matrix.
  25532. * Returns the TransformNode.
  25533. */
  25534. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  25535. /**
  25536. * Sets a new pivot point to the current node
  25537. * @param point defines the new pivot point to use
  25538. * @param space defines if the point is in world or local space (local by default)
  25539. * @returns the current TransformNode
  25540. */
  25541. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  25542. /**
  25543. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  25544. */
  25545. getPivotPoint(): Vector3;
  25546. /**
  25547. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  25548. * Returns the TransformNode.
  25549. */
  25550. getPivotPointToRef(result: Vector3): TransformNode;
  25551. /**
  25552. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  25553. */
  25554. getAbsolutePivotPoint(): Vector3;
  25555. /**
  25556. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  25557. * Returns the TransformNode.
  25558. */
  25559. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  25560. /**
  25561. * Defines the passed node as the parent of the current node.
  25562. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  25563. * Returns the TransformNode.
  25564. */
  25565. setParent(node: Nullable<Node>): TransformNode;
  25566. private _nonUniformScaling;
  25567. readonly nonUniformScaling: boolean;
  25568. _updateNonUniformScalingState(value: boolean): boolean;
  25569. /**
  25570. * Attach the current TransformNode to another TransformNode associated with a bone
  25571. * @param bone Bone affecting the TransformNode
  25572. * @param affectedTransformNode TransformNode associated with the bone
  25573. */
  25574. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  25575. detachFromBone(): TransformNode;
  25576. private static _rotationAxisCache;
  25577. /**
  25578. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  25579. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  25580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  25581. * The passed axis is also normalized.
  25582. * Returns the TransformNode.
  25583. */
  25584. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25585. /**
  25586. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  25587. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  25588. * The passed axis is also normalized.
  25589. * Returns the TransformNode.
  25590. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  25591. */
  25592. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  25593. /**
  25594. * Translates the mesh along the axis vector for the passed distance in the given space.
  25595. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  25596. * Returns the TransformNode.
  25597. */
  25598. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25599. /**
  25600. * Adds a rotation step to the mesh current rotation.
  25601. * x, y, z are Euler angles expressed in radians.
  25602. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  25603. * This means this rotation is made in the mesh local space only.
  25604. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  25605. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  25606. * ```javascript
  25607. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  25608. * ```
  25609. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  25610. * 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.
  25611. * Returns the TransformNode.
  25612. */
  25613. addRotation(x: number, y: number, z: number): TransformNode;
  25614. /**
  25615. * Computes the mesh World matrix and returns it.
  25616. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  25617. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  25618. * If the parameter `force`is set to `true`, the actual computation is done.
  25619. * Returns the mesh World Matrix.
  25620. */
  25621. computeWorldMatrix(force?: boolean): Matrix;
  25622. protected _afterComputeWorldMatrix(): void;
  25623. /**
  25624. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  25625. * @param func: callback function to add
  25626. *
  25627. * Returns the TransformNode.
  25628. */
  25629. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  25630. /**
  25631. * Removes a registered callback function.
  25632. * Returns the TransformNode.
  25633. */
  25634. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  25635. /**
  25636. * Clone the current transform node
  25637. * Returns the new transform node
  25638. * @param name Name of the new clone
  25639. * @param newParent New parent for the clone
  25640. * @param doNotCloneChildren Do not clone children hierarchy
  25641. */
  25642. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  25643. serialize(currentSerializationObject?: any): any;
  25644. /**
  25645. * Returns a new TransformNode object parsed from the source provided.
  25646. * The parameter `parsedMesh` is the source.
  25647. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  25648. */
  25649. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  25650. /**
  25651. * Releases resources associated with this transform node.
  25652. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25653. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25654. */
  25655. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25656. }
  25657. }
  25658. declare module BABYLON {
  25659. class VertexBuffer {
  25660. /** @hidden */
  25661. _buffer: Buffer;
  25662. private _kind;
  25663. private _size;
  25664. private _ownsBuffer;
  25665. private _instanced;
  25666. private _instanceDivisor;
  25667. /**
  25668. * The byte type.
  25669. */
  25670. static readonly BYTE: number;
  25671. /**
  25672. * The unsigned byte type.
  25673. */
  25674. static readonly UNSIGNED_BYTE: number;
  25675. /**
  25676. * The short type.
  25677. */
  25678. static readonly SHORT: number;
  25679. /**
  25680. * The unsigned short type.
  25681. */
  25682. static readonly UNSIGNED_SHORT: number;
  25683. /**
  25684. * The integer type.
  25685. */
  25686. static readonly INT: number;
  25687. /**
  25688. * The unsigned integer type.
  25689. */
  25690. static readonly UNSIGNED_INT: number;
  25691. /**
  25692. * The float type.
  25693. */
  25694. static readonly FLOAT: number;
  25695. /**
  25696. * Gets or sets the instance divisor when in instanced mode
  25697. */
  25698. instanceDivisor: number;
  25699. /**
  25700. * Gets the byte stride.
  25701. */
  25702. readonly byteStride: number;
  25703. /**
  25704. * Gets the byte offset.
  25705. */
  25706. readonly byteOffset: number;
  25707. /**
  25708. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  25709. */
  25710. readonly normalized: boolean;
  25711. /**
  25712. * Gets the data type of each component in the array.
  25713. */
  25714. readonly type: number;
  25715. /**
  25716. * Constructor
  25717. * @param engine the engine
  25718. * @param data the data to use for this vertex buffer
  25719. * @param kind the vertex buffer kind
  25720. * @param updatable whether the data is updatable
  25721. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25722. * @param stride the stride (optional)
  25723. * @param instanced whether the buffer is instanced (optional)
  25724. * @param offset the offset of the data (optional)
  25725. * @param size the number of components (optional)
  25726. * @param type the type of the component (optional)
  25727. * @param normalized whether the data contains normalized data (optional)
  25728. * @param useBytes set to true if stride and offset are in bytes (optional)
  25729. */
  25730. 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);
  25731. _rebuild(): void;
  25732. /**
  25733. * Returns the kind of the VertexBuffer (string).
  25734. */
  25735. getKind(): string;
  25736. /**
  25737. * Boolean : is the VertexBuffer updatable ?
  25738. */
  25739. isUpdatable(): boolean;
  25740. /**
  25741. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  25742. */
  25743. getData(): Nullable<DataArray>;
  25744. /**
  25745. * Returns the WebGLBuffer associated to the VertexBuffer.
  25746. */
  25747. getBuffer(): Nullable<WebGLBuffer>;
  25748. /**
  25749. * Returns the stride as a multiple of the type byte length.
  25750. * DEPRECATED. Use byteStride instead.
  25751. */
  25752. getStrideSize(): number;
  25753. /**
  25754. * Returns the offset as a multiple of the type byte length.
  25755. * DEPRECATED. Use byteOffset instead.
  25756. */
  25757. getOffset(): number;
  25758. /**
  25759. * Returns the number of components per vertex attribute (integer).
  25760. */
  25761. getSize(): number;
  25762. /**
  25763. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  25764. */
  25765. getIsInstanced(): boolean;
  25766. /**
  25767. * Returns the instancing divisor, zero for non-instanced (integer).
  25768. */
  25769. getInstanceDivisor(): number;
  25770. /**
  25771. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  25772. * Returns the created WebGLBuffer.
  25773. */
  25774. create(data?: DataArray): void;
  25775. /**
  25776. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  25777. * This function will create a new buffer if the current one is not updatable
  25778. * Returns the updated WebGLBuffer.
  25779. */
  25780. update(data: DataArray): void;
  25781. /**
  25782. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  25783. * Returns the directly updated WebGLBuffer.
  25784. * @param data the new data
  25785. * @param offset the new offset
  25786. * @param useBytes set to true if the offset is in bytes
  25787. */
  25788. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  25789. /**
  25790. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  25791. */
  25792. dispose(): void;
  25793. /**
  25794. * Enumerates each value of this vertex buffer as numbers.
  25795. * @param count the number of values to enumerate
  25796. * @param callback the callback function called for each value
  25797. */
  25798. forEach(count: number, callback: (value: number, index: number) => void): void;
  25799. private static _PositionKind;
  25800. private static _NormalKind;
  25801. private static _TangentKind;
  25802. private static _UVKind;
  25803. private static _UV2Kind;
  25804. private static _UV3Kind;
  25805. private static _UV4Kind;
  25806. private static _UV5Kind;
  25807. private static _UV6Kind;
  25808. private static _ColorKind;
  25809. private static _MatricesIndicesKind;
  25810. private static _MatricesWeightsKind;
  25811. private static _MatricesIndicesExtraKind;
  25812. private static _MatricesWeightsExtraKind;
  25813. static readonly PositionKind: string;
  25814. static readonly NormalKind: string;
  25815. static readonly TangentKind: string;
  25816. static readonly UVKind: string;
  25817. static readonly UV2Kind: string;
  25818. static readonly UV3Kind: string;
  25819. static readonly UV4Kind: string;
  25820. static readonly UV5Kind: string;
  25821. static readonly UV6Kind: string;
  25822. static readonly ColorKind: string;
  25823. static readonly MatricesIndicesKind: string;
  25824. static readonly MatricesWeightsKind: string;
  25825. static readonly MatricesIndicesExtraKind: string;
  25826. static readonly MatricesWeightsExtraKind: string;
  25827. /**
  25828. * Deduces the stride given a kind.
  25829. * @param kind The kind string to deduce
  25830. * @returns The deduced stride
  25831. */
  25832. static DeduceStride(kind: string): number;
  25833. /**
  25834. * Gets the byte length of the given type.
  25835. * @param type the type
  25836. * @returns the number of bytes
  25837. */
  25838. static GetTypeByteLength(type: number): number;
  25839. /**
  25840. * Enumerates each value of the given parameters as numbers.
  25841. * @param data the data to enumerate
  25842. * @param byteOffset the byte offset of the data
  25843. * @param byteStride the byte stride of the data
  25844. * @param componentCount the number of components per element
  25845. * @param componentType the type of the component
  25846. * @param count the total number of components
  25847. * @param normalized whether the data is normalized
  25848. * @param callback the callback function called for each value
  25849. */
  25850. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  25851. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  25852. }
  25853. }
  25854. declare module BABYLON {
  25855. interface PhysicsImpostorJoint {
  25856. mainImpostor: PhysicsImpostor;
  25857. connectedImpostor: PhysicsImpostor;
  25858. joint: PhysicsJoint;
  25859. }
  25860. class PhysicsEngine {
  25861. private _physicsPlugin;
  25862. gravity: Vector3;
  25863. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  25864. setGravity(gravity: Vector3): void;
  25865. /**
  25866. * Set the time step of the physics engine.
  25867. * default is 1/60.
  25868. * To slow it down, enter 1/600 for example.
  25869. * To speed it up, 1/30
  25870. * @param {number} newTimeStep the new timestep to apply to this world.
  25871. */
  25872. setTimeStep(newTimeStep?: number): void;
  25873. /**
  25874. * Get the time step of the physics engine.
  25875. */
  25876. getTimeStep(): number;
  25877. dispose(): void;
  25878. getPhysicsPluginName(): string;
  25879. static Epsilon: number;
  25880. private _impostors;
  25881. private _joints;
  25882. /**
  25883. * Adding a new impostor for the impostor tracking.
  25884. * This will be done by the impostor itself.
  25885. * @param {PhysicsImpostor} impostor the impostor to add
  25886. */
  25887. addImpostor(impostor: PhysicsImpostor): void;
  25888. /**
  25889. * Remove an impostor from the engine.
  25890. * This impostor and its mesh will not longer be updated by the physics engine.
  25891. * @param {PhysicsImpostor} impostor the impostor to remove
  25892. */
  25893. removeImpostor(impostor: PhysicsImpostor): void;
  25894. /**
  25895. * Add a joint to the physics engine
  25896. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  25897. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  25898. * @param {PhysicsJoint} the joint that will connect both impostors.
  25899. */
  25900. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25901. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25902. /**
  25903. * Called by the scene. no need to call it.
  25904. */
  25905. _step(delta: number): void;
  25906. getPhysicsPlugin(): IPhysicsEnginePlugin;
  25907. getImpostors(): Array<PhysicsImpostor>;
  25908. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25909. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  25910. }
  25911. interface IPhysicsEnginePlugin {
  25912. world: any;
  25913. name: string;
  25914. setGravity(gravity: Vector3): void;
  25915. setTimeStep(timeStep: number): void;
  25916. getTimeStep(): number;
  25917. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  25918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  25921. removePhysicsBody(impostor: PhysicsImpostor): void;
  25922. generateJoint(joint: PhysicsImpostorJoint): void;
  25923. removeJoint(joint: PhysicsImpostorJoint): void;
  25924. isSupported(): boolean;
  25925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  25926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  25927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25930. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25931. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  25932. getBodyMass(impostor: PhysicsImpostor): number;
  25933. getBodyFriction(impostor: PhysicsImpostor): number;
  25934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  25935. getBodyRestitution(impostor: PhysicsImpostor): number;
  25936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  25937. sleepBody(impostor: PhysicsImpostor): void;
  25938. wakeUpBody(impostor: PhysicsImpostor): void;
  25939. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  25940. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  25941. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25942. getRadius(impostor: PhysicsImpostor): number;
  25943. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  25944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  25945. dispose(): void;
  25946. }
  25947. }
  25948. declare module BABYLON {
  25949. class PhysicsHelper {
  25950. private _scene;
  25951. private _physicsEngine;
  25952. constructor(scene: Scene);
  25953. /**
  25954. * @param {Vector3} origin the origin of the explosion
  25955. * @param {number} radius the explosion radius
  25956. * @param {number} strength the explosion strength
  25957. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25958. */
  25959. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25960. /**
  25961. * @param {Vector3} origin the origin of the explosion
  25962. * @param {number} radius the explosion radius
  25963. * @param {number} strength the explosion strength
  25964. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25965. */
  25966. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25967. /**
  25968. * @param {Vector3} origin the origin of the explosion
  25969. * @param {number} radius the explosion radius
  25970. * @param {number} strength the explosion strength
  25971. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25972. */
  25973. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25974. /**
  25975. * @param {Vector3} origin the origin of the updraft
  25976. * @param {number} radius the radius of the updraft
  25977. * @param {number} strength the strength of the updraft
  25978. * @param {number} height the height of the updraft
  25979. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  25980. */
  25981. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  25982. /**
  25983. * @param {Vector3} origin the of the vortex
  25984. * @param {number} radius the radius of the vortex
  25985. * @param {number} strength the strength of the vortex
  25986. * @param {number} height the height of the vortex
  25987. */
  25988. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  25989. }
  25990. /***** Radial explosion *****/
  25991. class PhysicsRadialExplosionEvent {
  25992. private _scene;
  25993. private _sphere;
  25994. private _sphereOptions;
  25995. private _rays;
  25996. private _dataFetched;
  25997. constructor(scene: Scene);
  25998. /**
  25999. * Returns the data related to the radial explosion event (sphere & rays).
  26000. * @returns {PhysicsRadialExplosionEventData}
  26001. */
  26002. getData(): PhysicsRadialExplosionEventData;
  26003. /**
  26004. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26005. * @param impostor
  26006. * @param {Vector3} origin the origin of the explosion
  26007. * @param {number} radius the explosion radius
  26008. * @param {number} strength the explosion strength
  26009. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26010. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26011. */
  26012. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26013. /**
  26014. * Disposes the sphere.
  26015. * @param {bolean} force
  26016. */
  26017. dispose(force?: boolean): void;
  26018. /*** Helpers ***/
  26019. private _prepareSphere();
  26020. private _intersectsWithSphere(impostor, origin, radius);
  26021. }
  26022. /***** Gravitational Field *****/
  26023. class PhysicsGravitationalFieldEvent {
  26024. private _physicsHelper;
  26025. private _scene;
  26026. private _origin;
  26027. private _radius;
  26028. private _strength;
  26029. private _falloff;
  26030. private _tickCallback;
  26031. private _sphere;
  26032. private _dataFetched;
  26033. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26034. /**
  26035. * Returns the data related to the gravitational field event (sphere).
  26036. * @returns {PhysicsGravitationalFieldEventData}
  26037. */
  26038. getData(): PhysicsGravitationalFieldEventData;
  26039. /**
  26040. * Enables the gravitational field.
  26041. */
  26042. enable(): void;
  26043. /**
  26044. * Disables the gravitational field.
  26045. */
  26046. disable(): void;
  26047. /**
  26048. * Disposes the sphere.
  26049. * @param {bolean} force
  26050. */
  26051. dispose(force?: boolean): void;
  26052. private _tick();
  26053. }
  26054. /***** Updraft *****/
  26055. class PhysicsUpdraftEvent {
  26056. private _scene;
  26057. private _origin;
  26058. private _radius;
  26059. private _strength;
  26060. private _height;
  26061. private _updraftMode;
  26062. private _physicsEngine;
  26063. private _originTop;
  26064. private _originDirection;
  26065. private _tickCallback;
  26066. private _cylinder;
  26067. private _cylinderPosition;
  26068. private _dataFetched;
  26069. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26070. /**
  26071. * Returns the data related to the updraft event (cylinder).
  26072. * @returns {PhysicsUpdraftEventData}
  26073. */
  26074. getData(): PhysicsUpdraftEventData;
  26075. /**
  26076. * Enables the updraft.
  26077. */
  26078. enable(): void;
  26079. /**
  26080. * Disables the cortex.
  26081. */
  26082. disable(): void;
  26083. /**
  26084. * Disposes the sphere.
  26085. * @param {bolean} force
  26086. */
  26087. dispose(force?: boolean): void;
  26088. private getImpostorForceAndContactPoint(impostor);
  26089. private _tick();
  26090. /*** Helpers ***/
  26091. private _prepareCylinder();
  26092. private _intersectsWithCylinder(impostor);
  26093. }
  26094. /***** Vortex *****/
  26095. class PhysicsVortexEvent {
  26096. private _scene;
  26097. private _origin;
  26098. private _radius;
  26099. private _strength;
  26100. private _height;
  26101. private _physicsEngine;
  26102. private _originTop;
  26103. private _centripetalForceThreshold;
  26104. private _updraftMultiplier;
  26105. private _tickCallback;
  26106. private _cylinder;
  26107. private _cylinderPosition;
  26108. private _dataFetched;
  26109. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26110. /**
  26111. * Returns the data related to the vortex event (cylinder).
  26112. * @returns {PhysicsVortexEventData}
  26113. */
  26114. getData(): PhysicsVortexEventData;
  26115. /**
  26116. * Enables the vortex.
  26117. */
  26118. enable(): void;
  26119. /**
  26120. * Disables the cortex.
  26121. */
  26122. disable(): void;
  26123. /**
  26124. * Disposes the sphere.
  26125. * @param {bolean} force
  26126. */
  26127. dispose(force?: boolean): void;
  26128. private getImpostorForceAndContactPoint(impostor);
  26129. private _tick();
  26130. /*** Helpers ***/
  26131. private _prepareCylinder();
  26132. private _intersectsWithCylinder(impostor);
  26133. }
  26134. /***** Enums *****/
  26135. /**
  26136. * The strenght of the force in correspondence to the distance of the affected object
  26137. */
  26138. enum PhysicsRadialImpulseFalloff {
  26139. /** Defines that impulse is constant in strength across it's whole radius */
  26140. Constant = 0,
  26141. /** DEfines that impulse gets weaker if it's further from the origin */
  26142. Linear = 1,
  26143. }
  26144. /**
  26145. * The strenght of the force in correspondence to the distance of the affected object
  26146. */
  26147. enum PhysicsUpdraftMode {
  26148. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26149. Center = 0,
  26150. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  26151. Perpendicular = 1,
  26152. }
  26153. /***** Data interfaces *****/
  26154. interface PhysicsForceAndContactPoint {
  26155. force: Vector3;
  26156. contactPoint: Vector3;
  26157. }
  26158. interface PhysicsRadialExplosionEventData {
  26159. sphere: Mesh;
  26160. rays: Array<Ray>;
  26161. }
  26162. interface PhysicsGravitationalFieldEventData {
  26163. sphere: Mesh;
  26164. }
  26165. interface PhysicsUpdraftEventData {
  26166. cylinder: Mesh;
  26167. }
  26168. interface PhysicsVortexEventData {
  26169. cylinder: Mesh;
  26170. }
  26171. }
  26172. declare module BABYLON {
  26173. interface PhysicsImpostorParameters {
  26174. mass: number;
  26175. friction?: number;
  26176. restitution?: number;
  26177. nativeOptions?: any;
  26178. ignoreParent?: boolean;
  26179. disableBidirectionalTransformation?: boolean;
  26180. }
  26181. interface IPhysicsEnabledObject {
  26182. position: Vector3;
  26183. rotationQuaternion: Nullable<Quaternion>;
  26184. scaling: Vector3;
  26185. rotation?: Vector3;
  26186. parent?: any;
  26187. getBoundingInfo(): BoundingInfo;
  26188. computeWorldMatrix(force: boolean): Matrix;
  26189. getWorldMatrix?(): Matrix;
  26190. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26191. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26192. getIndices?(): Nullable<IndicesArray>;
  26193. getScene?(): Scene;
  26194. getAbsolutePosition(): Vector3;
  26195. getAbsolutePivotPoint(): Vector3;
  26196. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26197. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26198. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26199. getClassName(): string;
  26200. }
  26201. class PhysicsImpostor {
  26202. object: IPhysicsEnabledObject;
  26203. type: number;
  26204. private _options;
  26205. private _scene;
  26206. static DEFAULT_OBJECT_SIZE: Vector3;
  26207. static IDENTITY_QUATERNION: Quaternion;
  26208. private _physicsEngine;
  26209. private _physicsBody;
  26210. private _bodyUpdateRequired;
  26211. private _onBeforePhysicsStepCallbacks;
  26212. private _onAfterPhysicsStepCallbacks;
  26213. private _onPhysicsCollideCallbacks;
  26214. private _deltaPosition;
  26215. private _deltaRotation;
  26216. private _deltaRotationConjugated;
  26217. private _parent;
  26218. private _isDisposed;
  26219. private static _tmpVecs;
  26220. private static _tmpQuat;
  26221. readonly isDisposed: boolean;
  26222. mass: number;
  26223. friction: number;
  26224. restitution: number;
  26225. uniqueId: number;
  26226. private _joints;
  26227. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26228. /**
  26229. * This function will completly initialize this impostor.
  26230. * It will create a new body - but only if this mesh has no parent.
  26231. * If it has, this impostor will not be used other than to define the impostor
  26232. * of the child mesh.
  26233. */
  26234. _init(): void;
  26235. private _getPhysicsParent();
  26236. /**
  26237. * Should a new body be generated.
  26238. */
  26239. isBodyInitRequired(): boolean;
  26240. setScalingUpdated(updated: boolean): void;
  26241. /**
  26242. * Force a regeneration of this or the parent's impostor's body.
  26243. * Use under cautious - This will remove all joints already implemented.
  26244. */
  26245. forceUpdate(): void;
  26246. /**
  26247. * Gets the body that holds this impostor. Either its own, or its parent.
  26248. */
  26249. /**
  26250. * Set the physics body. Used mainly by the physics engine/plugin
  26251. */
  26252. physicsBody: any;
  26253. parent: Nullable<PhysicsImpostor>;
  26254. resetUpdateFlags(): void;
  26255. getObjectExtendSize(): Vector3;
  26256. getObjectCenter(): Vector3;
  26257. /**
  26258. * Get a specific parametes from the options parameter.
  26259. */
  26260. getParam(paramName: string): any;
  26261. /**
  26262. * Sets a specific parameter in the options given to the physics plugin
  26263. */
  26264. setParam(paramName: string, value: number): void;
  26265. /**
  26266. * Specifically change the body's mass option. Won't recreate the physics body object
  26267. */
  26268. setMass(mass: number): void;
  26269. getLinearVelocity(): Nullable<Vector3>;
  26270. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26271. getAngularVelocity(): Nullable<Vector3>;
  26272. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26273. /**
  26274. * Execute a function with the physics plugin native code.
  26275. * Provide a function the will have two variables - the world object and the physics body object.
  26276. */
  26277. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26278. /**
  26279. * Register a function that will be executed before the physics world is stepping forward.
  26280. */
  26281. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26282. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26283. /**
  26284. * Register a function that will be executed after the physics step
  26285. */
  26286. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26287. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26288. /**
  26289. * register a function that will be executed when this impostor collides against a different body.
  26290. */
  26291. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26292. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26293. private _tmpQuat;
  26294. private _tmpQuat2;
  26295. getParentsRotation(): Quaternion;
  26296. /**
  26297. * this function is executed by the physics engine.
  26298. */
  26299. beforeStep: () => void;
  26300. /**
  26301. * this function is executed by the physics engine.
  26302. */
  26303. afterStep: () => void;
  26304. /**
  26305. * Legacy collision detection event support
  26306. */
  26307. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26308. onCollide: (e: {
  26309. body: any;
  26310. }) => void;
  26311. /**
  26312. * Apply a force
  26313. */
  26314. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26315. /**
  26316. * Apply an impulse
  26317. */
  26318. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26319. /**
  26320. * A help function to create a joint.
  26321. */
  26322. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26323. /**
  26324. * Add a joint to this impostor with a different impostor.
  26325. */
  26326. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26327. /**
  26328. * Will keep this body still, in a sleep mode.
  26329. */
  26330. sleep(): PhysicsImpostor;
  26331. /**
  26332. * Wake the body up.
  26333. */
  26334. wakeUp(): PhysicsImpostor;
  26335. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26336. dispose(): void;
  26337. setDeltaPosition(position: Vector3): void;
  26338. setDeltaRotation(rotation: Quaternion): void;
  26339. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26340. getRadius(): number;
  26341. /**
  26342. * Sync a bone with this impostor
  26343. * @param bone The bone to sync to the impostor.
  26344. * @param boneMesh The mesh that the bone is influencing.
  26345. * @param jointPivot The pivot of the joint / bone in local space.
  26346. * @param distToJoint Optional distance from the impostor to the joint.
  26347. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26348. */
  26349. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26350. /**
  26351. * Sync impostor to a bone
  26352. * @param bone The bone that the impostor will be synced to.
  26353. * @param boneMesh The mesh that the bone is influencing.
  26354. * @param jointPivot The pivot of the joint / bone in local space.
  26355. * @param distToJoint Optional distance from the impostor to the joint.
  26356. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26357. * @param boneAxis Optional vector3 axis the bone is aligned with
  26358. */
  26359. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  26360. static NoImpostor: number;
  26361. static SphereImpostor: number;
  26362. static BoxImpostor: number;
  26363. static PlaneImpostor: number;
  26364. static MeshImpostor: number;
  26365. static CylinderImpostor: number;
  26366. static ParticleImpostor: number;
  26367. static HeightmapImpostor: number;
  26368. }
  26369. }
  26370. declare module BABYLON {
  26371. interface PhysicsJointData {
  26372. mainPivot?: Vector3;
  26373. connectedPivot?: Vector3;
  26374. mainAxis?: Vector3;
  26375. connectedAxis?: Vector3;
  26376. collision?: boolean;
  26377. nativeParams?: any;
  26378. }
  26379. /**
  26380. * This is a holder class for the physics joint created by the physics plugin.
  26381. * It holds a set of functions to control the underlying joint.
  26382. */
  26383. class PhysicsJoint {
  26384. type: number;
  26385. jointData: PhysicsJointData;
  26386. private _physicsJoint;
  26387. protected _physicsPlugin: IPhysicsEnginePlugin;
  26388. constructor(type: number, jointData: PhysicsJointData);
  26389. physicsJoint: any;
  26390. physicsPlugin: IPhysicsEnginePlugin;
  26391. /**
  26392. * Execute a function that is physics-plugin specific.
  26393. * @param {Function} func the function that will be executed.
  26394. * It accepts two parameters: the physics world and the physics joint.
  26395. */
  26396. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26397. static DistanceJoint: number;
  26398. static HingeJoint: number;
  26399. static BallAndSocketJoint: number;
  26400. static WheelJoint: number;
  26401. static SliderJoint: number;
  26402. static PrismaticJoint: number;
  26403. static UniversalJoint: number;
  26404. static Hinge2Joint: number;
  26405. static PointToPointJoint: number;
  26406. static SpringJoint: number;
  26407. static LockJoint: number;
  26408. }
  26409. /**
  26410. * A class representing a physics distance joint.
  26411. */
  26412. class DistanceJoint extends PhysicsJoint {
  26413. constructor(jointData: DistanceJointData);
  26414. /**
  26415. * Update the predefined distance.
  26416. */
  26417. updateDistance(maxDistance: number, minDistance?: number): void;
  26418. }
  26419. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26420. constructor(type: number, jointData: PhysicsJointData);
  26421. /**
  26422. * Set the motor values.
  26423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26424. * @param {number} force the force to apply
  26425. * @param {number} maxForce max force for this motor.
  26426. */
  26427. setMotor(force?: number, maxForce?: number): void;
  26428. /**
  26429. * Set the motor's limits.
  26430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26431. */
  26432. setLimit(upperLimit: number, lowerLimit?: number): void;
  26433. }
  26434. /**
  26435. * This class represents a single hinge physics joint
  26436. */
  26437. class HingeJoint extends MotorEnabledJoint {
  26438. constructor(jointData: PhysicsJointData);
  26439. /**
  26440. * Set the motor values.
  26441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26442. * @param {number} force the force to apply
  26443. * @param {number} maxForce max force for this motor.
  26444. */
  26445. setMotor(force?: number, maxForce?: number): void;
  26446. /**
  26447. * Set the motor's limits.
  26448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26449. */
  26450. setLimit(upperLimit: number, lowerLimit?: number): void;
  26451. }
  26452. /**
  26453. * This class represents a dual hinge physics joint (same as wheel joint)
  26454. */
  26455. class Hinge2Joint extends MotorEnabledJoint {
  26456. constructor(jointData: PhysicsJointData);
  26457. /**
  26458. * Set the motor values.
  26459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26460. * @param {number} force the force to apply
  26461. * @param {number} maxForce max force for this motor.
  26462. * @param {motorIndex} the motor's index, 0 or 1.
  26463. */
  26464. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26465. /**
  26466. * Set the motor limits.
  26467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26468. * @param {number} upperLimit the upper limit
  26469. * @param {number} lowerLimit lower limit
  26470. * @param {motorIndex} the motor's index, 0 or 1.
  26471. */
  26472. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26473. }
  26474. interface IMotorEnabledJoint {
  26475. physicsJoint: any;
  26476. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26477. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26478. }
  26479. interface DistanceJointData extends PhysicsJointData {
  26480. maxDistance: number;
  26481. }
  26482. interface SpringJointData extends PhysicsJointData {
  26483. length: number;
  26484. stiffness: number;
  26485. damping: number;
  26486. }
  26487. }
  26488. declare module BABYLON {
  26489. class ReflectionProbe {
  26490. name: string;
  26491. private _scene;
  26492. private _renderTargetTexture;
  26493. private _projectionMatrix;
  26494. private _viewMatrix;
  26495. private _target;
  26496. private _add;
  26497. private _attachedMesh;
  26498. private _invertYAxis;
  26499. position: Vector3;
  26500. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26501. samples: number;
  26502. refreshRate: number;
  26503. getScene(): Scene;
  26504. readonly cubeTexture: RenderTargetTexture;
  26505. readonly renderList: Nullable<AbstractMesh[]>;
  26506. attachToMesh(mesh: AbstractMesh): void;
  26507. /**
  26508. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26509. *
  26510. * @param renderingGroupId The rendering group id corresponding to its index
  26511. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26512. */
  26513. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26514. dispose(): void;
  26515. }
  26516. }
  26517. declare module BABYLON {
  26518. class Sprite {
  26519. name: string;
  26520. position: Vector3;
  26521. color: Color4;
  26522. width: number;
  26523. height: number;
  26524. angle: number;
  26525. cellIndex: number;
  26526. invertU: number;
  26527. invertV: number;
  26528. disposeWhenFinishedAnimating: boolean;
  26529. animations: Animation[];
  26530. isPickable: boolean;
  26531. actionManager: ActionManager;
  26532. private _animationStarted;
  26533. private _loopAnimation;
  26534. private _fromIndex;
  26535. private _toIndex;
  26536. private _delay;
  26537. private _direction;
  26538. private _manager;
  26539. private _time;
  26540. private _onAnimationEnd;
  26541. /**
  26542. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  26543. */
  26544. isVisible: boolean;
  26545. size: number;
  26546. constructor(name: string, manager: SpriteManager);
  26547. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26548. stopAnimation(): void;
  26549. _animate(deltaTime: number): void;
  26550. dispose(): void;
  26551. }
  26552. }
  26553. declare module BABYLON {
  26554. class SpriteManager {
  26555. name: string;
  26556. sprites: Sprite[];
  26557. renderingGroupId: number;
  26558. layerMask: number;
  26559. fogEnabled: boolean;
  26560. isPickable: boolean;
  26561. cellWidth: number;
  26562. cellHeight: number;
  26563. /**
  26564. * An event triggered when the manager is disposed.
  26565. */
  26566. onDisposeObservable: Observable<SpriteManager>;
  26567. private _onDisposeObserver;
  26568. onDispose: () => void;
  26569. private _capacity;
  26570. private _spriteTexture;
  26571. private _epsilon;
  26572. private _scene;
  26573. private _vertexData;
  26574. private _buffer;
  26575. private _vertexBuffers;
  26576. private _indexBuffer;
  26577. private _effectBase;
  26578. private _effectFog;
  26579. texture: Texture;
  26580. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26581. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26582. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26583. render(): void;
  26584. dispose(): void;
  26585. }
  26586. }
  26587. declare module BABYLON {
  26588. interface Scene {
  26589. /** @hidden (Backing field) */
  26590. _boundingBoxRenderer: BoundingBoxRenderer;
  26591. /** @hidden (Backing field) */
  26592. _forceShowBoundingBoxes: boolean;
  26593. /**
  26594. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  26595. */
  26596. forceShowBoundingBoxes: boolean;
  26597. /**
  26598. * Gets the bounding box renderer associated with the scene
  26599. * @returns a BoundingBoxRenderer
  26600. */
  26601. getBoundingBoxRenderer(): BoundingBoxRenderer;
  26602. }
  26603. interface AbstractMesh {
  26604. /** @hidden (Backing field) */
  26605. _showBoundingBox: boolean;
  26606. /**
  26607. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  26608. */
  26609. showBoundingBox: boolean;
  26610. }
  26611. class BoundingBoxRenderer implements ISceneComponent {
  26612. /**
  26613. * The component name helpfull to identify the component in the list of scene components.
  26614. */
  26615. readonly name: string;
  26616. /**
  26617. * The scene the component belongs to.
  26618. */
  26619. scene: Scene;
  26620. frontColor: Color3;
  26621. backColor: Color3;
  26622. showBackLines: boolean;
  26623. renderList: SmartArray<BoundingBox>;
  26624. private _colorShader;
  26625. private _vertexBuffers;
  26626. private _indexBuffer;
  26627. constructor(scene: Scene);
  26628. /**
  26629. * Registers the component in a given scene
  26630. */
  26631. register(): void;
  26632. private _evaluateSubMesh(mesh, subMesh);
  26633. private _activeMesh(sourceMesh, mesh);
  26634. private _prepareRessources();
  26635. private _createIndexBuffer();
  26636. /**
  26637. * Rebuilds the elements related to this component in case of
  26638. * context lost for instance.
  26639. */
  26640. rebuild(): void;
  26641. reset(): void;
  26642. render(): void;
  26643. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26644. dispose(): void;
  26645. }
  26646. }
  26647. declare module BABYLON {
  26648. /**
  26649. * This represents a depth renderer in Babylon.
  26650. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26651. */
  26652. class DepthRenderer {
  26653. private _scene;
  26654. private _depthMap;
  26655. private _effect;
  26656. private _cachedDefines;
  26657. private _camera;
  26658. /**
  26659. * Instantiates a depth renderer
  26660. * @param scene The scene the renderer belongs to
  26661. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26662. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26663. */
  26664. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26665. /**
  26666. * Creates the depth rendering effect and checks if the effect is ready.
  26667. * @param subMesh The submesh to be used to render the depth map of
  26668. * @param useInstances If multiple world instances should be used
  26669. * @returns if the depth renderer is ready to render the depth map
  26670. */
  26671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26672. /**
  26673. * Gets the texture which the depth map will be written to.
  26674. * @returns The depth map texture
  26675. */
  26676. getDepthMap(): RenderTargetTexture;
  26677. /**
  26678. * Disposes of the depth renderer.
  26679. */
  26680. dispose(): void;
  26681. }
  26682. }
  26683. declare module BABYLON {
  26684. class EdgesRenderer {
  26685. edgesWidthScalerForOrthographic: number;
  26686. edgesWidthScalerForPerspective: number;
  26687. private _source;
  26688. private _linesPositions;
  26689. private _linesNormals;
  26690. private _linesIndices;
  26691. private _epsilon;
  26692. private _indicesCount;
  26693. private _lineShader;
  26694. private _ib;
  26695. private _buffers;
  26696. private _checkVerticesInsteadOfIndices;
  26697. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26698. isEnabled: boolean;
  26699. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26700. private _prepareRessources();
  26701. _rebuild(): void;
  26702. dispose(): void;
  26703. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26704. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26705. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26706. _generateEdgesLines(): void;
  26707. render(): void;
  26708. }
  26709. }
  26710. declare module BABYLON {
  26711. /**
  26712. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26713. */
  26714. class GeometryBufferRenderer {
  26715. private _scene;
  26716. private _multiRenderTarget;
  26717. private _ratio;
  26718. private _enablePosition;
  26719. protected _effect: Effect;
  26720. protected _cachedDefines: string;
  26721. /**
  26722. * Set the render list (meshes to be rendered) used in the G buffer.
  26723. */
  26724. renderList: Mesh[];
  26725. /**
  26726. * Gets wether or not G buffer are supported by the running hardware.
  26727. * This requires draw buffer supports
  26728. */
  26729. readonly isSupported: boolean;
  26730. /**
  26731. * Gets wether or not position are enabled for the G buffer.
  26732. */
  26733. /**
  26734. * Sets wether or not position are enabled for the G buffer.
  26735. */
  26736. enablePosition: boolean;
  26737. /**
  26738. * Gets the scene associated with the buffer.
  26739. */
  26740. readonly scene: Scene;
  26741. /**
  26742. * Gets the ratio used by the buffer during its creation.
  26743. * How big is the buffer related to the main canvas.
  26744. */
  26745. readonly ratio: number;
  26746. /**
  26747. * Creates a new G Buffer for the scene
  26748. * @param scene The scene the buffer belongs to
  26749. * @param ratio How big is the buffer related to the main canvas.
  26750. */
  26751. constructor(scene: Scene, ratio?: number);
  26752. /**
  26753. * Checks wether everything is ready to render a submesh to the G buffer.
  26754. * @param subMesh the submesh to check readiness for
  26755. * @param useInstances is the mesh drawn using instance or not
  26756. * @returns true if ready otherwise false
  26757. */
  26758. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26759. /**
  26760. * Gets the current underlying G Buffer.
  26761. * @returns the buffer
  26762. */
  26763. getGBuffer(): MultiRenderTarget;
  26764. /**
  26765. * Gets the number of samples used to render the buffer (anti aliasing).
  26766. */
  26767. /**
  26768. * Sets the number of samples used to render the buffer (anti aliasing).
  26769. */
  26770. samples: number;
  26771. /**
  26772. * Disposes the renderer and frees up associated resources.
  26773. */
  26774. dispose(): void;
  26775. protected _createRenderTargets(): void;
  26776. }
  26777. }
  26778. declare module BABYLON {
  26779. class OutlineRenderer {
  26780. private _scene;
  26781. private _effect;
  26782. private _cachedDefines;
  26783. zOffset: number;
  26784. constructor(scene: Scene);
  26785. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26787. }
  26788. }
  26789. declare module BABYLON {
  26790. class RenderingGroup {
  26791. index: number;
  26792. private _scene;
  26793. private _opaqueSubMeshes;
  26794. private _transparentSubMeshes;
  26795. private _alphaTestSubMeshes;
  26796. private _depthOnlySubMeshes;
  26797. private _particleSystems;
  26798. private _spriteManagers;
  26799. private _opaqueSortCompareFn;
  26800. private _alphaTestSortCompareFn;
  26801. private _transparentSortCompareFn;
  26802. private _renderOpaque;
  26803. private _renderAlphaTest;
  26804. private _renderTransparent;
  26805. private _edgesRenderers;
  26806. onBeforeTransparentRendering: () => void;
  26807. /**
  26808. * Set the opaque sort comparison function.
  26809. * If null the sub meshes will be render in the order they were created
  26810. */
  26811. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26812. /**
  26813. * Set the alpha test sort comparison function.
  26814. * If null the sub meshes will be render in the order they were created
  26815. */
  26816. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26817. /**
  26818. * Set the transparent sort comparison function.
  26819. * If null the sub meshes will be render in the order they were created
  26820. */
  26821. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26822. /**
  26823. * Creates a new rendering group.
  26824. * @param index The rendering group index
  26825. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26826. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26827. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26828. */
  26829. 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>);
  26830. /**
  26831. * Render all the sub meshes contained in the group.
  26832. * @param customRenderFunction Used to override the default render behaviour of the group.
  26833. * @returns true if rendered some submeshes.
  26834. */
  26835. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26836. /**
  26837. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26838. * @param subMeshes The submeshes to render
  26839. */
  26840. private renderOpaqueSorted(subMeshes);
  26841. /**
  26842. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26843. * @param subMeshes The submeshes to render
  26844. */
  26845. private renderAlphaTestSorted(subMeshes);
  26846. /**
  26847. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26848. * @param subMeshes The submeshes to render
  26849. */
  26850. private renderTransparentSorted(subMeshes);
  26851. /**
  26852. * Renders the submeshes in a specified order.
  26853. * @param subMeshes The submeshes to sort before render
  26854. * @param sortCompareFn The comparison function use to sort
  26855. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26856. * @param transparent Specifies to activate blending if true
  26857. */
  26858. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26859. /**
  26860. * Renders the submeshes in the order they were dispatched (no sort applied).
  26861. * @param subMeshes The submeshes to render
  26862. */
  26863. private static renderUnsorted(subMeshes);
  26864. /**
  26865. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26866. * are rendered back to front if in the same alpha index.
  26867. *
  26868. * @param a The first submesh
  26869. * @param b The second submesh
  26870. * @returns The result of the comparison
  26871. */
  26872. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26873. /**
  26874. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26875. * are rendered back to front.
  26876. *
  26877. * @param a The first submesh
  26878. * @param b The second submesh
  26879. * @returns The result of the comparison
  26880. */
  26881. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26882. /**
  26883. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26884. * are rendered front to back (prevent overdraw).
  26885. *
  26886. * @param a The first submesh
  26887. * @param b The second submesh
  26888. * @returns The result of the comparison
  26889. */
  26890. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26891. /**
  26892. * Resets the different lists of submeshes to prepare a new frame.
  26893. */
  26894. prepare(): void;
  26895. dispose(): void;
  26896. /**
  26897. * Inserts the submesh in its correct queue depending on its material.
  26898. * @param subMesh The submesh to dispatch
  26899. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26900. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26901. */
  26902. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26903. dispatchSprites(spriteManager: SpriteManager): void;
  26904. dispatchParticles(particleSystem: IParticleSystem): void;
  26905. private _renderParticles(activeMeshes);
  26906. private _renderSprites();
  26907. }
  26908. }
  26909. declare module BABYLON {
  26910. class RenderingManager {
  26911. /**
  26912. * The max id used for rendering groups (not included)
  26913. */
  26914. static MAX_RENDERINGGROUPS: number;
  26915. /**
  26916. * The min id used for rendering groups (included)
  26917. */
  26918. static MIN_RENDERINGGROUPS: number;
  26919. /**
  26920. * Used to globally prevent autoclearing scenes.
  26921. */
  26922. static AUTOCLEAR: boolean;
  26923. private _scene;
  26924. private _renderingGroups;
  26925. private _depthStencilBufferAlreadyCleaned;
  26926. private _autoClearDepthStencil;
  26927. private _customOpaqueSortCompareFn;
  26928. private _customAlphaTestSortCompareFn;
  26929. private _customTransparentSortCompareFn;
  26930. private _renderinGroupInfo;
  26931. constructor(scene: Scene);
  26932. private _clearDepthStencilBuffer(depth?, stencil?);
  26933. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26934. reset(): void;
  26935. dispose(): void;
  26936. /**
  26937. * Clear the info related to rendering groups preventing retention points during dispose.
  26938. */
  26939. freeRenderingGroups(): void;
  26940. private _prepareRenderingGroup(renderingGroupId);
  26941. dispatchSprites(spriteManager: SpriteManager): void;
  26942. dispatchParticles(particleSystem: IParticleSystem): void;
  26943. /**
  26944. * @param subMesh The submesh to dispatch
  26945. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26946. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26947. */
  26948. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26949. /**
  26950. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26951. * This allowed control for front to back rendering or reversly depending of the special needs.
  26952. *
  26953. * @param renderingGroupId The rendering group id corresponding to its index
  26954. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26955. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26956. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26957. */
  26958. 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;
  26959. /**
  26960. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26961. *
  26962. * @param renderingGroupId The rendering group id corresponding to its index
  26963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26964. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26965. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26966. */
  26967. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26968. }
  26969. }
  26970. declare module BABYLON {
  26971. /**
  26972. * Renders a layer on top of an existing scene
  26973. */
  26974. class UtilityLayerRenderer implements IDisposable {
  26975. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26976. private _pointerCaptures;
  26977. private _lastPointerEvents;
  26978. private static _DefaultUtilityLayer;
  26979. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  26980. /**
  26981. * The scene that is rendered on top of the original scene
  26982. */
  26983. utilityLayerScene: Scene;
  26984. /**
  26985. * If the utility layer should automatically be rendered on top of existing scene
  26986. */
  26987. shouldRender: boolean;
  26988. /**
  26989. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  26990. */
  26991. onlyCheckPointerDownEvents: boolean;
  26992. /**
  26993. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  26994. */
  26995. processAllEvents: boolean;
  26996. /**
  26997. * Observable raised when the pointer move from the utility layer scene to the main scene
  26998. */
  26999. onPointerOutObservable: Observable<number>;
  27000. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  27001. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  27002. private _afterRenderObserver;
  27003. private _sceneDisposeObserver;
  27004. private _originalPointerObserver;
  27005. /**
  27006. * Instantiates a UtilityLayerRenderer
  27007. * @param originalScene the original scene that will be rendered on top of
  27008. */
  27009. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  27010. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  27011. /**
  27012. * Renders the utility layers scene on top of the original scene
  27013. */
  27014. render(): void;
  27015. /**
  27016. * Disposes of the renderer
  27017. */
  27018. dispose(): void;
  27019. private _updateCamera();
  27020. }
  27021. }
  27022. declare module BABYLON {
  27023. /**
  27024. * Postprocess used to generate anaglyphic rendering
  27025. */
  27026. class AnaglyphPostProcess extends PostProcess {
  27027. private _passedProcess;
  27028. /**
  27029. * Creates a new AnaglyphPostProcess
  27030. * @param name defines postprocess name
  27031. * @param options defines creation options or target ratio scale
  27032. * @param rigCameras defines cameras using this postprocess
  27033. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27034. * @param engine defines hosting engine
  27035. * @param reusable defines if the postprocess will be reused multiple times per frame
  27036. */
  27037. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27038. }
  27039. }
  27040. declare module BABYLON {
  27041. class BlackAndWhitePostProcess extends PostProcess {
  27042. degree: number;
  27043. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27044. }
  27045. }
  27046. declare module BABYLON {
  27047. /**
  27048. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27049. */
  27050. class BloomEffect extends PostProcessRenderEffect {
  27051. private bloomScale;
  27052. /**
  27053. * Internal
  27054. */
  27055. _effects: Array<PostProcess>;
  27056. /**
  27057. * Internal
  27058. */
  27059. _downscale: ExtractHighlightsPostProcess;
  27060. private _blurX;
  27061. private _blurY;
  27062. private _merge;
  27063. /**
  27064. * The luminance threshold to find bright areas of the image to bloom.
  27065. */
  27066. threshold: number;
  27067. /**
  27068. * The strength of the bloom.
  27069. */
  27070. weight: number;
  27071. /**
  27072. * Specifies the size of the bloom blur kernel, relative to the final output size
  27073. */
  27074. kernel: number;
  27075. /**
  27076. * Creates a new instance of @see BloomEffect
  27077. * @param scene The scene the effect belongs to.
  27078. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27079. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27080. * @param bloomWeight The the strength of bloom.
  27081. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27082. * @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)
  27083. */
  27084. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27085. /**
  27086. * Disposes each of the internal effects for a given camera.
  27087. * @param camera The camera to dispose the effect on.
  27088. */
  27089. disposeEffects(camera: Camera): void;
  27090. /**
  27091. * Internal
  27092. */
  27093. _updateEffects(): void;
  27094. /**
  27095. * Internal
  27096. * @returns if all the contained post processes are ready.
  27097. */
  27098. _isReady(): boolean;
  27099. }
  27100. }
  27101. declare module BABYLON {
  27102. /**
  27103. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27104. */
  27105. class BloomMergePostProcess extends PostProcess {
  27106. /** Weight of the bloom to be added to the original input. */ weight: number;
  27107. /**
  27108. * Creates a new instance of @see BloomMergePostProcess
  27109. * @param name The name of the effect.
  27110. * @param originalFromInput Post process which's input will be used for the merge.
  27111. * @param blurred Blurred highlights post process which's output will be used.
  27112. * @param weight Weight of the bloom to be added to the original input.
  27113. * @param options The required width/height ratio to downsize to before computing the render pass.
  27114. * @param camera The camera to apply the render pass to.
  27115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27116. * @param engine The engine which the post process will be applied. (default: current engine)
  27117. * @param reusable If the post process can be reused on the same frame. (default: false)
  27118. * @param textureType Type of textures used when performing the post process. (default: 0)
  27119. * @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)
  27120. */
  27121. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27122. }
  27123. }
  27124. declare module BABYLON {
  27125. /**
  27126. * The Blur Post Process which blurs an image based on a kernel and direction.
  27127. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27128. */
  27129. class BlurPostProcess extends PostProcess {
  27130. /** The direction in which to blur the image. */ direction: Vector2;
  27131. private blockCompilation;
  27132. protected _kernel: number;
  27133. protected _idealKernel: number;
  27134. protected _packedFloat: boolean;
  27135. private _staticDefines;
  27136. /**
  27137. * Gets the length in pixels of the blur sample region
  27138. */
  27139. /**
  27140. * Sets the length in pixels of the blur sample region
  27141. */
  27142. kernel: number;
  27143. /**
  27144. * Gets wether or not the blur is unpacking/repacking floats
  27145. */
  27146. /**
  27147. * Sets wether or not the blur needs to unpack/repack floats
  27148. */
  27149. packedFloat: boolean;
  27150. /**
  27151. * Creates a new instance BlurPostProcess
  27152. * @param name The name of the effect.
  27153. * @param direction The direction in which to blur the image.
  27154. * @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.
  27155. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27156. * @param camera The camera to apply the render pass to.
  27157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27158. * @param engine The engine which the post process will be applied. (default: current engine)
  27159. * @param reusable If the post process can be reused on the same frame. (default: false)
  27160. * @param textureType Type of textures used when performing the post process. (default: 0)
  27161. * @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)
  27162. */
  27163. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27164. /**
  27165. * Updates the effect with the current post process compile time values and recompiles the shader.
  27166. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27167. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27168. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27169. * @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
  27170. * @param onCompiled Called when the shader has been compiled.
  27171. * @param onError Called if there is an error when compiling a shader.
  27172. */
  27173. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27174. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27175. /**
  27176. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27177. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27178. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27179. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27180. * The gaps between physical kernels are compensated for in the weighting of the samples
  27181. * @param idealKernel Ideal blur kernel.
  27182. * @return Nearest best kernel.
  27183. */
  27184. protected _nearestBestKernel(idealKernel: number): number;
  27185. /**
  27186. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27187. * @param x The point on the Gaussian distribution to sample.
  27188. * @return the value of the Gaussian function at x.
  27189. */
  27190. protected _gaussianWeight(x: number): number;
  27191. /**
  27192. * Generates a string that can be used as a floating point number in GLSL.
  27193. * @param x Value to print.
  27194. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27195. * @return GLSL float string.
  27196. */
  27197. protected _glslFloat(x: number, decimalFigures?: number): string;
  27198. }
  27199. }
  27200. declare module BABYLON {
  27201. /**
  27202. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27203. */
  27204. class ChromaticAberrationPostProcess extends PostProcess {
  27205. /**
  27206. * The amount of seperation of rgb channels (default: 30)
  27207. */
  27208. aberrationAmount: number;
  27209. /**
  27210. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27211. */
  27212. radialIntensity: number;
  27213. /**
  27214. * 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))
  27215. */
  27216. direction: Vector2;
  27217. /**
  27218. * 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))
  27219. */
  27220. centerPosition: Vector2;
  27221. /**
  27222. * Creates a new instance ChromaticAberrationPostProcess
  27223. * @param name The name of the effect.
  27224. * @param screenWidth The width of the screen to apply the effect on.
  27225. * @param screenHeight The height of the screen to apply the effect on.
  27226. * @param options The required width/height ratio to downsize to before computing the render pass.
  27227. * @param camera The camera to apply the render pass to.
  27228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27229. * @param engine The engine which the post process will be applied. (default: current engine)
  27230. * @param reusable If the post process can be reused on the same frame. (default: false)
  27231. * @param textureType Type of textures used when performing the post process. (default: 0)
  27232. * @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)
  27233. */
  27234. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27235. }
  27236. }
  27237. declare module BABYLON {
  27238. /**
  27239. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27240. */
  27241. class CircleOfConfusionPostProcess extends PostProcess {
  27242. /**
  27243. * 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.
  27244. */
  27245. lensSize: number;
  27246. /**
  27247. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27248. */
  27249. fStop: number;
  27250. /**
  27251. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27252. */
  27253. focusDistance: number;
  27254. /**
  27255. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27256. */
  27257. focalLength: number;
  27258. private _depthTexture;
  27259. /**
  27260. * Creates a new instance CircleOfConfusionPostProcess
  27261. * @param name The name of the effect.
  27262. * @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.
  27263. * @param options The required width/height ratio to downsize to before computing the render pass.
  27264. * @param camera The camera to apply the render pass to.
  27265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27266. * @param engine The engine which the post process will be applied. (default: current engine)
  27267. * @param reusable If the post process can be reused on the same frame. (default: false)
  27268. * @param textureType Type of textures used when performing the post process. (default: 0)
  27269. * @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)
  27270. */
  27271. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27272. /**
  27273. * 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.
  27274. */
  27275. depthTexture: RenderTargetTexture;
  27276. }
  27277. }
  27278. declare module BABYLON {
  27279. class ColorCorrectionPostProcess extends PostProcess {
  27280. private _colorTableTexture;
  27281. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27282. }
  27283. }
  27284. declare module BABYLON {
  27285. /**
  27286. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27287. * input texture to perform effects such as edge detection or sharpening
  27288. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27289. */
  27290. class ConvolutionPostProcess extends PostProcess {
  27291. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  27292. /**
  27293. * Creates a new instance ConvolutionPostProcess
  27294. * @param name The name of the effect.
  27295. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27296. * @param options The required width/height ratio to downsize to before computing the render pass.
  27297. * @param camera The camera to apply the render pass to.
  27298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27299. * @param engine The engine which the post process will be applied. (default: current engine)
  27300. * @param reusable If the post process can be reused on the same frame. (default: false)
  27301. * @param textureType Type of textures used when performing the post process. (default: 0)
  27302. */
  27303. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27304. /**
  27305. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27306. */
  27307. static EdgeDetect0Kernel: number[];
  27308. /**
  27309. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27310. */
  27311. static EdgeDetect1Kernel: number[];
  27312. /**
  27313. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27314. */
  27315. static EdgeDetect2Kernel: number[];
  27316. /**
  27317. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27318. */
  27319. static SharpenKernel: number[];
  27320. /**
  27321. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27322. */
  27323. static EmbossKernel: number[];
  27324. /**
  27325. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27326. */
  27327. static GaussianKernel: number[];
  27328. }
  27329. }
  27330. declare module BABYLON {
  27331. /**
  27332. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27333. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27334. * based on samples that have a large difference in distance than the center pixel.
  27335. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27336. */
  27337. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27338. direction: Vector2;
  27339. /**
  27340. * Creates a new instance CircleOfConfusionPostProcess
  27341. * @param name The name of the effect.
  27342. * @param scene The scene the effect belongs to.
  27343. * @param direction The direction the blur should be applied.
  27344. * @param kernel The size of the kernel used to blur.
  27345. * @param options The required width/height ratio to downsize to before computing the render pass.
  27346. * @param camera The camera to apply the render pass to.
  27347. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27348. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27350. * @param engine The engine which the post process will be applied. (default: current engine)
  27351. * @param reusable If the post process can be reused on the same frame. (default: false)
  27352. * @param textureType Type of textures used when performing the post process. (default: 0)
  27353. * @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)
  27354. */
  27355. 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);
  27356. }
  27357. }
  27358. declare module BABYLON {
  27359. /**
  27360. * Specifies the level of max blur that should be applied when using the depth of field effect
  27361. */
  27362. enum DepthOfFieldEffectBlurLevel {
  27363. /**
  27364. * Subtle blur
  27365. */
  27366. Low = 0,
  27367. /**
  27368. * Medium blur
  27369. */
  27370. Medium = 1,
  27371. /**
  27372. * Large blur
  27373. */
  27374. High = 2,
  27375. }
  27376. /**
  27377. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27378. */
  27379. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27380. private _circleOfConfusion;
  27381. /**
  27382. * Internal, blurs from high to low
  27383. */
  27384. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27385. private _depthOfFieldBlurY;
  27386. private _dofMerge;
  27387. /**
  27388. * Internal post processes in depth of field effect
  27389. */
  27390. _effects: Array<PostProcess>;
  27391. /**
  27392. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27393. */
  27394. focalLength: number;
  27395. /**
  27396. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27397. */
  27398. fStop: number;
  27399. /**
  27400. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27401. */
  27402. focusDistance: number;
  27403. /**
  27404. * 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.
  27405. */
  27406. lensSize: number;
  27407. /**
  27408. * Creates a new instance DepthOfFieldEffect
  27409. * @param scene The scene the effect belongs to.
  27410. * @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.
  27411. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27412. * @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)
  27413. */
  27414. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27415. /**
  27416. * 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.
  27417. */
  27418. depthTexture: RenderTargetTexture;
  27419. /**
  27420. * Disposes each of the internal effects for a given camera.
  27421. * @param camera The camera to dispose the effect on.
  27422. */
  27423. disposeEffects(camera: Camera): void;
  27424. /**
  27425. * Internal
  27426. */
  27427. _updateEffects(): void;
  27428. /**
  27429. * Internal
  27430. * @returns if all the contained post processes are ready.
  27431. */
  27432. _isReady(): boolean;
  27433. }
  27434. }
  27435. declare module BABYLON {
  27436. /**
  27437. * Options to be set when merging outputs from the default pipeline.
  27438. */
  27439. class DepthOfFieldMergePostProcessOptions {
  27440. /**
  27441. * The original image to merge on top of
  27442. */
  27443. originalFromInput: PostProcess;
  27444. /**
  27445. * Parameters to perform the merge of the depth of field effect
  27446. */
  27447. depthOfField?: {
  27448. circleOfConfusion: PostProcess;
  27449. blurSteps: Array<PostProcess>;
  27450. };
  27451. /**
  27452. * Parameters to perform the merge of bloom effect
  27453. */
  27454. bloom?: {
  27455. blurred: PostProcess;
  27456. weight: number;
  27457. };
  27458. }
  27459. /**
  27460. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27461. */
  27462. class DepthOfFieldMergePostProcess extends PostProcess {
  27463. private blurSteps;
  27464. /**
  27465. * Creates a new instance of DepthOfFieldMergePostProcess
  27466. * @param name The name of the effect.
  27467. * @param originalFromInput Post process which's input will be used for the merge.
  27468. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27469. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27470. * @param options The required width/height ratio to downsize to before computing the render pass.
  27471. * @param camera The camera to apply the render pass to.
  27472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27473. * @param engine The engine which the post process will be applied. (default: current engine)
  27474. * @param reusable If the post process can be reused on the same frame. (default: false)
  27475. * @param textureType Type of textures used when performing the post process. (default: 0)
  27476. * @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)
  27477. */
  27478. 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);
  27479. /**
  27480. * Updates the effect with the current post process compile time values and recompiles the shader.
  27481. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27482. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27483. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27484. * @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
  27485. * @param onCompiled Called when the shader has been compiled.
  27486. * @param onError Called if there is an error when compiling a shader.
  27487. */
  27488. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27489. }
  27490. }
  27491. declare module BABYLON {
  27492. class DisplayPassPostProcess extends PostProcess {
  27493. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27494. }
  27495. }
  27496. declare module BABYLON {
  27497. /**
  27498. * 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.
  27499. */
  27500. class ExtractHighlightsPostProcess extends PostProcess {
  27501. /**
  27502. * The luminance threshold, pixels below this value will be set to black.
  27503. */
  27504. threshold: number;
  27505. /**
  27506. * Internal
  27507. */
  27508. _exposure: number;
  27509. /**
  27510. * Post process which has the input texture to be used when performing highlight extraction
  27511. */
  27512. _inputPostProcess: Nullable<PostProcess>;
  27513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27514. }
  27515. }
  27516. declare module BABYLON {
  27517. class FilterPostProcess extends PostProcess {
  27518. kernelMatrix: Matrix;
  27519. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27520. }
  27521. }
  27522. declare module BABYLON {
  27523. class FxaaPostProcess extends PostProcess {
  27524. texelWidth: number;
  27525. texelHeight: number;
  27526. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27527. private _getDefines();
  27528. }
  27529. }
  27530. declare module BABYLON {
  27531. /**
  27532. * The GrainPostProcess adds noise to the image at mid luminance levels
  27533. */
  27534. class GrainPostProcess extends PostProcess {
  27535. /**
  27536. * The intensity of the grain added (default: 30)
  27537. */
  27538. intensity: number;
  27539. /**
  27540. * If the grain should be randomized on every frame
  27541. */
  27542. animated: boolean;
  27543. /**
  27544. * Creates a new instance of @see GrainPostProcess
  27545. * @param name The name of the effect.
  27546. * @param options The required width/height ratio to downsize to before computing the render pass.
  27547. * @param camera The camera to apply the render pass to.
  27548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27549. * @param engine The engine which the post process will be applied. (default: current engine)
  27550. * @param reusable If the post process can be reused on the same frame. (default: false)
  27551. * @param textureType Type of textures used when performing the post process. (default: 0)
  27552. * @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)
  27553. */
  27554. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27555. }
  27556. }
  27557. declare module BABYLON {
  27558. class HighlightsPostProcess extends PostProcess {
  27559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27560. }
  27561. }
  27562. declare module BABYLON {
  27563. class ImageProcessingPostProcess extends PostProcess {
  27564. /**
  27565. * Default configuration related to image processing available in the PBR Material.
  27566. */
  27567. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27568. /**
  27569. * Gets the image processing configuration used either in this material.
  27570. */
  27571. /**
  27572. * Sets the Default image processing configuration used either in the this material.
  27573. *
  27574. * If sets to null, the scene one is in use.
  27575. */
  27576. imageProcessingConfiguration: ImageProcessingConfiguration;
  27577. /**
  27578. * Keep track of the image processing observer to allow dispose and replace.
  27579. */
  27580. private _imageProcessingObserver;
  27581. /**
  27582. * Attaches a new image processing configuration to the PBR Material.
  27583. * @param configuration
  27584. */
  27585. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27586. /**
  27587. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27588. */
  27589. /**
  27590. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27591. */
  27592. colorCurves: Nullable<ColorCurves>;
  27593. /**
  27594. * Gets wether the color curves effect is enabled.
  27595. */
  27596. /**
  27597. * Sets wether the color curves effect is enabled.
  27598. */
  27599. colorCurvesEnabled: boolean;
  27600. /**
  27601. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27602. */
  27603. /**
  27604. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27605. */
  27606. colorGradingTexture: Nullable<BaseTexture>;
  27607. /**
  27608. * Gets wether the color grading effect is enabled.
  27609. */
  27610. /**
  27611. * Gets wether the color grading effect is enabled.
  27612. */
  27613. colorGradingEnabled: boolean;
  27614. /**
  27615. * Gets exposure used in the effect.
  27616. */
  27617. /**
  27618. * Sets exposure used in the effect.
  27619. */
  27620. exposure: number;
  27621. /**
  27622. * Gets wether tonemapping is enabled or not.
  27623. */
  27624. /**
  27625. * Sets wether tonemapping is enabled or not
  27626. */
  27627. toneMappingEnabled: boolean;
  27628. /**
  27629. * Gets contrast used in the effect.
  27630. */
  27631. /**
  27632. * Sets contrast used in the effect.
  27633. */
  27634. contrast: number;
  27635. /**
  27636. * Gets Vignette stretch size.
  27637. */
  27638. /**
  27639. * Sets Vignette stretch size.
  27640. */
  27641. vignetteStretch: number;
  27642. /**
  27643. * Gets Vignette centre X Offset.
  27644. */
  27645. /**
  27646. * Sets Vignette centre X Offset.
  27647. */
  27648. vignetteCentreX: number;
  27649. /**
  27650. * Gets Vignette centre Y Offset.
  27651. */
  27652. /**
  27653. * Sets Vignette centre Y Offset.
  27654. */
  27655. vignetteCentreY: number;
  27656. /**
  27657. * Gets Vignette weight or intensity of the vignette effect.
  27658. */
  27659. /**
  27660. * Sets Vignette weight or intensity of the vignette effect.
  27661. */
  27662. vignetteWeight: number;
  27663. /**
  27664. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27665. * if vignetteEnabled is set to true.
  27666. */
  27667. /**
  27668. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27669. * if vignetteEnabled is set to true.
  27670. */
  27671. vignetteColor: Color4;
  27672. /**
  27673. * Gets Camera field of view used by the Vignette effect.
  27674. */
  27675. /**
  27676. * Sets Camera field of view used by the Vignette effect.
  27677. */
  27678. vignetteCameraFov: number;
  27679. /**
  27680. * Gets the vignette blend mode allowing different kind of effect.
  27681. */
  27682. /**
  27683. * Sets the vignette blend mode allowing different kind of effect.
  27684. */
  27685. vignetteBlendMode: number;
  27686. /**
  27687. * Gets wether the vignette effect is enabled.
  27688. */
  27689. /**
  27690. * Sets wether the vignette effect is enabled.
  27691. */
  27692. vignetteEnabled: boolean;
  27693. private _fromLinearSpace;
  27694. /**
  27695. * Gets wether the input of the processing is in Gamma or Linear Space.
  27696. */
  27697. /**
  27698. * Sets wether the input of the processing is in Gamma or Linear Space.
  27699. */
  27700. fromLinearSpace: boolean;
  27701. /**
  27702. * Defines cache preventing GC.
  27703. */
  27704. private _defines;
  27705. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27706. getClassName(): string;
  27707. protected _updateParameters(): void;
  27708. dispose(camera?: Camera): void;
  27709. }
  27710. }
  27711. declare module BABYLON {
  27712. class PassPostProcess extends PostProcess {
  27713. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27714. }
  27715. }
  27716. declare module BABYLON {
  27717. type PostProcessOptions = {
  27718. width: number;
  27719. height: number;
  27720. };
  27721. /**
  27722. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27723. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27724. */
  27725. class PostProcess {
  27726. /** Name of the PostProcess. */ name: string;
  27727. /**
  27728. * Width of the texture to apply the post process on
  27729. */
  27730. width: number;
  27731. /**
  27732. * Height of the texture to apply the post process on
  27733. */
  27734. height: number;
  27735. /**
  27736. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27737. */
  27738. _outputTexture: Nullable<InternalTexture>;
  27739. /**
  27740. * Sampling mode used by the shader
  27741. * See https://doc.babylonjs.com/classes/3.1/texture
  27742. */
  27743. renderTargetSamplingMode: number;
  27744. /**
  27745. * Clear color to use when screen clearing
  27746. */
  27747. clearColor: Color4;
  27748. /**
  27749. * If the buffer needs to be cleared before applying the post process. (default: true)
  27750. * Should be set to false if shader will overwrite all previous pixels.
  27751. */
  27752. autoClear: boolean;
  27753. /**
  27754. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27755. */
  27756. alphaMode: number;
  27757. /**
  27758. * Sets the setAlphaBlendConstants of the babylon engine
  27759. */
  27760. alphaConstants: Color4;
  27761. /**
  27762. * Animations to be used for the post processing
  27763. */
  27764. animations: Animation[];
  27765. /**
  27766. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27767. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27768. */
  27769. enablePixelPerfectMode: boolean;
  27770. /**
  27771. * Force the postprocess to be applied without taking in account viewport
  27772. */
  27773. forceFullscreenViewport: boolean;
  27774. /**
  27775. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27776. *
  27777. * | Value | Type | Description |
  27778. * | ----- | ----------------------------------- | ----------- |
  27779. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27780. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27781. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27782. *
  27783. */
  27784. scaleMode: number;
  27785. /**
  27786. * Force textures to be a power of two (default: false)
  27787. */
  27788. alwaysForcePOT: boolean;
  27789. /**
  27790. * Number of sample textures (default: 1)
  27791. */
  27792. samples: number;
  27793. /**
  27794. * Modify the scale of the post process to be the same as the viewport (default: false)
  27795. */
  27796. adaptScaleToCurrentViewport: boolean;
  27797. private _camera;
  27798. private _scene;
  27799. private _engine;
  27800. private _options;
  27801. private _reusable;
  27802. private _textureType;
  27803. /**
  27804. * Smart array of input and output textures for the post process.
  27805. */
  27806. _textures: SmartArray<InternalTexture>;
  27807. /**
  27808. * The index in _textures that corresponds to the output texture.
  27809. */
  27810. _currentRenderTextureInd: number;
  27811. private _effect;
  27812. private _samplers;
  27813. private _fragmentUrl;
  27814. private _vertexUrl;
  27815. private _parameters;
  27816. private _scaleRatio;
  27817. protected _indexParameters: any;
  27818. private _shareOutputWithPostProcess;
  27819. private _texelSize;
  27820. private _forcedOutputTexture;
  27821. /**
  27822. * An event triggered when the postprocess is activated.
  27823. */
  27824. onActivateObservable: Observable<Camera>;
  27825. private _onActivateObserver;
  27826. /**
  27827. * A function that is added to the onActivateObservable
  27828. */
  27829. onActivate: Nullable<(camera: Camera) => void>;
  27830. /**
  27831. * An event triggered when the postprocess changes its size.
  27832. */
  27833. onSizeChangedObservable: Observable<PostProcess>;
  27834. private _onSizeChangedObserver;
  27835. /**
  27836. * A function that is added to the onSizeChangedObservable
  27837. */
  27838. onSizeChanged: (postProcess: PostProcess) => void;
  27839. /**
  27840. * An event triggered when the postprocess applies its effect.
  27841. */
  27842. onApplyObservable: Observable<Effect>;
  27843. private _onApplyObserver;
  27844. /**
  27845. * A function that is added to the onApplyObservable
  27846. */
  27847. onApply: (effect: Effect) => void;
  27848. /**
  27849. * An event triggered before rendering the postprocess
  27850. */
  27851. onBeforeRenderObservable: Observable<Effect>;
  27852. private _onBeforeRenderObserver;
  27853. /**
  27854. * A function that is added to the onBeforeRenderObservable
  27855. */
  27856. onBeforeRender: (effect: Effect) => void;
  27857. /**
  27858. * An event triggered after rendering the postprocess
  27859. */
  27860. onAfterRenderObservable: Observable<Effect>;
  27861. private _onAfterRenderObserver;
  27862. /**
  27863. * A function that is added to the onAfterRenderObservable
  27864. */
  27865. onAfterRender: (efect: Effect) => void;
  27866. /**
  27867. * 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
  27868. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27869. */
  27870. inputTexture: InternalTexture;
  27871. /**
  27872. * Gets the camera which post process is applied to.
  27873. * @returns The camera the post process is applied to.
  27874. */
  27875. getCamera(): Camera;
  27876. /**
  27877. * Gets the texel size of the postprocess.
  27878. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27879. */
  27880. readonly texelSize: Vector2;
  27881. /**
  27882. * Creates a new instance PostProcess
  27883. * @param name The name of the PostProcess.
  27884. * @param fragmentUrl The url of the fragment shader to be used.
  27885. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27886. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27887. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27888. * @param camera The camera to apply the render pass to.
  27889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27890. * @param engine The engine which the post process will be applied. (default: current engine)
  27891. * @param reusable If the post process can be reused on the same frame. (default: false)
  27892. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27893. * @param textureType Type of textures used when performing the post process. (default: 0)
  27894. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27895. * @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
  27896. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27897. */
  27898. constructor(/** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  27899. /**
  27900. * Gets the engine which this post process belongs to.
  27901. * @returns The engine the post process was enabled with.
  27902. */
  27903. getEngine(): Engine;
  27904. /**
  27905. * The effect that is created when initializing the post process.
  27906. * @returns The created effect corrisponding the the postprocess.
  27907. */
  27908. getEffect(): Effect;
  27909. /**
  27910. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27911. * @param postProcess The post process to share the output with.
  27912. * @returns This post process.
  27913. */
  27914. shareOutputWith(postProcess: PostProcess): PostProcess;
  27915. /**
  27916. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27917. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27918. */
  27919. useOwnOutput(): void;
  27920. /**
  27921. * Updates the effect with the current post process compile time values and recompiles the shader.
  27922. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27923. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27924. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27925. * @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
  27926. * @param onCompiled Called when the shader has been compiled.
  27927. * @param onError Called if there is an error when compiling a shader.
  27928. */
  27929. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27930. /**
  27931. * The post process is reusable if it can be used multiple times within one frame.
  27932. * @returns If the post process is reusable
  27933. */
  27934. isReusable(): boolean;
  27935. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27936. markTextureDirty(): void;
  27937. /**
  27938. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27939. * 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.
  27940. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27941. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27942. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27943. * @returns The target texture that was bound to be written to.
  27944. */
  27945. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27946. /**
  27947. * If the post process is supported.
  27948. */
  27949. readonly isSupported: boolean;
  27950. /**
  27951. * The aspect ratio of the output texture.
  27952. */
  27953. readonly aspectRatio: number;
  27954. /**
  27955. * Get a value indicating if the post-process is ready to be used
  27956. * @returns true if the post-process is ready (shader is compiled)
  27957. */
  27958. isReady(): boolean;
  27959. /**
  27960. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27961. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27962. */
  27963. apply(): Nullable<Effect>;
  27964. private _disposeTextures();
  27965. /**
  27966. * Disposes the post process.
  27967. * @param camera The camera to dispose the post process on.
  27968. */
  27969. dispose(camera?: Camera): void;
  27970. }
  27971. }
  27972. declare module BABYLON {
  27973. /**
  27974. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27975. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27976. */
  27977. class PostProcessManager {
  27978. private _scene;
  27979. private _indexBuffer;
  27980. private _vertexBuffers;
  27981. /**
  27982. * Creates a new instance PostProcess
  27983. * @param scene The scene that the post process is associated with.
  27984. */
  27985. constructor(scene: Scene);
  27986. private _prepareBuffers();
  27987. private _buildIndexBuffer();
  27988. /**
  27989. * Rebuilds the vertex buffers of the manager.
  27990. */
  27991. _rebuild(): void;
  27992. /**
  27993. * Prepares a frame to be run through a post process.
  27994. * @param sourceTexture The input texture to the post procesess. (default: null)
  27995. * @param postProcesses An array of post processes to be run. (default: null)
  27996. * @returns True if the post processes were able to be run.
  27997. */
  27998. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27999. /**
  28000. * Manually render a set of post processes to a texture.
  28001. * @param postProcesses An array of post processes to be run.
  28002. * @param targetTexture The target texture to render to.
  28003. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28004. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28005. * @param lodLevel defines which lod of the texture to render to
  28006. */
  28007. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28008. /**
  28009. * Finalize the result of the output of the postprocesses.
  28010. * @param doNotPresent If true the result will not be displayed to the screen.
  28011. * @param targetTexture The target texture to render to.
  28012. * @param faceIndex The index of the face to bind the target texture to.
  28013. * @param postProcesses The array of post processes to render.
  28014. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28015. */
  28016. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28017. /**
  28018. * Disposes of the post process manager.
  28019. */
  28020. dispose(): void;
  28021. }
  28022. }
  28023. declare module BABYLON {
  28024. class RefractionPostProcess extends PostProcess {
  28025. color: Color3;
  28026. depth: number;
  28027. colorLevel: number;
  28028. private _refTexture;
  28029. private _ownRefractionTexture;
  28030. /**
  28031. * Gets or sets the refraction texture
  28032. * Please note that you are responsible for disposing the texture if you set it manually
  28033. */
  28034. refractionTexture: Texture;
  28035. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28036. dispose(camera: Camera): void;
  28037. }
  28038. }
  28039. declare module BABYLON {
  28040. /**
  28041. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28042. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28043. */
  28044. class SharpenPostProcess extends PostProcess {
  28045. /**
  28046. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28047. */
  28048. colorAmount: number;
  28049. /**
  28050. * How much sharpness should be applied (default: 0.3)
  28051. */
  28052. edgeAmount: number;
  28053. /**
  28054. * Creates a new instance ConvolutionPostProcess
  28055. * @param name The name of the effect.
  28056. * @param options The required width/height ratio to downsize to before computing the render pass.
  28057. * @param camera The camera to apply the render pass to.
  28058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28059. * @param engine The engine which the post process will be applied. (default: current engine)
  28060. * @param reusable If the post process can be reused on the same frame. (default: false)
  28061. * @param textureType Type of textures used when performing the post process. (default: 0)
  28062. * @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)
  28063. */
  28064. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28065. }
  28066. }
  28067. declare module BABYLON {
  28068. class StereoscopicInterlacePostProcess extends PostProcess {
  28069. private _stepSize;
  28070. private _passedProcess;
  28071. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28072. }
  28073. }
  28074. declare module BABYLON {
  28075. /** Defines operator used for tonemapping */
  28076. enum TonemappingOperator {
  28077. /** Hable */
  28078. Hable = 0,
  28079. /** Reinhard */
  28080. Reinhard = 1,
  28081. /** HejiDawson */
  28082. HejiDawson = 2,
  28083. /** Photographic */
  28084. Photographic = 3,
  28085. }
  28086. /**
  28087. * Defines a post process to apply tone mapping
  28088. */
  28089. class TonemapPostProcess extends PostProcess {
  28090. private _operator;
  28091. /** Defines the required exposure adjustement */
  28092. exposureAdjustment: number;
  28093. /**
  28094. * Creates a new TonemapPostProcess
  28095. * @param name defines the name of the postprocess
  28096. * @param _operator defines the operator to use
  28097. * @param exposureAdjustment defines the required exposure adjustement
  28098. * @param camera defines the camera to use (can be null)
  28099. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28100. * @param engine defines the hosting engine (can be ignore if camera is set)
  28101. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28102. */
  28103. constructor(name: string, _operator: TonemappingOperator,
  28104. /** Defines the required exposure adjustement */
  28105. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28106. }
  28107. }
  28108. declare module BABYLON {
  28109. class VolumetricLightScatteringPostProcess extends PostProcess {
  28110. private _volumetricLightScatteringPass;
  28111. private _volumetricLightScatteringRTT;
  28112. private _viewPort;
  28113. private _screenCoordinates;
  28114. private _cachedDefines;
  28115. /**
  28116. * If not undefined, the mesh position is computed from the attached node position
  28117. */
  28118. attachedNode: {
  28119. position: Vector3;
  28120. };
  28121. /**
  28122. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28123. */
  28124. customMeshPosition: Vector3;
  28125. /**
  28126. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28127. */
  28128. useCustomMeshPosition: boolean;
  28129. /**
  28130. * If the post-process should inverse the light scattering direction
  28131. */
  28132. invert: boolean;
  28133. /**
  28134. * The internal mesh used by the post-process
  28135. */
  28136. mesh: Mesh;
  28137. useDiffuseColor: boolean;
  28138. /**
  28139. * Array containing the excluded meshes not rendered in the internal pass
  28140. */
  28141. excludedMeshes: AbstractMesh[];
  28142. /**
  28143. * Controls the overall intensity of the post-process
  28144. */
  28145. exposure: number;
  28146. /**
  28147. * Dissipates each sample's contribution in range [0, 1]
  28148. */
  28149. decay: number;
  28150. /**
  28151. * Controls the overall intensity of each sample
  28152. */
  28153. weight: number;
  28154. /**
  28155. * Controls the density of each sample
  28156. */
  28157. density: number;
  28158. /**
  28159. * @constructor
  28160. * @param {string} name - The post-process name
  28161. * @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)
  28162. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28163. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28164. * @param {number} samples - The post-process quality, default 100
  28165. * @param {number} samplingMode - The post-process filtering mode
  28166. * @param {BABYLON.Engine} engine - The babylon engine
  28167. * @param {boolean} reusable - If the post-process is reusable
  28168. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  28169. */
  28170. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28171. getClassName(): string;
  28172. private _isReady(subMesh, useInstances);
  28173. /**
  28174. * Sets the new light position for light scattering effect
  28175. * @param {BABYLON.Vector3} The new custom light position
  28176. */
  28177. setCustomMeshPosition(position: Vector3): void;
  28178. /**
  28179. * Returns the light position for light scattering effect
  28180. * @return {BABYLON.Vector3} The custom light position
  28181. */
  28182. getCustomMeshPosition(): Vector3;
  28183. /**
  28184. * Disposes the internal assets and detaches the post-process from the camera
  28185. */
  28186. dispose(camera: Camera): void;
  28187. /**
  28188. * Returns the render target texture used by the post-process
  28189. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28190. */
  28191. getPass(): RenderTargetTexture;
  28192. private _meshExcluded(mesh);
  28193. private _createPass(scene, ratio);
  28194. private _updateMeshScreenCoordinates(scene);
  28195. /**
  28196. * Creates a default mesh for the Volumeric Light Scattering post-process
  28197. * @param {string} The mesh name
  28198. * @param {BABYLON.Scene} The scene where to create the mesh
  28199. * @return {BABYLON.Mesh} the default mesh
  28200. */
  28201. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28202. }
  28203. }
  28204. declare module BABYLON {
  28205. class VRDistortionCorrectionPostProcess extends PostProcess {
  28206. private _isRightEye;
  28207. private _distortionFactors;
  28208. private _postProcessScaleFactor;
  28209. private _lensCenterOffset;
  28210. private _scaleIn;
  28211. private _scaleFactor;
  28212. private _lensCenter;
  28213. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28214. }
  28215. }
  28216. declare module BABYLON {
  28217. /**
  28218. * @hidden
  28219. **/
  28220. class _AlphaState {
  28221. private _isAlphaBlendDirty;
  28222. private _isBlendFunctionParametersDirty;
  28223. private _isBlendEquationParametersDirty;
  28224. private _isBlendConstantsDirty;
  28225. private _alphaBlend;
  28226. private _blendFunctionParameters;
  28227. private _blendEquationParameters;
  28228. private _blendConstants;
  28229. /**
  28230. * Initializes the state.
  28231. */
  28232. constructor();
  28233. readonly isDirty: boolean;
  28234. alphaBlend: boolean;
  28235. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28236. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28237. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28238. reset(): void;
  28239. apply(gl: WebGLRenderingContext): void;
  28240. }
  28241. }
  28242. declare module BABYLON {
  28243. /**
  28244. * @hidden
  28245. **/
  28246. class _DepthCullingState {
  28247. private _isDepthTestDirty;
  28248. private _isDepthMaskDirty;
  28249. private _isDepthFuncDirty;
  28250. private _isCullFaceDirty;
  28251. private _isCullDirty;
  28252. private _isZOffsetDirty;
  28253. private _isFrontFaceDirty;
  28254. private _depthTest;
  28255. private _depthMask;
  28256. private _depthFunc;
  28257. private _cull;
  28258. private _cullFace;
  28259. private _zOffset;
  28260. private _frontFace;
  28261. /**
  28262. * Initializes the state.
  28263. */
  28264. constructor();
  28265. readonly isDirty: boolean;
  28266. zOffset: number;
  28267. cullFace: Nullable<number>;
  28268. cull: Nullable<boolean>;
  28269. depthFunc: Nullable<number>;
  28270. depthMask: boolean;
  28271. depthTest: boolean;
  28272. frontFace: Nullable<number>;
  28273. reset(): void;
  28274. apply(gl: WebGLRenderingContext): void;
  28275. }
  28276. }
  28277. declare module BABYLON {
  28278. /**
  28279. * @hidden
  28280. **/
  28281. class _StencilState {
  28282. private _isStencilTestDirty;
  28283. private _isStencilMaskDirty;
  28284. private _isStencilFuncDirty;
  28285. private _isStencilOpDirty;
  28286. private _stencilTest;
  28287. private _stencilMask;
  28288. private _stencilFunc;
  28289. private _stencilFuncRef;
  28290. private _stencilFuncMask;
  28291. private _stencilOpStencilFail;
  28292. private _stencilOpDepthFail;
  28293. private _stencilOpStencilDepthPass;
  28294. readonly isDirty: boolean;
  28295. stencilFunc: number;
  28296. stencilFuncRef: number;
  28297. stencilFuncMask: number;
  28298. stencilOpStencilFail: number;
  28299. stencilOpDepthFail: number;
  28300. stencilOpStencilDepthPass: number;
  28301. stencilMask: number;
  28302. stencilTest: boolean;
  28303. constructor();
  28304. reset(): void;
  28305. apply(gl: WebGLRenderingContext): void;
  28306. }
  28307. }
  28308. declare module BABYLON {
  28309. /**
  28310. * Class used to evalaute queries containing `and` and `or` operators
  28311. */
  28312. class AndOrNotEvaluator {
  28313. /**
  28314. * Evaluate a query
  28315. * @param query defines the query to evaluate
  28316. * @param evaluateCallback defines the callback used to filter result
  28317. * @returns true if the query matches
  28318. */
  28319. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  28320. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  28321. private static _SimplifyNegation(booleanString);
  28322. }
  28323. }
  28324. declare module BABYLON {
  28325. /**
  28326. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  28327. */
  28328. enum AssetTaskState {
  28329. /**
  28330. * Initialization
  28331. */
  28332. INIT = 0,
  28333. /**
  28334. * Running
  28335. */
  28336. RUNNING = 1,
  28337. /**
  28338. * Done
  28339. */
  28340. DONE = 2,
  28341. /**
  28342. * Error
  28343. */
  28344. ERROR = 3,
  28345. }
  28346. /**
  28347. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  28348. */
  28349. abstract class AbstractAssetTask {
  28350. /**
  28351. * Task name
  28352. */ name: string;
  28353. /**
  28354. * Callback called when the task is successful
  28355. */
  28356. onSuccess: (task: any) => void;
  28357. /**
  28358. * Callback called when the task is not successful
  28359. */
  28360. onError: (task: any, message?: string, exception?: any) => void;
  28361. /**
  28362. * Creates a new {BABYLON.AssetsManager}
  28363. * @param name defines the name of the task
  28364. */
  28365. constructor(
  28366. /**
  28367. * Task name
  28368. */ name: string);
  28369. private _isCompleted;
  28370. private _taskState;
  28371. private _errorObject;
  28372. /**
  28373. * Get if the task is completed
  28374. */
  28375. readonly isCompleted: boolean;
  28376. /**
  28377. * Gets the current state of the task
  28378. */
  28379. readonly taskState: AssetTaskState;
  28380. /**
  28381. * Gets the current error object (if task is in error)
  28382. */
  28383. readonly errorObject: {
  28384. message?: string;
  28385. exception?: any;
  28386. };
  28387. /**
  28388. * Internal only
  28389. * @hidden
  28390. */
  28391. _setErrorObject(message?: string, exception?: any): void;
  28392. /**
  28393. * Execute the current task
  28394. * @param scene defines the scene where you want your assets to be loaded
  28395. * @param onSuccess is a callback called when the task is successfully executed
  28396. * @param onError is a callback called if an error occurs
  28397. */
  28398. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28399. /**
  28400. * Execute the current task
  28401. * @param scene defines the scene where you want your assets to be loaded
  28402. * @param onSuccess is a callback called when the task is successfully executed
  28403. * @param onError is a callback called if an error occurs
  28404. */
  28405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28406. /**
  28407. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  28408. * This can be used with failed tasks that have the reason for failure fixed.
  28409. */
  28410. reset(): void;
  28411. private onErrorCallback(onError, message?, exception?);
  28412. private onDoneCallback(onSuccess, onError);
  28413. }
  28414. /**
  28415. * Define the interface used by progress events raised during assets loading
  28416. */
  28417. interface IAssetsProgressEvent {
  28418. /**
  28419. * Defines the number of remaining tasks to process
  28420. */
  28421. remainingCount: number;
  28422. /**
  28423. * Defines the total number of tasks
  28424. */
  28425. totalCount: number;
  28426. /**
  28427. * Defines the task that was just processed
  28428. */
  28429. task: AbstractAssetTask;
  28430. }
  28431. /**
  28432. * Class used to share progress information about assets loading
  28433. */
  28434. class AssetsProgressEvent implements IAssetsProgressEvent {
  28435. /**
  28436. * Defines the number of remaining tasks to process
  28437. */
  28438. remainingCount: number;
  28439. /**
  28440. * Defines the total number of tasks
  28441. */
  28442. totalCount: number;
  28443. /**
  28444. * Defines the task that was just processed
  28445. */
  28446. task: AbstractAssetTask;
  28447. /**
  28448. * Creates a {BABYLON.AssetsProgressEvent}
  28449. * @param remainingCount defines the number of remaining tasks to process
  28450. * @param totalCount defines the total number of tasks
  28451. * @param task defines the task that was just processed
  28452. */
  28453. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  28454. }
  28455. /**
  28456. * Define a task used by {BABYLON.AssetsManager} to load meshes
  28457. */
  28458. class MeshAssetTask extends AbstractAssetTask {
  28459. /**
  28460. * Defines the name of the task
  28461. */
  28462. name: string;
  28463. /**
  28464. * Defines the list of mesh's names you want to load
  28465. */
  28466. meshesNames: any;
  28467. /**
  28468. * Defines the root url to use as a base to load your meshes and associated resources
  28469. */
  28470. rootUrl: string;
  28471. /**
  28472. * Defines the filename of the scene to load from
  28473. */
  28474. sceneFilename: string;
  28475. /**
  28476. * Gets the list of loaded meshes
  28477. */
  28478. loadedMeshes: Array<AbstractMesh>;
  28479. /**
  28480. * Gets the list of loaded particle systems
  28481. */
  28482. loadedParticleSystems: Array<IParticleSystem>;
  28483. /**
  28484. * Gets the list of loaded skeletons
  28485. */
  28486. loadedSkeletons: Array<Skeleton>;
  28487. /**
  28488. * Callback called when the task is successful
  28489. */
  28490. onSuccess: (task: MeshAssetTask) => void;
  28491. /**
  28492. * Callback called when the task is successful
  28493. */
  28494. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  28495. /**
  28496. * Creates a new {BABYLON.MeshAssetTask}
  28497. * @param name defines the name of the task
  28498. * @param meshesNames defines the list of mesh's names you want to load
  28499. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  28500. * @param sceneFilename defines the filename of the scene to load from
  28501. */
  28502. constructor(
  28503. /**
  28504. * Defines the name of the task
  28505. */
  28506. name: string,
  28507. /**
  28508. * Defines the list of mesh's names you want to load
  28509. */
  28510. meshesNames: any,
  28511. /**
  28512. * Defines the root url to use as a base to load your meshes and associated resources
  28513. */
  28514. rootUrl: string,
  28515. /**
  28516. * Defines the filename of the scene to load from
  28517. */
  28518. sceneFilename: string);
  28519. /**
  28520. * Execute the current task
  28521. * @param scene defines the scene where you want your assets to be loaded
  28522. * @param onSuccess is a callback called when the task is successfully executed
  28523. * @param onError is a callback called if an error occurs
  28524. */
  28525. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28526. }
  28527. /**
  28528. * Define a task used by {BABYLON.AssetsManager} to load text content
  28529. */
  28530. class TextFileAssetTask extends AbstractAssetTask {
  28531. /**
  28532. * Defines the name of the task
  28533. */
  28534. name: string;
  28535. /**
  28536. * Defines the location of the file to load
  28537. */
  28538. url: string;
  28539. /**
  28540. * Gets the loaded text string
  28541. */
  28542. text: string;
  28543. /**
  28544. * Callback called when the task is successful
  28545. */
  28546. onSuccess: (task: TextFileAssetTask) => void;
  28547. /**
  28548. * Callback called when the task is successful
  28549. */
  28550. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  28551. /**
  28552. * Creates a new TextFileAssetTask object
  28553. * @param name defines the name of the task
  28554. * @param url defines the location of the file to load
  28555. */
  28556. constructor(
  28557. /**
  28558. * Defines the name of the task
  28559. */
  28560. name: string,
  28561. /**
  28562. * Defines the location of the file to load
  28563. */
  28564. url: string);
  28565. /**
  28566. * Execute the current task
  28567. * @param scene defines the scene where you want your assets to be loaded
  28568. * @param onSuccess is a callback called when the task is successfully executed
  28569. * @param onError is a callback called if an error occurs
  28570. */
  28571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28572. }
  28573. /**
  28574. * Define a task used by {BABYLON.AssetsManager} to load binary data
  28575. */
  28576. class BinaryFileAssetTask extends AbstractAssetTask {
  28577. /**
  28578. * Defines the name of the task
  28579. */
  28580. name: string;
  28581. /**
  28582. * Defines the location of the file to load
  28583. */
  28584. url: string;
  28585. /**
  28586. * Gets the lodaded data (as an array buffer)
  28587. */
  28588. data: ArrayBuffer;
  28589. /**
  28590. * Callback called when the task is successful
  28591. */
  28592. onSuccess: (task: BinaryFileAssetTask) => void;
  28593. /**
  28594. * Callback called when the task is successful
  28595. */
  28596. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  28597. /**
  28598. * Creates a new BinaryFileAssetTask object
  28599. * @param name defines the name of the new task
  28600. * @param url defines the location of the file to load
  28601. */
  28602. constructor(
  28603. /**
  28604. * Defines the name of the task
  28605. */
  28606. name: string,
  28607. /**
  28608. * Defines the location of the file to load
  28609. */
  28610. url: string);
  28611. /**
  28612. * Execute the current task
  28613. * @param scene defines the scene where you want your assets to be loaded
  28614. * @param onSuccess is a callback called when the task is successfully executed
  28615. * @param onError is a callback called if an error occurs
  28616. */
  28617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28618. }
  28619. /**
  28620. * Define a task used by {BABYLON.AssetsManager} to load images
  28621. */
  28622. class ImageAssetTask extends AbstractAssetTask {
  28623. /**
  28624. * Defines the name of the task
  28625. */
  28626. name: string;
  28627. /**
  28628. * Defines the location of the image to load
  28629. */
  28630. url: string;
  28631. /**
  28632. * Gets the loaded images
  28633. */
  28634. image: HTMLImageElement;
  28635. /**
  28636. * Callback called when the task is successful
  28637. */
  28638. onSuccess: (task: ImageAssetTask) => void;
  28639. /**
  28640. * Callback called when the task is successful
  28641. */
  28642. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  28643. /**
  28644. * Creates a new ImageAssetTask
  28645. * @param name defines the name of the task
  28646. * @param url defines the location of the image to load
  28647. */
  28648. constructor(
  28649. /**
  28650. * Defines the name of the task
  28651. */
  28652. name: string,
  28653. /**
  28654. * Defines the location of the image to load
  28655. */
  28656. url: string);
  28657. /**
  28658. * Execute the current task
  28659. * @param scene defines the scene where you want your assets to be loaded
  28660. * @param onSuccess is a callback called when the task is successfully executed
  28661. * @param onError is a callback called if an error occurs
  28662. */
  28663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28664. }
  28665. /**
  28666. * Defines the interface used by texture loading tasks
  28667. */
  28668. interface ITextureAssetTask<TEX extends BaseTexture> {
  28669. /**
  28670. * Gets the loaded texture
  28671. */
  28672. texture: TEX;
  28673. }
  28674. /**
  28675. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  28676. */
  28677. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  28678. /**
  28679. * Defines the name of the task
  28680. */
  28681. name: string;
  28682. /**
  28683. * Defines the location of the file to load
  28684. */
  28685. url: string;
  28686. /**
  28687. * Defines if mipmap should not be generated (default is false)
  28688. */
  28689. noMipmap: boolean | undefined;
  28690. /**
  28691. * Defines if texture must be inverted on Y axis (default is false)
  28692. */
  28693. invertY: boolean | undefined;
  28694. /**
  28695. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28696. */
  28697. samplingMode: number;
  28698. /**
  28699. * Gets the loaded texture
  28700. */
  28701. texture: Texture;
  28702. /**
  28703. * Callback called when the task is successful
  28704. */
  28705. onSuccess: (task: TextureAssetTask) => void;
  28706. /**
  28707. * Callback called when the task is successful
  28708. */
  28709. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  28710. /**
  28711. * Creates a new TextureAssetTask object
  28712. * @param name defines the name of the task
  28713. * @param url defines the location of the file to load
  28714. * @param noMipmap defines if mipmap should not be generated (default is false)
  28715. * @param invertY defines if texture must be inverted on Y axis (default is false)
  28716. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28717. */
  28718. constructor(
  28719. /**
  28720. * Defines the name of the task
  28721. */
  28722. name: string,
  28723. /**
  28724. * Defines the location of the file to load
  28725. */
  28726. url: string,
  28727. /**
  28728. * Defines if mipmap should not be generated (default is false)
  28729. */
  28730. noMipmap?: boolean | undefined,
  28731. /**
  28732. * Defines if texture must be inverted on Y axis (default is false)
  28733. */
  28734. invertY?: boolean | undefined,
  28735. /**
  28736. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28737. */
  28738. samplingMode?: number);
  28739. /**
  28740. * Execute the current task
  28741. * @param scene defines the scene where you want your assets to be loaded
  28742. * @param onSuccess is a callback called when the task is successfully executed
  28743. * @param onError is a callback called if an error occurs
  28744. */
  28745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28746. }
  28747. /**
  28748. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  28749. */
  28750. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  28751. /**
  28752. * Defines the name of the task
  28753. */
  28754. name: string;
  28755. /**
  28756. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28757. */
  28758. url: string;
  28759. /**
  28760. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28761. */
  28762. extensions: string[] | undefined;
  28763. /**
  28764. * Defines if mipmaps should not be generated (default is false)
  28765. */
  28766. noMipmap: boolean | undefined;
  28767. /**
  28768. * Defines the explicit list of files (undefined by default)
  28769. */
  28770. files: string[] | undefined;
  28771. /**
  28772. * Gets the loaded texture
  28773. */
  28774. texture: CubeTexture;
  28775. /**
  28776. * Callback called when the task is successful
  28777. */
  28778. onSuccess: (task: CubeTextureAssetTask) => void;
  28779. /**
  28780. * Callback called when the task is successful
  28781. */
  28782. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  28783. /**
  28784. * Creates a new CubeTextureAssetTask
  28785. * @param name defines the name of the task
  28786. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28787. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28788. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28789. * @param files defines the explicit list of files (undefined by default)
  28790. */
  28791. constructor(
  28792. /**
  28793. * Defines the name of the task
  28794. */
  28795. name: string,
  28796. /**
  28797. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28798. */
  28799. url: string,
  28800. /**
  28801. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28802. */
  28803. extensions?: string[] | undefined,
  28804. /**
  28805. * Defines if mipmaps should not be generated (default is false)
  28806. */
  28807. noMipmap?: boolean | undefined,
  28808. /**
  28809. * Defines the explicit list of files (undefined by default)
  28810. */
  28811. files?: string[] | undefined);
  28812. /**
  28813. * Execute the current task
  28814. * @param scene defines the scene where you want your assets to be loaded
  28815. * @param onSuccess is a callback called when the task is successfully executed
  28816. * @param onError is a callback called if an error occurs
  28817. */
  28818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28819. }
  28820. /**
  28821. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  28822. */
  28823. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  28824. /**
  28825. * Defines the name of the task
  28826. */
  28827. name: string;
  28828. /**
  28829. * Defines the location of the file to load
  28830. */
  28831. url: string;
  28832. /**
  28833. * Defines the desired size (the more it increases the longer the generation will be)
  28834. */
  28835. size: number;
  28836. /**
  28837. * Defines if mipmaps should not be generated (default is false)
  28838. */
  28839. noMipmap: boolean;
  28840. /**
  28841. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28842. */
  28843. generateHarmonics: boolean;
  28844. /**
  28845. * 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)
  28846. */
  28847. gammaSpace: boolean;
  28848. /**
  28849. * Internal Use Only
  28850. */
  28851. reserved: boolean;
  28852. /**
  28853. * Gets the loaded texture
  28854. */
  28855. texture: HDRCubeTexture;
  28856. /**
  28857. * Callback called when the task is successful
  28858. */
  28859. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  28860. /**
  28861. * Callback called when the task is successful
  28862. */
  28863. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  28864. /**
  28865. * Creates a new HDRCubeTextureAssetTask object
  28866. * @param name defines the name of the task
  28867. * @param url defines the location of the file to load
  28868. * @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.
  28869. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28870. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28871. * @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)
  28872. * @param reserved Internal use only
  28873. */
  28874. constructor(
  28875. /**
  28876. * Defines the name of the task
  28877. */
  28878. name: string,
  28879. /**
  28880. * Defines the location of the file to load
  28881. */
  28882. url: string,
  28883. /**
  28884. * Defines the desired size (the more it increases the longer the generation will be)
  28885. */
  28886. size: number,
  28887. /**
  28888. * Defines if mipmaps should not be generated (default is false)
  28889. */
  28890. noMipmap?: boolean,
  28891. /**
  28892. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28893. */
  28894. generateHarmonics?: boolean,
  28895. /**
  28896. * 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)
  28897. */
  28898. gammaSpace?: boolean,
  28899. /**
  28900. * Internal Use Only
  28901. */
  28902. reserved?: boolean);
  28903. /**
  28904. * Execute the current task
  28905. * @param scene defines the scene where you want your assets to be loaded
  28906. * @param onSuccess is a callback called when the task is successfully executed
  28907. * @param onError is a callback called if an error occurs
  28908. */
  28909. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28910. }
  28911. /**
  28912. * This class can be used to easily import assets into a scene
  28913. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  28914. */
  28915. class AssetsManager {
  28916. private _scene;
  28917. private _isLoading;
  28918. protected _tasks: AbstractAssetTask[];
  28919. protected _waitingTasksCount: number;
  28920. protected _totalTasksCount: number;
  28921. /**
  28922. * Callback called when all tasks are processed
  28923. */
  28924. onFinish: (tasks: AbstractAssetTask[]) => void;
  28925. /**
  28926. * Callback called when a task is successful
  28927. */
  28928. onTaskSuccess: (task: AbstractAssetTask) => void;
  28929. /**
  28930. * Callback called when a task had an error
  28931. */
  28932. onTaskError: (task: AbstractAssetTask) => void;
  28933. /**
  28934. * Callback called when a task is done (whatever the result is)
  28935. */
  28936. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  28937. /**
  28938. * Observable called when all tasks are processed
  28939. */
  28940. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  28941. /**
  28942. * Observable called when a task had an error
  28943. */
  28944. onTaskErrorObservable: Observable<AbstractAssetTask>;
  28945. /**
  28946. * Observable called when a task is successful
  28947. */
  28948. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  28949. /**
  28950. * Observable called when a task is done (whatever the result is)
  28951. */
  28952. onProgressObservable: Observable<IAssetsProgressEvent>;
  28953. /**
  28954. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  28955. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28956. */
  28957. useDefaultLoadingScreen: boolean;
  28958. /**
  28959. * Creates a new AssetsManager
  28960. * @param scene defines the scene to work on
  28961. */
  28962. constructor(scene: Scene);
  28963. /**
  28964. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  28965. * @param taskName defines the name of the new task
  28966. * @param meshesNames defines the name of meshes to load
  28967. * @param rootUrl defines the root url to use to locate files
  28968. * @param sceneFilename defines the filename of the scene file
  28969. * @returns a new {BABYLON.MeshAssetTask} object
  28970. */
  28971. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  28972. /**
  28973. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  28974. * @param taskName defines the name of the new task
  28975. * @param url defines the url of the file to load
  28976. * @returns a new {BABYLON.TextFileAssetTask} object
  28977. */
  28978. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  28979. /**
  28980. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  28981. * @param taskName defines the name of the new task
  28982. * @param url defines the url of the file to load
  28983. * @returns a new {BABYLON.BinaryFileAssetTask} object
  28984. */
  28985. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  28986. /**
  28987. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  28988. * @param taskName defines the name of the new task
  28989. * @param url defines the url of the file to load
  28990. * @returns a new {BABYLON.ImageAssetTask} object
  28991. */
  28992. addImageTask(taskName: string, url: string): ImageAssetTask;
  28993. /**
  28994. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  28995. * @param taskName defines the name of the new task
  28996. * @param url defines the url of the file to load
  28997. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28998. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  28999. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29000. * @returns a new {BABYLON.TextureAssetTask} object
  29001. */
  29002. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29003. /**
  29004. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29005. * @param taskName defines the name of the new task
  29006. * @param url defines the url of the file to load
  29007. * @param extensions defines the extension to use to load the cube map (can be null)
  29008. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29009. * @param files defines the list of files to load (can be null)
  29010. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29011. */
  29012. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29013. /**
  29014. *
  29015. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29016. * @param taskName defines the name of the new task
  29017. * @param url defines the url of the file to load
  29018. * @param size defines the size you want for the cubemap (can be null)
  29019. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29020. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29021. * @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)
  29022. * @param reserved Internal use only
  29023. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29024. */
  29025. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29026. /**
  29027. * Remove a task from the assets manager.
  29028. * @param task the task to remove
  29029. */
  29030. removeTask(task: AbstractAssetTask): void;
  29031. private _decreaseWaitingTasksCount(task);
  29032. private _runTask(task);
  29033. /**
  29034. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29035. * @return the current instance of the {BABYLON.AssetsManager}
  29036. */
  29037. reset(): AssetsManager;
  29038. /**
  29039. * Start the loading process
  29040. * @return the current instance of the {BABYLON.AssetsManager}
  29041. */
  29042. load(): AssetsManager;
  29043. }
  29044. }
  29045. declare module BABYLON {
  29046. /**
  29047. * Class used to enable access to IndexedDB
  29048. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29049. */
  29050. class Database {
  29051. private callbackManifestChecked;
  29052. private currentSceneUrl;
  29053. private db;
  29054. private _enableSceneOffline;
  29055. private _enableTexturesOffline;
  29056. private manifestVersionFound;
  29057. private mustUpdateRessources;
  29058. private hasReachedQuota;
  29059. private isSupported;
  29060. private idbFactory;
  29061. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29062. static IsUASupportingBlobStorage: boolean;
  29063. /** Gets a boolean indicating if Database storate is enabled */
  29064. static IDBStorageEnabled: boolean;
  29065. /**
  29066. * Gets a boolean indicating if scene must be saved in the database
  29067. */
  29068. readonly enableSceneOffline: boolean;
  29069. /**
  29070. * Gets a boolean indicating if textures must be saved in the database
  29071. */
  29072. readonly enableTexturesOffline: boolean;
  29073. /**
  29074. * Creates a new Database
  29075. * @param urlToScene defines the url to load the scene
  29076. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29077. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29078. */
  29079. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29080. private static _ParseURL;
  29081. private static _ReturnFullUrlLocation;
  29082. private _checkManifestFile();
  29083. /**
  29084. * Open the database and make it available
  29085. * @param successCallback defines the callback to call on success
  29086. * @param errorCallback defines the callback to call on error
  29087. */
  29088. openAsync(successCallback: () => void, errorCallback: () => void): void;
  29089. /**
  29090. * Loads an image from the database
  29091. * @param url defines the url to load from
  29092. * @param image defines the target DOM image
  29093. */
  29094. loadImageFromDB(url: string, image: HTMLImageElement): void;
  29095. private _loadImageFromDBAsync(url, image, notInDBCallback);
  29096. private _saveImageIntoDBAsync(url, image);
  29097. private _checkVersionFromDB(url, versionLoaded);
  29098. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  29099. private _saveVersionIntoDBAsync(url, callback);
  29100. /**
  29101. * Loads a file from database
  29102. * @param url defines the URL to load from
  29103. * @param sceneLoaded defines a callback to call on success
  29104. * @param progressCallBack defines a callback to call when progress changed
  29105. * @param errorCallback defines a callback to call on error
  29106. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29107. */
  29108. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29109. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  29110. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?, errorCallback?);
  29111. }
  29112. }
  29113. declare module BABYLON {
  29114. interface DDSInfo {
  29115. width: number;
  29116. height: number;
  29117. mipmapCount: number;
  29118. isFourCC: boolean;
  29119. isRGB: boolean;
  29120. isLuminance: boolean;
  29121. isCube: boolean;
  29122. isCompressed: boolean;
  29123. dxgiFormat: number;
  29124. textureType: number;
  29125. /** Sphericle polynomial created for the dds texture */
  29126. sphericalPolynomial?: SphericalPolynomial;
  29127. }
  29128. class DDSTools {
  29129. static StoreLODInAlphaChannel: boolean;
  29130. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  29131. private static _FloatView;
  29132. private static _Int32View;
  29133. private static _ToHalfFloat(value);
  29134. private static _FromHalfFloat(value);
  29135. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29136. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29137. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29138. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29139. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29140. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  29141. private static _ExtractLongWordOrder(value);
  29142. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  29143. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  29144. /**
  29145. * Uploads DDS Levels to a Babylon Texture
  29146. * @hidden
  29147. */
  29148. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  29149. }
  29150. }
  29151. declare module BABYLON {
  29152. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29153. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29154. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29155. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29156. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29157. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29158. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29159. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29160. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29161. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29162. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29163. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29164. /**
  29165. * Decorator used to define property that can be serialized as reference to a camera
  29166. * @param sourceName defines the name of the property to decorate
  29167. */
  29168. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29169. class SerializationHelper {
  29170. static Serialize<T>(entity: T, serializationObject?: any): any;
  29171. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29172. static Clone<T>(creationFunction: () => T, source: T): T;
  29173. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29174. }
  29175. }
  29176. declare module BABYLON {
  29177. /**
  29178. * Wrapper class for promise with external resolve and reject.
  29179. */
  29180. class Deferred<T> {
  29181. /**
  29182. * The promise associated with this deferred object.
  29183. */
  29184. readonly promise: Promise<T>;
  29185. private _resolve;
  29186. private _reject;
  29187. /**
  29188. * The resolve method of the promise associated with this deferred object.
  29189. */
  29190. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  29191. /**
  29192. * The reject method of the promise associated with this deferred object.
  29193. */
  29194. readonly reject: (reason?: any) => void;
  29195. /**
  29196. * Constructor for this deferred object.
  29197. */
  29198. constructor();
  29199. }
  29200. }
  29201. declare module BABYLON {
  29202. /**
  29203. * Raw texture data and descriptor sufficient for WebGL texture upload
  29204. */
  29205. interface EnvironmentTextureInfo {
  29206. /**
  29207. * Version of the environment map
  29208. */
  29209. version: number;
  29210. /**
  29211. * Width of image
  29212. */
  29213. width: number;
  29214. /**
  29215. * Irradiance information stored in the file.
  29216. */
  29217. irradiance: any;
  29218. /**
  29219. * Specular information stored in the file.
  29220. */
  29221. specular: any;
  29222. }
  29223. /**
  29224. * Sets of helpers addressing the serialization and deserialization of environment texture
  29225. * stored in a BabylonJS env file.
  29226. * Those files are usually stored as .env files.
  29227. */
  29228. class EnvironmentTextureTools {
  29229. /**
  29230. * Magic number identifying the env file.
  29231. */
  29232. private static _MagicBytes;
  29233. /**
  29234. * Gets the environment info from an env file.
  29235. * @param data The array buffer containing the .env bytes.
  29236. * @returns the environment file info (the json header) if successfully parsed.
  29237. */
  29238. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  29239. /**
  29240. * Creates an environment texture from a loaded cube texture.
  29241. * @param texture defines the cube texture to convert in env file
  29242. * @return a promise containing the environment data if succesfull.
  29243. */
  29244. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  29245. /**
  29246. * Creates a JSON representation of the spherical data.
  29247. * @param texture defines the texture containing the polynomials
  29248. * @return the JSON representation of the spherical info
  29249. */
  29250. private static _CreateEnvTextureIrradiance(texture);
  29251. /**
  29252. * Uploads the texture info contained in the env file to the GPU.
  29253. * @param texture defines the internal texture to upload to
  29254. * @param arrayBuffer defines the buffer cotaining the data to load
  29255. * @param info defines the texture info retrieved through the GetEnvInfo method
  29256. * @returns a promise
  29257. */
  29258. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  29259. /**
  29260. * Uploads the levels of image data to the GPU.
  29261. * @param texture defines the internal texture to upload to
  29262. * @param imageData defines the array buffer views of image data [mipmap][face]
  29263. * @returns a promise
  29264. */
  29265. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  29266. /**
  29267. * Uploads spherical polynomials information to the texture.
  29268. * @param texture defines the texture we are trying to upload the information to
  29269. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  29270. */
  29271. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  29272. }
  29273. }
  29274. declare module BABYLON {
  29275. class FilesInput {
  29276. static FilesToLoad: {
  29277. [key: string]: File;
  29278. };
  29279. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  29280. private _engine;
  29281. private _currentScene;
  29282. private _sceneLoadedCallback;
  29283. private _progressCallback;
  29284. private _additionalRenderLoopLogicCallback;
  29285. private _textureLoadingCallback;
  29286. private _startingProcessingFilesCallback;
  29287. private _onReloadCallback;
  29288. private _errorCallback;
  29289. private _elementToMonitor;
  29290. private _sceneFileToLoad;
  29291. private _filesToLoad;
  29292. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  29293. private _dragEnterHandler;
  29294. private _dragOverHandler;
  29295. private _dropHandler;
  29296. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  29297. dispose(): void;
  29298. private renderFunction();
  29299. private drag(e);
  29300. private drop(eventDrop);
  29301. private _traverseFolder(folder, files, remaining, callback);
  29302. private _processFiles(files);
  29303. loadFiles(event: any): void;
  29304. private _processReload();
  29305. reload(): void;
  29306. }
  29307. }
  29308. declare module BABYLON {
  29309. /**
  29310. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29311. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29312. */
  29313. class KhronosTextureContainer {
  29314. arrayBuffer: any;
  29315. static HEADER_LEN: number;
  29316. static COMPRESSED_2D: number;
  29317. static COMPRESSED_3D: number;
  29318. static TEX_2D: number;
  29319. static TEX_3D: number;
  29320. glType: number;
  29321. glTypeSize: number;
  29322. glFormat: number;
  29323. glInternalFormat: number;
  29324. glBaseInternalFormat: number;
  29325. pixelWidth: number;
  29326. pixelHeight: number;
  29327. pixelDepth: number;
  29328. numberOfArrayElements: number;
  29329. numberOfFaces: number;
  29330. numberOfMipmapLevels: number;
  29331. bytesOfKeyValueData: number;
  29332. loadType: number;
  29333. /**
  29334. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  29335. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  29336. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  29337. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  29338. */
  29339. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  29340. switchEndainness(val: number): number;
  29341. /**
  29342. * Uploads KTX content to a Babylon Texture.
  29343. * It is assumed that the texture has already been created & is currently bound
  29344. * @hidden
  29345. */
  29346. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  29347. private _upload2DCompressedLevels(texture, loadMipmaps);
  29348. }
  29349. }
  29350. declare module BABYLON {
  29351. /**
  29352. * A class serves as a medium between the observable and its observers
  29353. */
  29354. class EventState {
  29355. /**
  29356. * Create a new EventState
  29357. * @param mask defines the mask associated with this state
  29358. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29359. * @param target defines the original target of the state
  29360. * @param currentTarget defines the current target of the state
  29361. */
  29362. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  29363. /**
  29364. * Initialize the current event state
  29365. * @param mask defines the mask associated with this state
  29366. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29367. * @param target defines the original target of the state
  29368. * @param currentTarget defines the current target of the state
  29369. * @returns the current event state
  29370. */
  29371. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  29372. /**
  29373. * An Observer can set this property to true to prevent subsequent observers of being notified
  29374. */
  29375. skipNextObservers: boolean;
  29376. /**
  29377. * Get the mask value that were used to trigger the event corresponding to this EventState object
  29378. */
  29379. mask: number;
  29380. /**
  29381. * The object that originally notified the event
  29382. */
  29383. target?: any;
  29384. /**
  29385. * The current object in the bubbling phase
  29386. */
  29387. currentTarget?: any;
  29388. /**
  29389. * This will be populated with the return value of the last function that was executed.
  29390. * If it is the first function in the callback chain it will be the event data.
  29391. */
  29392. lastReturnValue?: any;
  29393. }
  29394. /**
  29395. * Represent an Observer registered to a given Observable object.
  29396. */
  29397. class Observer<T> {
  29398. /**
  29399. * Defines the callback to call when the observer is notified
  29400. */
  29401. callback: (eventData: T, eventState: EventState) => void;
  29402. /**
  29403. * Defines the mask of the observer (used to filter notifications)
  29404. */
  29405. mask: number;
  29406. /**
  29407. * Defines the current scope used to restore the JS context
  29408. */
  29409. scope: any;
  29410. /** @hidden */
  29411. _willBeUnregistered: boolean;
  29412. /**
  29413. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  29414. */
  29415. unregisterOnNextCall: boolean;
  29416. /**
  29417. * Creates a new observer
  29418. * @param callback defines the callback to call when the observer is notified
  29419. * @param mask defines the mask of the observer (used to filter notifications)
  29420. * @param scope defines the current scope used to restore the JS context
  29421. */
  29422. constructor(
  29423. /**
  29424. * Defines the callback to call when the observer is notified
  29425. */
  29426. callback: (eventData: T, eventState: EventState) => void,
  29427. /**
  29428. * Defines the mask of the observer (used to filter notifications)
  29429. */
  29430. mask: number,
  29431. /**
  29432. * Defines the current scope used to restore the JS context
  29433. */
  29434. scope?: any);
  29435. }
  29436. /**
  29437. * Represent a list of observers registered to multiple Observables object.
  29438. */
  29439. class MultiObserver<T> {
  29440. private _observers;
  29441. private _observables;
  29442. /**
  29443. * Release associated resources
  29444. */
  29445. dispose(): void;
  29446. /**
  29447. * Raise a callback when one of the observable will notify
  29448. * @param observables defines a list of observables to watch
  29449. * @param callback defines the callback to call on notification
  29450. * @param mask defines the mask used to filter notifications
  29451. * @param scope defines the current scope used to restore the JS context
  29452. * @returns the new MultiObserver
  29453. */
  29454. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  29455. }
  29456. /**
  29457. * The Observable class is a simple implementation of the Observable pattern.
  29458. *
  29459. * 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.
  29460. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  29461. * 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).
  29462. * 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.
  29463. */
  29464. class Observable<T> {
  29465. private _observers;
  29466. private _eventState;
  29467. private _onObserverAdded;
  29468. /**
  29469. * Creates a new observable
  29470. * @param onObserverAdded defines a callback to call when a new observer is added
  29471. */
  29472. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  29473. /**
  29474. * Create a new Observer with the specified callback
  29475. * @param callback the callback that will be executed for that Observer
  29476. * @param mask the mask used to filter observers
  29477. * @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.
  29478. * @param scope optional scope for the callback to be called from
  29479. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  29480. * @returns the new observer created for the callback
  29481. */
  29482. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  29483. /**
  29484. * Create a new Observer with the specified callback and unregisters after the next notification
  29485. * @param callback the callback that will be executed for that Observer
  29486. * @returns the new observer created for the callback
  29487. */
  29488. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  29489. /**
  29490. * Remove an Observer from the Observable object
  29491. * @param observer the instance of the Observer to remove
  29492. * @returns false if it doesn't belong to this Observable
  29493. */
  29494. remove(observer: Nullable<Observer<T>>): boolean;
  29495. /**
  29496. * Remove a callback from the Observable object
  29497. * @param callback the callback to remove
  29498. * @param scope optional scope. If used only the callbacks with this scope will be removed
  29499. * @returns false if it doesn't belong to this Observable
  29500. */
  29501. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  29502. private _deferUnregister(observer);
  29503. private _remove(observer);
  29504. /**
  29505. * Notify all Observers by calling their respective callback with the given data
  29506. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  29507. * @param eventData defines the data to send to all observers
  29508. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  29509. * @param target defines the original target of the state
  29510. * @param currentTarget defines the current target of the state
  29511. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  29512. */
  29513. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  29514. /**
  29515. * Calling this will execute each callback, expecting it to be a promise or return a value.
  29516. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  29517. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  29518. * and it is crucial that all callbacks will be executed.
  29519. * The order of the callbacks is kept, callbacks are not executed parallel.
  29520. *
  29521. * @param eventData The data to be sent to each callback
  29522. * @param mask is used to filter observers defaults to -1
  29523. * @param target defines the callback target (see EventState)
  29524. * @param currentTarget defines he current object in the bubbling phase
  29525. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  29526. */
  29527. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  29528. /**
  29529. * Notify a specific observer
  29530. * @param observer defines the observer to notify
  29531. * @param eventData defines the data to be sent to each callback
  29532. * @param mask is used to filter observers defaults to -1
  29533. */
  29534. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  29535. /**
  29536. * Gets a boolean indicating if the observable has at least one observer
  29537. * @returns true is the Observable has at least one Observer registered
  29538. */
  29539. hasObservers(): boolean;
  29540. /**
  29541. * Clear the list of observers
  29542. */
  29543. clear(): void;
  29544. /**
  29545. * Clone the current observable
  29546. * @returns a new observable
  29547. */
  29548. clone(): Observable<T>;
  29549. /**
  29550. * Does this observable handles observer registered with a given mask
  29551. * @param mask defines the mask to be tested
  29552. * @return whether or not one observer registered with the given mask is handeled
  29553. **/
  29554. hasSpecificMask(mask?: number): boolean;
  29555. }
  29556. }
  29557. declare module BABYLON {
  29558. /**
  29559. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29560. */
  29561. class PerformanceMonitor {
  29562. private _enabled;
  29563. private _rollingFrameTime;
  29564. private _lastFrameTimeMs;
  29565. /**
  29566. * constructor
  29567. * @param frameSampleSize The number of samples required to saturate the sliding window
  29568. */
  29569. constructor(frameSampleSize?: number);
  29570. /**
  29571. * Samples current frame
  29572. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29573. */
  29574. sampleFrame(timeMs?: number): void;
  29575. /**
  29576. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29577. * @return Average frame time in milliseconds
  29578. */
  29579. readonly averageFrameTime: number;
  29580. /**
  29581. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29582. * @return Frame time variance in milliseconds squared
  29583. */
  29584. readonly averageFrameTimeVariance: number;
  29585. /**
  29586. * Returns the frame time of the most recent frame
  29587. * @return Frame time in milliseconds
  29588. */
  29589. readonly instantaneousFrameTime: number;
  29590. /**
  29591. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29592. * @return Framerate in frames per second
  29593. */
  29594. readonly averageFPS: number;
  29595. /**
  29596. * Returns the average framerate in frames per second using the most recent frame time
  29597. * @return Framerate in frames per second
  29598. */
  29599. readonly instantaneousFPS: number;
  29600. /**
  29601. * Returns true if enough samples have been taken to completely fill the sliding window
  29602. * @return true if saturated
  29603. */
  29604. readonly isSaturated: boolean;
  29605. /**
  29606. * Enables contributions to the sliding window sample set
  29607. */
  29608. enable(): void;
  29609. /**
  29610. * Disables contributions to the sliding window sample set
  29611. * Samples will not be interpolated over the disabled period
  29612. */
  29613. disable(): void;
  29614. /**
  29615. * Returns true if sampling is enabled
  29616. * @return true if enabled
  29617. */
  29618. readonly isEnabled: boolean;
  29619. /**
  29620. * Resets performance monitor
  29621. */
  29622. reset(): void;
  29623. }
  29624. /**
  29625. * RollingAverage
  29626. *
  29627. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29628. */
  29629. class RollingAverage {
  29630. /**
  29631. * Current average
  29632. */
  29633. average: number;
  29634. /**
  29635. * Current variance
  29636. */
  29637. variance: number;
  29638. protected _samples: Array<number>;
  29639. protected _sampleCount: number;
  29640. protected _pos: number;
  29641. protected _m2: number;
  29642. /**
  29643. * constructor
  29644. * @param length The number of samples required to saturate the sliding window
  29645. */
  29646. constructor(length: number);
  29647. /**
  29648. * Adds a sample to the sample set
  29649. * @param v The sample value
  29650. */
  29651. add(v: number): void;
  29652. /**
  29653. * Returns previously added values or null if outside of history or outside the sliding window domain
  29654. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  29655. * @return Value previously recorded with add() or null if outside of range
  29656. */
  29657. history(i: number): number;
  29658. /**
  29659. * Returns true if enough samples have been taken to completely fill the sliding window
  29660. * @return true if sample-set saturated
  29661. */
  29662. isSaturated(): boolean;
  29663. /**
  29664. * Resets the rolling average (equivalent to 0 samples taken so far)
  29665. */
  29666. reset(): void;
  29667. /**
  29668. * Wraps a value around the sample range boundaries
  29669. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  29670. * @return Wrapped position in sample range
  29671. */
  29672. protected _wrapPosition(i: number): number;
  29673. }
  29674. }
  29675. declare module BABYLON {
  29676. /**
  29677. * Helper class that provides a small promise polyfill
  29678. */
  29679. class PromisePolyfill {
  29680. /**
  29681. * Static function used to check if the polyfill is required
  29682. * If this is the case then the function will inject the polyfill to window.Promise
  29683. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  29684. */
  29685. static Apply(force?: boolean): void;
  29686. }
  29687. }
  29688. declare module BABYLON {
  29689. /**
  29690. * Defines the root class used to create scene optimization to use with SceneOptimizer
  29691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29692. */
  29693. class SceneOptimization {
  29694. /**
  29695. * Defines the priority of this optimization (0 by default which means first in the list)
  29696. */
  29697. priority: number;
  29698. /**
  29699. * Gets a string describing the action executed by the current optimization
  29700. * @returns description string
  29701. */
  29702. getDescription(): string;
  29703. /**
  29704. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29705. * @param scene defines the current scene where to apply this optimization
  29706. * @param optimizer defines the current optimizer
  29707. * @returns true if everything that can be done was applied
  29708. */
  29709. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29710. /**
  29711. * Creates the SceneOptimization object
  29712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29713. * @param desc defines the description associated with the optimization
  29714. */
  29715. constructor(
  29716. /**
  29717. * Defines the priority of this optimization (0 by default which means first in the list)
  29718. */
  29719. priority?: number);
  29720. }
  29721. /**
  29722. * Defines an optimization used to reduce the size of render target textures
  29723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29724. */
  29725. class TextureOptimization extends SceneOptimization {
  29726. /**
  29727. * Defines the priority of this optimization (0 by default which means first in the list)
  29728. */
  29729. priority: number;
  29730. /**
  29731. * 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
  29732. */
  29733. maximumSize: number;
  29734. /**
  29735. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29736. */
  29737. step: number;
  29738. /**
  29739. * Gets a string describing the action executed by the current optimization
  29740. * @returns description string
  29741. */
  29742. getDescription(): string;
  29743. /**
  29744. * Creates the TextureOptimization object
  29745. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29746. * @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
  29747. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29748. */
  29749. constructor(
  29750. /**
  29751. * Defines the priority of this optimization (0 by default which means first in the list)
  29752. */
  29753. priority?: number,
  29754. /**
  29755. * 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
  29756. */
  29757. maximumSize?: number,
  29758. /**
  29759. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29760. */
  29761. step?: number);
  29762. /**
  29763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29764. * @param scene defines the current scene where to apply this optimization
  29765. * @param optimizer defines the current optimizer
  29766. * @returns true if everything that can be done was applied
  29767. */
  29768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29769. }
  29770. /**
  29771. * Defines an optimization used to increase or decrease the rendering resolution
  29772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29773. */
  29774. class HardwareScalingOptimization extends SceneOptimization {
  29775. /**
  29776. * Defines the priority of this optimization (0 by default which means first in the list)
  29777. */
  29778. priority: number;
  29779. /**
  29780. * Defines the maximum scale to use (2 by default)
  29781. */
  29782. maximumScale: number;
  29783. /**
  29784. * Defines the step to use between two passes (0.5 by default)
  29785. */
  29786. step: number;
  29787. private _currentScale;
  29788. private _directionOffset;
  29789. /**
  29790. * Gets a string describing the action executed by the current optimization
  29791. * @return description string
  29792. */
  29793. getDescription(): string;
  29794. /**
  29795. * Creates the HardwareScalingOptimization object
  29796. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29797. * @param maximumScale defines the maximum scale to use (2 by default)
  29798. * @param step defines the step to use between two passes (0.5 by default)
  29799. */
  29800. constructor(
  29801. /**
  29802. * Defines the priority of this optimization (0 by default which means first in the list)
  29803. */
  29804. priority?: number,
  29805. /**
  29806. * Defines the maximum scale to use (2 by default)
  29807. */
  29808. maximumScale?: number,
  29809. /**
  29810. * Defines the step to use between two passes (0.5 by default)
  29811. */
  29812. step?: number);
  29813. /**
  29814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29815. * @param scene defines the current scene where to apply this optimization
  29816. * @param optimizer defines the current optimizer
  29817. * @returns true if everything that can be done was applied
  29818. */
  29819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29820. }
  29821. /**
  29822. * Defines an optimization used to remove shadows
  29823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29824. */
  29825. class ShadowsOptimization extends SceneOptimization {
  29826. /**
  29827. * Gets a string describing the action executed by the current optimization
  29828. * @return description string
  29829. */
  29830. getDescription(): string;
  29831. /**
  29832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29833. * @param scene defines the current scene where to apply this optimization
  29834. * @param optimizer defines the current optimizer
  29835. * @returns true if everything that can be done was applied
  29836. */
  29837. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29838. }
  29839. /**
  29840. * Defines an optimization used to turn post-processes off
  29841. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29842. */
  29843. class PostProcessesOptimization extends SceneOptimization {
  29844. /**
  29845. * Gets a string describing the action executed by the current optimization
  29846. * @return description string
  29847. */
  29848. getDescription(): string;
  29849. /**
  29850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29851. * @param scene defines the current scene where to apply this optimization
  29852. * @param optimizer defines the current optimizer
  29853. * @returns true if everything that can be done was applied
  29854. */
  29855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29856. }
  29857. /**
  29858. * Defines an optimization used to turn lens flares off
  29859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29860. */
  29861. class LensFlaresOptimization extends SceneOptimization {
  29862. /**
  29863. * Gets a string describing the action executed by the current optimization
  29864. * @return description string
  29865. */
  29866. getDescription(): string;
  29867. /**
  29868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29869. * @param scene defines the current scene where to apply this optimization
  29870. * @param optimizer defines the current optimizer
  29871. * @returns true if everything that can be done was applied
  29872. */
  29873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29874. }
  29875. /**
  29876. * Defines an optimization based on user defined callback.
  29877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29878. */
  29879. class CustomOptimization extends SceneOptimization {
  29880. /**
  29881. * Callback called to apply the custom optimization.
  29882. */
  29883. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  29884. /**
  29885. * Callback called to get custom description
  29886. */
  29887. onGetDescription: () => string;
  29888. /**
  29889. * Gets a string describing the action executed by the current optimization
  29890. * @returns description string
  29891. */
  29892. getDescription(): string;
  29893. /**
  29894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29895. * @param scene defines the current scene where to apply this optimization
  29896. * @param optimizer defines the current optimizer
  29897. * @returns true if everything that can be done was applied
  29898. */
  29899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29900. }
  29901. /**
  29902. * Defines an optimization used to turn particles off
  29903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29904. */
  29905. class ParticlesOptimization extends SceneOptimization {
  29906. /**
  29907. * Gets a string describing the action executed by the current optimization
  29908. * @return description string
  29909. */
  29910. getDescription(): string;
  29911. /**
  29912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29913. * @param scene defines the current scene where to apply this optimization
  29914. * @param optimizer defines the current optimizer
  29915. * @returns true if everything that can be done was applied
  29916. */
  29917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29918. }
  29919. /**
  29920. * Defines an optimization used to turn render targets off
  29921. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29922. */
  29923. class RenderTargetsOptimization extends SceneOptimization {
  29924. /**
  29925. * Gets a string describing the action executed by the current optimization
  29926. * @return description string
  29927. */
  29928. getDescription(): string;
  29929. /**
  29930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29931. * @param scene defines the current scene where to apply this optimization
  29932. * @param optimizer defines the current optimizer
  29933. * @returns true if everything that can be done was applied
  29934. */
  29935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29936. }
  29937. /**
  29938. * Defines an optimization used to merge meshes with compatible materials
  29939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29940. */
  29941. class MergeMeshesOptimization extends SceneOptimization {
  29942. private static _UpdateSelectionTree;
  29943. /**
  29944. * Gets or sets a boolean which defines if optimization octree has to be updated
  29945. */
  29946. /**
  29947. * Gets or sets a boolean which defines if optimization octree has to be updated
  29948. */
  29949. static UpdateSelectionTree: boolean;
  29950. /**
  29951. * Gets a string describing the action executed by the current optimization
  29952. * @return description string
  29953. */
  29954. getDescription(): string;
  29955. private _canBeMerged;
  29956. /**
  29957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29958. * @param scene defines the current scene where to apply this optimization
  29959. * @param optimizer defines the current optimizer
  29960. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  29961. * @returns true if everything that can be done was applied
  29962. */
  29963. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  29964. }
  29965. /**
  29966. * Defines a list of options used by SceneOptimizer
  29967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29968. */
  29969. class SceneOptimizerOptions {
  29970. /**
  29971. * Defines the target frame rate to reach (60 by default)
  29972. */
  29973. targetFrameRate: number;
  29974. /**
  29975. * Defines the interval between two checkes (2000ms by default)
  29976. */
  29977. trackerDuration: number;
  29978. /**
  29979. * Gets the list of optimizations to apply
  29980. */
  29981. optimizations: SceneOptimization[];
  29982. /**
  29983. * Creates a new list of options used by SceneOptimizer
  29984. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  29985. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  29986. */
  29987. constructor(
  29988. /**
  29989. * Defines the target frame rate to reach (60 by default)
  29990. */
  29991. targetFrameRate?: number,
  29992. /**
  29993. * Defines the interval between two checkes (2000ms by default)
  29994. */
  29995. trackerDuration?: number);
  29996. /**
  29997. * Add a new optimization
  29998. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  29999. * @returns the current SceneOptimizerOptions
  30000. */
  30001. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30002. /**
  30003. * Add a new custom optimization
  30004. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30005. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30007. * @returns the current SceneOptimizerOptions
  30008. */
  30009. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30010. /**
  30011. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30012. * @param targetFrameRate defines the target frame rate (60 by default)
  30013. * @returns a SceneOptimizerOptions object
  30014. */
  30015. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30016. /**
  30017. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30018. * @param targetFrameRate defines the target frame rate (60 by default)
  30019. * @returns a SceneOptimizerOptions object
  30020. */
  30021. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30022. /**
  30023. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  30024. * @param targetFrameRate defines the target frame rate (60 by default)
  30025. * @returns a SceneOptimizerOptions object
  30026. */
  30027. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30028. }
  30029. /**
  30030. * Class used to run optimizations in order to reach a target frame rate
  30031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30032. */
  30033. class SceneOptimizer implements IDisposable {
  30034. private _isRunning;
  30035. private _options;
  30036. private _scene;
  30037. private _currentPriorityLevel;
  30038. private _targetFrameRate;
  30039. private _trackerDuration;
  30040. private _currentFrameRate;
  30041. private _sceneDisposeObserver;
  30042. private _improvementMode;
  30043. /**
  30044. * Defines an observable called when the optimizer reaches the target frame rate
  30045. */
  30046. onSuccessObservable: Observable<SceneOptimizer>;
  30047. /**
  30048. * Defines an observable called when the optimizer enables an optimization
  30049. */
  30050. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30051. /**
  30052. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30053. */
  30054. onFailureObservable: Observable<SceneOptimizer>;
  30055. /**
  30056. * Gets a boolean indicating if the optimizer is in improvement mode
  30057. */
  30058. readonly isInImprovementMode: boolean;
  30059. /**
  30060. * Gets the current priority level (0 at start)
  30061. */
  30062. readonly currentPriorityLevel: number;
  30063. /**
  30064. * Gets the current frame rate checked by the SceneOptimizer
  30065. */
  30066. readonly currentFrameRate: number;
  30067. /**
  30068. * Gets or sets the current target frame rate (60 by default)
  30069. */
  30070. /**
  30071. * Gets or sets the current target frame rate (60 by default)
  30072. */
  30073. targetFrameRate: number;
  30074. /**
  30075. * Gets or sets the current interval between two checks (every 2000ms by default)
  30076. */
  30077. /**
  30078. * Gets or sets the current interval between two checks (every 2000ms by default)
  30079. */
  30080. trackerDuration: number;
  30081. /**
  30082. * Gets the list of active optimizations
  30083. */
  30084. readonly optimizations: SceneOptimization[];
  30085. /**
  30086. * Creates a new SceneOptimizer
  30087. * @param scene defines the scene to work on
  30088. * @param options defines the options to use with the SceneOptimizer
  30089. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  30090. * @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)
  30091. */
  30092. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  30093. /**
  30094. * Stops the current optimizer
  30095. */
  30096. stop(): void;
  30097. /**
  30098. * Reset the optimizer to initial step (current priority level = 0)
  30099. */
  30100. reset(): void;
  30101. /**
  30102. * Start the optimizer. By default it will try to reach a specific framerate
  30103. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  30104. */
  30105. start(): void;
  30106. private _checkCurrentState();
  30107. /**
  30108. * Release all resources
  30109. */
  30110. dispose(): void;
  30111. /**
  30112. * Helper function to create a SceneOptimizer with one single line of code
  30113. * @param scene defines the scene to work on
  30114. * @param options defines the options to use with the SceneOptimizer
  30115. * @param onSuccess defines a callback to call on success
  30116. * @param onFailure defines a callback to call on failure
  30117. * @returns the new SceneOptimizer object
  30118. */
  30119. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  30120. }
  30121. }
  30122. declare module BABYLON {
  30123. class SceneSerializer {
  30124. static ClearCache(): void;
  30125. static Serialize(scene: Scene): any;
  30126. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  30127. }
  30128. }
  30129. declare module BABYLON {
  30130. class SmartArray<T> {
  30131. data: Array<T>;
  30132. length: number;
  30133. protected _id: number;
  30134. [index: number]: T;
  30135. constructor(capacity: number);
  30136. push(value: T): void;
  30137. forEach(func: (content: T) => void): void;
  30138. sort(compareFn: (a: T, b: T) => number): void;
  30139. reset(): void;
  30140. dispose(): void;
  30141. concat(array: any): void;
  30142. indexOf(value: T): number;
  30143. contains(value: T): boolean;
  30144. private static _GlobalId;
  30145. }
  30146. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  30147. private _duplicateId;
  30148. [index: number]: T;
  30149. push(value: T): void;
  30150. pushNoDuplicate(value: T): boolean;
  30151. reset(): void;
  30152. concatWithNoDuplicate(array: any): void;
  30153. }
  30154. }
  30155. declare module BABYLON {
  30156. /**
  30157. * This class implement a typical dictionary using a string as key and the generic type T as value.
  30158. * The underlying implementation relies on an associative array to ensure the best performances.
  30159. * The value can be anything including 'null' but except 'undefined'
  30160. */
  30161. class StringDictionary<T> {
  30162. /**
  30163. * This will clear this dictionary and copy the content from the 'source' one.
  30164. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  30165. * @param source the dictionary to take the content from and copy to this dictionary
  30166. */
  30167. copyFrom(source: StringDictionary<T>): void;
  30168. /**
  30169. * Get a value based from its key
  30170. * @param key the given key to get the matching value from
  30171. * @return the value if found, otherwise undefined is returned
  30172. */
  30173. get(key: string): T | undefined;
  30174. /**
  30175. * Get a value from its key or add it if it doesn't exist.
  30176. * This method will ensure you that a given key/data will be present in the dictionary.
  30177. * @param key the given key to get the matching value from
  30178. * @param factory the factory that will create the value if the key is not present in the dictionary.
  30179. * The factory will only be invoked if there's no data for the given key.
  30180. * @return the value corresponding to the key.
  30181. */
  30182. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  30183. /**
  30184. * Get a value from its key if present in the dictionary otherwise add it
  30185. * @param key the key to get the value from
  30186. * @param val if there's no such key/value pair in the dictionary add it with this value
  30187. * @return the value corresponding to the key
  30188. */
  30189. getOrAdd(key: string, val: T): T;
  30190. /**
  30191. * Check if there's a given key in the dictionary
  30192. * @param key the key to check for
  30193. * @return true if the key is present, false otherwise
  30194. */
  30195. contains(key: string): boolean;
  30196. /**
  30197. * Add a new key and its corresponding value
  30198. * @param key the key to add
  30199. * @param value the value corresponding to the key
  30200. * @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
  30201. */
  30202. add(key: string, value: T): boolean;
  30203. set(key: string, value: T): boolean;
  30204. /**
  30205. * Get the element of the given key and remove it from the dictionary
  30206. * @param key
  30207. */
  30208. getAndRemove(key: string): Nullable<T>;
  30209. /**
  30210. * Remove a key/value from the dictionary.
  30211. * @param key the key to remove
  30212. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  30213. */
  30214. remove(key: string): boolean;
  30215. /**
  30216. * Clear the whole content of the dictionary
  30217. */
  30218. clear(): void;
  30219. readonly count: number;
  30220. /**
  30221. * Execute a callback on each key/val of the dictionary.
  30222. * Note that you can remove any element in this dictionary in the callback implementation
  30223. * @param callback the callback to execute on a given key/value pair
  30224. */
  30225. forEach(callback: (key: string, val: T) => void): void;
  30226. /**
  30227. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  30228. * If the callback returns null or undefined the method will iterate to the next key/value pair
  30229. * Note that you can remove any element in this dictionary in the callback implementation
  30230. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  30231. */
  30232. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  30233. private _count;
  30234. private _data;
  30235. }
  30236. }
  30237. declare module BABYLON {
  30238. class Tags {
  30239. static EnableFor(obj: any): void;
  30240. static DisableFor(obj: any): void;
  30241. static HasTags(obj: any): boolean;
  30242. static GetTags(obj: any, asString?: boolean): any;
  30243. static AddTagsTo(obj: any, tagsString: string): void;
  30244. static _AddTagTo(obj: any, tag: string): void;
  30245. static RemoveTagsFrom(obj: any, tagsString: string): void;
  30246. static _RemoveTagFrom(obj: any, tag: string): void;
  30247. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  30248. }
  30249. }
  30250. declare module BABYLON {
  30251. class TextureTools {
  30252. /**
  30253. * Uses the GPU to create a copy texture rescaled at a given size
  30254. * @param texture Texture to copy from
  30255. * @param width Desired width
  30256. * @param height Desired height
  30257. * @return Generated texture
  30258. */
  30259. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  30260. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  30261. private static _environmentBRDFBase64Texture;
  30262. }
  30263. }
  30264. declare module BABYLON {
  30265. class TGATools {
  30266. private static _TYPE_INDEXED;
  30267. private static _TYPE_RGB;
  30268. private static _TYPE_GREY;
  30269. private static _TYPE_RLE_INDEXED;
  30270. private static _TYPE_RLE_RGB;
  30271. private static _TYPE_RLE_GREY;
  30272. private static _ORIGIN_MASK;
  30273. private static _ORIGIN_SHIFT;
  30274. private static _ORIGIN_BL;
  30275. private static _ORIGIN_BR;
  30276. private static _ORIGIN_UL;
  30277. private static _ORIGIN_UR;
  30278. static GetTGAHeader(data: Uint8Array): any;
  30279. /**
  30280. * Uploads TGA content to a Babylon Texture
  30281. * @hidden
  30282. */
  30283. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  30284. 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;
  30285. 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;
  30286. 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;
  30287. 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;
  30288. 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;
  30289. 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;
  30290. }
  30291. }
  30292. declare module BABYLON {
  30293. interface IAnimatable {
  30294. animations: Array<Animation>;
  30295. }
  30296. /** Interface used by value gradients (color, factor, ...) */
  30297. interface IValueGradient {
  30298. /**
  30299. * Gets or sets the gradient value (between 0 and 1)
  30300. */
  30301. gradient: number;
  30302. }
  30303. /** Class used to store color gradient */
  30304. class ColorGradient implements IValueGradient {
  30305. /**
  30306. * Gets or sets the gradient value (between 0 and 1)
  30307. */
  30308. gradient: number;
  30309. /**
  30310. * Gets or sets first associated color
  30311. */
  30312. color1: Color4;
  30313. /**
  30314. * Gets or sets second associated color
  30315. */
  30316. color2?: Color4;
  30317. /**
  30318. * Will get a color picked randomly between color1 and color2.
  30319. * If color2 is undefined then color1 will be used
  30320. * @param result defines the target Color4 to store the result in
  30321. */
  30322. getColorToRef(result: Color4): void;
  30323. }
  30324. /** Class used to store factor gradient */
  30325. class FactorGradient implements IValueGradient {
  30326. /**
  30327. * Gets or sets the gradient value (between 0 and 1)
  30328. */
  30329. gradient: number;
  30330. /**
  30331. * Gets or sets first associated factor
  30332. */
  30333. factor1: number;
  30334. /**
  30335. * Gets or sets second associated factor
  30336. */
  30337. factor2?: number;
  30338. /**
  30339. * Will get a number picked randomly between factor1 and factor2.
  30340. * If factor2 is undefined then factor1 will be used
  30341. * @returns the picked number
  30342. */
  30343. getFactor(): number;
  30344. }
  30345. class LoadFileError extends Error {
  30346. request: XMLHttpRequest | undefined;
  30347. private static _setPrototypeOf;
  30348. constructor(message: string, request?: XMLHttpRequest | undefined);
  30349. }
  30350. class RetryStrategy {
  30351. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30352. }
  30353. interface IFileRequest {
  30354. /**
  30355. * Raised when the request is complete (success or error).
  30356. */
  30357. onCompleteObservable: Observable<IFileRequest>;
  30358. /**
  30359. * Aborts the request for a file.
  30360. */
  30361. abort: () => void;
  30362. }
  30363. class Tools {
  30364. static BaseUrl: string;
  30365. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30366. /**
  30367. * Default behaviour for cors in the application.
  30368. * It can be a string if the expected behavior is identical in the entire app.
  30369. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30370. */
  30371. static CorsBehavior: string | ((url: string | string[]) => string);
  30372. static UseFallbackTexture: boolean;
  30373. /**
  30374. * Use this object to register external classes like custom textures or material
  30375. * to allow the laoders to instantiate them
  30376. */
  30377. static RegisteredExternalClasses: {
  30378. [key: string]: Object;
  30379. };
  30380. static fallbackTexture: string;
  30381. /**
  30382. * Interpolates between a and b via alpha
  30383. * @param a The lower value (returned when alpha = 0)
  30384. * @param b The upper value (returned when alpha = 1)
  30385. * @param alpha The interpolation-factor
  30386. * @return The mixed value
  30387. */
  30388. static Mix(a: number, b: number, alpha: number): number;
  30389. static Instantiate(className: string): any;
  30390. /**
  30391. * Provides a slice function that will work even on IE
  30392. * @param data defines the array to slice
  30393. * @param start defines the start of the data (optional)
  30394. * @param end defines the end of the data (optional)
  30395. * @returns the new sliced array
  30396. */
  30397. static Slice<T>(data: T, start?: number, end?: number): T;
  30398. static SetImmediate(action: () => void): void;
  30399. static IsExponentOfTwo(value: number): boolean;
  30400. private static _tmpFloatArray;
  30401. /**
  30402. * Returns the nearest 32-bit single precision float representation of a Number
  30403. * @param value A Number. If the parameter is of a different type, it will get converted
  30404. * to a number or to NaN if it cannot be converted
  30405. * @returns number
  30406. */
  30407. static FloatRound(value: number): number;
  30408. /**
  30409. * Find the next highest power of two.
  30410. * @param x Number to start search from.
  30411. * @return Next highest power of two.
  30412. */
  30413. static CeilingPOT(x: number): number;
  30414. /**
  30415. * Find the next lowest power of two.
  30416. * @param x Number to start search from.
  30417. * @return Next lowest power of two.
  30418. */
  30419. static FloorPOT(x: number): number;
  30420. /**
  30421. * Find the nearest power of two.
  30422. * @param x Number to start search from.
  30423. * @return Next nearest power of two.
  30424. */
  30425. static NearestPOT(x: number): number;
  30426. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30427. static GetFilename(path: string): string;
  30428. /**
  30429. * Extracts the "folder" part of a path (everything before the filename).
  30430. * @param uri The URI to extract the info from
  30431. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30432. * @returns The "folder" part of the path
  30433. */
  30434. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30435. static GetDOMTextContent(element: HTMLElement): string;
  30436. static ToDegrees(angle: number): number;
  30437. static ToRadians(angle: number): number;
  30438. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30439. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30440. minimum: Vector3;
  30441. maximum: Vector3;
  30442. };
  30443. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30444. minimum: Vector3;
  30445. maximum: Vector3;
  30446. };
  30447. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  30448. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  30449. minimum: Vector2;
  30450. maximum: Vector2;
  30451. };
  30452. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30453. static GetPointerPrefix(): string;
  30454. /**
  30455. * @param func - the function to be called
  30456. * @param requester - the object that will request the next frame. Falls back to window.
  30457. */
  30458. static QueueNewFrame(func: () => void, requester?: any): number;
  30459. static RequestFullscreen(element: HTMLElement): void;
  30460. static ExitFullscreen(): void;
  30461. static SetCorsBehavior(url: string | string[], element: {
  30462. crossOrigin: string | null;
  30463. }): void;
  30464. static CleanUrl(url: string): string;
  30465. static PreprocessUrl: (url: string) => string;
  30466. /**
  30467. * Loads an image as an HTMLImageElement.
  30468. * @param input url string, ArrayBuffer, or Blob to load
  30469. * @param onLoad callback called when the image successfully loads
  30470. * @param onError callback called when the image fails to load
  30471. * @param database database for caching
  30472. * @returns the HTMLImageElement of the loaded image
  30473. */
  30474. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  30475. 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;
  30476. /**
  30477. * Load a script (identified by an url). When the url returns, the
  30478. * content of this file is added into a new script element, attached to the DOM (body element)
  30479. */
  30480. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30481. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30482. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30483. static FileAsURL(content: string): string;
  30484. static Format(value: number, decimals?: number): string;
  30485. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30486. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30487. static IsEmpty(obj: any): boolean;
  30488. static RegisterTopRootEvents(events: {
  30489. name: string;
  30490. handler: Nullable<(e: FocusEvent) => any>;
  30491. }[]): void;
  30492. static UnregisterTopRootEvents(events: {
  30493. name: string;
  30494. handler: Nullable<(e: FocusEvent) => any>;
  30495. }[]): void;
  30496. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30497. /**
  30498. * Converts the canvas data to blob.
  30499. * This acts as a polyfill for browsers not supporting the to blob function.
  30500. * @param canvas Defines the canvas to extract the data from
  30501. * @param successCallback Defines the callback triggered once the data are available
  30502. * @param mimeType Defines the mime type of the result
  30503. */
  30504. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30505. /**
  30506. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30507. * @param successCallback Defines the callback triggered once the data are available
  30508. * @param mimeType Defines the mime type of the result
  30509. * @param fileName The filename to download. If present, the result will automatically be downloaded
  30510. */
  30511. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30512. /**
  30513. * Downloads a blob in the browser
  30514. * @param blob defines the blob to download
  30515. * @param fileName defines the name of the downloaded file
  30516. */
  30517. static Download(blob: Blob, fileName: string): void;
  30518. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30519. /**
  30520. * Generates an image screenshot from the specified camera.
  30521. *
  30522. * @param engine The engine to use for rendering
  30523. * @param camera The camera to use for rendering
  30524. * @param size This parameter can be set to a single number or to an object with the
  30525. * following (optional) properties: precision, width, height. If a single number is passed,
  30526. * it will be used for both width and height. If an object is passed, the screenshot size
  30527. * will be derived from the parameters. The precision property is a multiplier allowing
  30528. * rendering at a higher or lower resolution.
  30529. * @param successCallback The callback receives a single parameter which contains the
  30530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30531. * src parameter of an <img> to display it.
  30532. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30533. * Check your browser for supported MIME types.
  30534. * @param samples Texture samples (default: 1)
  30535. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30536. * @param fileName A name for for the downloaded file.
  30537. * @constructor
  30538. */
  30539. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30540. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  30541. /**
  30542. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30543. * Be aware Math.random() could cause collisions, but:
  30544. * "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"
  30545. */
  30546. static RandomId(): string;
  30547. /**
  30548. * Test if the given uri is a base64 string.
  30549. * @param uri The uri to test
  30550. * @return True if the uri is a base64 string or false otherwise.
  30551. */
  30552. static IsBase64(uri: string): boolean;
  30553. /**
  30554. * Decode the given base64 uri.
  30555. * @param uri The uri to decode
  30556. * @return The decoded base64 data.
  30557. */
  30558. static DecodeBase64(uri: string): ArrayBuffer;
  30559. private static _NoneLogLevel;
  30560. private static _MessageLogLevel;
  30561. private static _WarningLogLevel;
  30562. private static _ErrorLogLevel;
  30563. private static _LogCache;
  30564. static errorsCount: number;
  30565. static OnNewCacheEntry: (entry: string) => void;
  30566. static readonly NoneLogLevel: number;
  30567. static readonly MessageLogLevel: number;
  30568. static readonly WarningLogLevel: number;
  30569. static readonly ErrorLogLevel: number;
  30570. static readonly AllLogLevel: number;
  30571. private static _AddLogEntry(entry);
  30572. private static _FormatMessage(message);
  30573. private static _LogDisabled(message);
  30574. private static _LogEnabled(message);
  30575. private static _WarnDisabled(message);
  30576. private static _WarnEnabled(message);
  30577. private static _ErrorDisabled(message);
  30578. private static _ErrorEnabled(message);
  30579. static Log: (message: string) => void;
  30580. static Warn: (message: string) => void;
  30581. static Error: (message: string) => void;
  30582. static readonly LogCache: string;
  30583. static ClearLogCache(): void;
  30584. static LogLevels: number;
  30585. static IsWindowObjectExist(): boolean;
  30586. private static _PerformanceNoneLogLevel;
  30587. private static _PerformanceUserMarkLogLevel;
  30588. private static _PerformanceConsoleLogLevel;
  30589. private static _performance;
  30590. static readonly PerformanceNoneLogLevel: number;
  30591. static readonly PerformanceUserMarkLogLevel: number;
  30592. static readonly PerformanceConsoleLogLevel: number;
  30593. static PerformanceLogLevel: number;
  30594. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30595. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30596. static _StartUserMark(counterName: string, condition?: boolean): void;
  30597. static _EndUserMark(counterName: string, condition?: boolean): void;
  30598. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  30599. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  30600. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30601. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30602. static readonly Now: number;
  30603. /**
  30604. * This method will return the name of the class used to create the instance of the given object.
  30605. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30606. * @param object the object to get the class name from
  30607. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  30608. */
  30609. static GetClassName(object: any, isType?: boolean): string;
  30610. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30611. /**
  30612. * This method will return the name of the full name of the class, including its owning module (if any).
  30613. * 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).
  30614. * @param object the object to get the class name from
  30615. * @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.
  30616. */
  30617. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30618. /**
  30619. * 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.
  30620. * @param array
  30621. */
  30622. static arrayOrStringFeeder(array: any): (i: number) => number;
  30623. /**
  30624. * Compute the hashCode of a stream of number
  30625. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  30626. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  30627. * @return the hash code computed
  30628. */
  30629. static hashCodeFromStream(feeder: (index: number) => number): number;
  30630. /**
  30631. * Returns a promise that resolves after the given amount of time.
  30632. * @param delay Number of milliseconds to delay
  30633. * @returns Promise that resolves after the given amount of time
  30634. */
  30635. static DelayAsync(delay: number): Promise<void>;
  30636. /**
  30637. * Gets the current gradient from an array of IValueGradient
  30638. * @param ratio defines the current ratio to get
  30639. * @param gradients defines the array of IValueGradient
  30640. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30641. */
  30642. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30643. }
  30644. /**
  30645. * This class is used to track a performance counter which is number based.
  30646. * The user has access to many properties which give statistics of different nature
  30647. *
  30648. * The implementer can track two kinds of Performance Counter: time and count
  30649. * 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.
  30650. * 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.
  30651. */
  30652. class PerfCounter {
  30653. static Enabled: boolean;
  30654. /**
  30655. * Returns the smallest value ever
  30656. */
  30657. readonly min: number;
  30658. /**
  30659. * Returns the biggest value ever
  30660. */
  30661. readonly max: number;
  30662. /**
  30663. * Returns the average value since the performance counter is running
  30664. */
  30665. readonly average: number;
  30666. /**
  30667. * Returns the average value of the last second the counter was monitored
  30668. */
  30669. readonly lastSecAverage: number;
  30670. /**
  30671. * Returns the current value
  30672. */
  30673. readonly current: number;
  30674. readonly total: number;
  30675. readonly count: number;
  30676. constructor();
  30677. /**
  30678. * Call this method to start monitoring a new frame.
  30679. * 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.
  30680. */
  30681. fetchNewFrame(): void;
  30682. /**
  30683. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30684. * @param newCount the count value to add to the monitored count
  30685. * @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.
  30686. */
  30687. addCount(newCount: number, fetchResult: boolean): void;
  30688. /**
  30689. * Start monitoring this performance counter
  30690. */
  30691. beginMonitoring(): void;
  30692. /**
  30693. * Compute the time lapsed since the previous beginMonitoring() call.
  30694. * @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
  30695. */
  30696. endMonitoring(newFrame?: boolean): void;
  30697. private _fetchResult();
  30698. private _startMonitoringTime;
  30699. private _min;
  30700. private _max;
  30701. private _average;
  30702. private _current;
  30703. private _totalValueCount;
  30704. private _totalAccumulated;
  30705. private _lastSecAverage;
  30706. private _lastSecAccumulated;
  30707. private _lastSecTime;
  30708. private _lastSecValueCount;
  30709. }
  30710. /**
  30711. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30712. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30713. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30714. * @param name The name of the class, case should be preserved
  30715. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30716. */
  30717. function className(name: string, module?: string): (target: Object) => void;
  30718. /**
  30719. * An implementation of a loop for asynchronous functions.
  30720. */
  30721. class AsyncLoop {
  30722. iterations: number;
  30723. private _fn;
  30724. private _successCallback;
  30725. index: number;
  30726. private _done;
  30727. /**
  30728. * Constroctor.
  30729. * @param iterations the number of iterations.
  30730. * @param _fn the function to run each iteration
  30731. * @param _successCallback the callback that will be called upon succesful execution
  30732. * @param offset starting offset.
  30733. */
  30734. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  30735. /**
  30736. * Execute the next iteration. Must be called after the last iteration was finished.
  30737. */
  30738. executeNext(): void;
  30739. /**
  30740. * Break the loop and run the success callback.
  30741. */
  30742. breakLoop(): void;
  30743. /**
  30744. * Helper function
  30745. */
  30746. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  30747. /**
  30748. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30749. * @param iterations total number of iterations
  30750. * @param syncedIterations number of synchronous iterations in each async iteration.
  30751. * @param fn the function to call each iteration.
  30752. * @param callback a success call back that will be called when iterating stops.
  30753. * @param breakFunction a break condition (optional)
  30754. * @param timeout timeout settings for the setTimeout function. default - 0.
  30755. * @constructor
  30756. */
  30757. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  30758. }
  30759. }
  30760. declare module BABYLON {
  30761. /**
  30762. * Defines the potential axis of a Joystick
  30763. */
  30764. enum JoystickAxis {
  30765. /** X axis */
  30766. X = 0,
  30767. /** Y axis */
  30768. Y = 1,
  30769. /** Z axis */
  30770. Z = 2,
  30771. }
  30772. /**
  30773. * Class used to define virtual joystick (used in touch mode)
  30774. */
  30775. class VirtualJoystick {
  30776. /**
  30777. * Gets or sets a boolean indicating that left and right values must be inverted
  30778. */
  30779. reverseLeftRight: boolean;
  30780. /**
  30781. * Gets or sets a boolean indicating that up and down values must be inverted
  30782. */
  30783. reverseUpDown: boolean;
  30784. /**
  30785. * Gets the offset value for the position (ie. the change of the position value)
  30786. */
  30787. deltaPosition: Vector3;
  30788. /**
  30789. * Gets a boolean indicating if the virtual joystick was pressed
  30790. */
  30791. pressed: boolean;
  30792. private static _globalJoystickIndex;
  30793. private static vjCanvas;
  30794. private static vjCanvasContext;
  30795. private static vjCanvasWidth;
  30796. private static vjCanvasHeight;
  30797. private static halfWidth;
  30798. private _action;
  30799. private _axisTargetedByLeftAndRight;
  30800. private _axisTargetedByUpAndDown;
  30801. private _joystickSensibility;
  30802. private _inversedSensibility;
  30803. private _joystickPointerID;
  30804. private _joystickColor;
  30805. private _joystickPointerPos;
  30806. private _joystickPreviousPointerPos;
  30807. private _joystickPointerStartPos;
  30808. private _deltaJoystickVector;
  30809. private _leftJoystick;
  30810. private _touches;
  30811. private _onPointerDownHandlerRef;
  30812. private _onPointerMoveHandlerRef;
  30813. private _onPointerUpHandlerRef;
  30814. private _onResize;
  30815. /**
  30816. * Creates a new virtual joystick
  30817. * @param leftJoystick defines that the joystick is for left hand (false by default)
  30818. */
  30819. constructor(leftJoystick?: boolean);
  30820. /**
  30821. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  30822. * @param newJoystickSensibility defines the new sensibility
  30823. */
  30824. setJoystickSensibility(newJoystickSensibility: number): void;
  30825. private _onPointerDown(e);
  30826. private _onPointerMove(e);
  30827. private _onPointerUp(e);
  30828. /**
  30829. * Change the color of the virtual joystick
  30830. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  30831. */
  30832. setJoystickColor(newColor: string): void;
  30833. /**
  30834. * Defines a callback to call when the joystick is touched
  30835. * @param action defines the callback
  30836. */
  30837. setActionOnTouch(action: () => any): void;
  30838. /**
  30839. * Defines which axis you'd like to control for left & right
  30840. * @param axis defines the axis to use
  30841. */
  30842. setAxisForLeftRight(axis: JoystickAxis): void;
  30843. /**
  30844. * Defines which axis you'd like to control for up & down
  30845. * @param axis defines the axis to use
  30846. */
  30847. setAxisForUpDown(axis: JoystickAxis): void;
  30848. private _drawVirtualJoystick();
  30849. /**
  30850. * Release internal HTML canvas
  30851. */
  30852. releaseCanvas(): void;
  30853. }
  30854. }
  30855. declare module BABYLON {
  30856. /**
  30857. * Helper class to push actions to a pool of workers.
  30858. */
  30859. class WorkerPool implements IDisposable {
  30860. private _workerInfos;
  30861. private _pendingActions;
  30862. /**
  30863. * Constructor
  30864. * @param workers Array of workers to use for actions
  30865. */
  30866. constructor(workers: Array<Worker>);
  30867. /**
  30868. * Terminates all workers and clears any pending actions.
  30869. */
  30870. dispose(): void;
  30871. /**
  30872. * Pushes an action to the worker pool. If all the workers are active, the action will be
  30873. * pended until a worker has completed its action.
  30874. * @param action The action to perform. Call onComplete when the action is complete.
  30875. */
  30876. push(action: (worker: Worker, onComplete: () => void) => void): void;
  30877. private _execute(workerInfo, action);
  30878. }
  30879. }
  30880. declare module BABYLON {
  30881. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  30882. readonly name: string;
  30883. private _zoomStopsAnimation;
  30884. private _idleRotationSpeed;
  30885. private _idleRotationWaitTime;
  30886. private _idleRotationSpinupTime;
  30887. /**
  30888. * Gets the flag that indicates if user zooming should stop animation.
  30889. */
  30890. /**
  30891. * Sets the flag that indicates if user zooming should stop animation.
  30892. */
  30893. zoomStopsAnimation: boolean;
  30894. /**
  30895. * Gets the default speed at which the camera rotates around the model.
  30896. */
  30897. /**
  30898. * Sets the default speed at which the camera rotates around the model.
  30899. */
  30900. idleRotationSpeed: number;
  30901. /**
  30902. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  30903. */
  30904. /**
  30905. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  30906. */
  30907. idleRotationWaitTime: number;
  30908. /**
  30909. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30910. */
  30911. /**
  30912. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30913. */
  30914. idleRotationSpinupTime: number;
  30915. /**
  30916. * Gets a value indicating if the camera is currently rotating because of this behavior
  30917. */
  30918. readonly rotationInProgress: boolean;
  30919. private _onPrePointerObservableObserver;
  30920. private _onAfterCheckInputsObserver;
  30921. private _attachedCamera;
  30922. private _isPointerDown;
  30923. private _lastFrameTime;
  30924. private _lastInteractionTime;
  30925. private _cameraRotationSpeed;
  30926. init(): void;
  30927. attach(camera: ArcRotateCamera): void;
  30928. detach(): void;
  30929. /**
  30930. * Returns true if user is scrolling.
  30931. * @return true if user is scrolling.
  30932. */
  30933. private _userIsZooming();
  30934. private _lastFrameRadius;
  30935. private _shouldAnimationStopForInteraction();
  30936. /**
  30937. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30938. */
  30939. private _applyUserInteraction();
  30940. private _userIsMoving();
  30941. }
  30942. }
  30943. declare module BABYLON {
  30944. /**
  30945. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  30946. */
  30947. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  30948. readonly name: string;
  30949. /**
  30950. * The easing function used by animations
  30951. */
  30952. static EasingFunction: BackEase;
  30953. /**
  30954. * The easing mode used by animations
  30955. */
  30956. static EasingMode: number;
  30957. /**
  30958. * The duration of the animation, in milliseconds
  30959. */
  30960. transitionDuration: number;
  30961. /**
  30962. * Length of the distance animated by the transition when lower radius is reached
  30963. */
  30964. lowerRadiusTransitionRange: number;
  30965. /**
  30966. * Length of the distance animated by the transition when upper radius is reached
  30967. */
  30968. upperRadiusTransitionRange: number;
  30969. private _autoTransitionRange;
  30970. /**
  30971. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30972. */
  30973. /**
  30974. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30975. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  30976. */
  30977. autoTransitionRange: boolean;
  30978. private _attachedCamera;
  30979. private _onAfterCheckInputsObserver;
  30980. private _onMeshTargetChangedObserver;
  30981. init(): void;
  30982. attach(camera: ArcRotateCamera): void;
  30983. detach(): void;
  30984. private _radiusIsAnimating;
  30985. private _radiusBounceTransition;
  30986. private _animatables;
  30987. private _cachedWheelPrecision;
  30988. /**
  30989. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  30990. * @param radiusLimit The limit to check against.
  30991. * @return Bool to indicate if at limit.
  30992. */
  30993. private _isRadiusAtLimit(radiusLimit);
  30994. /**
  30995. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  30996. * @param radiusDelta The delta by which to animate to. Can be negative.
  30997. */
  30998. private _applyBoundRadiusAnimation(radiusDelta);
  30999. /**
  31000. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  31001. */
  31002. protected _clearAnimationLocks(): void;
  31003. /**
  31004. * Stops and removes all animations that have been applied to the camera
  31005. */
  31006. stopAllAnimations(): void;
  31007. }
  31008. }
  31009. declare module BABYLON {
  31010. class FramingBehavior implements Behavior<ArcRotateCamera> {
  31011. readonly name: string;
  31012. private _mode;
  31013. private _radiusScale;
  31014. private _positionScale;
  31015. private _defaultElevation;
  31016. private _elevationReturnTime;
  31017. private _elevationReturnWaitTime;
  31018. private _zoomStopsAnimation;
  31019. private _framingTime;
  31020. /**
  31021. * The easing function used by animations
  31022. */
  31023. static EasingFunction: ExponentialEase;
  31024. /**
  31025. * The easing mode used by animations
  31026. */
  31027. static EasingMode: number;
  31028. /**
  31029. * Gets current mode used by the behavior.
  31030. */
  31031. /**
  31032. * Sets the current mode used by the behavior
  31033. */
  31034. mode: number;
  31035. /**
  31036. * Gets the scale applied to the radius
  31037. */
  31038. /**
  31039. * Sets the scale applied to the radius (1 by default)
  31040. */
  31041. radiusScale: number;
  31042. /**
  31043. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31044. */
  31045. /**
  31046. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31047. */
  31048. positionScale: number;
  31049. /**
  31050. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31051. * behaviour is triggered, in radians.
  31052. */
  31053. /**
  31054. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31055. * behaviour is triggered, in radians.
  31056. */
  31057. defaultElevation: number;
  31058. /**
  31059. * Gets the time (in milliseconds) taken to return to the default beta position.
  31060. * Negative value indicates camera should not return to default.
  31061. */
  31062. /**
  31063. * Sets the time (in milliseconds) taken to return to the default beta position.
  31064. * Negative value indicates camera should not return to default.
  31065. */
  31066. elevationReturnTime: number;
  31067. /**
  31068. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31069. */
  31070. /**
  31071. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31072. */
  31073. elevationReturnWaitTime: number;
  31074. /**
  31075. * Gets the flag that indicates if user zooming should stop animation.
  31076. */
  31077. /**
  31078. * Sets the flag that indicates if user zooming should stop animation.
  31079. */
  31080. zoomStopsAnimation: boolean;
  31081. /**
  31082. * Gets the transition time when framing the mesh, in milliseconds
  31083. */
  31084. /**
  31085. * Sets the transition time when framing the mesh, in milliseconds
  31086. */
  31087. framingTime: number;
  31088. private _onPrePointerObservableObserver;
  31089. private _onAfterCheckInputsObserver;
  31090. private _onMeshTargetChangedObserver;
  31091. private _attachedCamera;
  31092. private _isPointerDown;
  31093. private _lastInteractionTime;
  31094. init(): void;
  31095. attach(camera: ArcRotateCamera): void;
  31096. detach(): void;
  31097. private _animatables;
  31098. private _betaIsAnimating;
  31099. private _betaTransition;
  31100. private _radiusTransition;
  31101. private _vectorTransition;
  31102. /**
  31103. * Targets the given mesh and updates zoom level accordingly.
  31104. * @param mesh The mesh to target.
  31105. * @param radius Optional. If a cached radius position already exists, overrides default.
  31106. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31107. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31108. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31109. */
  31110. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31111. /**
  31112. * Targets the given mesh with its children and updates zoom level accordingly.
  31113. * @param mesh The mesh to target.
  31114. * @param radius Optional. If a cached radius position already exists, overrides default.
  31115. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31116. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31117. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31118. */
  31119. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31120. /**
  31121. * Targets the given meshes with their children and updates zoom level accordingly.
  31122. * @param meshes The mesh to target.
  31123. * @param radius Optional. If a cached radius position already exists, overrides default.
  31124. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31125. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31126. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31127. */
  31128. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31129. /**
  31130. * Targets the given mesh and updates zoom level accordingly.
  31131. * @param mesh The mesh to target.
  31132. * @param radius Optional. If a cached radius position already exists, overrides default.
  31133. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31134. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31135. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31136. */
  31137. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31138. /**
  31139. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  31140. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  31141. * frustum width.
  31142. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  31143. * to fully enclose the mesh in the viewing frustum.
  31144. */
  31145. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  31146. /**
  31147. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  31148. * is automatically returned to its default position (expected to be above ground plane).
  31149. */
  31150. private _maintainCameraAboveGround();
  31151. /**
  31152. * Returns the frustum slope based on the canvas ratio and camera FOV
  31153. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  31154. */
  31155. private _getFrustumSlope();
  31156. /**
  31157. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  31158. */
  31159. private _clearAnimationLocks();
  31160. /**
  31161. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31162. */
  31163. private _applyUserInteraction();
  31164. /**
  31165. * Stops and removes all animations that have been applied to the camera
  31166. */
  31167. stopAllAnimations(): void;
  31168. /**
  31169. * Gets a value indicating if the user is moving the camera
  31170. */
  31171. readonly isUserIsMoving: boolean;
  31172. /**
  31173. * The camera can move all the way towards the mesh.
  31174. */
  31175. static IgnoreBoundsSizeMode: number;
  31176. /**
  31177. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  31178. */
  31179. static FitFrustumSidesMode: number;
  31180. }
  31181. }
  31182. declare module BABYLON {
  31183. /**
  31184. * A behavior that when attached to a mesh will allow the mesh to be scaled
  31185. */
  31186. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  31187. private _dragBehaviorA;
  31188. private _dragBehaviorB;
  31189. private _startDistance;
  31190. private _initialScale;
  31191. private _targetScale;
  31192. private _ownerNode;
  31193. private _sceneRenderObserver;
  31194. constructor();
  31195. /**
  31196. * The name of the behavior
  31197. */
  31198. readonly name: string;
  31199. /**
  31200. * Initializes the behavior
  31201. */
  31202. init(): void;
  31203. private _getCurrentDistance();
  31204. /**
  31205. * Attaches the scale behavior the passed in mesh
  31206. * @param ownerNode The mesh that will be scaled around once attached
  31207. */
  31208. attach(ownerNode: Mesh): void;
  31209. /**
  31210. * Detaches the behavior from the mesh
  31211. */
  31212. detach(): void;
  31213. }
  31214. }
  31215. declare module BABYLON {
  31216. /**
  31217. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  31218. */
  31219. class PointerDragBehavior implements Behavior<Mesh> {
  31220. private _attachedNode;
  31221. private _dragPlane;
  31222. private _scene;
  31223. private _pointerObserver;
  31224. private static _planeScene;
  31225. /**
  31226. * 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)
  31227. */
  31228. maxDragAngle: number;
  31229. /**
  31230. * @hidden
  31231. */
  31232. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  31233. /**
  31234. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31235. */
  31236. currentDraggingPointerID: number;
  31237. /**
  31238. * The last position where the pointer hit the drag plane in world space
  31239. */
  31240. lastDragPosition: Vector3;
  31241. /**
  31242. * If the behavior is currently in a dragging state
  31243. */
  31244. dragging: boolean;
  31245. /**
  31246. * 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)
  31247. */
  31248. dragDeltaRatio: number;
  31249. /**
  31250. * If the drag plane orientation should be updated during the dragging (Default: true)
  31251. */
  31252. updateDragPlane: boolean;
  31253. private _debugMode;
  31254. private _moving;
  31255. /**
  31256. * Fires each time the attached mesh is dragged with the pointer
  31257. * * delta between last drag position and current drag position in world space
  31258. * * dragDistance along the drag axis
  31259. * * dragPlaneNormal normal of the current drag plane used during the drag
  31260. * * dragPlanePoint in world space where the drag intersects the drag plane
  31261. */
  31262. onDragObservable: Observable<{
  31263. delta: Vector3;
  31264. dragPlanePoint: Vector3;
  31265. dragPlaneNormal: Vector3;
  31266. dragDistance: number;
  31267. pointerId: number;
  31268. }>;
  31269. /**
  31270. * Fires each time a drag begins (eg. mouse down on mesh)
  31271. */
  31272. onDragStartObservable: Observable<{
  31273. dragPlanePoint: Vector3;
  31274. pointerId: number;
  31275. }>;
  31276. /**
  31277. * Fires each time a drag ends (eg. mouse release after drag)
  31278. */
  31279. onDragEndObservable: Observable<{
  31280. dragPlanePoint: Vector3;
  31281. pointerId: number;
  31282. }>;
  31283. /**
  31284. * If the attached mesh should be moved when dragged
  31285. */
  31286. moveAttached: boolean;
  31287. /**
  31288. * If the drag behavior will react to drag events (Default: true)
  31289. */
  31290. enabled: boolean;
  31291. /**
  31292. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  31293. */
  31294. useObjectOrienationForDragging: boolean;
  31295. private _options;
  31296. /**
  31297. * Creates a pointer drag behavior that can be attached to a mesh
  31298. * @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)
  31299. */
  31300. constructor(options?: {
  31301. dragAxis?: Vector3;
  31302. dragPlaneNormal?: Vector3;
  31303. });
  31304. /**
  31305. * The name of the behavior
  31306. */
  31307. readonly name: string;
  31308. /**
  31309. * Initializes the behavior
  31310. */
  31311. init(): void;
  31312. private _tmpVector;
  31313. private _alternatePickedPoint;
  31314. private _worldDragAxis;
  31315. /**
  31316. * Attaches the drag behavior the passed in mesh
  31317. * @param ownerNode The mesh that will be dragged around once attached
  31318. */
  31319. attach(ownerNode: Mesh): void;
  31320. releaseDrag(): void;
  31321. private _pickWithRayOnDragPlane(ray);
  31322. private _pointA;
  31323. private _pointB;
  31324. private _pointC;
  31325. private _lineA;
  31326. private _lineB;
  31327. private _localAxis;
  31328. private _lookAt;
  31329. private _updateDragPlanePosition(ray, dragPlanePosition);
  31330. /**
  31331. * Detaches the behavior from the mesh
  31332. */
  31333. detach(): void;
  31334. }
  31335. }
  31336. declare module BABYLON {
  31337. /**
  31338. * 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
  31339. */
  31340. class SixDofDragBehavior implements Behavior<Mesh> {
  31341. private static _virtualScene;
  31342. private _ownerNode;
  31343. private _sceneRenderObserver;
  31344. private _scene;
  31345. private _targetPosition;
  31346. private _virtualOriginMesh;
  31347. private _virtualDragMesh;
  31348. private _pointerObserver;
  31349. private _moving;
  31350. private _startingOrientation;
  31351. /**
  31352. * 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)
  31353. */
  31354. private zDragFactor;
  31355. /**
  31356. * If the behavior is currently in a dragging state
  31357. */
  31358. dragging: boolean;
  31359. /**
  31360. * 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)
  31361. */
  31362. dragDeltaRatio: number;
  31363. /**
  31364. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31365. */
  31366. currentDraggingPointerID: number;
  31367. constructor();
  31368. /**
  31369. * The name of the behavior
  31370. */
  31371. readonly name: string;
  31372. /**
  31373. * Initializes the behavior
  31374. */
  31375. init(): void;
  31376. /**
  31377. * Attaches the scale behavior the passed in mesh
  31378. * @param ownerNode The mesh that will be scaled around once attached
  31379. */
  31380. attach(ownerNode: Mesh): void;
  31381. /**
  31382. * Detaches the behavior from the mesh
  31383. */
  31384. detach(): void;
  31385. }
  31386. }
  31387. declare module BABYLON {
  31388. interface IOctreeContainer<T> {
  31389. blocks: Array<OctreeBlock<T>>;
  31390. }
  31391. class Octree<T> {
  31392. maxDepth: number;
  31393. blocks: Array<OctreeBlock<T>>;
  31394. dynamicContent: T[];
  31395. private _maxBlockCapacity;
  31396. private _selectionContent;
  31397. private _creationFunc;
  31398. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  31399. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  31400. addMesh(entry: T): void;
  31401. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  31402. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  31403. intersectsRay(ray: Ray): SmartArray<T>;
  31404. 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;
  31405. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  31406. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  31407. }
  31408. }
  31409. declare module BABYLON {
  31410. class OctreeBlock<T> {
  31411. entries: T[];
  31412. blocks: Array<OctreeBlock<T>>;
  31413. private _depth;
  31414. private _maxDepth;
  31415. private _capacity;
  31416. private _minPoint;
  31417. private _maxPoint;
  31418. private _boundingVectors;
  31419. private _creationFunc;
  31420. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  31421. readonly capacity: number;
  31422. readonly minPoint: Vector3;
  31423. readonly maxPoint: Vector3;
  31424. addEntry(entry: T): void;
  31425. addEntries(entries: T[]): void;
  31426. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31427. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31428. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  31429. createInnerBlocks(): void;
  31430. }
  31431. }
  31432. declare module BABYLON {
  31433. interface Engine {
  31434. /**
  31435. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  31436. * @return the new query
  31437. */
  31438. createQuery(): WebGLQuery;
  31439. /**
  31440. * Delete and release a webGL query
  31441. * @param query defines the query to delete
  31442. * @return the current engine
  31443. */
  31444. deleteQuery(query: WebGLQuery): Engine;
  31445. /**
  31446. * Check if a given query has resolved and got its value
  31447. * @param query defines the query to check
  31448. * @returns true if the query got its value
  31449. */
  31450. isQueryResultAvailable(query: WebGLQuery): boolean;
  31451. /**
  31452. * Gets the value of a given query
  31453. * @param query defines the query to check
  31454. * @returns the value of the query
  31455. */
  31456. getQueryResult(query: WebGLQuery): number;
  31457. /**
  31458. * Initiates an occlusion query
  31459. * @param algorithmType defines the algorithm to use
  31460. * @param query defines the query to use
  31461. * @returns the current engine
  31462. * @see http://doc.babylonjs.com/features/occlusionquery
  31463. */
  31464. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  31465. /**
  31466. * Ends an occlusion query
  31467. * @see http://doc.babylonjs.com/features/occlusionquery
  31468. * @param algorithmType defines the algorithm to use
  31469. * @returns the current engine
  31470. */
  31471. endOcclusionQuery(algorithmType: number): Engine;
  31472. /**
  31473. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  31474. * Please note that only one query can be issued at a time
  31475. * @returns a time token used to track the time span
  31476. */
  31477. startTimeQuery(): Nullable<_TimeToken>;
  31478. /**
  31479. * Ends a time query
  31480. * @param token defines the token used to measure the time span
  31481. * @returns the time spent (in ns)
  31482. */
  31483. endTimeQuery(token: _TimeToken): int;
  31484. /** @hidden */
  31485. _currentNonTimestampToken: Nullable<_TimeToken>;
  31486. /** @hidden */
  31487. _createTimeQuery(): WebGLQuery;
  31488. /** @hidden */
  31489. _deleteTimeQuery(query: WebGLQuery): void;
  31490. /** @hidden */
  31491. _getGlAlgorithmType(algorithmType: number): number;
  31492. /** @hidden */
  31493. _getTimeQueryResult(query: WebGLQuery): any;
  31494. /** @hidden */
  31495. _getTimeQueryAvailability(query: WebGLQuery): any;
  31496. }
  31497. }
  31498. declare module BABYLON {
  31499. interface Engine {
  31500. /**
  31501. * Creates a webGL transform feedback object
  31502. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  31503. * @returns the webGL transform feedback object
  31504. */
  31505. createTransformFeedback(): WebGLTransformFeedback;
  31506. /**
  31507. * Delete a webGL transform feedback object
  31508. * @param value defines the webGL transform feedback object to delete
  31509. */
  31510. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  31511. /**
  31512. * Bind a webGL transform feedback object to the webgl context
  31513. * @param value defines the webGL transform feedback object to bind
  31514. */
  31515. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  31516. /**
  31517. * Begins a transform feedback operation
  31518. * @param usePoints defines if points or triangles must be used
  31519. */
  31520. beginTransformFeedback(usePoints: boolean): void;
  31521. /**
  31522. * Ends a transform feedback operation
  31523. */
  31524. endTransformFeedback(): void;
  31525. /**
  31526. * Specify the varyings to use with transform feedback
  31527. * @param program defines the associated webGL program
  31528. * @param value defines the list of strings representing the varying names
  31529. */
  31530. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  31531. /**
  31532. * Bind a webGL buffer for a transform feedback operation
  31533. * @param value defines the webGL buffer to bind
  31534. */
  31535. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  31536. }
  31537. }
  31538. declare module BABYLON {
  31539. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31540. camera: ArcRotateCamera;
  31541. gamepad: Nullable<Gamepad>;
  31542. private _onGamepadConnectedObserver;
  31543. private _onGamepadDisconnectedObserver;
  31544. gamepadRotationSensibility: number;
  31545. gamepadMoveSensibility: number;
  31546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31547. detachControl(element: Nullable<HTMLElement>): void;
  31548. checkInputs(): void;
  31549. getClassName(): string;
  31550. getSimpleName(): string;
  31551. }
  31552. }
  31553. declare module BABYLON {
  31554. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31555. camera: ArcRotateCamera;
  31556. private _keys;
  31557. keysUp: number[];
  31558. keysDown: number[];
  31559. keysLeft: number[];
  31560. keysRight: number[];
  31561. keysReset: number[];
  31562. panningSensibility: number;
  31563. zoomingSensibility: number;
  31564. useAltToZoom: boolean;
  31565. private _ctrlPressed;
  31566. private _altPressed;
  31567. private _onCanvasBlurObserver;
  31568. private _onKeyboardObserver;
  31569. private _engine;
  31570. private _scene;
  31571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31572. detachControl(element: Nullable<HTMLElement>): void;
  31573. checkInputs(): void;
  31574. getClassName(): string;
  31575. getSimpleName(): string;
  31576. }
  31577. }
  31578. declare module BABYLON {
  31579. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31580. camera: ArcRotateCamera;
  31581. private _wheel;
  31582. private _observer;
  31583. wheelPrecision: number;
  31584. /**
  31585. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31586. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31587. */
  31588. wheelDeltaPercentage: number;
  31589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31590. detachControl(element: Nullable<HTMLElement>): void;
  31591. getClassName(): string;
  31592. getSimpleName(): string;
  31593. }
  31594. }
  31595. declare module BABYLON {
  31596. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31597. camera: ArcRotateCamera;
  31598. buttons: number[];
  31599. angularSensibilityX: number;
  31600. angularSensibilityY: number;
  31601. pinchPrecision: number;
  31602. /**
  31603. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31604. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31605. */
  31606. pinchDeltaPercentage: number;
  31607. panningSensibility: number;
  31608. multiTouchPanning: boolean;
  31609. multiTouchPanAndZoom: boolean;
  31610. private _isPanClick;
  31611. pinchInwards: boolean;
  31612. private _pointerInput;
  31613. private _observer;
  31614. private _onMouseMove;
  31615. private _onGestureStart;
  31616. private _onGesture;
  31617. private _MSGestureHandler;
  31618. private _onLostFocus;
  31619. private _onContextMenu;
  31620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31621. detachControl(element: Nullable<HTMLElement>): void;
  31622. getClassName(): string;
  31623. getSimpleName(): string;
  31624. }
  31625. }
  31626. declare module BABYLON {
  31627. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  31628. camera: ArcRotateCamera;
  31629. alphaCorrection: number;
  31630. betaCorrection: number;
  31631. gammaCorrection: number;
  31632. private _alpha;
  31633. private _gamma;
  31634. private _dirty;
  31635. private _deviceOrientationHandler;
  31636. constructor();
  31637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31638. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  31639. checkInputs(): void;
  31640. detachControl(element: Nullable<HTMLElement>): void;
  31641. getClassName(): string;
  31642. getSimpleName(): string;
  31643. }
  31644. }
  31645. declare module BABYLON {
  31646. /**
  31647. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  31648. * Screen rotation is taken into account.
  31649. */
  31650. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  31651. private _camera;
  31652. private _screenOrientationAngle;
  31653. private _constantTranform;
  31654. private _screenQuaternion;
  31655. private _alpha;
  31656. private _beta;
  31657. private _gamma;
  31658. constructor();
  31659. camera: FreeCamera;
  31660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31661. private _orientationChanged;
  31662. private _deviceOrientation;
  31663. detachControl(element: Nullable<HTMLElement>): void;
  31664. checkInputs(): void;
  31665. getClassName(): string;
  31666. getSimpleName(): string;
  31667. }
  31668. }
  31669. declare module BABYLON {
  31670. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  31671. camera: FreeCamera;
  31672. gamepad: Nullable<Gamepad>;
  31673. private _onGamepadConnectedObserver;
  31674. private _onGamepadDisconnectedObserver;
  31675. gamepadAngularSensibility: number;
  31676. gamepadMoveSensibility: number;
  31677. private _cameraTransform;
  31678. private _deltaTransform;
  31679. private _vector3;
  31680. private _vector2;
  31681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31682. detachControl(element: Nullable<HTMLElement>): void;
  31683. checkInputs(): void;
  31684. getClassName(): string;
  31685. getSimpleName(): string;
  31686. }
  31687. }
  31688. declare module BABYLON {
  31689. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  31690. camera: FreeCamera;
  31691. private _keys;
  31692. private _onCanvasBlurObserver;
  31693. private _onKeyboardObserver;
  31694. private _engine;
  31695. private _scene;
  31696. keysUp: number[];
  31697. keysDown: number[];
  31698. keysLeft: number[];
  31699. keysRight: number[];
  31700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31701. detachControl(element: Nullable<HTMLElement>): void;
  31702. checkInputs(): void;
  31703. getClassName(): string;
  31704. _onLostFocus(e: FocusEvent): void;
  31705. getSimpleName(): string;
  31706. }
  31707. }
  31708. declare module BABYLON {
  31709. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  31710. touchEnabled: boolean;
  31711. camera: FreeCamera;
  31712. buttons: number[];
  31713. angularSensibility: number;
  31714. private _pointerInput;
  31715. private _onMouseMove;
  31716. private _observer;
  31717. private previousPosition;
  31718. constructor(touchEnabled?: boolean);
  31719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31720. detachControl(element: Nullable<HTMLElement>): void;
  31721. getClassName(): string;
  31722. getSimpleName(): string;
  31723. }
  31724. }
  31725. declare module BABYLON {
  31726. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  31727. camera: FreeCamera;
  31728. private _offsetX;
  31729. private _offsetY;
  31730. private _pointerPressed;
  31731. private _pointerInput;
  31732. private _observer;
  31733. private _onLostFocus;
  31734. touchAngularSensibility: number;
  31735. touchMoveSensibility: number;
  31736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31737. detachControl(element: Nullable<HTMLElement>): void;
  31738. checkInputs(): void;
  31739. getClassName(): string;
  31740. getSimpleName(): string;
  31741. }
  31742. }
  31743. declare module BABYLON {
  31744. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  31745. camera: FreeCamera;
  31746. private _leftjoystick;
  31747. private _rightjoystick;
  31748. getLeftJoystick(): VirtualJoystick;
  31749. getRightJoystick(): VirtualJoystick;
  31750. checkInputs(): void;
  31751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31752. detachControl(element: Nullable<HTMLElement>): void;
  31753. getClassName(): string;
  31754. getSimpleName(): string;
  31755. }
  31756. }
  31757. declare module BABYLON {
  31758. /**
  31759. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  31760. */
  31761. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  31762. /**
  31763. * Creates a new AnaglyphArcRotateCamera
  31764. * @param name defines camera name
  31765. * @param alpha defines alpha angle (in radians)
  31766. * @param beta defines beta angle (in radians)
  31767. * @param radius defines radius
  31768. * @param target defines camera target
  31769. * @param interaxialDistance defines distance between each color axis
  31770. * @param scene defines the hosting scene
  31771. */
  31772. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  31773. /**
  31774. * Gets camera class name
  31775. * @returns AnaglyphArcRotateCamera
  31776. */
  31777. getClassName(): string;
  31778. }
  31779. }
  31780. declare module BABYLON {
  31781. /**
  31782. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  31783. */
  31784. class AnaglyphFreeCamera extends FreeCamera {
  31785. /**
  31786. * Creates a new AnaglyphFreeCamera
  31787. * @param name defines camera name
  31788. * @param position defines initial position
  31789. * @param interaxialDistance defines distance between each color axis
  31790. * @param scene defines the hosting scene
  31791. */
  31792. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31793. /**
  31794. * Gets camera class name
  31795. * @returns AnaglyphFreeCamera
  31796. */
  31797. getClassName(): string;
  31798. }
  31799. }
  31800. declare module BABYLON {
  31801. /**
  31802. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  31803. */
  31804. class AnaglyphGamepadCamera extends GamepadCamera {
  31805. /**
  31806. * Creates a new AnaglyphGamepadCamera
  31807. * @param name defines camera name
  31808. * @param position defines initial position
  31809. * @param interaxialDistance defines distance between each color axis
  31810. * @param scene defines the hosting scene
  31811. */
  31812. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31813. /**
  31814. * Gets camera class name
  31815. * @returns AnaglyphGamepadCamera
  31816. */
  31817. getClassName(): string;
  31818. }
  31819. }
  31820. declare module BABYLON {
  31821. /**
  31822. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  31823. */
  31824. class AnaglyphUniversalCamera extends UniversalCamera {
  31825. /**
  31826. * Creates a new AnaglyphUniversalCamera
  31827. * @param name defines camera name
  31828. * @param position defines initial position
  31829. * @param interaxialDistance defines distance between each color axis
  31830. * @param scene defines the hosting scene
  31831. */
  31832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31833. /**
  31834. * Gets camera class name
  31835. * @returns AnaglyphUniversalCamera
  31836. */
  31837. getClassName(): string;
  31838. }
  31839. }
  31840. declare module BABYLON {
  31841. /**
  31842. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  31843. */
  31844. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  31845. /**
  31846. * Creates a new StereoscopicArcRotateCamera
  31847. * @param name defines camera name
  31848. * @param alpha defines alpha angle (in radians)
  31849. * @param beta defines beta angle (in radians)
  31850. * @param radius defines radius
  31851. * @param target defines camera target
  31852. * @param interaxialDistance defines distance between each color axis
  31853. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31854. * @param scene defines the hosting scene
  31855. */
  31856. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31857. /**
  31858. * Gets camera class name
  31859. * @returns StereoscopicArcRotateCamera
  31860. */
  31861. getClassName(): string;
  31862. }
  31863. }
  31864. declare module BABYLON {
  31865. /**
  31866. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  31867. */
  31868. class StereoscopicFreeCamera extends FreeCamera {
  31869. /**
  31870. * Creates a new StereoscopicFreeCamera
  31871. * @param name defines camera name
  31872. * @param position defines initial position
  31873. * @param interaxialDistance defines distance between each color axis
  31874. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31875. * @param scene defines the hosting scene
  31876. */
  31877. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31878. /**
  31879. * Gets camera class name
  31880. * @returns StereoscopicFreeCamera
  31881. */
  31882. getClassName(): string;
  31883. }
  31884. }
  31885. declare module BABYLON {
  31886. /**
  31887. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  31888. */
  31889. class StereoscopicGamepadCamera extends GamepadCamera {
  31890. /**
  31891. * Creates a new StereoscopicGamepadCamera
  31892. * @param name defines camera name
  31893. * @param position defines initial position
  31894. * @param interaxialDistance defines distance between each color axis
  31895. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31896. * @param scene defines the hosting scene
  31897. */
  31898. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31899. /**
  31900. * Gets camera class name
  31901. * @returns StereoscopicGamepadCamera
  31902. */
  31903. getClassName(): string;
  31904. }
  31905. }
  31906. declare module BABYLON {
  31907. /**
  31908. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  31909. */
  31910. class StereoscopicUniversalCamera extends UniversalCamera {
  31911. /**
  31912. * Creates a new StereoscopicUniversalCamera
  31913. * @param name defines camera name
  31914. * @param position defines initial position
  31915. * @param interaxialDistance defines distance between each color axis
  31916. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31917. * @param scene defines the hosting scene
  31918. */
  31919. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31920. /**
  31921. * Gets camera class name
  31922. * @returns StereoscopicUniversalCamera
  31923. */
  31924. getClassName(): string;
  31925. }
  31926. }
  31927. declare module BABYLON {
  31928. class VRCameraMetrics {
  31929. hResolution: number;
  31930. vResolution: number;
  31931. hScreenSize: number;
  31932. vScreenSize: number;
  31933. vScreenCenter: number;
  31934. eyeToScreenDistance: number;
  31935. lensSeparationDistance: number;
  31936. interpupillaryDistance: number;
  31937. distortionK: number[];
  31938. chromaAbCorrection: number[];
  31939. postProcessScaleFactor: number;
  31940. lensCenterOffset: number;
  31941. compensateDistortion: boolean;
  31942. readonly aspectRatio: number;
  31943. readonly aspectRatioFov: number;
  31944. readonly leftHMatrix: Matrix;
  31945. readonly rightHMatrix: Matrix;
  31946. readonly leftPreViewMatrix: Matrix;
  31947. readonly rightPreViewMatrix: Matrix;
  31948. static GetDefault(): VRCameraMetrics;
  31949. }
  31950. }
  31951. declare module BABYLON {
  31952. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  31953. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31954. getClassName(): string;
  31955. }
  31956. }
  31957. declare module BABYLON {
  31958. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  31959. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31960. getClassName(): string;
  31961. }
  31962. }
  31963. declare module BABYLON {
  31964. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  31965. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31966. getClassName(): string;
  31967. }
  31968. }
  31969. declare module BABYLON {
  31970. /**
  31971. * Options to modify the vr teleportation behavior.
  31972. */
  31973. interface VRTeleportationOptions {
  31974. /**
  31975. * The name of the mesh which should be used as the teleportation floor. (default: null)
  31976. */
  31977. floorMeshName?: string;
  31978. /**
  31979. * A list of meshes to be used as the teleportation floor. (default: empty)
  31980. */
  31981. floorMeshes?: Mesh[];
  31982. }
  31983. /**
  31984. * Options to modify the vr experience helper's behavior.
  31985. */
  31986. interface VRExperienceHelperOptions extends WebVROptions {
  31987. /**
  31988. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  31989. */
  31990. createDeviceOrientationCamera?: boolean;
  31991. /**
  31992. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  31993. */
  31994. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  31995. /**
  31996. * Uses the main button on the controller to toggle the laser casted. (default: true)
  31997. */
  31998. laserToggle?: boolean;
  31999. /**
  32000. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  32001. */
  32002. floorMeshes?: Mesh[];
  32003. }
  32004. /**
  32005. * Helps to quickly add VR support to an existing scene.
  32006. * See http://doc.babylonjs.com/how_to/webvr_helper
  32007. */
  32008. class VRExperienceHelper {
  32009. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  32010. private _scene;
  32011. private _position;
  32012. private _btnVR;
  32013. private _btnVRDisplayed;
  32014. private _webVRsupported;
  32015. private _webVRready;
  32016. private _webVRrequesting;
  32017. private _webVRpresenting;
  32018. private _fullscreenVRpresenting;
  32019. private _canvas;
  32020. private _webVRCamera;
  32021. private _vrDeviceOrientationCamera;
  32022. private _deviceOrientationCamera;
  32023. private _existingCamera;
  32024. private _onKeyDown;
  32025. private _onVrDisplayPresentChange;
  32026. private _onVRDisplayChanged;
  32027. private _onVRRequestPresentStart;
  32028. private _onVRRequestPresentComplete;
  32029. /**
  32030. * Observable raised when entering VR.
  32031. */
  32032. onEnteringVRObservable: Observable<VRExperienceHelper>;
  32033. /**
  32034. * Observable raised when exiting VR.
  32035. */
  32036. onExitingVRObservable: Observable<VRExperienceHelper>;
  32037. /**
  32038. * Observable raised when controller mesh is loaded.
  32039. */
  32040. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32041. /** Return this.onEnteringVRObservable
  32042. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  32043. */
  32044. readonly onEnteringVR: Observable<VRExperienceHelper>;
  32045. /** Return this.onExitingVRObservable
  32046. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  32047. */
  32048. readonly onExitingVR: Observable<VRExperienceHelper>;
  32049. /** Return this.onControllerMeshLoadedObservable
  32050. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  32051. */
  32052. readonly onControllerMeshLoaded: Observable<WebVRController>;
  32053. private _rayLength;
  32054. private _useCustomVRButton;
  32055. private _teleportationRequested;
  32056. private _teleportActive;
  32057. private _floorMeshName;
  32058. private _floorMeshesCollection;
  32059. private _rotationAllowed;
  32060. private _teleportBackwardsVector;
  32061. private _teleportationTarget;
  32062. private _isDefaultTeleportationTarget;
  32063. private _postProcessMove;
  32064. private _teleportationFillColor;
  32065. private _teleportationBorderColor;
  32066. private _rotationAngle;
  32067. private _haloCenter;
  32068. private _cameraGazer;
  32069. private _padSensibilityUp;
  32070. private _padSensibilityDown;
  32071. private leftController;
  32072. private rightController;
  32073. /**
  32074. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  32075. */
  32076. onNewMeshSelected: Observable<AbstractMesh>;
  32077. /**
  32078. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  32079. */
  32080. onNewMeshPicked: Observable<PickingInfo>;
  32081. private _circleEase;
  32082. /**
  32083. * Observable raised before camera teleportation
  32084. */
  32085. onBeforeCameraTeleport: Observable<Vector3>;
  32086. /**
  32087. * Observable raised after camera teleportation
  32088. */
  32089. onAfterCameraTeleport: Observable<Vector3>;
  32090. /**
  32091. * Observable raised when current selected mesh gets unselected
  32092. */
  32093. onSelectedMeshUnselected: Observable<AbstractMesh>;
  32094. private _raySelectionPredicate;
  32095. /**
  32096. * To be optionaly changed by user to define custom ray selection
  32097. */
  32098. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  32099. /**
  32100. * To be optionaly changed by user to define custom selection logic (after ray selection)
  32101. */
  32102. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  32103. /**
  32104. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  32105. */
  32106. teleportationEnabled: boolean;
  32107. private _defaultHeight;
  32108. private _teleportationInitialized;
  32109. private _interactionsEnabled;
  32110. private _interactionsRequested;
  32111. private _displayGaze;
  32112. private _displayLaserPointer;
  32113. /**
  32114. * The mesh used to display where the user is going to teleport.
  32115. */
  32116. /**
  32117. * Sets the mesh to be used to display where the user is going to teleport.
  32118. */
  32119. teleportationTarget: Mesh;
  32120. /**
  32121. * The mesh used to display where the user is selecting,
  32122. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  32123. * See http://doc.babylonjs.com/resources/baking_transformations
  32124. */
  32125. gazeTrackerMesh: Mesh;
  32126. /**
  32127. * If the ray of the gaze should be displayed.
  32128. */
  32129. /**
  32130. * Sets if the ray of the gaze should be displayed.
  32131. */
  32132. displayGaze: boolean;
  32133. /**
  32134. * If the ray of the LaserPointer should be displayed.
  32135. */
  32136. /**
  32137. * Sets if the ray of the LaserPointer should be displayed.
  32138. */
  32139. displayLaserPointer: boolean;
  32140. /**
  32141. * The deviceOrientationCamera used as the camera when not in VR.
  32142. */
  32143. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  32144. /**
  32145. * Based on the current WebVR support, returns the current VR camera used.
  32146. */
  32147. readonly currentVRCamera: Nullable<Camera>;
  32148. /**
  32149. * The webVRCamera which is used when in VR.
  32150. */
  32151. readonly webVRCamera: WebVRFreeCamera;
  32152. /**
  32153. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  32154. */
  32155. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  32156. private readonly _teleportationRequestInitiated;
  32157. /**
  32158. * Instantiates a VRExperienceHelper.
  32159. * Helps to quickly add VR support to an existing scene.
  32160. * @param scene The scene the VRExperienceHelper belongs to.
  32161. * @param webVROptions Options to modify the vr experience helper's behavior.
  32162. */
  32163. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  32164. private _onDefaultMeshLoaded(webVRController);
  32165. private _onResize;
  32166. private _onFullscreenChange;
  32167. /**
  32168. * Gets a value indicating if we are currently in VR mode.
  32169. */
  32170. readonly isInVRMode: boolean;
  32171. private onVrDisplayPresentChange();
  32172. private onVRDisplayChanged(eventArgs);
  32173. private moveButtonToBottomRight();
  32174. private displayVRButton();
  32175. private updateButtonVisibility();
  32176. /**
  32177. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  32178. * Otherwise, will use the fullscreen API.
  32179. */
  32180. enterVR(): void;
  32181. /**
  32182. * Attempt to exit VR, or fullscreen.
  32183. */
  32184. exitVR(): void;
  32185. /**
  32186. * The position of the vr experience helper.
  32187. */
  32188. /**
  32189. * Sets the position of the vr experience helper.
  32190. */
  32191. position: Vector3;
  32192. /**
  32193. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  32194. */
  32195. enableInteractions(): void;
  32196. private readonly _noControllerIsActive;
  32197. private beforeRender;
  32198. private _isTeleportationFloor(mesh);
  32199. /**
  32200. * Adds a floor mesh to be used for teleportation.
  32201. * @param floorMesh the mesh to be used for teleportation.
  32202. */
  32203. addFloorMesh(floorMesh: Mesh): void;
  32204. /**
  32205. * Removes a floor mesh from being used for teleportation.
  32206. * @param floorMesh the mesh to be removed.
  32207. */
  32208. removeFloorMesh(floorMesh: Mesh): void;
  32209. /**
  32210. * Enables interactions and teleportation using the VR controllers and gaze.
  32211. * @param vrTeleportationOptions options to modify teleportation behavior.
  32212. */
  32213. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  32214. private _onNewGamepadConnected;
  32215. private _tryEnableInteractionOnController;
  32216. private _onNewGamepadDisconnected;
  32217. private _enableInteractionOnController(controller);
  32218. private _checkTeleportWithRay(stateObject, gazer);
  32219. private _checkRotate(stateObject, gazer);
  32220. private _checkTeleportBackwards(stateObject, gazer);
  32221. private _enableTeleportationOnController(controller);
  32222. private _createTeleportationCircles();
  32223. private _displayTeleportationTarget();
  32224. private _hideTeleportationTarget();
  32225. private _rotateCamera(right);
  32226. private _moveTeleportationSelectorTo(hit, gazer, ray);
  32227. private _workingVector;
  32228. private _workingQuaternion;
  32229. private _workingMatrix;
  32230. private _teleportCamera(location);
  32231. private _convertNormalToDirectionOfRay(normal, ray);
  32232. private _castRayAndSelectObject(gazer);
  32233. private _notifySelectedMeshUnselected(mesh);
  32234. /**
  32235. * Sets the color of the laser ray from the vr controllers.
  32236. * @param color new color for the ray.
  32237. */
  32238. changeLaserColor(color: Color3): void;
  32239. /**
  32240. * Sets the color of the ray from the vr headsets gaze.
  32241. * @param color new color for the ray.
  32242. */
  32243. changeGazeColor(color: Color3): void;
  32244. /**
  32245. * Exits VR and disposes of the vr experience helper
  32246. */
  32247. dispose(): void;
  32248. /**
  32249. * Gets the name of the VRExperienceHelper class
  32250. * @returns "VRExperienceHelper"
  32251. */
  32252. getClassName(): string;
  32253. }
  32254. }
  32255. declare module BABYLON {
  32256. /**
  32257. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  32258. * IMPORTANT!! The data is right-hand data.
  32259. * @export
  32260. * @interface DevicePose
  32261. */
  32262. interface DevicePose {
  32263. /**
  32264. * The position of the device, values in array are [x,y,z].
  32265. */
  32266. readonly position: Nullable<Float32Array>;
  32267. /**
  32268. * The linearVelocity of the device, values in array are [x,y,z].
  32269. */
  32270. readonly linearVelocity: Nullable<Float32Array>;
  32271. /**
  32272. * The linearAcceleration of the device, values in array are [x,y,z].
  32273. */
  32274. readonly linearAcceleration: Nullable<Float32Array>;
  32275. /**
  32276. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  32277. */
  32278. readonly orientation: Nullable<Float32Array>;
  32279. /**
  32280. * The angularVelocity of the device, values in array are [x,y,z].
  32281. */
  32282. readonly angularVelocity: Nullable<Float32Array>;
  32283. /**
  32284. * The angularAcceleration of the device, values in array are [x,y,z].
  32285. */
  32286. readonly angularAcceleration: Nullable<Float32Array>;
  32287. }
  32288. /**
  32289. * Interface representing a pose controlled object in Babylon.
  32290. * A pose controlled object has both regular pose values as well as pose values
  32291. * from an external device such as a VR head mounted display
  32292. */
  32293. interface PoseControlled {
  32294. /**
  32295. * The position of the object in babylon space.
  32296. */
  32297. position: Vector3;
  32298. /**
  32299. * The rotation quaternion of the object in babylon space.
  32300. */
  32301. rotationQuaternion: Quaternion;
  32302. /**
  32303. * The position of the device in babylon space.
  32304. */
  32305. devicePosition?: Vector3;
  32306. /**
  32307. * The rotation quaternion of the device in babylon space.
  32308. */
  32309. deviceRotationQuaternion: Quaternion;
  32310. /**
  32311. * The raw pose coming from the device.
  32312. */
  32313. rawPose: Nullable<DevicePose>;
  32314. /**
  32315. * The scale of the device to be used when translating from device space to babylon space.
  32316. */
  32317. deviceScaleFactor: number;
  32318. /**
  32319. * Updates the poseControlled values based on the input device pose.
  32320. * @param poseData the pose data to update the object with
  32321. */
  32322. updateFromDevice(poseData: DevicePose): void;
  32323. }
  32324. /**
  32325. * Set of options to customize the webVRCamera
  32326. */
  32327. interface WebVROptions {
  32328. /**
  32329. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  32330. */
  32331. trackPosition?: boolean;
  32332. /**
  32333. * Sets the scale of the vrDevice in babylon space. (default: 1)
  32334. */
  32335. positionScale?: number;
  32336. /**
  32337. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  32338. */
  32339. displayName?: string;
  32340. /**
  32341. * Should the native controller meshes be initialized. (default: true)
  32342. */
  32343. controllerMeshes?: boolean;
  32344. /**
  32345. * Creating a default HemiLight only on controllers. (default: true)
  32346. */
  32347. defaultLightingOnControllers?: boolean;
  32348. /**
  32349. * If you don't want to use the default VR button of the helper. (default: false)
  32350. */
  32351. useCustomVRButton?: boolean;
  32352. /**
  32353. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  32354. */
  32355. customVRButton?: HTMLButtonElement;
  32356. /**
  32357. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  32358. */
  32359. rayLength?: number;
  32360. /**
  32361. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  32362. */
  32363. defaultHeight?: number;
  32364. }
  32365. /**
  32366. * This represents a WebVR camera.
  32367. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  32368. * @example http://doc.babylonjs.com/how_to/webvr_camera
  32369. */
  32370. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  32371. private webVROptions;
  32372. /**
  32373. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  32374. */
  32375. _vrDevice: any;
  32376. /**
  32377. * The rawPose of the vrDevice.
  32378. */
  32379. rawPose: Nullable<DevicePose>;
  32380. private _onVREnabled;
  32381. private _specsVersion;
  32382. private _attached;
  32383. private _frameData;
  32384. protected _descendants: Array<Node>;
  32385. private _deviceRoomPosition;
  32386. /** @hidden */
  32387. _deviceRoomRotationQuaternion: Quaternion;
  32388. private _standingMatrix;
  32389. /**
  32390. * Represents device position in babylon space.
  32391. */
  32392. devicePosition: Vector3;
  32393. /**
  32394. * Represents device rotation in babylon space.
  32395. */
  32396. deviceRotationQuaternion: Quaternion;
  32397. /**
  32398. * The scale of the device to be used when translating from device space to babylon space.
  32399. */
  32400. deviceScaleFactor: number;
  32401. private _deviceToWorld;
  32402. private _worldToDevice;
  32403. /**
  32404. * References to the webVR controllers for the vrDevice.
  32405. */
  32406. controllers: Array<WebVRController>;
  32407. /**
  32408. * Emits an event when a controller is attached.
  32409. */
  32410. onControllersAttachedObservable: Observable<WebVRController[]>;
  32411. /**
  32412. * Emits an event when a controller's mesh has been loaded;
  32413. */
  32414. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32415. /**
  32416. * Emits an event when the HMD's pose has been updated.
  32417. */
  32418. onPoseUpdatedFromDeviceObservable: Observable<any>;
  32419. private _poseSet;
  32420. /**
  32421. * If the rig cameras be used as parent instead of this camera.
  32422. */
  32423. rigParenting: boolean;
  32424. private _lightOnControllers;
  32425. private _defaultHeight?;
  32426. /**
  32427. * Instantiates a WebVRFreeCamera.
  32428. * @param name The name of the WebVRFreeCamera
  32429. * @param position The starting anchor position for the camera
  32430. * @param scene The scene the camera belongs to
  32431. * @param webVROptions a set of customizable options for the webVRCamera
  32432. */
  32433. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  32434. /**
  32435. * Gets the device distance from the ground in meters.
  32436. * @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.
  32437. */
  32438. deviceDistanceToRoomGround(): number;
  32439. /**
  32440. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32441. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  32442. */
  32443. useStandingMatrix(callback?: (bool: boolean) => void): void;
  32444. /**
  32445. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32446. * @returns A promise with a boolean set to if the standing matrix is supported.
  32447. */
  32448. useStandingMatrixAsync(): Promise<boolean>;
  32449. /**
  32450. * Disposes the camera
  32451. */
  32452. dispose(): void;
  32453. /**
  32454. * Gets a vrController by name.
  32455. * @param name The name of the controller to retreive
  32456. * @returns the controller matching the name specified or null if not found
  32457. */
  32458. getControllerByName(name: string): Nullable<WebVRController>;
  32459. private _leftController;
  32460. /**
  32461. * The controller corrisponding to the users left hand.
  32462. */
  32463. readonly leftController: Nullable<WebVRController>;
  32464. private _rightController;
  32465. /**
  32466. * The controller corrisponding to the users right hand.
  32467. */
  32468. readonly rightController: Nullable<WebVRController>;
  32469. /**
  32470. * Casts a ray forward from the vrCamera's gaze.
  32471. * @param length Length of the ray (default: 100)
  32472. * @returns the ray corrisponding to the gaze
  32473. */
  32474. getForwardRay(length?: number): Ray;
  32475. /**
  32476. * Updates the camera based on device's frame data
  32477. */
  32478. _checkInputs(): void;
  32479. /**
  32480. * Updates the poseControlled values based on the input device pose.
  32481. * @param poseData Pose coming from the device
  32482. */
  32483. updateFromDevice(poseData: DevicePose): void;
  32484. /**
  32485. * WebVR's attach control will start broadcasting frames to the device.
  32486. * Note that in certain browsers (chrome for example) this function must be called
  32487. * within a user-interaction callback. Example:
  32488. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  32489. *
  32490. * @param element html element to attach the vrDevice to
  32491. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  32492. */
  32493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32494. /**
  32495. * Detaches the camera from the html element and disables VR
  32496. *
  32497. * @param element html element to detach from
  32498. */
  32499. detachControl(element: HTMLElement): void;
  32500. /**
  32501. * @returns the name of this class
  32502. */
  32503. getClassName(): string;
  32504. /**
  32505. * Calls resetPose on the vrDisplay
  32506. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  32507. */
  32508. resetToCurrentRotation(): void;
  32509. /**
  32510. * Updates the rig cameras (left and right eye)
  32511. */
  32512. _updateRigCameras(): void;
  32513. private _workingVector;
  32514. private _oneVector;
  32515. private _workingMatrix;
  32516. private updateCacheCalled;
  32517. /**
  32518. * Updates the cached values of the camera
  32519. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  32520. */
  32521. _updateCache(ignoreParentClass?: boolean): void;
  32522. /**
  32523. * Updates the current device position and rotation in the babylon world
  32524. */
  32525. update(): void;
  32526. /**
  32527. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  32528. * @returns an identity matrix
  32529. */
  32530. _getViewMatrix(): Matrix;
  32531. /**
  32532. * This function is called by the two RIG cameras.
  32533. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  32534. */
  32535. protected _getWebVRViewMatrix(): Matrix;
  32536. protected _getWebVRProjectionMatrix(): Matrix;
  32537. private _onGamepadConnectedObserver;
  32538. private _onGamepadDisconnectedObserver;
  32539. /**
  32540. * Initializes the controllers and their meshes
  32541. */
  32542. initControllers(): void;
  32543. }
  32544. }
  32545. declare module BABYLON {
  32546. /**
  32547. * Google Daydream controller
  32548. */
  32549. class DaydreamController extends WebVRController {
  32550. /**
  32551. * Base Url for the controller model.
  32552. */
  32553. static MODEL_BASE_URL: string;
  32554. /**
  32555. * File name for the controller model.
  32556. */
  32557. static MODEL_FILENAME: string;
  32558. /**
  32559. * Gamepad Id prefix used to identify Daydream Controller.
  32560. */
  32561. static readonly GAMEPAD_ID_PREFIX: string;
  32562. /**
  32563. * Creates a new DaydreamController from a gamepad
  32564. * @param vrGamepad the gamepad that the controller should be created from
  32565. */
  32566. constructor(vrGamepad: any);
  32567. /**
  32568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32569. * @param scene scene in which to add meshes
  32570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32571. */
  32572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32573. /**
  32574. * Called once for each button that changed state since the last frame
  32575. * @param buttonIdx Which button index changed
  32576. * @param state New state of the button
  32577. * @param changes Which properties on the state changed since last frame
  32578. */
  32579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32580. }
  32581. }
  32582. declare module BABYLON {
  32583. /**
  32584. * Gear VR Controller
  32585. */
  32586. class GearVRController extends WebVRController {
  32587. /**
  32588. * Base Url for the controller model.
  32589. */
  32590. static MODEL_BASE_URL: string;
  32591. /**
  32592. * File name for the controller model.
  32593. */
  32594. static MODEL_FILENAME: string;
  32595. private _maxRotationDistFromHeadset;
  32596. private _draggedRoomRotation;
  32597. private _tmpVector;
  32598. /**
  32599. * Gamepad Id prefix used to identify this controller.
  32600. */
  32601. static readonly GAMEPAD_ID_PREFIX: string;
  32602. private readonly _buttonIndexToObservableNameMap;
  32603. /**
  32604. * Creates a new GearVRController from a gamepad
  32605. * @param vrGamepad the gamepad that the controller should be created from
  32606. */
  32607. constructor(vrGamepad: any);
  32608. /**
  32609. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  32610. * @param poseData raw pose fromthe device
  32611. */
  32612. updateFromDevice(poseData: DevicePose): void;
  32613. /**
  32614. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32615. * @param scene scene in which to add meshes
  32616. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32617. */
  32618. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32619. /**
  32620. * Called once for each button that changed state since the last frame
  32621. * @param buttonIdx Which button index changed
  32622. * @param state New state of the button
  32623. * @param changes Which properties on the state changed since last frame
  32624. */
  32625. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32626. }
  32627. }
  32628. declare module BABYLON {
  32629. /**
  32630. * Generic Controller
  32631. */
  32632. class GenericController extends WebVRController {
  32633. /**
  32634. * Base Url for the controller model.
  32635. */
  32636. static readonly MODEL_BASE_URL: string;
  32637. /**
  32638. * File name for the controller model.
  32639. */
  32640. static readonly MODEL_FILENAME: string;
  32641. /**
  32642. * Creates a new GenericController from a gamepad
  32643. * @param vrGamepad the gamepad that the controller should be created from
  32644. */
  32645. constructor(vrGamepad: any);
  32646. /**
  32647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32648. * @param scene scene in which to add meshes
  32649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32650. */
  32651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32652. /**
  32653. * Called once for each button that changed state since the last frame
  32654. * @param buttonIdx Which button index changed
  32655. * @param state New state of the button
  32656. * @param changes Which properties on the state changed since last frame
  32657. */
  32658. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32659. }
  32660. }
  32661. declare module BABYLON {
  32662. /**
  32663. * Oculus Touch Controller
  32664. */
  32665. class OculusTouchController extends WebVRController {
  32666. /**
  32667. * Base Url for the controller model.
  32668. */
  32669. static MODEL_BASE_URL: string;
  32670. /**
  32671. * File name for the left controller model.
  32672. */
  32673. static MODEL_LEFT_FILENAME: string;
  32674. /**
  32675. * File name for the right controller model.
  32676. */
  32677. static MODEL_RIGHT_FILENAME: string;
  32678. /**
  32679. * Fired when the secondary trigger on this controller is modified
  32680. */
  32681. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32682. /**
  32683. * Fired when the thumb rest on this controller is modified
  32684. */
  32685. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  32686. /**
  32687. * Creates a new OculusTouchController from a gamepad
  32688. * @param vrGamepad the gamepad that the controller should be created from
  32689. */
  32690. constructor(vrGamepad: any);
  32691. /**
  32692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32693. * @param scene scene in which to add meshes
  32694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32695. */
  32696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32697. /**
  32698. * Fired when the A button on this controller is modified
  32699. */
  32700. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32701. /**
  32702. * Fired when the B button on this controller is modified
  32703. */
  32704. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32705. /**
  32706. * Fired when the X button on this controller is modified
  32707. */
  32708. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32709. /**
  32710. * Fired when the Y button on this controller is modified
  32711. */
  32712. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32713. /**
  32714. * Called once for each button that changed state since the last frame
  32715. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  32716. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  32717. * 2) secondary trigger (same)
  32718. * 3) A (right) X (left), touch, pressed = value
  32719. * 4) B / Y
  32720. * 5) thumb rest
  32721. * @param buttonIdx Which button index changed
  32722. * @param state New state of the button
  32723. * @param changes Which properties on the state changed since last frame
  32724. */
  32725. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32726. }
  32727. }
  32728. declare module BABYLON {
  32729. /**
  32730. * Defines the types of pose enabled controllers that are supported
  32731. */
  32732. enum PoseEnabledControllerType {
  32733. /**
  32734. * HTC Vive
  32735. */
  32736. VIVE = 0,
  32737. /**
  32738. * Oculus Rift
  32739. */
  32740. OCULUS = 1,
  32741. /**
  32742. * Windows mixed reality
  32743. */
  32744. WINDOWS = 2,
  32745. /**
  32746. * Samsung gear VR
  32747. */
  32748. GEAR_VR = 3,
  32749. /**
  32750. * Google Daydream
  32751. */
  32752. DAYDREAM = 4,
  32753. /**
  32754. * Generic
  32755. */
  32756. GENERIC = 5,
  32757. }
  32758. /**
  32759. * Defines the MutableGamepadButton interface for the state of a gamepad button
  32760. */
  32761. interface MutableGamepadButton {
  32762. /**
  32763. * Value of the button/trigger
  32764. */
  32765. value: number;
  32766. /**
  32767. * If the button/trigger is currently touched
  32768. */
  32769. touched: boolean;
  32770. /**
  32771. * If the button/trigger is currently pressed
  32772. */
  32773. pressed: boolean;
  32774. }
  32775. /**
  32776. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  32777. * @hidden
  32778. */
  32779. interface ExtendedGamepadButton extends GamepadButton {
  32780. /**
  32781. * If the button/trigger is currently pressed
  32782. */
  32783. readonly pressed: boolean;
  32784. /**
  32785. * If the button/trigger is currently touched
  32786. */
  32787. readonly touched: boolean;
  32788. /**
  32789. * Value of the button/trigger
  32790. */
  32791. readonly value: number;
  32792. }
  32793. /**
  32794. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32795. */
  32796. class PoseEnabledControllerHelper {
  32797. /**
  32798. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32799. * @param vrGamepad the gamepad to initialized
  32800. * @returns a vr controller of the type the gamepad identified as
  32801. */
  32802. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  32803. }
  32804. /**
  32805. * Defines the PoseEnabledController object that contains state of a vr capable controller
  32806. */
  32807. class PoseEnabledController extends Gamepad implements PoseControlled {
  32808. private _deviceRoomPosition;
  32809. private _deviceRoomRotationQuaternion;
  32810. /**
  32811. * The device position in babylon space
  32812. */
  32813. devicePosition: Vector3;
  32814. /**
  32815. * The device rotation in babylon space
  32816. */
  32817. deviceRotationQuaternion: Quaternion;
  32818. /**
  32819. * The scale factor of the device in babylon space
  32820. */
  32821. deviceScaleFactor: number;
  32822. /**
  32823. * (Likely devicePosition should be used instead) The device position in its room space
  32824. */
  32825. position: Vector3;
  32826. /**
  32827. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  32828. */
  32829. rotationQuaternion: Quaternion;
  32830. /**
  32831. * The type of controller (Eg. Windows mixed reality)
  32832. */
  32833. controllerType: PoseEnabledControllerType;
  32834. protected _calculatedPosition: Vector3;
  32835. private _calculatedRotation;
  32836. /**
  32837. * The raw pose from the device
  32838. */
  32839. rawPose: DevicePose;
  32840. /**
  32841. * Internal, the mesh attached to the controller
  32842. */
  32843. _mesh: Nullable<AbstractMesh>;
  32844. private _poseControlledCamera;
  32845. private _leftHandSystemQuaternion;
  32846. /**
  32847. * Internal, matrix used to convert room space to babylon space
  32848. */
  32849. _deviceToWorld: Matrix;
  32850. /**
  32851. * Node to be used when casting a ray from the controller
  32852. */
  32853. _pointingPoseNode: Nullable<AbstractMesh>;
  32854. /**
  32855. * Name of the child mesh that can be used to cast a ray from the controller
  32856. */
  32857. static readonly POINTING_POSE: string;
  32858. /**
  32859. * Creates a new PoseEnabledController from a gamepad
  32860. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  32861. */
  32862. constructor(browserGamepad: any);
  32863. private _workingMatrix;
  32864. /**
  32865. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  32866. */
  32867. update(): void;
  32868. /**
  32869. * Updates only the pose device and mesh without doing any button event checking
  32870. */
  32871. protected _updatePoseAndMesh(): void;
  32872. /**
  32873. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  32874. * @param poseData raw pose fromthe device
  32875. */
  32876. updateFromDevice(poseData: DevicePose): void;
  32877. /**
  32878. * @hidden
  32879. */
  32880. _meshAttachedObservable: Observable<AbstractMesh>;
  32881. /**
  32882. * Attaches a mesh to the controller
  32883. * @param mesh the mesh to be attached
  32884. */
  32885. attachToMesh(mesh: AbstractMesh): void;
  32886. /**
  32887. * Attaches the controllers mesh to a camera
  32888. * @param camera the camera the mesh should be attached to
  32889. */
  32890. attachToPoseControlledCamera(camera: TargetCamera): void;
  32891. /**
  32892. * Disposes of the controller
  32893. */
  32894. dispose(): void;
  32895. /**
  32896. * The mesh that is attached to the controller
  32897. */
  32898. readonly mesh: Nullable<AbstractMesh>;
  32899. /**
  32900. * Gets the ray of the controller in the direction the controller is pointing
  32901. * @param length the length the resulting ray should be
  32902. * @returns a ray in the direction the controller is pointing
  32903. */
  32904. getForwardRay(length?: number): Ray;
  32905. }
  32906. }
  32907. declare module BABYLON {
  32908. /**
  32909. * Vive Controller
  32910. */
  32911. class ViveController extends WebVRController {
  32912. /**
  32913. * Base Url for the controller model.
  32914. */
  32915. static MODEL_BASE_URL: string;
  32916. /**
  32917. * File name for the controller model.
  32918. */
  32919. static MODEL_FILENAME: string;
  32920. /**
  32921. * Creates a new ViveController from a gamepad
  32922. * @param vrGamepad the gamepad that the controller should be created from
  32923. */
  32924. constructor(vrGamepad: any);
  32925. /**
  32926. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32927. * @param scene scene in which to add meshes
  32928. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32929. */
  32930. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32931. /**
  32932. * Fired when the left button on this controller is modified
  32933. */
  32934. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32935. /**
  32936. * Fired when the right button on this controller is modified
  32937. */
  32938. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32939. /**
  32940. * Fired when the menu button on this controller is modified
  32941. */
  32942. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32943. /**
  32944. * Called once for each button that changed state since the last frame
  32945. * Vive mapping:
  32946. * 0: touchpad
  32947. * 1: trigger
  32948. * 2: left AND right buttons
  32949. * 3: menu button
  32950. * @param buttonIdx Which button index changed
  32951. * @param state New state of the button
  32952. * @param changes Which properties on the state changed since last frame
  32953. */
  32954. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32955. }
  32956. }
  32957. declare module BABYLON {
  32958. /**
  32959. * Defines the WebVRController object that represents controllers tracked in 3D space
  32960. */
  32961. abstract class WebVRController extends PoseEnabledController {
  32962. /**
  32963. * Internal, the default controller model for the controller
  32964. */
  32965. protected _defaultModel: AbstractMesh;
  32966. /**
  32967. * Fired when the trigger state has changed
  32968. */
  32969. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32970. /**
  32971. * Fired when the main button state has changed
  32972. */
  32973. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32974. /**
  32975. * Fired when the secondary button state has changed
  32976. */
  32977. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32978. /**
  32979. * Fired when the pad state has changed
  32980. */
  32981. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  32982. /**
  32983. * Fired when controllers stick values have changed
  32984. */
  32985. onPadValuesChangedObservable: Observable<StickValues>;
  32986. /**
  32987. * Array of button availible on the controller
  32988. */
  32989. protected _buttons: Array<MutableGamepadButton>;
  32990. private _onButtonStateChange;
  32991. /**
  32992. * Fired when a controller button's state has changed
  32993. * @param callback the callback containing the button that was modified
  32994. */
  32995. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  32996. /**
  32997. * X and Y axis corrisponding to the controllers joystick
  32998. */
  32999. pad: StickValues;
  33000. /**
  33001. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  33002. */
  33003. hand: string;
  33004. /**
  33005. * The default controller model for the controller
  33006. */
  33007. readonly defaultModel: AbstractMesh;
  33008. /**
  33009. * Creates a new WebVRController from a gamepad
  33010. * @param vrGamepad the gamepad that the WebVRController should be created from
  33011. */
  33012. constructor(vrGamepad: any);
  33013. /**
  33014. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  33015. */
  33016. update(): void;
  33017. /**
  33018. * Function to be called when a button is modified
  33019. */
  33020. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33021. /**
  33022. * Loads a mesh and attaches it to the controller
  33023. * @param scene the scene the mesh should be added to
  33024. * @param meshLoaded callback for when the mesh has been loaded
  33025. */
  33026. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33027. private _setButtonValue(newState, currentState, buttonIndex);
  33028. private _changes;
  33029. private _checkChanges(newState, currentState);
  33030. /**
  33031. * Disposes of th webVRCOntroller
  33032. */
  33033. dispose(): void;
  33034. }
  33035. }
  33036. declare module BABYLON {
  33037. /**
  33038. * Defines the WindowsMotionController object that the state of the windows motion controller
  33039. */
  33040. class WindowsMotionController extends WebVRController {
  33041. /**
  33042. * The base url used to load the left and right controller models
  33043. */
  33044. static MODEL_BASE_URL: string;
  33045. /**
  33046. * The name of the left controller model file
  33047. */
  33048. static MODEL_LEFT_FILENAME: string;
  33049. /**
  33050. * The name of the right controller model file
  33051. */
  33052. static MODEL_RIGHT_FILENAME: string;
  33053. /**
  33054. * The controller name prefix for this controller type
  33055. */
  33056. static readonly GAMEPAD_ID_PREFIX: string;
  33057. /**
  33058. * The controller id pattern for this controller type
  33059. */
  33060. private static readonly GAMEPAD_ID_PATTERN;
  33061. private _loadedMeshInfo;
  33062. private readonly _mapping;
  33063. /**
  33064. * Fired when the trackpad on this controller is clicked
  33065. */
  33066. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  33067. /**
  33068. * Fired when the trackpad on this controller is modified
  33069. */
  33070. onTrackpadValuesChangedObservable: Observable<StickValues>;
  33071. /**
  33072. * The current x and y values of this controller's trackpad
  33073. */
  33074. trackpad: StickValues;
  33075. /**
  33076. * Creates a new WindowsMotionController from a gamepad
  33077. * @param vrGamepad the gamepad that the controller should be created from
  33078. */
  33079. constructor(vrGamepad: any);
  33080. /**
  33081. * Fired when the trigger on this controller is modified
  33082. */
  33083. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33084. /**
  33085. * Fired when the menu button on this controller is modified
  33086. */
  33087. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33088. /**
  33089. * Fired when the grip button on this controller is modified
  33090. */
  33091. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33092. /**
  33093. * Fired when the thumbstick button on this controller is modified
  33094. */
  33095. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33096. /**
  33097. * Fired when the touchpad button on this controller is modified
  33098. */
  33099. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33100. /**
  33101. * Fired when the touchpad values on this controller are modified
  33102. */
  33103. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  33104. private _updateTrackpad();
  33105. /**
  33106. * Called once per frame by the engine.
  33107. */
  33108. update(): void;
  33109. /**
  33110. * Called once for each button that changed state since the last frame
  33111. * @param buttonIdx Which button index changed
  33112. * @param state New state of the button
  33113. * @param changes Which properties on the state changed since last frame
  33114. */
  33115. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33116. /**
  33117. * Moves the buttons on the controller mesh based on their current state
  33118. * @param buttonName the name of the button to move
  33119. * @param buttonValue the value of the button which determines the buttons new position
  33120. */
  33121. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  33122. /**
  33123. * Moves the axis on the controller mesh based on its current state
  33124. * @param axis the index of the axis
  33125. * @param axisValue the value of the axis which determines the meshes new position
  33126. * @hidden
  33127. */
  33128. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  33129. /**
  33130. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33131. * @param scene scene in which to add meshes
  33132. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33133. */
  33134. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  33135. /**
  33136. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  33137. * can be transformed by button presses and axes values, based on this._mapping.
  33138. *
  33139. * @param scene scene in which the meshes exist
  33140. * @param meshes list of meshes that make up the controller model to process
  33141. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  33142. */
  33143. private processModel(scene, meshes);
  33144. private createMeshInfo(rootNode);
  33145. /**
  33146. * Gets the ray of the controller in the direction the controller is pointing
  33147. * @param length the length the resulting ray should be
  33148. * @returns a ray in the direction the controller is pointing
  33149. */
  33150. getForwardRay(length?: number): Ray;
  33151. /**
  33152. * Disposes of the controller
  33153. */
  33154. dispose(): void;
  33155. }
  33156. }
  33157. declare module BABYLON {
  33158. /**
  33159. * Interface to implement to create a shadow generator compatible with BJS.
  33160. */
  33161. interface IShadowGenerator {
  33162. /**
  33163. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33164. * @returns The render target texture if present otherwise, null
  33165. */
  33166. getShadowMap(): Nullable<RenderTargetTexture>;
  33167. /**
  33168. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33169. * @returns The render target texture if the shadow map is present otherwise, null
  33170. */
  33171. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33172. /**
  33173. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33174. * @param subMesh The submesh we want to render in the shadow map
  33175. * @param useInstances Defines wether will draw in the map using instances
  33176. * @returns true if ready otherwise, false
  33177. */
  33178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33179. /**
  33180. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33181. * @param defines Defines of the material we want to update
  33182. * @param lightIndex Index of the light in the enabled light list of the material
  33183. */
  33184. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  33185. /**
  33186. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33187. * defined in the generator but impacting the effect).
  33188. * It implies the unifroms available on the materials are the standard BJS ones.
  33189. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33190. * @param effect The effect we are binfing the information for
  33191. */
  33192. bindShadowLight(lightIndex: string, effect: Effect): void;
  33193. /**
  33194. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33195. * (eq to shadow prjection matrix * light transform matrix)
  33196. * @returns The transform matrix used to create the shadow map
  33197. */
  33198. getTransformMatrix(): Matrix;
  33199. /**
  33200. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33201. * Cube and 2D textures for instance.
  33202. */
  33203. recreateShadowMap(): void;
  33204. /**
  33205. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33206. * @param onCompiled Callback triggered at the and of the effects compilation
  33207. * @param options Sets of optional options forcing the compilation with different modes
  33208. */
  33209. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33210. useInstances: boolean;
  33211. }>): void;
  33212. /**
  33213. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33214. * @param options Sets of optional options forcing the compilation with different modes
  33215. * @returns A promise that resolves when the compilation completes
  33216. */
  33217. forceCompilationAsync(options?: Partial<{
  33218. useInstances: boolean;
  33219. }>): Promise<void>;
  33220. /**
  33221. * Serializes the shadow generator setup to a json object.
  33222. * @returns The serialized JSON object
  33223. */
  33224. serialize(): any;
  33225. /**
  33226. * Disposes the Shadow map and related Textures and effects.
  33227. */
  33228. dispose(): void;
  33229. }
  33230. /**
  33231. * Default implementation IShadowGenerator.
  33232. * This is the main object responsible of generating shadows in the framework.
  33233. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  33234. */
  33235. class ShadowGenerator implements IShadowGenerator {
  33236. /**
  33237. * Shadow generator mode None: no filtering applied.
  33238. */
  33239. static readonly FILTER_NONE: number;
  33240. /**
  33241. * Shadow generator mode ESM: Exponential Shadow Mapping.
  33242. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33243. */
  33244. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  33245. /**
  33246. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  33247. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  33248. */
  33249. static readonly FILTER_POISSONSAMPLING: number;
  33250. /**
  33251. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  33252. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33253. */
  33254. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  33255. /**
  33256. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  33257. * edge artifacts on steep falloff.
  33258. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33259. */
  33260. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  33261. /**
  33262. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  33263. * edge artifacts on steep falloff.
  33264. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33265. */
  33266. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  33267. /**
  33268. * Shadow generator mode PCF: Percentage Closer Filtering
  33269. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33270. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  33271. */
  33272. static readonly FILTER_PCF: number;
  33273. /**
  33274. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  33275. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33276. * Contact Hardening
  33277. */
  33278. static readonly FILTER_PCSS: number;
  33279. /**
  33280. * Reserved for PCF and PCSS
  33281. * Highest Quality.
  33282. *
  33283. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  33284. *
  33285. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  33286. */
  33287. static readonly QUALITY_HIGH: number;
  33288. /**
  33289. * Reserved for PCF and PCSS
  33290. * Good tradeoff for quality/perf cross devices
  33291. *
  33292. * Execute PCF on a 3*3 kernel.
  33293. *
  33294. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  33295. */
  33296. static readonly QUALITY_MEDIUM: number;
  33297. /**
  33298. * Reserved for PCF and PCSS
  33299. * The lowest quality but the fastest.
  33300. *
  33301. * Execute PCF on a 1*1 kernel.
  33302. *
  33303. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  33304. */
  33305. static readonly QUALITY_LOW: number;
  33306. private _bias;
  33307. /**
  33308. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  33309. */
  33310. /**
  33311. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  33312. */
  33313. bias: number;
  33314. private _normalBias;
  33315. /**
  33316. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33317. */
  33318. /**
  33319. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33320. */
  33321. normalBias: number;
  33322. private _blurBoxOffset;
  33323. /**
  33324. * Gets the blur box offset: offset applied during the blur pass.
  33325. * Only usefull if useKernelBlur = false
  33326. */
  33327. /**
  33328. * Sets the blur box offset: offset applied during the blur pass.
  33329. * Only usefull if useKernelBlur = false
  33330. */
  33331. blurBoxOffset: number;
  33332. private _blurScale;
  33333. /**
  33334. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  33335. * 2 means half of the size.
  33336. */
  33337. /**
  33338. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  33339. * 2 means half of the size.
  33340. */
  33341. blurScale: number;
  33342. private _blurKernel;
  33343. /**
  33344. * Gets the blur kernel: kernel size of the blur pass.
  33345. * Only usefull if useKernelBlur = true
  33346. */
  33347. /**
  33348. * Sets the blur kernel: kernel size of the blur pass.
  33349. * Only usefull if useKernelBlur = true
  33350. */
  33351. blurKernel: number;
  33352. private _useKernelBlur;
  33353. /**
  33354. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  33355. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33356. */
  33357. /**
  33358. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  33359. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33360. */
  33361. useKernelBlur: boolean;
  33362. private _depthScale;
  33363. /**
  33364. * Gets the depth scale used in ESM mode.
  33365. */
  33366. /**
  33367. * Sets the depth scale used in ESM mode.
  33368. * This can override the scale stored on the light.
  33369. */
  33370. depthScale: number;
  33371. private _filter;
  33372. /**
  33373. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  33374. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33375. */
  33376. /**
  33377. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  33378. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33379. */
  33380. filter: number;
  33381. /**
  33382. * Gets if the current filter is set to Poisson Sampling.
  33383. */
  33384. /**
  33385. * Sets the current filter to Poisson Sampling.
  33386. */
  33387. usePoissonSampling: boolean;
  33388. /**
  33389. * Gets if the current filter is set to VSM.
  33390. * DEPRECATED. Should use useExponentialShadowMap instead.
  33391. */
  33392. /**
  33393. * Sets the current filter is to VSM.
  33394. * DEPRECATED. Should use useExponentialShadowMap instead.
  33395. */
  33396. useVarianceShadowMap: boolean;
  33397. /**
  33398. * Gets if the current filter is set to blurred VSM.
  33399. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33400. */
  33401. /**
  33402. * Sets the current filter is to blurred VSM.
  33403. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33404. */
  33405. useBlurVarianceShadowMap: boolean;
  33406. /**
  33407. * Gets if the current filter is set to ESM.
  33408. */
  33409. /**
  33410. * Sets the current filter is to ESM.
  33411. */
  33412. useExponentialShadowMap: boolean;
  33413. /**
  33414. * Gets if the current filter is set to filtered ESM.
  33415. */
  33416. /**
  33417. * Gets if the current filter is set to filtered ESM.
  33418. */
  33419. useBlurExponentialShadowMap: boolean;
  33420. /**
  33421. * Gets if the current filter is set to "close ESM" (using the inverse of the
  33422. * exponential to prevent steep falloff artifacts).
  33423. */
  33424. /**
  33425. * Sets the current filter to "close ESM" (using the inverse of the
  33426. * exponential to prevent steep falloff artifacts).
  33427. */
  33428. useCloseExponentialShadowMap: boolean;
  33429. /**
  33430. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  33431. * exponential to prevent steep falloff artifacts).
  33432. */
  33433. /**
  33434. * Sets the current filter to filtered "close ESM" (using the inverse of the
  33435. * exponential to prevent steep falloff artifacts).
  33436. */
  33437. useBlurCloseExponentialShadowMap: boolean;
  33438. /**
  33439. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  33440. */
  33441. /**
  33442. * Sets the current filter to "PCF" (percentage closer filtering).
  33443. */
  33444. usePercentageCloserFiltering: boolean;
  33445. private _filteringQuality;
  33446. /**
  33447. * Gets the PCF or PCSS Quality.
  33448. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33449. */
  33450. /**
  33451. * Sets the PCF or PCSS Quality.
  33452. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33453. */
  33454. filteringQuality: number;
  33455. /**
  33456. * Gets if the current filter is set to "PCSS" (contact hardening).
  33457. */
  33458. /**
  33459. * Sets the current filter to "PCSS" (contact hardening).
  33460. */
  33461. useContactHardeningShadow: boolean;
  33462. private _contactHardeningLightSizeUVRatio;
  33463. /**
  33464. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33465. * Using a ratio helps keeping shape stability independently of the map size.
  33466. *
  33467. * It does not account for the light projection as it was having too much
  33468. * instability during the light setup or during light position changes.
  33469. *
  33470. * Only valid if useContactHardeningShadow is true.
  33471. */
  33472. /**
  33473. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33474. * Using a ratio helps keeping shape stability independently of the map size.
  33475. *
  33476. * It does not account for the light projection as it was having too much
  33477. * instability during the light setup or during light position changes.
  33478. *
  33479. * Only valid if useContactHardeningShadow is true.
  33480. */
  33481. contactHardeningLightSizeUVRatio: number;
  33482. private _darkness;
  33483. /**
  33484. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  33485. * 0 means strongest and 1 would means no shadow.
  33486. * @returns the darkness.
  33487. */
  33488. getDarkness(): number;
  33489. /**
  33490. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  33491. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  33492. * @returns the shadow generator allowing fluent coding.
  33493. */
  33494. setDarkness(darkness: number): ShadowGenerator;
  33495. private _transparencyShadow;
  33496. /**
  33497. * Sets the ability to have transparent shadow (boolean).
  33498. * @param transparent True if transparent else False
  33499. * @returns the shadow generator allowing fluent coding
  33500. */
  33501. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  33502. private _shadowMap;
  33503. private _shadowMap2;
  33504. /**
  33505. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33506. * @returns The render target texture if present otherwise, null
  33507. */
  33508. getShadowMap(): Nullable<RenderTargetTexture>;
  33509. /**
  33510. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33511. * @returns The render target texture if the shadow map is present otherwise, null
  33512. */
  33513. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33514. /**
  33515. * Helper function to add a mesh and its descendants to the list of shadow casters.
  33516. * @param mesh Mesh to add
  33517. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  33518. * @returns the Shadow Generator itself
  33519. */
  33520. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33521. /**
  33522. * Helper function to remove a mesh and its descendants from the list of shadow casters
  33523. * @param mesh Mesh to remove
  33524. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  33525. * @returns the Shadow Generator itself
  33526. */
  33527. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33528. /**
  33529. * Controls the extent to which the shadows fade out at the edge of the frustum
  33530. * Used only by directionals and spots
  33531. */
  33532. frustumEdgeFalloff: number;
  33533. private _light;
  33534. /**
  33535. * Returns the associated light object.
  33536. * @returns the light generating the shadow
  33537. */
  33538. getLight(): IShadowLight;
  33539. /**
  33540. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  33541. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  33542. * It might on the other hand introduce peter panning.
  33543. */
  33544. forceBackFacesOnly: boolean;
  33545. private _scene;
  33546. private _lightDirection;
  33547. private _effect;
  33548. private _viewMatrix;
  33549. private _projectionMatrix;
  33550. private _transformMatrix;
  33551. private _cachedPosition;
  33552. private _cachedDirection;
  33553. private _cachedDefines;
  33554. private _currentRenderID;
  33555. private _boxBlurPostprocess;
  33556. private _kernelBlurXPostprocess;
  33557. private _kernelBlurYPostprocess;
  33558. private _blurPostProcesses;
  33559. private _mapSize;
  33560. private _currentFaceIndex;
  33561. private _currentFaceIndexCache;
  33562. private _textureType;
  33563. private _defaultTextureMatrix;
  33564. /**
  33565. * Creates a ShadowGenerator object.
  33566. * A ShadowGenerator is the required tool to use the shadows.
  33567. * Each light casting shadows needs to use its own ShadowGenerator.
  33568. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  33569. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  33570. * @param light The light object generating the shadows.
  33571. * @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.
  33572. */
  33573. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  33574. private _initializeGenerator();
  33575. private _initializeShadowMap();
  33576. private _initializeBlurRTTAndPostProcesses();
  33577. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  33578. private _renderSubMeshForShadowMap(subMesh);
  33579. private _applyFilterValues();
  33580. /**
  33581. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33582. * @param onCompiled Callback triggered at the and of the effects compilation
  33583. * @param options Sets of optional options forcing the compilation with different modes
  33584. */
  33585. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33586. useInstances: boolean;
  33587. }>): void;
  33588. /**
  33589. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33590. * @param options Sets of optional options forcing the compilation with different modes
  33591. * @returns A promise that resolves when the compilation completes
  33592. */
  33593. forceCompilationAsync(options?: Partial<{
  33594. useInstances: boolean;
  33595. }>): Promise<void>;
  33596. /**
  33597. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33598. * @param subMesh The submesh we want to render in the shadow map
  33599. * @param useInstances Defines wether will draw in the map using instances
  33600. * @returns true if ready otherwise, false
  33601. */
  33602. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33603. /**
  33604. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33605. * @param defines Defines of the material we want to update
  33606. * @param lightIndex Index of the light in the enabled light list of the material
  33607. */
  33608. prepareDefines(defines: any, lightIndex: number): void;
  33609. /**
  33610. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33611. * defined in the generator but impacting the effect).
  33612. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33613. * @param effect The effect we are binfing the information for
  33614. */
  33615. bindShadowLight(lightIndex: string, effect: Effect): void;
  33616. /**
  33617. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33618. * (eq to shadow prjection matrix * light transform matrix)
  33619. * @returns The transform matrix used to create the shadow map
  33620. */
  33621. getTransformMatrix(): Matrix;
  33622. /**
  33623. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33624. * Cube and 2D textures for instance.
  33625. */
  33626. recreateShadowMap(): void;
  33627. private _disposeBlurPostProcesses();
  33628. private _disposeRTTandPostProcesses();
  33629. /**
  33630. * Disposes the ShadowGenerator.
  33631. * Returns nothing.
  33632. */
  33633. dispose(): void;
  33634. /**
  33635. * Serializes the shadow generator setup to a json object.
  33636. * @returns The serialized JSON object
  33637. */
  33638. serialize(): any;
  33639. /**
  33640. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  33641. * @param parsedShadowGenerator The JSON object to parse
  33642. * @param scene The scene to create the shadow map for
  33643. * @returns The parsed shadow generator
  33644. */
  33645. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  33646. }
  33647. }
  33648. declare module BABYLON {
  33649. }
  33650. declare module BABYLON {
  33651. /**
  33652. * Background material used to create an efficient environement around your scene.
  33653. */
  33654. class BackgroundMaterial extends PushMaterial {
  33655. /**
  33656. * Standard reflectance value at parallel view angle.
  33657. */
  33658. static StandardReflectance0: number;
  33659. /**
  33660. * Standard reflectance value at grazing angle.
  33661. */
  33662. static StandardReflectance90: number;
  33663. protected _primaryColor: Color3;
  33664. /**
  33665. * Key light Color (multiply against the environement texture)
  33666. */
  33667. primaryColor: Color3;
  33668. protected __perceptualColor: Nullable<Color3>;
  33669. /**
  33670. * Experimental Internal Use Only.
  33671. *
  33672. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  33673. * This acts as a helper to set the primary color to a more "human friendly" value.
  33674. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  33675. * output color as close as possible from the chosen value.
  33676. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  33677. * part of lighting setup.)
  33678. */
  33679. _perceptualColor: Nullable<Color3>;
  33680. protected _primaryColorShadowLevel: float;
  33681. /**
  33682. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  33683. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  33684. */
  33685. primaryColorShadowLevel: float;
  33686. protected _primaryColorHighlightLevel: float;
  33687. /**
  33688. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  33689. * The primary color is used at the level chosen to define what the white area would look.
  33690. */
  33691. primaryColorHighlightLevel: float;
  33692. protected _reflectionTexture: Nullable<BaseTexture>;
  33693. /**
  33694. * Reflection Texture used in the material.
  33695. * Should be author in a specific way for the best result (refer to the documentation).
  33696. */
  33697. reflectionTexture: Nullable<BaseTexture>;
  33698. protected _reflectionBlur: float;
  33699. /**
  33700. * Reflection Texture level of blur.
  33701. *
  33702. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  33703. * texture twice.
  33704. */
  33705. reflectionBlur: float;
  33706. protected _diffuseTexture: Nullable<BaseTexture>;
  33707. /**
  33708. * Diffuse Texture used in the material.
  33709. * Should be author in a specific way for the best result (refer to the documentation).
  33710. */
  33711. diffuseTexture: Nullable<BaseTexture>;
  33712. protected _shadowLights: Nullable<IShadowLight[]>;
  33713. /**
  33714. * Specify the list of lights casting shadow on the material.
  33715. * All scene shadow lights will be included if null.
  33716. */
  33717. shadowLights: Nullable<IShadowLight[]>;
  33718. protected _shadowLevel: float;
  33719. /**
  33720. * Helps adjusting the shadow to a softer level if required.
  33721. * 0 means black shadows and 1 means no shadows.
  33722. */
  33723. shadowLevel: float;
  33724. protected _sceneCenter: Vector3;
  33725. /**
  33726. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  33727. * It is usually zero but might be interesting to modify according to your setup.
  33728. */
  33729. sceneCenter: Vector3;
  33730. protected _opacityFresnel: boolean;
  33731. /**
  33732. * This helps specifying that the material is falling off to the sky box at grazing angle.
  33733. * This helps ensuring a nice transition when the camera goes under the ground.
  33734. */
  33735. opacityFresnel: boolean;
  33736. protected _reflectionFresnel: boolean;
  33737. /**
  33738. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  33739. * This helps adding a mirror texture on the ground.
  33740. */
  33741. reflectionFresnel: boolean;
  33742. protected _reflectionFalloffDistance: number;
  33743. /**
  33744. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  33745. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  33746. */
  33747. reflectionFalloffDistance: number;
  33748. protected _reflectionAmount: number;
  33749. /**
  33750. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  33751. */
  33752. reflectionAmount: number;
  33753. protected _reflectionReflectance0: number;
  33754. /**
  33755. * This specifies the weight of the reflection at grazing angle.
  33756. */
  33757. reflectionReflectance0: number;
  33758. protected _reflectionReflectance90: number;
  33759. /**
  33760. * This specifies the weight of the reflection at a perpendicular point of view.
  33761. */
  33762. reflectionReflectance90: number;
  33763. /**
  33764. * Sets the reflection reflectance fresnel values according to the default standard
  33765. * empirically know to work well :-)
  33766. */
  33767. reflectionStandardFresnelWeight: number;
  33768. protected _useRGBColor: boolean;
  33769. /**
  33770. * Helps to directly use the maps channels instead of their level.
  33771. */
  33772. useRGBColor: boolean;
  33773. protected _enableNoise: boolean;
  33774. /**
  33775. * This helps reducing the banding effect that could occur on the background.
  33776. */
  33777. enableNoise: boolean;
  33778. /**
  33779. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  33780. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  33781. * Recommended to be keep at 1.0 except for special cases.
  33782. */
  33783. fovMultiplier: number;
  33784. private _fovMultiplier;
  33785. /**
  33786. * Enable the FOV adjustment feature controlled by fovMultiplier.
  33787. */
  33788. useEquirectangularFOV: boolean;
  33789. private _maxSimultaneousLights;
  33790. /**
  33791. * Number of Simultaneous lights allowed on the material.
  33792. */
  33793. maxSimultaneousLights: int;
  33794. /**
  33795. * Default configuration related to image processing available in the Background Material.
  33796. */
  33797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33798. /**
  33799. * Keep track of the image processing observer to allow dispose and replace.
  33800. */
  33801. private _imageProcessingObserver;
  33802. /**
  33803. * Attaches a new image processing configuration to the PBR Material.
  33804. * @param configuration (if null the scene configuration will be use)
  33805. */
  33806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33807. /**
  33808. * Gets the image processing configuration used either in this material.
  33809. */
  33810. /**
  33811. * Sets the Default image processing configuration used either in the this material.
  33812. *
  33813. * If sets to null, the scene one is in use.
  33814. */
  33815. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  33816. /**
  33817. * Gets wether the color curves effect is enabled.
  33818. */
  33819. /**
  33820. * Sets wether the color curves effect is enabled.
  33821. */
  33822. cameraColorCurvesEnabled: boolean;
  33823. /**
  33824. * Gets wether the color grading effect is enabled.
  33825. */
  33826. /**
  33827. * Gets wether the color grading effect is enabled.
  33828. */
  33829. cameraColorGradingEnabled: boolean;
  33830. /**
  33831. * Gets wether tonemapping is enabled or not.
  33832. */
  33833. /**
  33834. * Sets wether tonemapping is enabled or not
  33835. */
  33836. cameraToneMappingEnabled: boolean;
  33837. /**
  33838. * The camera exposure used on this material.
  33839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33840. * This corresponds to a photographic exposure.
  33841. */
  33842. /**
  33843. * The camera exposure used on this material.
  33844. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33845. * This corresponds to a photographic exposure.
  33846. */
  33847. cameraExposure: float;
  33848. /**
  33849. * Gets The camera contrast used on this material.
  33850. */
  33851. /**
  33852. * Sets The camera contrast used on this material.
  33853. */
  33854. cameraContrast: float;
  33855. /**
  33856. * Gets the Color Grading 2D Lookup Texture.
  33857. */
  33858. /**
  33859. * Sets the Color Grading 2D Lookup Texture.
  33860. */
  33861. cameraColorGradingTexture: Nullable<BaseTexture>;
  33862. /**
  33863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33865. * 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;
  33866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33867. */
  33868. /**
  33869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33871. * 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;
  33872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33873. */
  33874. cameraColorCurves: Nullable<ColorCurves>;
  33875. /**
  33876. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  33877. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  33878. */
  33879. switchToBGR: boolean;
  33880. private _renderTargets;
  33881. private _reflectionControls;
  33882. private _white;
  33883. private _primaryShadowColor;
  33884. private _primaryHighlightColor;
  33885. /**
  33886. * Instantiates a Background Material in the given scene
  33887. * @param name The friendly name of the material
  33888. * @param scene The scene to add the material to
  33889. */
  33890. constructor(name: string, scene: Scene);
  33891. /**
  33892. * The entire material has been created in order to prevent overdraw.
  33893. * @returns false
  33894. */
  33895. needAlphaTesting(): boolean;
  33896. /**
  33897. * The entire material has been created in order to prevent overdraw.
  33898. * @returns true if blending is enable
  33899. */
  33900. needAlphaBlending(): boolean;
  33901. /**
  33902. * Checks wether the material is ready to be rendered for a given mesh.
  33903. * @param mesh The mesh to render
  33904. * @param subMesh The submesh to check against
  33905. * @param useInstances Specify wether or not the material is used with instances
  33906. * @returns true if all the dependencies are ready (Textures, Effects...)
  33907. */
  33908. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  33909. /**
  33910. * Compute the primary color according to the chosen perceptual color.
  33911. */
  33912. private _computePrimaryColorFromPerceptualColor();
  33913. /**
  33914. * Compute the highlights and shadow colors according to their chosen levels.
  33915. */
  33916. private _computePrimaryColors();
  33917. /**
  33918. * Build the uniform buffer used in the material.
  33919. */
  33920. buildUniformLayout(): void;
  33921. /**
  33922. * Unbind the material.
  33923. */
  33924. unbind(): void;
  33925. /**
  33926. * Bind only the world matrix to the material.
  33927. * @param world The world matrix to bind.
  33928. */
  33929. bindOnlyWorldMatrix(world: Matrix): void;
  33930. /**
  33931. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  33932. * @param world The world matrix to bind.
  33933. * @param subMesh The submesh to bind for.
  33934. */
  33935. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  33936. /**
  33937. * Dispose the material.
  33938. * @param forceDisposeEffect Force disposal of the associated effect.
  33939. * @param forceDisposeTextures Force disposal of the associated textures.
  33940. */
  33941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  33942. /**
  33943. * Clones the material.
  33944. * @param name The cloned name.
  33945. * @returns The cloned material.
  33946. */
  33947. clone(name: string): BackgroundMaterial;
  33948. /**
  33949. * Serializes the current material to its JSON representation.
  33950. * @returns The JSON representation.
  33951. */
  33952. serialize(): any;
  33953. /**
  33954. * Gets the class name of the material
  33955. * @returns "BackgroundMaterial"
  33956. */
  33957. getClassName(): string;
  33958. /**
  33959. * Parse a JSON input to create back a background material.
  33960. * @param source The JSON data to parse
  33961. * @param scene The scene to create the parsed material in
  33962. * @param rootUrl The root url of the assets the material depends upon
  33963. * @returns the instantiated BackgroundMaterial.
  33964. */
  33965. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  33966. }
  33967. }
  33968. declare module BABYLON {
  33969. /**
  33970. * The Physically based material base class of BJS.
  33971. *
  33972. * This offers the main features of a standard PBR material.
  33973. * For more information, please refer to the documentation :
  33974. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33975. */
  33976. abstract class PBRBaseMaterial extends PushMaterial {
  33977. /**
  33978. * Intensity of the direct lights e.g. the four lights available in your scene.
  33979. * This impacts both the direct diffuse and specular highlights.
  33980. */
  33981. protected _directIntensity: number;
  33982. /**
  33983. * Intensity of the emissive part of the material.
  33984. * This helps controlling the emissive effect without modifying the emissive color.
  33985. */
  33986. protected _emissiveIntensity: number;
  33987. /**
  33988. * Intensity of the environment e.g. how much the environment will light the object
  33989. * either through harmonics for rough material or through the refelction for shiny ones.
  33990. */
  33991. protected _environmentIntensity: number;
  33992. /**
  33993. * This is a special control allowing the reduction of the specular highlights coming from the
  33994. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33995. */
  33996. protected _specularIntensity: number;
  33997. /**
  33998. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  33999. */
  34000. private _lightingInfos;
  34001. /**
  34002. * Debug Control allowing disabling the bump map on this material.
  34003. */
  34004. protected _disableBumpMap: boolean;
  34005. /**
  34006. * AKA Diffuse Texture in standard nomenclature.
  34007. */
  34008. protected _albedoTexture: BaseTexture;
  34009. /**
  34010. * AKA Occlusion Texture in other nomenclature.
  34011. */
  34012. protected _ambientTexture: BaseTexture;
  34013. /**
  34014. * AKA Occlusion Texture Intensity in other nomenclature.
  34015. */
  34016. protected _ambientTextureStrength: number;
  34017. /**
  34018. * Stores the alpha values in a texture.
  34019. */
  34020. protected _opacityTexture: BaseTexture;
  34021. /**
  34022. * Stores the reflection values in a texture.
  34023. */
  34024. protected _reflectionTexture: BaseTexture;
  34025. /**
  34026. * Stores the refraction values in a texture.
  34027. */
  34028. protected _refractionTexture: BaseTexture;
  34029. /**
  34030. * Stores the emissive values in a texture.
  34031. */
  34032. protected _emissiveTexture: BaseTexture;
  34033. /**
  34034. * AKA Specular texture in other nomenclature.
  34035. */
  34036. protected _reflectivityTexture: BaseTexture;
  34037. /**
  34038. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34039. */
  34040. protected _metallicTexture: BaseTexture;
  34041. /**
  34042. * Specifies the metallic scalar of the metallic/roughness workflow.
  34043. * Can also be used to scale the metalness values of the metallic texture.
  34044. */
  34045. protected _metallic: number;
  34046. /**
  34047. * Specifies the roughness scalar of the metallic/roughness workflow.
  34048. * Can also be used to scale the roughness values of the metallic texture.
  34049. */
  34050. protected _roughness: number;
  34051. /**
  34052. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34053. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34054. */
  34055. protected _microSurfaceTexture: BaseTexture;
  34056. /**
  34057. * Stores surface normal data used to displace a mesh in a texture.
  34058. */
  34059. protected _bumpTexture: BaseTexture;
  34060. /**
  34061. * Stores the pre-calculated light information of a mesh in a texture.
  34062. */
  34063. protected _lightmapTexture: BaseTexture;
  34064. /**
  34065. * The color of a material in ambient lighting.
  34066. */
  34067. protected _ambientColor: Color3;
  34068. /**
  34069. * AKA Diffuse Color in other nomenclature.
  34070. */
  34071. protected _albedoColor: Color3;
  34072. /**
  34073. * AKA Specular Color in other nomenclature.
  34074. */
  34075. protected _reflectivityColor: Color3;
  34076. /**
  34077. * The color applied when light is reflected from a material.
  34078. */
  34079. protected _reflectionColor: Color3;
  34080. /**
  34081. * The color applied when light is emitted from a material.
  34082. */
  34083. protected _emissiveColor: Color3;
  34084. /**
  34085. * AKA Glossiness in other nomenclature.
  34086. */
  34087. protected _microSurface: number;
  34088. /**
  34089. * source material index of refraction (IOR)' / 'destination material IOR.
  34090. */
  34091. protected _indexOfRefraction: number;
  34092. /**
  34093. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34094. */
  34095. protected _invertRefractionY: boolean;
  34096. /**
  34097. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34098. * Materials half opaque for instance using refraction could benefit from this control.
  34099. */
  34100. protected _linkRefractionWithTransparency: boolean;
  34101. /**
  34102. * Specifies that the material will use the light map as a show map.
  34103. */
  34104. protected _useLightmapAsShadowmap: boolean;
  34105. /**
  34106. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34107. * makes the reflect vector face the model (under horizon).
  34108. */
  34109. protected _useHorizonOcclusion: boolean;
  34110. /**
  34111. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34112. * too much the area relying on ambient texture to define their ambient occlusion.
  34113. */
  34114. protected _useRadianceOcclusion: boolean;
  34115. /**
  34116. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34117. */
  34118. protected _useAlphaFromAlbedoTexture: boolean;
  34119. /**
  34120. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34121. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34122. */
  34123. protected _useSpecularOverAlpha: boolean;
  34124. /**
  34125. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34126. */
  34127. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34128. /**
  34129. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34130. */
  34131. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  34132. /**
  34133. * Specifies if the metallic texture contains the roughness information in its green channel.
  34134. */
  34135. protected _useRoughnessFromMetallicTextureGreen: boolean;
  34136. /**
  34137. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34138. */
  34139. protected _useMetallnessFromMetallicTextureBlue: boolean;
  34140. /**
  34141. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34142. */
  34143. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  34144. /**
  34145. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34146. */
  34147. protected _useAmbientInGrayScale: boolean;
  34148. /**
  34149. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34150. * The material will try to infer what glossiness each pixel should be.
  34151. */
  34152. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  34153. /**
  34154. * BJS is using an harcoded light falloff based on a manually sets up range.
  34155. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34156. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34157. */
  34158. protected _usePhysicalLightFalloff: boolean;
  34159. /**
  34160. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34161. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34162. */
  34163. protected _useRadianceOverAlpha: boolean;
  34164. /**
  34165. * Allows using an object space normal map (instead of tangent space).
  34166. */
  34167. protected _useObjectSpaceNormalMap: boolean;
  34168. /**
  34169. * Allows using the bump map in parallax mode.
  34170. */
  34171. protected _useParallax: boolean;
  34172. /**
  34173. * Allows using the bump map in parallax occlusion mode.
  34174. */
  34175. protected _useParallaxOcclusion: boolean;
  34176. /**
  34177. * Controls the scale bias of the parallax mode.
  34178. */
  34179. protected _parallaxScaleBias: number;
  34180. /**
  34181. * If sets to true, disables all the lights affecting the material.
  34182. */
  34183. protected _disableLighting: boolean;
  34184. /**
  34185. * Number of Simultaneous lights allowed on the material.
  34186. */
  34187. protected _maxSimultaneousLights: number;
  34188. /**
  34189. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  34190. */
  34191. protected _invertNormalMapX: boolean;
  34192. /**
  34193. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  34194. */
  34195. protected _invertNormalMapY: boolean;
  34196. /**
  34197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34198. */
  34199. protected _twoSidedLighting: boolean;
  34200. /**
  34201. * Defines the alpha limits in alpha test mode.
  34202. */
  34203. protected _alphaCutOff: number;
  34204. /**
  34205. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34206. */
  34207. protected _forceAlphaTest: boolean;
  34208. /**
  34209. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34210. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34211. */
  34212. protected _useAlphaFresnel: boolean;
  34213. /**
  34214. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34215. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34216. */
  34217. protected _useLinearAlphaFresnel: boolean;
  34218. /**
  34219. * The transparency mode of the material.
  34220. */
  34221. protected _transparencyMode: Nullable<number>;
  34222. /**
  34223. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  34224. * from cos thetav and roughness:
  34225. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  34226. */
  34227. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  34228. /**
  34229. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34230. */
  34231. protected _forceIrradianceInFragment: boolean;
  34232. /**
  34233. * Force normal to face away from face.
  34234. */
  34235. protected _forceNormalForward: boolean;
  34236. /**
  34237. * Enables specular anti aliasing in the PBR shader.
  34238. * It will both interacts on the Geometry for analytical and IBL lighting.
  34239. * It also prefilter the roughness map based on the bump values.
  34240. */
  34241. protected _enableSpecularAntiAliasing: boolean;
  34242. /**
  34243. * Default configuration related to image processing available in the PBR Material.
  34244. */
  34245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34246. /**
  34247. * Keep track of the image processing observer to allow dispose and replace.
  34248. */
  34249. private _imageProcessingObserver;
  34250. /**
  34251. * Attaches a new image processing configuration to the PBR Material.
  34252. * @param configuration
  34253. */
  34254. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34255. /**
  34256. * Stores the available render targets.
  34257. */
  34258. private _renderTargets;
  34259. /**
  34260. * Sets the global ambient color for the material used in lighting calculations.
  34261. */
  34262. private _globalAmbientColor;
  34263. /**
  34264. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  34265. */
  34266. private _useLogarithmicDepth;
  34267. /**
  34268. * If set to true, no lighting calculations will be applied.
  34269. */
  34270. private _unlit;
  34271. /**
  34272. * Instantiates a new PBRMaterial instance.
  34273. *
  34274. * @param name The material name
  34275. * @param scene The scene the material will be use in.
  34276. */
  34277. constructor(name: string, scene: Scene);
  34278. /**
  34279. * Gets the name of the material class.
  34280. */
  34281. getClassName(): string;
  34282. /**
  34283. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34284. */
  34285. /**
  34286. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34287. */
  34288. useLogarithmicDepth: boolean;
  34289. /**
  34290. * Gets the current transparency mode.
  34291. */
  34292. /**
  34293. * Sets the transparency mode of the material.
  34294. *
  34295. * | Value | Type | Description |
  34296. * | ----- | ----------------------------------- | ----------- |
  34297. * | 0 | OPAQUE | |
  34298. * | 1 | ALPHATEST | |
  34299. * | 2 | ALPHABLEND | |
  34300. * | 3 | ALPHATESTANDBLEND | |
  34301. *
  34302. */
  34303. transparencyMode: Nullable<number>;
  34304. /**
  34305. * Returns true if alpha blending should be disabled.
  34306. */
  34307. private readonly _disableAlphaBlending;
  34308. /**
  34309. * Specifies whether or not this material should be rendered in alpha blend mode.
  34310. */
  34311. needAlphaBlending(): boolean;
  34312. /**
  34313. * Specifies if the mesh will require alpha blending.
  34314. * @param mesh - BJS mesh.
  34315. */
  34316. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  34317. /**
  34318. * Specifies whether or not this material should be rendered in alpha test mode.
  34319. */
  34320. needAlphaTesting(): boolean;
  34321. /**
  34322. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  34323. */
  34324. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  34325. /**
  34326. * Gets the texture used for the alpha test.
  34327. */
  34328. getAlphaTestTexture(): BaseTexture;
  34329. /**
  34330. * Stores the reflectivity values based on metallic roughness workflow.
  34331. */
  34332. private static _scaledReflectivity;
  34333. /**
  34334. * Specifies that the submesh is ready to be used.
  34335. * @param mesh - BJS mesh.
  34336. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  34337. * @param useInstances - Specifies that instances should be used.
  34338. * @returns - boolean indicating that the submesh is ready or not.
  34339. */
  34340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34341. /**
  34342. * Specifies if the material uses metallic roughness workflow.
  34343. * @returns boolean specifiying if the material uses metallic roughness workflow.
  34344. */
  34345. isMetallicWorkflow(): boolean;
  34346. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  34347. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  34348. /**
  34349. * Force shader compilation
  34350. */
  34351. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  34352. clipPlane: boolean;
  34353. }>): void;
  34354. /**
  34355. * Initializes the uniform buffer layout for the shader.
  34356. */
  34357. buildUniformLayout(): void;
  34358. /**
  34359. * Unbinds the textures.
  34360. */
  34361. unbind(): void;
  34362. /**
  34363. * Binds the submesh data.
  34364. * @param world - The world matrix.
  34365. * @param mesh - The BJS mesh.
  34366. * @param subMesh - A submesh of the BJS mesh.
  34367. */
  34368. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34369. /**
  34370. * Returns the animatable textures.
  34371. * @returns - Array of animatable textures.
  34372. */
  34373. getAnimatables(): IAnimatable[];
  34374. /**
  34375. * Returns the texture used for reflections.
  34376. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  34377. */
  34378. private _getReflectionTexture();
  34379. /**
  34380. * Returns the texture used for refraction or null if none is used.
  34381. * @returns - Refection texture if present. If no refraction texture and refraction
  34382. * is linked with transparency, returns environment texture. Otherwise, returns null.
  34383. */
  34384. private _getRefractionTexture();
  34385. /**
  34386. * Disposes the resources of the material.
  34387. * @param forceDisposeEffect - Forces the disposal of effects.
  34388. * @param forceDisposeTextures - Forces the disposal of all textures.
  34389. */
  34390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34391. }
  34392. }
  34393. declare module BABYLON {
  34394. /**
  34395. * The Physically based simple base material of BJS.
  34396. *
  34397. * This enables better naming and convention enforcements on top of the pbrMaterial.
  34398. * It is used as the base class for both the specGloss and metalRough conventions.
  34399. */
  34400. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  34401. /**
  34402. * Number of Simultaneous lights allowed on the material.
  34403. */
  34404. maxSimultaneousLights: number;
  34405. /**
  34406. * If sets to true, disables all the lights affecting the material.
  34407. */
  34408. disableLighting: boolean;
  34409. /**
  34410. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  34411. */
  34412. environmentTexture: BaseTexture;
  34413. /**
  34414. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34415. */
  34416. invertNormalMapX: boolean;
  34417. /**
  34418. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34419. */
  34420. invertNormalMapY: boolean;
  34421. /**
  34422. * Normal map used in the model.
  34423. */
  34424. normalTexture: BaseTexture;
  34425. /**
  34426. * Emissivie color used to self-illuminate the model.
  34427. */
  34428. emissiveColor: Color3;
  34429. /**
  34430. * Emissivie texture used to self-illuminate the model.
  34431. */
  34432. emissiveTexture: BaseTexture;
  34433. /**
  34434. * Occlusion Channel Strenght.
  34435. */
  34436. occlusionStrength: number;
  34437. /**
  34438. * Occlusion Texture of the material (adding extra occlusion effects).
  34439. */
  34440. occlusionTexture: BaseTexture;
  34441. /**
  34442. * Defines the alpha limits in alpha test mode.
  34443. */
  34444. alphaCutOff: number;
  34445. /**
  34446. * Gets the current double sided mode.
  34447. */
  34448. /**
  34449. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34450. */
  34451. doubleSided: boolean;
  34452. lightmapTexture: BaseTexture;
  34453. useLightmapAsShadowmap: boolean;
  34454. /**
  34455. * Return the active textures of the material.
  34456. */
  34457. getActiveTextures(): BaseTexture[];
  34458. hasTexture(texture: BaseTexture): boolean;
  34459. /**
  34460. * Instantiates a new PBRMaterial instance.
  34461. *
  34462. * @param name The material name
  34463. * @param scene The scene the material will be use in.
  34464. */
  34465. constructor(name: string, scene: Scene);
  34466. getClassName(): string;
  34467. }
  34468. }
  34469. declare module BABYLON {
  34470. /**
  34471. * The Physically based material of BJS.
  34472. *
  34473. * This offers the main features of a standard PBR material.
  34474. * For more information, please refer to the documentation :
  34475. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34476. */
  34477. class PBRMaterial extends PBRBaseMaterial {
  34478. private static _PBRMATERIAL_OPAQUE;
  34479. /**
  34480. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  34481. */
  34482. static readonly PBRMATERIAL_OPAQUE: number;
  34483. /**
  34484. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34485. */
  34486. private static _PBRMATERIAL_ALPHATEST;
  34487. /**
  34488. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34489. */
  34490. static readonly PBRMATERIAL_ALPHATEST: number;
  34491. /**
  34492. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34493. */
  34494. private static _PBRMATERIAL_ALPHABLEND;
  34495. /**
  34496. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34497. */
  34498. static readonly PBRMATERIAL_ALPHABLEND: number;
  34499. /**
  34500. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34501. * They are also discarded below the alpha cutoff threshold to improve performances.
  34502. */
  34503. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  34504. /**
  34505. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34506. * They are also discarded below the alpha cutoff threshold to improve performances.
  34507. */
  34508. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  34509. /**
  34510. * Intensity of the direct lights e.g. the four lights available in your scene.
  34511. * This impacts both the direct diffuse and specular highlights.
  34512. */
  34513. directIntensity: number;
  34514. /**
  34515. * Intensity of the emissive part of the material.
  34516. * This helps controlling the emissive effect without modifying the emissive color.
  34517. */
  34518. emissiveIntensity: number;
  34519. /**
  34520. * Intensity of the environment e.g. how much the environment will light the object
  34521. * either through harmonics for rough material or through the refelction for shiny ones.
  34522. */
  34523. environmentIntensity: number;
  34524. /**
  34525. * This is a special control allowing the reduction of the specular highlights coming from the
  34526. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34527. */
  34528. specularIntensity: number;
  34529. /**
  34530. * Debug Control allowing disabling the bump map on this material.
  34531. */
  34532. disableBumpMap: boolean;
  34533. /**
  34534. * AKA Diffuse Texture in standard nomenclature.
  34535. */
  34536. albedoTexture: BaseTexture;
  34537. /**
  34538. * AKA Occlusion Texture in other nomenclature.
  34539. */
  34540. ambientTexture: BaseTexture;
  34541. /**
  34542. * AKA Occlusion Texture Intensity in other nomenclature.
  34543. */
  34544. ambientTextureStrength: number;
  34545. /**
  34546. * Stores the alpha values in a texture.
  34547. */
  34548. opacityTexture: BaseTexture;
  34549. /**
  34550. * Stores the reflection values in a texture.
  34551. */
  34552. reflectionTexture: Nullable<BaseTexture>;
  34553. /**
  34554. * Stores the emissive values in a texture.
  34555. */
  34556. emissiveTexture: BaseTexture;
  34557. /**
  34558. * AKA Specular texture in other nomenclature.
  34559. */
  34560. reflectivityTexture: BaseTexture;
  34561. /**
  34562. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34563. */
  34564. metallicTexture: BaseTexture;
  34565. /**
  34566. * Specifies the metallic scalar of the metallic/roughness workflow.
  34567. * Can also be used to scale the metalness values of the metallic texture.
  34568. */
  34569. metallic: number;
  34570. /**
  34571. * Specifies the roughness scalar of the metallic/roughness workflow.
  34572. * Can also be used to scale the roughness values of the metallic texture.
  34573. */
  34574. roughness: number;
  34575. /**
  34576. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34577. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34578. */
  34579. microSurfaceTexture: BaseTexture;
  34580. /**
  34581. * Stores surface normal data used to displace a mesh in a texture.
  34582. */
  34583. bumpTexture: BaseTexture;
  34584. /**
  34585. * Stores the pre-calculated light information of a mesh in a texture.
  34586. */
  34587. lightmapTexture: BaseTexture;
  34588. /**
  34589. * Stores the refracted light information in a texture.
  34590. */
  34591. refractionTexture: BaseTexture;
  34592. /**
  34593. * The color of a material in ambient lighting.
  34594. */
  34595. ambientColor: Color3;
  34596. /**
  34597. * AKA Diffuse Color in other nomenclature.
  34598. */
  34599. albedoColor: Color3;
  34600. /**
  34601. * AKA Specular Color in other nomenclature.
  34602. */
  34603. reflectivityColor: Color3;
  34604. /**
  34605. * The color reflected from the material.
  34606. */
  34607. reflectionColor: Color3;
  34608. /**
  34609. * The color emitted from the material.
  34610. */
  34611. emissiveColor: Color3;
  34612. /**
  34613. * AKA Glossiness in other nomenclature.
  34614. */
  34615. microSurface: number;
  34616. /**
  34617. * source material index of refraction (IOR)' / 'destination material IOR.
  34618. */
  34619. indexOfRefraction: number;
  34620. /**
  34621. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34622. */
  34623. invertRefractionY: boolean;
  34624. /**
  34625. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34626. * Materials half opaque for instance using refraction could benefit from this control.
  34627. */
  34628. linkRefractionWithTransparency: boolean;
  34629. useLightmapAsShadowmap: boolean;
  34630. /**
  34631. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34632. */
  34633. useAlphaFromAlbedoTexture: boolean;
  34634. /**
  34635. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34636. */
  34637. forceAlphaTest: boolean;
  34638. /**
  34639. * Defines the alpha limits in alpha test mode.
  34640. */
  34641. alphaCutOff: number;
  34642. /**
  34643. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34644. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34645. */
  34646. useSpecularOverAlpha: boolean;
  34647. /**
  34648. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34649. */
  34650. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34651. /**
  34652. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34653. */
  34654. useRoughnessFromMetallicTextureAlpha: boolean;
  34655. /**
  34656. * Specifies if the metallic texture contains the roughness information in its green channel.
  34657. */
  34658. useRoughnessFromMetallicTextureGreen: boolean;
  34659. /**
  34660. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34661. */
  34662. useMetallnessFromMetallicTextureBlue: boolean;
  34663. /**
  34664. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34665. */
  34666. useAmbientOcclusionFromMetallicTextureRed: boolean;
  34667. /**
  34668. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34669. */
  34670. useAmbientInGrayScale: boolean;
  34671. /**
  34672. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34673. * The material will try to infer what glossiness each pixel should be.
  34674. */
  34675. useAutoMicroSurfaceFromReflectivityMap: boolean;
  34676. /**
  34677. * BJS is using an harcoded light falloff based on a manually sets up range.
  34678. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34679. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34680. */
  34681. usePhysicalLightFalloff: boolean;
  34682. /**
  34683. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34684. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34685. */
  34686. useRadianceOverAlpha: boolean;
  34687. /**
  34688. * Allows using an object space normal map (instead of tangent space).
  34689. */
  34690. useObjectSpaceNormalMap: boolean;
  34691. /**
  34692. * Allows using the bump map in parallax mode.
  34693. */
  34694. useParallax: boolean;
  34695. /**
  34696. * Allows using the bump map in parallax occlusion mode.
  34697. */
  34698. useParallaxOcclusion: boolean;
  34699. /**
  34700. * Controls the scale bias of the parallax mode.
  34701. */
  34702. parallaxScaleBias: number;
  34703. /**
  34704. * If sets to true, disables all the lights affecting the material.
  34705. */
  34706. disableLighting: boolean;
  34707. /**
  34708. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34709. */
  34710. forceIrradianceInFragment: boolean;
  34711. /**
  34712. * Number of Simultaneous lights allowed on the material.
  34713. */
  34714. maxSimultaneousLights: number;
  34715. /**
  34716. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34717. */
  34718. invertNormalMapX: boolean;
  34719. /**
  34720. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34721. */
  34722. invertNormalMapY: boolean;
  34723. /**
  34724. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34725. */
  34726. twoSidedLighting: boolean;
  34727. /**
  34728. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34729. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34730. */
  34731. useAlphaFresnel: boolean;
  34732. /**
  34733. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34734. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34735. */
  34736. useLinearAlphaFresnel: boolean;
  34737. /**
  34738. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34739. * And/Or occlude the blended part.
  34740. */
  34741. environmentBRDFTexture: Nullable<BaseTexture>;
  34742. /**
  34743. * Force normal to face away from face.
  34744. */
  34745. forceNormalForward: boolean;
  34746. /**
  34747. * Enables specular anti aliasing in the PBR shader.
  34748. * It will both interacts on the Geometry for analytical and IBL lighting.
  34749. * It also prefilter the roughness map based on the bump values.
  34750. */
  34751. enableSpecularAntiAliasing: boolean;
  34752. /**
  34753. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34754. * makes the reflect vector face the model (under horizon).
  34755. */
  34756. useHorizonOcclusion: boolean;
  34757. /**
  34758. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34759. * too much the area relying on ambient texture to define their ambient occlusion.
  34760. */
  34761. useRadianceOcclusion: boolean;
  34762. /**
  34763. * If set to true, no lighting calculations will be applied.
  34764. */
  34765. unlit: boolean;
  34766. /**
  34767. * Gets the image processing configuration used either in this material.
  34768. */
  34769. /**
  34770. * Sets the Default image processing configuration used either in the this material.
  34771. *
  34772. * If sets to null, the scene one is in use.
  34773. */
  34774. imageProcessingConfiguration: ImageProcessingConfiguration;
  34775. /**
  34776. * Gets wether the color curves effect is enabled.
  34777. */
  34778. /**
  34779. * Sets wether the color curves effect is enabled.
  34780. */
  34781. cameraColorCurvesEnabled: boolean;
  34782. /**
  34783. * Gets wether the color grading effect is enabled.
  34784. */
  34785. /**
  34786. * Gets wether the color grading effect is enabled.
  34787. */
  34788. cameraColorGradingEnabled: boolean;
  34789. /**
  34790. * Gets wether tonemapping is enabled or not.
  34791. */
  34792. /**
  34793. * Sets wether tonemapping is enabled or not
  34794. */
  34795. cameraToneMappingEnabled: boolean;
  34796. /**
  34797. * The camera exposure used on this material.
  34798. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34799. * This corresponds to a photographic exposure.
  34800. */
  34801. /**
  34802. * The camera exposure used on this material.
  34803. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34804. * This corresponds to a photographic exposure.
  34805. */
  34806. cameraExposure: number;
  34807. /**
  34808. * Gets The camera contrast used on this material.
  34809. */
  34810. /**
  34811. * Sets The camera contrast used on this material.
  34812. */
  34813. cameraContrast: number;
  34814. /**
  34815. * Gets the Color Grading 2D Lookup Texture.
  34816. */
  34817. /**
  34818. * Sets the Color Grading 2D Lookup Texture.
  34819. */
  34820. cameraColorGradingTexture: Nullable<BaseTexture>;
  34821. /**
  34822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34824. * 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;
  34825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34826. */
  34827. /**
  34828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34830. * 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;
  34831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34832. */
  34833. cameraColorCurves: Nullable<ColorCurves>;
  34834. /**
  34835. * Instantiates a new PBRMaterial instance.
  34836. *
  34837. * @param name The material name
  34838. * @param scene The scene the material will be use in.
  34839. */
  34840. constructor(name: string, scene: Scene);
  34841. /**
  34842. * Returns the name of this material class.
  34843. */
  34844. getClassName(): string;
  34845. /**
  34846. * Returns an array of the actively used textures.
  34847. * @returns - Array of BaseTextures
  34848. */
  34849. getActiveTextures(): BaseTexture[];
  34850. /**
  34851. * Checks to see if a texture is used in the material.
  34852. * @param texture - Base texture to use.
  34853. * @returns - Boolean specifying if a texture is used in the material.
  34854. */
  34855. hasTexture(texture: BaseTexture): boolean;
  34856. /**
  34857. * Makes a duplicate of the current material.
  34858. * @param name - name to use for the new material.
  34859. */
  34860. clone(name: string): PBRMaterial;
  34861. /**
  34862. * Serializes this PBR Material.
  34863. * @returns - An object with the serialized material.
  34864. */
  34865. serialize(): any;
  34866. /**
  34867. * Parses a PBR Material from a serialized object.
  34868. * @param source - Serialized object.
  34869. * @param scene - BJS scene instance.
  34870. * @param rootUrl - url for the scene object
  34871. * @returns - PBRMaterial
  34872. */
  34873. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  34874. }
  34875. }
  34876. declare module BABYLON {
  34877. /**
  34878. * The PBR material of BJS following the metal roughness convention.
  34879. *
  34880. * This fits to the PBR convention in the GLTF definition:
  34881. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  34882. */
  34883. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  34884. /**
  34885. * The base color has two different interpretations depending on the value of metalness.
  34886. * When the material is a metal, the base color is the specific measured reflectance value
  34887. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  34888. * of the material.
  34889. */
  34890. baseColor: Color3;
  34891. /**
  34892. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  34893. * well as opacity information in the alpha channel.
  34894. */
  34895. baseTexture: BaseTexture;
  34896. /**
  34897. * Specifies the metallic scalar value of the material.
  34898. * Can also be used to scale the metalness values of the metallic texture.
  34899. */
  34900. metallic: number;
  34901. /**
  34902. * Specifies the roughness scalar value of the material.
  34903. * Can also be used to scale the roughness values of the metallic texture.
  34904. */
  34905. roughness: number;
  34906. /**
  34907. * Texture containing both the metallic value in the B channel and the
  34908. * roughness value in the G channel to keep better precision.
  34909. */
  34910. metallicRoughnessTexture: BaseTexture;
  34911. /**
  34912. * Instantiates a new PBRMetalRoughnessMaterial instance.
  34913. *
  34914. * @param name The material name
  34915. * @param scene The scene the material will be use in.
  34916. */
  34917. constructor(name: string, scene: Scene);
  34918. /**
  34919. * Return the currrent class name of the material.
  34920. */
  34921. getClassName(): string;
  34922. /**
  34923. * Return the active textures of the material.
  34924. */
  34925. getActiveTextures(): BaseTexture[];
  34926. /**
  34927. * Checks to see if a texture is used in the material.
  34928. * @param texture - Base texture to use.
  34929. * @returns - Boolean specifying if a texture is used in the material.
  34930. */
  34931. hasTexture(texture: BaseTexture): boolean;
  34932. /**
  34933. * Makes a duplicate of the current material.
  34934. * @param name - name to use for the new material.
  34935. */
  34936. clone(name: string): PBRMetallicRoughnessMaterial;
  34937. /**
  34938. * Serialize the material to a parsable JSON object.
  34939. */
  34940. serialize(): any;
  34941. /**
  34942. * Parses a JSON object correponding to the serialize function.
  34943. */
  34944. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  34945. }
  34946. }
  34947. declare module BABYLON {
  34948. /**
  34949. * The PBR material of BJS following the specular glossiness convention.
  34950. *
  34951. * This fits to the PBR convention in the GLTF definition:
  34952. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  34953. */
  34954. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  34955. /**
  34956. * Specifies the diffuse color of the material.
  34957. */
  34958. diffuseColor: Color3;
  34959. /**
  34960. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  34961. * channel.
  34962. */
  34963. diffuseTexture: BaseTexture;
  34964. /**
  34965. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  34966. */
  34967. specularColor: Color3;
  34968. /**
  34969. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  34970. */
  34971. glossiness: number;
  34972. /**
  34973. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  34974. */
  34975. specularGlossinessTexture: BaseTexture;
  34976. /**
  34977. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  34978. *
  34979. * @param name The material name
  34980. * @param scene The scene the material will be use in.
  34981. */
  34982. constructor(name: string, scene: Scene);
  34983. /**
  34984. * Return the currrent class name of the material.
  34985. */
  34986. getClassName(): string;
  34987. /**
  34988. * Return the active textures of the material.
  34989. */
  34990. getActiveTextures(): BaseTexture[];
  34991. /**
  34992. * Checks to see if a texture is used in the material.
  34993. * @param texture - Base texture to use.
  34994. * @returns - Boolean specifying if a texture is used in the material.
  34995. */
  34996. hasTexture(texture: BaseTexture): boolean;
  34997. /**
  34998. * Makes a duplicate of the current material.
  34999. * @param name - name to use for the new material.
  35000. */
  35001. clone(name: string): PBRSpecularGlossinessMaterial;
  35002. /**
  35003. * Serialize the material to a parsable JSON object.
  35004. */
  35005. serialize(): any;
  35006. /**
  35007. * Parses a JSON object correponding to the serialize function.
  35008. */
  35009. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  35010. }
  35011. }
  35012. declare module BABYLON {
  35013. class BaseTexture {
  35014. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35015. name: string;
  35016. private _hasAlpha;
  35017. hasAlpha: boolean;
  35018. getAlphaFromRGB: boolean;
  35019. level: number;
  35020. coordinatesIndex: number;
  35021. private _coordinatesMode;
  35022. /**
  35023. * How a texture is mapped.
  35024. *
  35025. * | Value | Type | Description |
  35026. * | ----- | ----------------------------------- | ----------- |
  35027. * | 0 | EXPLICIT_MODE | |
  35028. * | 1 | SPHERICAL_MODE | |
  35029. * | 2 | PLANAR_MODE | |
  35030. * | 3 | CUBIC_MODE | |
  35031. * | 4 | PROJECTION_MODE | |
  35032. * | 5 | SKYBOX_MODE | |
  35033. * | 6 | INVCUBIC_MODE | |
  35034. * | 7 | EQUIRECTANGULAR_MODE | |
  35035. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35036. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35037. */
  35038. coordinatesMode: number;
  35039. /**
  35040. * | Value | Type | Description |
  35041. * | ----- | ------------------ | ----------- |
  35042. * | 0 | CLAMP_ADDRESSMODE | |
  35043. * | 1 | WRAP_ADDRESSMODE | |
  35044. * | 2 | MIRROR_ADDRESSMODE | |
  35045. */
  35046. wrapU: number;
  35047. /**
  35048. * | Value | Type | Description |
  35049. * | ----- | ------------------ | ----------- |
  35050. * | 0 | CLAMP_ADDRESSMODE | |
  35051. * | 1 | WRAP_ADDRESSMODE | |
  35052. * | 2 | MIRROR_ADDRESSMODE | |
  35053. */
  35054. wrapV: number;
  35055. /**
  35056. * | Value | Type | Description |
  35057. * | ----- | ------------------ | ----------- |
  35058. * | 0 | CLAMP_ADDRESSMODE | |
  35059. * | 1 | WRAP_ADDRESSMODE | |
  35060. * | 2 | MIRROR_ADDRESSMODE | |
  35061. */
  35062. wrapR: number;
  35063. anisotropicFilteringLevel: number;
  35064. isCube: boolean;
  35065. is3D: boolean;
  35066. gammaSpace: boolean;
  35067. /**
  35068. * Gets whether or not the texture contains RGBD data.
  35069. */
  35070. readonly isRGBD: boolean;
  35071. invertZ: boolean;
  35072. lodLevelInAlpha: boolean;
  35073. lodGenerationOffset: number;
  35074. lodGenerationScale: number;
  35075. isRenderTarget: boolean;
  35076. readonly uid: string;
  35077. toString(): string;
  35078. getClassName(): string;
  35079. animations: Animation[];
  35080. /**
  35081. * An event triggered when the texture is disposed.
  35082. */
  35083. onDisposeObservable: Observable<BaseTexture>;
  35084. private _onDisposeObserver;
  35085. onDispose: () => void;
  35086. delayLoadState: number;
  35087. private _scene;
  35088. _texture: Nullable<InternalTexture>;
  35089. private _uid;
  35090. readonly isBlocking: boolean;
  35091. constructor(scene: Nullable<Scene>);
  35092. getScene(): Nullable<Scene>;
  35093. getTextureMatrix(): Matrix;
  35094. getReflectionTextureMatrix(): Matrix;
  35095. getInternalTexture(): Nullable<InternalTexture>;
  35096. isReadyOrNotBlocking(): boolean;
  35097. isReady(): boolean;
  35098. private _cachedSize;
  35099. getSize(): ISize;
  35100. getBaseSize(): ISize;
  35101. scale(ratio: number): void;
  35102. readonly canRescale: boolean;
  35103. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  35104. _rebuild(): void;
  35105. delayLoad(): void;
  35106. clone(): Nullable<BaseTexture>;
  35107. readonly textureType: number;
  35108. readonly textureFormat: number;
  35109. /**
  35110. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35111. * This will returns an RGBA array buffer containing either in values (0-255) or
  35112. * float values (0-1) depending of the underlying buffer type.
  35113. * @param faceIndex The face of the texture to read (in case of cube texture)
  35114. * @param level The LOD level of the texture to read (in case of Mip Maps)
  35115. * @returns The Array buffer containing the pixels data.
  35116. */
  35117. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  35118. releaseInternalTexture(): void;
  35119. sphericalPolynomial: Nullable<SphericalPolynomial>;
  35120. readonly _lodTextureHigh: Nullable<BaseTexture>;
  35121. readonly _lodTextureMid: Nullable<BaseTexture>;
  35122. readonly _lodTextureLow: Nullable<BaseTexture>;
  35123. dispose(): void;
  35124. serialize(): any;
  35125. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35126. }
  35127. }
  35128. declare module BABYLON {
  35129. /**
  35130. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  35131. * It can help converting any input color in a desired output one. This can then be used to create effects
  35132. * from sepia, black and white to sixties or futuristic rendering...
  35133. *
  35134. * The only supported format is currently 3dl.
  35135. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  35136. */
  35137. class ColorGradingTexture extends BaseTexture {
  35138. /**
  35139. * The current texture matrix. (will always be identity in color grading texture)
  35140. */
  35141. private _textureMatrix;
  35142. /**
  35143. * The texture URL.
  35144. */
  35145. url: string;
  35146. /**
  35147. * Empty line regex stored for GC.
  35148. */
  35149. private static _noneEmptyLineRegex;
  35150. private _engine;
  35151. /**
  35152. * Instantiates a ColorGradingTexture from the following parameters.
  35153. *
  35154. * @param url The location of the color gradind data (currently only supporting 3dl)
  35155. * @param scene The scene the texture will be used in
  35156. */
  35157. constructor(url: string, scene: Scene);
  35158. /**
  35159. * Returns the texture matrix used in most of the material.
  35160. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  35161. */
  35162. getTextureMatrix(): Matrix;
  35163. /**
  35164. * Occurs when the file being loaded is a .3dl LUT file.
  35165. */
  35166. private load3dlTexture();
  35167. /**
  35168. * Starts the loading process of the texture.
  35169. */
  35170. private loadTexture();
  35171. /**
  35172. * Clones the color gradind texture.
  35173. */
  35174. clone(): ColorGradingTexture;
  35175. /**
  35176. * Called during delayed load for textures.
  35177. */
  35178. delayLoad(): void;
  35179. /**
  35180. * Parses a color grading texture serialized by Babylon.
  35181. * @param parsedTexture The texture information being parsedTexture
  35182. * @param scene The scene to load the texture in
  35183. * @param rootUrl The root url of the data assets to load
  35184. * @return A color gradind texture
  35185. */
  35186. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  35187. /**
  35188. * Serializes the LUT texture to json format.
  35189. */
  35190. serialize(): any;
  35191. }
  35192. }
  35193. declare module BABYLON {
  35194. class CubeTexture extends BaseTexture {
  35195. url: string;
  35196. /**
  35197. * Gets or sets the center of the bounding box associated with the cube texture
  35198. * It must define where the camera used to render the texture was set
  35199. */
  35200. boundingBoxPosition: Vector3;
  35201. private _boundingBoxSize;
  35202. /**
  35203. * Gets or sets the size of the bounding box associated with the cube texture
  35204. * When defined, the cubemap will switch to local mode
  35205. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35206. * @example https://www.babylonjs-playground.com/#RNASML
  35207. */
  35208. boundingBoxSize: Vector3;
  35209. protected _rotationY: number;
  35210. /**
  35211. * Gets texture matrix rotation angle around Y axis radians.
  35212. */
  35213. /**
  35214. * Sets texture matrix rotation angle around Y axis in radians.
  35215. */
  35216. rotationY: number;
  35217. private _noMipmap;
  35218. private _files;
  35219. private _extensions;
  35220. private _textureMatrix;
  35221. private _format;
  35222. private _createPolynomials;
  35223. /** @hidden */
  35224. readonly _prefiltered: boolean;
  35225. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  35226. /**
  35227. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  35228. * @param url defines the url of the prefiltered texture
  35229. * @param scene defines the scene the texture is attached to
  35230. * @param forcedExtension defines the extension of the file if different from the url
  35231. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35232. * @return the prefiltered texture
  35233. */
  35234. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  35235. /**
  35236. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  35237. * as prefiltered data.
  35238. * @param rootUrl defines the url of the texture or the root name of the six images
  35239. * @param scene defines the scene the texture is attached to
  35240. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  35241. * @param noMipmap defines if mipmaps should be created or not
  35242. * @param files defines the six files to load for the different faces
  35243. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  35244. * @param onError defines a callback triggered in case of error during load
  35245. * @param format defines the internal format to use for the texture once loaded
  35246. * @param prefiltered defines whether or not the texture is created from prefiltered data
  35247. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  35248. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35249. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35250. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35251. * @return the cube texture
  35252. */
  35253. 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);
  35254. delayLoad(): void;
  35255. getReflectionTextureMatrix(): Matrix;
  35256. setReflectionTextureMatrix(value: Matrix): void;
  35257. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  35258. clone(): CubeTexture;
  35259. }
  35260. }
  35261. declare module BABYLON {
  35262. /**
  35263. * A class extending {BABYLON.Texture} allowing drawing on a texture
  35264. * @see http://doc.babylonjs.com/how_to/dynamictexture
  35265. */
  35266. class DynamicTexture extends Texture {
  35267. private _generateMipMaps;
  35268. private _canvas;
  35269. private _context;
  35270. private _engine;
  35271. /**
  35272. * Creates a {BABYLON.DynamicTexture}
  35273. * @param name defines the name of the texture
  35274. * @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
  35275. * @param scene defines the scene where you want the texture
  35276. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  35277. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35278. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  35279. */
  35280. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  35281. /**
  35282. * Gets the current state of canRescale
  35283. */
  35284. readonly canRescale: boolean;
  35285. private _recreate(textureSize);
  35286. /**
  35287. * Scales the texture
  35288. * @param ratio the scale factor to apply to both width and height
  35289. */
  35290. scale(ratio: number): void;
  35291. /**
  35292. * Resizes the texture
  35293. * @param width the new width
  35294. * @param height the new height
  35295. */
  35296. scaleTo(width: number, height: number): void;
  35297. /**
  35298. * Gets the context of the canvas used by the texture
  35299. * @returns the canvas context of the dynamic texture
  35300. */
  35301. getContext(): CanvasRenderingContext2D;
  35302. /**
  35303. * Clears the texture
  35304. */
  35305. clear(): void;
  35306. /**
  35307. * Updates the texture
  35308. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35309. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  35310. */
  35311. update(invertY?: boolean, premulAlpha?: boolean): void;
  35312. /**
  35313. * Draws text onto the texture
  35314. * @param text defines the text to be drawn
  35315. * @param x defines the placement of the text from the left
  35316. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  35317. * @param font defines the font to be used with font-style, font-size, font-name
  35318. * @param color defines the color used for the text
  35319. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  35320. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35321. * @param update defines whether texture is immediately update (default is true)
  35322. */
  35323. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  35324. /**
  35325. * Clones the texture
  35326. * @returns the clone of the texture.
  35327. */
  35328. clone(): DynamicTexture;
  35329. /** @hidden */
  35330. _rebuild(): void;
  35331. }
  35332. }
  35333. declare module BABYLON {
  35334. /**
  35335. * This represents a texture coming from an HDR input.
  35336. *
  35337. * The only supported format is currently panorama picture stored in RGBE format.
  35338. * Example of such files can be found on HDRLib: http://hdrlib.com/
  35339. */
  35340. class HDRCubeTexture extends BaseTexture {
  35341. private static _facesMapping;
  35342. private _generateHarmonics;
  35343. private _noMipmap;
  35344. private _textureMatrix;
  35345. private _size;
  35346. private _onLoad;
  35347. private _onError;
  35348. /**
  35349. * The texture URL.
  35350. */
  35351. url: string;
  35352. /**
  35353. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  35354. */
  35355. coordinatesMode: number;
  35356. protected _isBlocking: boolean;
  35357. /**
  35358. * Gets wether or not the texture is blocking during loading.
  35359. */
  35360. /**
  35361. * Sets wether or not the texture is blocking during loading.
  35362. */
  35363. isBlocking: boolean;
  35364. protected _rotationY: number;
  35365. /**
  35366. * Gets texture matrix rotation angle around Y axis radians.
  35367. */
  35368. /**
  35369. * Sets texture matrix rotation angle around Y axis in radians.
  35370. */
  35371. rotationY: number;
  35372. /**
  35373. * Gets or sets the center of the bounding box associated with the cube texture
  35374. * It must define where the camera used to render the texture was set
  35375. */
  35376. boundingBoxPosition: Vector3;
  35377. private _boundingBoxSize;
  35378. /**
  35379. * Gets or sets the size of the bounding box associated with the cube texture
  35380. * When defined, the cubemap will switch to local mode
  35381. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35382. * @example https://www.babylonjs-playground.com/#RNASML
  35383. */
  35384. boundingBoxSize: Vector3;
  35385. /**
  35386. * Instantiates an HDRTexture from the following parameters.
  35387. *
  35388. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  35389. * @param scene The scene the texture will be used in
  35390. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  35391. * @param noMipmap Forces to not generate the mipmap if true
  35392. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  35393. * @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)
  35394. * @param reserved Reserved flag for internal use.
  35395. */
  35396. 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>);
  35397. /**
  35398. * Occurs when the file is raw .hdr file.
  35399. */
  35400. private loadTexture();
  35401. clone(): HDRCubeTexture;
  35402. delayLoad(): void;
  35403. getReflectionTextureMatrix(): Matrix;
  35404. setReflectionTextureMatrix(value: Matrix): void;
  35405. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  35406. serialize(): any;
  35407. }
  35408. }
  35409. declare module BABYLON {
  35410. /**
  35411. * Class used to store data associated with WebGL texture data for the engine
  35412. * This class should not be used directly
  35413. */
  35414. class InternalTexture implements IInternalTextureTracker {
  35415. /**
  35416. * The source of the texture data is unknown
  35417. */
  35418. static DATASOURCE_UNKNOWN: number;
  35419. /**
  35420. * Texture data comes from an URL
  35421. */
  35422. static DATASOURCE_URL: number;
  35423. /**
  35424. * Texture data is only used for temporary storage
  35425. */
  35426. static DATASOURCE_TEMP: number;
  35427. /**
  35428. * Texture data comes from raw data (ArrayBuffer)
  35429. */
  35430. static DATASOURCE_RAW: number;
  35431. /**
  35432. * Texture content is dynamic (video or dynamic texture)
  35433. */
  35434. static DATASOURCE_DYNAMIC: number;
  35435. /**
  35436. * Texture content is generated by rendering to it
  35437. */
  35438. static DATASOURCE_RENDERTARGET: number;
  35439. /**
  35440. * Texture content is part of a multi render target process
  35441. */
  35442. static DATASOURCE_MULTIRENDERTARGET: number;
  35443. /**
  35444. * Texture data comes from a cube data file
  35445. */
  35446. static DATASOURCE_CUBE: number;
  35447. /**
  35448. * Texture data comes from a raw cube data
  35449. */
  35450. static DATASOURCE_CUBERAW: number;
  35451. /**
  35452. * Texture data come from a prefiltered cube data file
  35453. */
  35454. static DATASOURCE_CUBEPREFILTERED: number;
  35455. /**
  35456. * Texture content is raw 3D data
  35457. */
  35458. static DATASOURCE_RAW3D: number;
  35459. /**
  35460. * Texture content is a depth texture
  35461. */
  35462. static DATASOURCE_DEPTHTEXTURE: number;
  35463. /**
  35464. * Texture data comes from a raw cube data encoded with RGBD
  35465. */
  35466. static DATASOURCE_CUBERAW_RGBD: number;
  35467. /**
  35468. * Defines if the texture is ready
  35469. */
  35470. isReady: boolean;
  35471. /**
  35472. * Defines if the texture is a cube texture
  35473. */
  35474. isCube: boolean;
  35475. /**
  35476. * Defines if the texture contains 3D data
  35477. */
  35478. is3D: boolean;
  35479. /**
  35480. * Gets the URL used to load this texture
  35481. */
  35482. url: string;
  35483. /**
  35484. * Gets the sampling mode of the texture
  35485. */
  35486. samplingMode: number;
  35487. /**
  35488. * Gets a boolean indicating if the texture needs mipmaps generation
  35489. */
  35490. generateMipMaps: boolean;
  35491. /**
  35492. * Gets the number of samples used by the texture (WebGL2+ only)
  35493. */
  35494. samples: number;
  35495. /**
  35496. * Gets the type of the texture
  35497. */
  35498. type: number;
  35499. /**
  35500. * Gets the format of the texture
  35501. */
  35502. format: number;
  35503. /**
  35504. * Observable called when the texture is loaded
  35505. */
  35506. onLoadedObservable: Observable<InternalTexture>;
  35507. /**
  35508. * Gets the width of the texture
  35509. */
  35510. width: number;
  35511. /**
  35512. * Gets the height of the texture
  35513. */
  35514. height: number;
  35515. /**
  35516. * Gets the depth of the texture
  35517. */
  35518. depth: number;
  35519. /**
  35520. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35521. */
  35522. baseWidth: number;
  35523. /**
  35524. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35525. */
  35526. baseHeight: number;
  35527. /**
  35528. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35529. */
  35530. baseDepth: number;
  35531. /**
  35532. * Gets a boolean indicating if the texture is inverted on Y axis
  35533. */
  35534. invertY: boolean;
  35535. /**
  35536. * Gets or set the previous tracker in the list
  35537. */
  35538. previous: Nullable<IInternalTextureTracker>;
  35539. /**
  35540. * Gets or set the next tracker in the list
  35541. */
  35542. next: Nullable<IInternalTextureTracker>;
  35543. /** @hidden */
  35544. _initialSlot: number;
  35545. /** @hidden */
  35546. _designatedSlot: number;
  35547. /** @hidden */
  35548. _dataSource: number;
  35549. /** @hidden */
  35550. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35551. /** @hidden */
  35552. _bufferView: Nullable<ArrayBufferView>;
  35553. /** @hidden */
  35554. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35555. /** @hidden */
  35556. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35557. /** @hidden */
  35558. _size: number;
  35559. /** @hidden */
  35560. _extension: string;
  35561. /** @hidden */
  35562. _files: Nullable<string[]>;
  35563. /** @hidden */
  35564. _workingCanvas: HTMLCanvasElement;
  35565. /** @hidden */
  35566. _workingContext: CanvasRenderingContext2D;
  35567. /** @hidden */
  35568. _framebuffer: Nullable<WebGLFramebuffer>;
  35569. /** @hidden */
  35570. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35571. /** @hidden */
  35572. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35573. /** @hidden */
  35574. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35575. /** @hidden */
  35576. _attachments: Nullable<number[]>;
  35577. /** @hidden */
  35578. _cachedCoordinatesMode: Nullable<number>;
  35579. /** @hidden */
  35580. _cachedWrapU: Nullable<number>;
  35581. /** @hidden */
  35582. _cachedWrapV: Nullable<number>;
  35583. /** @hidden */
  35584. _cachedWrapR: Nullable<number>;
  35585. /** @hidden */
  35586. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35587. /** @hidden */
  35588. _isDisabled: boolean;
  35589. /** @hidden */
  35590. _compression: Nullable<string>;
  35591. /** @hidden */
  35592. _generateStencilBuffer: boolean;
  35593. /** @hidden */
  35594. _generateDepthBuffer: boolean;
  35595. /** @hidden */
  35596. _comparisonFunction: number;
  35597. /** @hidden */
  35598. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35599. /** @hidden */
  35600. _lodGenerationScale: number;
  35601. /** @hidden */
  35602. _lodGenerationOffset: number;
  35603. /** @hidden */
  35604. _lodTextureHigh: BaseTexture;
  35605. /** @hidden */
  35606. _lodTextureMid: BaseTexture;
  35607. /** @hidden */
  35608. _lodTextureLow: BaseTexture;
  35609. /** @hidden */
  35610. _isRGBD: boolean;
  35611. /** @hidden */
  35612. _webGLTexture: Nullable<WebGLTexture>;
  35613. /** @hidden */
  35614. _references: number;
  35615. private _engine;
  35616. /**
  35617. * Gets the Engine the texture belongs to.
  35618. * @returns The babylon engine
  35619. */
  35620. getEngine(): Engine;
  35621. /**
  35622. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  35623. */
  35624. readonly dataSource: number;
  35625. /**
  35626. * Creates a new InternalTexture
  35627. * @param engine defines the engine to use
  35628. * @param dataSource defines the type of data that will be used
  35629. */
  35630. constructor(engine: Engine, dataSource: number);
  35631. /**
  35632. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  35633. */
  35634. incrementReferences(): void;
  35635. /**
  35636. * Change the size of the texture (not the size of the content)
  35637. * @param width defines the new width
  35638. * @param height defines the new height
  35639. * @param depth defines the new depth (1 by default)
  35640. */
  35641. updateSize(width: int, height: int, depth?: int): void;
  35642. /** @hidden */
  35643. _rebuild(): void;
  35644. _swapAndDie(target: InternalTexture): void;
  35645. /**
  35646. * Dispose the current allocated resources
  35647. */
  35648. dispose(): void;
  35649. }
  35650. }
  35651. declare module BABYLON {
  35652. /**
  35653. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  35654. */
  35655. interface IInternalTextureTracker {
  35656. /**
  35657. * Gets or set the previous tracker in the list
  35658. */
  35659. previous: Nullable<IInternalTextureTracker>;
  35660. /**
  35661. * Gets or set the next tracker in the list
  35662. */
  35663. next: Nullable<IInternalTextureTracker>;
  35664. }
  35665. /**
  35666. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  35667. */
  35668. class DummyInternalTextureTracker {
  35669. /**
  35670. * Gets or set the previous tracker in the list
  35671. */
  35672. previous: Nullable<IInternalTextureTracker>;
  35673. /**
  35674. * Gets or set the next tracker in the list
  35675. */
  35676. next: Nullable<IInternalTextureTracker>;
  35677. }
  35678. }
  35679. declare module BABYLON {
  35680. class MirrorTexture extends RenderTargetTexture {
  35681. private scene;
  35682. mirrorPlane: Plane;
  35683. private _transformMatrix;
  35684. private _mirrorMatrix;
  35685. private _savedViewMatrix;
  35686. private _blurX;
  35687. private _blurY;
  35688. private _adaptiveBlurKernel;
  35689. private _blurKernelX;
  35690. private _blurKernelY;
  35691. private _blurRatio;
  35692. blurRatio: number;
  35693. adaptiveBlurKernel: number;
  35694. blurKernel: number;
  35695. blurKernelX: number;
  35696. blurKernelY: number;
  35697. private _autoComputeBlurKernel();
  35698. protected _onRatioRescale(): void;
  35699. private _updateGammaSpace();
  35700. private _imageProcessingConfigChangeObserver;
  35701. constructor(name: string, size: number | {
  35702. width: number;
  35703. height: number;
  35704. } | {
  35705. ratio: number;
  35706. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  35707. private _preparePostProcesses();
  35708. clone(): MirrorTexture;
  35709. serialize(): any;
  35710. dispose(): void;
  35711. }
  35712. }
  35713. declare module BABYLON {
  35714. interface IMultiRenderTargetOptions {
  35715. generateMipMaps?: boolean;
  35716. types?: number[];
  35717. samplingModes?: number[];
  35718. generateDepthBuffer?: boolean;
  35719. generateStencilBuffer?: boolean;
  35720. generateDepthTexture?: boolean;
  35721. textureCount?: number;
  35722. doNotChangeAspectRatio?: boolean;
  35723. defaultType?: number;
  35724. }
  35725. class MultiRenderTarget extends RenderTargetTexture {
  35726. private _internalTextures;
  35727. private _textures;
  35728. readonly isSupported: boolean;
  35729. private _multiRenderTargetOptions;
  35730. readonly textures: Texture[];
  35731. readonly depthTexture: Texture;
  35732. wrapU: number;
  35733. wrapV: number;
  35734. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  35735. _rebuild(): void;
  35736. private _createInternalTextures();
  35737. private _createTextures();
  35738. samples: number;
  35739. resize(size: any): void;
  35740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  35741. dispose(): void;
  35742. releaseInternalTextures(): void;
  35743. }
  35744. }
  35745. declare module BABYLON {
  35746. /**
  35747. * Raw cube texture where the raw buffers are passed in
  35748. */
  35749. class RawCubeTexture extends CubeTexture {
  35750. /**
  35751. * Creates a cube texture where the raw buffers are passed in.
  35752. * @param scene defines the scene the texture is attached to
  35753. * @param data defines the array of data to use to create each face
  35754. * @param size defines the size of the textures
  35755. * @param format defines the format of the data
  35756. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  35757. * @param generateMipMaps defines if the engine should generate the mip levels
  35758. * @param invertY defines if data must be stored with Y axis inverted
  35759. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  35760. * @param compression defines the compression used (null by default)
  35761. */
  35762. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  35763. /**
  35764. * Updates the raw cube texture.
  35765. * @param data defines the data to store
  35766. * @param format defines the data format
  35767. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35768. * @param invertY defines if data must be stored with Y axis inverted
  35769. * @param compression defines the compression used (null by default)
  35770. * @param level defines which level of the texture to update
  35771. */
  35772. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  35773. /**
  35774. * Updates a raw cube texture with RGBD encoded data.
  35775. * @param data defines the array of data [mipmap][face] to use to create each face
  35776. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  35777. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35778. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35779. * @returns a promsie that resolves when the operation is complete
  35780. */
  35781. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  35782. /**
  35783. * Clones the raw cube texture.
  35784. * @return a new cube texture
  35785. */
  35786. clone(): CubeTexture;
  35787. /** @hidden */
  35788. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  35789. }
  35790. }
  35791. declare module BABYLON {
  35792. class RawTexture extends Texture {
  35793. format: number;
  35794. private _engine;
  35795. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  35796. update(data: ArrayBufferView): void;
  35797. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35798. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35799. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35800. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35801. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35802. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35803. }
  35804. }
  35805. declare module BABYLON {
  35806. /**
  35807. * Class used to store 3D textures containing user data
  35808. */
  35809. class RawTexture3D extends Texture {
  35810. /** Gets or sets the texture format to use */
  35811. format: number;
  35812. private _engine;
  35813. /**
  35814. * Create a new RawTexture3D
  35815. * @param data defines the data of the texture
  35816. * @param width defines the width of the texture
  35817. * @param height defines the height of the texture
  35818. * @param depth defines the depth of the texture
  35819. * @param format defines the texture format to use
  35820. * @param scene defines the hosting scene
  35821. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  35822. * @param invertY defines if texture must be stored with Y axis inverted
  35823. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  35824. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  35825. */
  35826. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  35827. /** Gets or sets the texture format to use */
  35828. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  35829. /**
  35830. * Update the texture with new data
  35831. * @param data defines the data to store in the texture
  35832. */
  35833. update(data: ArrayBufferView): void;
  35834. }
  35835. }
  35836. declare module BABYLON {
  35837. /**
  35838. * Creates a refraction texture used by refraction channel of the standard material.
  35839. * @param name the texture name
  35840. * @param size size of the underlying texture
  35841. * @param scene root scene
  35842. */
  35843. class RefractionTexture extends RenderTargetTexture {
  35844. refractionPlane: Plane;
  35845. depth: number;
  35846. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  35847. clone(): RefractionTexture;
  35848. serialize(): any;
  35849. }
  35850. }
  35851. declare module BABYLON {
  35852. class RenderTargetTexture extends Texture {
  35853. isCube: boolean;
  35854. static _REFRESHRATE_RENDER_ONCE: number;
  35855. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35856. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35857. static readonly REFRESHRATE_RENDER_ONCE: number;
  35858. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35859. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35860. /**
  35861. * Use this predicate to dynamically define the list of mesh you want to render.
  35862. * If set, the renderList property will be overwritten.
  35863. */
  35864. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  35865. /**
  35866. * Use this list to define the list of mesh you want to render.
  35867. */
  35868. renderList: Nullable<Array<AbstractMesh>>;
  35869. renderParticles: boolean;
  35870. renderSprites: boolean;
  35871. coordinatesMode: number;
  35872. activeCamera: Nullable<Camera>;
  35873. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  35874. useCameraPostProcesses: boolean;
  35875. ignoreCameraViewport: boolean;
  35876. private _postProcessManager;
  35877. private _postProcesses;
  35878. private _resizeObserver;
  35879. /**
  35880. * An event triggered when the texture is unbind.
  35881. */
  35882. onBeforeBindObservable: Observable<RenderTargetTexture>;
  35883. /**
  35884. * An event triggered when the texture is unbind.
  35885. */
  35886. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  35887. private _onAfterUnbindObserver;
  35888. onAfterUnbind: () => void;
  35889. /**
  35890. * An event triggered before rendering the texture
  35891. */
  35892. onBeforeRenderObservable: Observable<number>;
  35893. private _onBeforeRenderObserver;
  35894. onBeforeRender: (faceIndex: number) => void;
  35895. /**
  35896. * An event triggered after rendering the texture
  35897. */
  35898. onAfterRenderObservable: Observable<number>;
  35899. private _onAfterRenderObserver;
  35900. onAfterRender: (faceIndex: number) => void;
  35901. /**
  35902. * An event triggered after the texture clear
  35903. */
  35904. onClearObservable: Observable<Engine>;
  35905. private _onClearObserver;
  35906. onClear: (Engine: Engine) => void;
  35907. clearColor: Color4;
  35908. protected _size: number | {
  35909. width: number;
  35910. height: number;
  35911. };
  35912. protected _initialSizeParameter: number | {
  35913. width: number;
  35914. height: number;
  35915. } | {
  35916. ratio: number;
  35917. };
  35918. protected _sizeRatio: Nullable<number>;
  35919. _generateMipMaps: boolean;
  35920. protected _renderingManager: RenderingManager;
  35921. _waitingRenderList: string[];
  35922. protected _doNotChangeAspectRatio: boolean;
  35923. protected _currentRefreshId: number;
  35924. protected _refreshRate: number;
  35925. protected _textureMatrix: Matrix;
  35926. protected _samples: number;
  35927. protected _renderTargetOptions: RenderTargetCreationOptions;
  35928. readonly renderTargetOptions: RenderTargetCreationOptions;
  35929. protected _engine: Engine;
  35930. protected _onRatioRescale(): void;
  35931. /**
  35932. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  35933. * It must define where the camera used to render the texture is set
  35934. */
  35935. boundingBoxPosition: Vector3;
  35936. private _boundingBoxSize;
  35937. /**
  35938. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  35939. * When defined, the cubemap will switch to local mode
  35940. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35941. * @example https://www.babylonjs-playground.com/#RNASML
  35942. */
  35943. boundingBoxSize: Vector3;
  35944. /**
  35945. * In case the RTT has been created with a depth texture, get the associated
  35946. * depth texture.
  35947. * Otherwise, return null.
  35948. */
  35949. depthStencilTexture: Nullable<InternalTexture>;
  35950. /**
  35951. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  35952. * or used a shadow, depth texture...
  35953. * @param name The friendly name of the texture
  35954. * @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)
  35955. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  35956. * @param generateMipMaps True if mip maps need to be generated after render.
  35957. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  35958. * @param type The type of the buffer in the RTT (int, half float, float...)
  35959. * @param isCube True if a cube texture needs to be created
  35960. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  35961. * @param generateDepthBuffer True to generate a depth buffer
  35962. * @param generateStencilBuffer True to generate a stencil buffer
  35963. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  35964. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  35965. */
  35966. constructor(name: string, size: number | {
  35967. width: number;
  35968. height: number;
  35969. } | {
  35970. ratio: number;
  35971. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  35972. /**
  35973. * Creates a depth stencil texture.
  35974. * This is only available in WebGL 2 or with the depth texture extension available.
  35975. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  35976. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  35977. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  35978. */
  35979. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  35980. private _processSizeParameter(size);
  35981. samples: number;
  35982. resetRefreshCounter(): void;
  35983. refreshRate: number;
  35984. addPostProcess(postProcess: PostProcess): void;
  35985. clearPostProcesses(dispose?: boolean): void;
  35986. removePostProcess(postProcess: PostProcess): void;
  35987. _shouldRender(): boolean;
  35988. getRenderSize(): number;
  35989. getRenderWidth(): number;
  35990. getRenderHeight(): number;
  35991. readonly canRescale: boolean;
  35992. scale(ratio: number): void;
  35993. getReflectionTextureMatrix(): Matrix;
  35994. resize(size: number | {
  35995. width: number;
  35996. height: number;
  35997. } | {
  35998. ratio: number;
  35999. }): void;
  36000. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  36001. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  36002. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36003. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  36004. /**
  36005. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36006. * This allowed control for front to back rendering or reversly depending of the special needs.
  36007. *
  36008. * @param renderingGroupId The rendering group id corresponding to its index
  36009. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36010. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36011. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36012. */
  36013. 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;
  36014. /**
  36015. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36016. *
  36017. * @param renderingGroupId The rendering group id corresponding to its index
  36018. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36019. */
  36020. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  36021. clone(): RenderTargetTexture;
  36022. serialize(): any;
  36023. disposeFramebufferObjects(): void;
  36024. dispose(): void;
  36025. _rebuild(): void;
  36026. /**
  36027. * Clear the info related to rendering groups preventing retention point in material dispose.
  36028. */
  36029. freeRenderingGroups(): void;
  36030. }
  36031. }
  36032. declare module BABYLON {
  36033. class Texture extends BaseTexture {
  36034. static NEAREST_SAMPLINGMODE: number;
  36035. static NEAREST_NEAREST_MIPLINEAR: number;
  36036. static BILINEAR_SAMPLINGMODE: number;
  36037. static LINEAR_LINEAR_MIPNEAREST: number;
  36038. static TRILINEAR_SAMPLINGMODE: number;
  36039. static LINEAR_LINEAR_MIPLINEAR: number;
  36040. static NEAREST_NEAREST_MIPNEAREST: number;
  36041. static NEAREST_LINEAR_MIPNEAREST: number;
  36042. static NEAREST_LINEAR_MIPLINEAR: number;
  36043. static NEAREST_LINEAR: number;
  36044. static NEAREST_NEAREST: number;
  36045. static LINEAR_NEAREST_MIPNEAREST: number;
  36046. static LINEAR_NEAREST_MIPLINEAR: number;
  36047. static LINEAR_LINEAR: number;
  36048. static LINEAR_NEAREST: number;
  36049. static EXPLICIT_MODE: number;
  36050. static SPHERICAL_MODE: number;
  36051. static PLANAR_MODE: number;
  36052. static CUBIC_MODE: number;
  36053. static PROJECTION_MODE: number;
  36054. static SKYBOX_MODE: number;
  36055. static INVCUBIC_MODE: number;
  36056. static EQUIRECTANGULAR_MODE: number;
  36057. static FIXED_EQUIRECTANGULAR_MODE: number;
  36058. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36059. static readonly CLAMP_ADDRESSMODE: number;
  36060. static readonly WRAP_ADDRESSMODE: number;
  36061. static readonly MIRROR_ADDRESSMODE: number;
  36062. /**
  36063. * 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
  36064. */
  36065. static UseSerializedUrlIfAny: boolean;
  36066. url: Nullable<string>;
  36067. uOffset: number;
  36068. vOffset: number;
  36069. uScale: number;
  36070. vScale: number;
  36071. uAng: number;
  36072. vAng: number;
  36073. wAng: number;
  36074. /**
  36075. * Defines the center of rotation (U)
  36076. */
  36077. uRotationCenter: number;
  36078. /**
  36079. * Defines the center of rotation (V)
  36080. */
  36081. vRotationCenter: number;
  36082. /**
  36083. * Defines the center of rotation (W)
  36084. */
  36085. wRotationCenter: number;
  36086. readonly noMipmap: boolean;
  36087. private _noMipmap;
  36088. _invertY: boolean;
  36089. private _rowGenerationMatrix;
  36090. private _cachedTextureMatrix;
  36091. private _projectionModeMatrix;
  36092. private _t0;
  36093. private _t1;
  36094. private _t2;
  36095. private _cachedUOffset;
  36096. private _cachedVOffset;
  36097. private _cachedUScale;
  36098. private _cachedVScale;
  36099. private _cachedUAng;
  36100. private _cachedVAng;
  36101. private _cachedWAng;
  36102. private _cachedProjectionMatrixId;
  36103. private _cachedCoordinatesMode;
  36104. _samplingMode: number;
  36105. /** @hidden */
  36106. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36107. private _deleteBuffer;
  36108. protected _format: Nullable<number>;
  36109. private _delayedOnLoad;
  36110. private _delayedOnError;
  36111. protected _onLoadObservable: Nullable<Observable<Texture>>;
  36112. protected _isBlocking: boolean;
  36113. isBlocking: boolean;
  36114. readonly samplingMode: number;
  36115. 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);
  36116. /**
  36117. * Update the url (and optional buffer) of this texture if url was null during construction.
  36118. * @param url the url of the texture
  36119. * @param buffer the buffer of the texture (defaults to null)
  36120. */
  36121. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  36122. delayLoad(): void;
  36123. updateSamplingMode(samplingMode: number): void;
  36124. private _prepareRowForTextureGeneration(x, y, z, t);
  36125. getTextureMatrix(): Matrix;
  36126. getReflectionTextureMatrix(): Matrix;
  36127. clone(): Texture;
  36128. readonly onLoadObservable: Observable<Texture>;
  36129. serialize(): any;
  36130. getClassName(): string;
  36131. dispose(): void;
  36132. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  36133. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  36134. 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;
  36135. }
  36136. }
  36137. declare module BABYLON {
  36138. /**
  36139. * Settings for finer control over video usage
  36140. */
  36141. interface VideoTextureSettings {
  36142. /**
  36143. * Applies `autoplay` to video, if specified
  36144. */
  36145. autoPlay?: boolean;
  36146. /**
  36147. * Applies `loop` to video, if specified
  36148. */
  36149. loop?: boolean;
  36150. /**
  36151. * Automatically updates internal texture from video at every frame in the render loop
  36152. */
  36153. autoUpdateTexture: boolean;
  36154. /**
  36155. * Image src displayed during the video loading or until the user interacts with the video.
  36156. */
  36157. poster?: string;
  36158. }
  36159. class VideoTexture extends Texture {
  36160. /**
  36161. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36162. */
  36163. readonly autoUpdateTexture: boolean;
  36164. /**
  36165. * The video instance used by the texture internally
  36166. */
  36167. readonly video: HTMLVideoElement;
  36168. private _onUserActionRequestedObservable;
  36169. readonly onUserActionRequestedObservable: Observable<Texture>;
  36170. private _generateMipMaps;
  36171. private _engine;
  36172. private _stillImageCaptured;
  36173. private _poster;
  36174. /**
  36175. * Creates a video texture.
  36176. * Sample : https://doc.babylonjs.com/how_to/video_texture
  36177. * @param {string | null} name optional name, will detect from video source, if not defined
  36178. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  36179. * @param {BABYLON.Scene} scene is obviously the current scene.
  36180. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36181. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  36182. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36183. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  36184. */
  36185. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36186. private _getName(src);
  36187. private _getVideo(src);
  36188. private _createInternalTexture;
  36189. private reset;
  36190. /**
  36191. * Internal method to initiate `update`.
  36192. */
  36193. _rebuild(): void;
  36194. /**
  36195. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36196. */
  36197. update(): void;
  36198. /**
  36199. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36200. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36201. */
  36202. updateTexture(isVisible: boolean): void;
  36203. protected _updateInternalTexture: (e?: Event | undefined) => void;
  36204. /**
  36205. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36206. * @param url New url.
  36207. */
  36208. updateURL(url: string): void;
  36209. dispose(): void;
  36210. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36211. minWidth: number;
  36212. maxWidth: number;
  36213. minHeight: number;
  36214. maxHeight: number;
  36215. deviceId: string;
  36216. }): void;
  36217. }
  36218. }
  36219. declare module BABYLON {
  36220. /**
  36221. * Particle emitter emitting particles from the inside of a box.
  36222. * It emits the particles randomly between 2 given directions.
  36223. */
  36224. class BoxParticleEmitter implements IParticleEmitterType {
  36225. /**
  36226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36227. */
  36228. direction1: Vector3;
  36229. /**
  36230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36231. */
  36232. direction2: Vector3;
  36233. /**
  36234. * 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.
  36235. */
  36236. minEmitBox: Vector3;
  36237. /**
  36238. * 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.
  36239. */
  36240. maxEmitBox: Vector3;
  36241. /**
  36242. * Creates a new instance BoxParticleEmitter
  36243. */
  36244. constructor();
  36245. /**
  36246. * Called by the particle System when the direction is computed for the created particle.
  36247. * @param worldMatrix is the world matrix of the particle system
  36248. * @param directionToUpdate is the direction vector to update with the result
  36249. * @param particle is the particle we are computed the direction for
  36250. */
  36251. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36252. /**
  36253. * Called by the particle System when the position is computed for the created particle.
  36254. * @param worldMatrix is the world matrix of the particle system
  36255. * @param positionToUpdate is the position vector to update with the result
  36256. * @param particle is the particle we are computed the position for
  36257. */
  36258. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36259. /**
  36260. * Clones the current emitter and returns a copy of it
  36261. * @returns the new emitter
  36262. */
  36263. clone(): BoxParticleEmitter;
  36264. /**
  36265. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36266. * @param effect defines the update shader
  36267. */
  36268. applyToShader(effect: Effect): void;
  36269. /**
  36270. * Returns a string to use to update the GPU particles update shader
  36271. * @returns a string containng the defines string
  36272. */
  36273. getEffectDefines(): string;
  36274. /**
  36275. * Returns the string "BoxParticleEmitter"
  36276. * @returns a string containing the class name
  36277. */
  36278. getClassName(): string;
  36279. /**
  36280. * Serializes the particle system to a JSON object.
  36281. * @returns the JSON object
  36282. */
  36283. serialize(): any;
  36284. /**
  36285. * Parse properties from a JSON object
  36286. * @param serializationObject defines the JSON object
  36287. */
  36288. parse(serializationObject: any): void;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. /**
  36293. * Particle emitter emitting particles from the inside of a cone.
  36294. * It emits the particles alongside the cone volume from the base to the particle.
  36295. * The emission direction might be randomized.
  36296. */
  36297. class ConeParticleEmitter implements IParticleEmitterType {
  36298. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36299. directionRandomizer: number;
  36300. private _radius;
  36301. private _angle;
  36302. private _height;
  36303. /**
  36304. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36305. */
  36306. radiusRange: number;
  36307. /**
  36308. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  36309. */
  36310. heightRange: number;
  36311. /**
  36312. * Gets or sets the radius of the emission cone
  36313. */
  36314. radius: number;
  36315. /**
  36316. * Gets or sets the angle of the emission cone
  36317. */
  36318. angle: number;
  36319. private _buildHeight();
  36320. /**
  36321. * Creates a new instance ConeParticleEmitter
  36322. * @param radius the radius of the emission cone (1 by default)
  36323. * @param angles the cone base angle (PI by default)
  36324. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  36325. */
  36326. constructor(radius?: number, angle?: number,
  36327. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36328. directionRandomizer?: number);
  36329. /**
  36330. * Called by the particle System when the direction is computed for the created particle.
  36331. * @param worldMatrix is the world matrix of the particle system
  36332. * @param directionToUpdate is the direction vector to update with the result
  36333. * @param particle is the particle we are computed the direction for
  36334. */
  36335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36336. /**
  36337. * Called by the particle System when the position is computed for the created particle.
  36338. * @param worldMatrix is the world matrix of the particle system
  36339. * @param positionToUpdate is the position vector to update with the result
  36340. * @param particle is the particle we are computed the position for
  36341. */
  36342. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36343. /**
  36344. * Clones the current emitter and returns a copy of it
  36345. * @returns the new emitter
  36346. */
  36347. clone(): ConeParticleEmitter;
  36348. /**
  36349. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36350. * @param effect defines the update shader
  36351. */
  36352. applyToShader(effect: Effect): void;
  36353. /**
  36354. * Returns a string to use to update the GPU particles update shader
  36355. * @returns a string containng the defines string
  36356. */
  36357. getEffectDefines(): string;
  36358. /**
  36359. * Returns the string "ConeParticleEmitter"
  36360. * @returns a string containing the class name
  36361. */
  36362. getClassName(): string;
  36363. /**
  36364. * Serializes the particle system to a JSON object.
  36365. * @returns the JSON object
  36366. */
  36367. serialize(): any;
  36368. /**
  36369. * Parse properties from a JSON object
  36370. * @param serializationObject defines the JSON object
  36371. */
  36372. parse(serializationObject: any): void;
  36373. }
  36374. }
  36375. declare module BABYLON {
  36376. /**
  36377. * Particle emitter represents a volume emitting particles.
  36378. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  36379. */
  36380. interface IParticleEmitterType {
  36381. /**
  36382. * Called by the particle System when the direction is computed for the created particle.
  36383. * @param worldMatrix is the world matrix of the particle system
  36384. * @param directionToUpdate is the direction vector to update with the result
  36385. * @param particle is the particle we are computed the direction for
  36386. */
  36387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36388. /**
  36389. * Called by the particle System when the position is computed for the created particle.
  36390. * @param worldMatrix is the world matrix of the particle system
  36391. * @param positionToUpdate is the position vector to update with the result
  36392. * @param particle is the particle we are computed the position for
  36393. */
  36394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36395. /**
  36396. * Clones the current emitter and returns a copy of it
  36397. * @returns the new emitter
  36398. */
  36399. clone(): IParticleEmitterType;
  36400. /**
  36401. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36402. * @param effect defines the update shader
  36403. */
  36404. applyToShader(effect: Effect): void;
  36405. /**
  36406. * Returns a string to use to update the GPU particles update shader
  36407. * @returns the effect defines string
  36408. */
  36409. getEffectDefines(): string;
  36410. /**
  36411. * Returns a string representing the class name
  36412. * @returns a string containing the class name
  36413. */
  36414. getClassName(): string;
  36415. /**
  36416. * Serializes the particle system to a JSON object.
  36417. * @returns the JSON object
  36418. */
  36419. serialize(): any;
  36420. /**
  36421. * Parse properties from a JSON object
  36422. * @param serializationObject defines the JSON object
  36423. */
  36424. parse(serializationObject: any): void;
  36425. }
  36426. }
  36427. declare module BABYLON {
  36428. /**
  36429. * Particle emitter emitting particles from the inside of a sphere.
  36430. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  36431. */
  36432. class SphereParticleEmitter implements IParticleEmitterType {
  36433. /**
  36434. * The radius of the emission sphere.
  36435. */
  36436. radius: number;
  36437. /**
  36438. * How much to randomize the particle direction [0-1].
  36439. */
  36440. directionRandomizer: number;
  36441. /**
  36442. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36443. */
  36444. radiusRange: number;
  36445. /**
  36446. * Creates a new instance SphereParticleEmitter
  36447. * @param radius the radius of the emission sphere (1 by default)
  36448. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  36449. */
  36450. constructor(
  36451. /**
  36452. * The radius of the emission sphere.
  36453. */
  36454. radius?: number,
  36455. /**
  36456. * How much to randomize the particle direction [0-1].
  36457. */
  36458. directionRandomizer?: number);
  36459. /**
  36460. * Called by the particle System when the direction is computed for the created particle.
  36461. * @param worldMatrix is the world matrix of the particle system
  36462. * @param directionToUpdate is the direction vector to update with the result
  36463. * @param particle is the particle we are computed the direction for
  36464. */
  36465. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36466. /**
  36467. * Called by the particle System when the position is computed for the created particle.
  36468. * @param worldMatrix is the world matrix of the particle system
  36469. * @param positionToUpdate is the position vector to update with the result
  36470. * @param particle is the particle we are computed the position for
  36471. */
  36472. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36473. /**
  36474. * Clones the current emitter and returns a copy of it
  36475. * @returns the new emitter
  36476. */
  36477. clone(): SphereParticleEmitter;
  36478. /**
  36479. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36480. * @param effect defines the update shader
  36481. */
  36482. applyToShader(effect: Effect): void;
  36483. /**
  36484. * Returns a string to use to update the GPU particles update shader
  36485. * @returns a string containng the defines string
  36486. */
  36487. getEffectDefines(): string;
  36488. /**
  36489. * Returns the string "SphereParticleEmitter"
  36490. * @returns a string containing the class name
  36491. */
  36492. getClassName(): string;
  36493. /**
  36494. * Serializes the particle system to a JSON object.
  36495. * @returns the JSON object
  36496. */
  36497. serialize(): any;
  36498. /**
  36499. * Parse properties from a JSON object
  36500. * @param serializationObject defines the JSON object
  36501. */
  36502. parse(serializationObject: any): void;
  36503. }
  36504. /**
  36505. * Particle emitter emitting particles from the inside of a sphere.
  36506. * It emits the particles randomly between two vectors.
  36507. */
  36508. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  36509. /**
  36510. * The min limit of the emission direction.
  36511. */
  36512. direction1: Vector3;
  36513. /**
  36514. * The max limit of the emission direction.
  36515. */
  36516. direction2: Vector3;
  36517. /**
  36518. * Creates a new instance SphereDirectedParticleEmitter
  36519. * @param radius the radius of the emission sphere (1 by default)
  36520. * @param direction1 the min limit of the emission direction (up vector by default)
  36521. * @param direction2 the max limit of the emission direction (up vector by default)
  36522. */
  36523. constructor(radius?: number,
  36524. /**
  36525. * The min limit of the emission direction.
  36526. */
  36527. direction1?: Vector3,
  36528. /**
  36529. * The max limit of the emission direction.
  36530. */
  36531. direction2?: Vector3);
  36532. /**
  36533. * Called by the particle System when the direction is computed for the created particle.
  36534. * @param worldMatrix is the world matrix of the particle system
  36535. * @param directionToUpdate is the direction vector to update with the result
  36536. * @param particle is the particle we are computed the direction for
  36537. */
  36538. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36539. /**
  36540. * Clones the current emitter and returns a copy of it
  36541. * @returns the new emitter
  36542. */
  36543. clone(): SphereDirectedParticleEmitter;
  36544. /**
  36545. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36546. * @param effect defines the update shader
  36547. */
  36548. applyToShader(effect: Effect): void;
  36549. /**
  36550. * Returns a string to use to update the GPU particles update shader
  36551. * @returns a string containng the defines string
  36552. */
  36553. getEffectDefines(): string;
  36554. /**
  36555. * Returns the string "SphereDirectedParticleEmitter"
  36556. * @returns a string containing the class name
  36557. */
  36558. getClassName(): string;
  36559. /**
  36560. * Serializes the particle system to a JSON object.
  36561. * @returns the JSON object
  36562. */
  36563. serialize(): any;
  36564. /**
  36565. * Parse properties from a JSON object
  36566. * @param serializationObject defines the JSON object
  36567. */
  36568. parse(serializationObject: any): void;
  36569. }
  36570. }
  36571. declare var DracoDecoderModule: any;
  36572. declare var WebAssembly: any;
  36573. declare module BABYLON {
  36574. /**
  36575. * Configuration for Draco compression
  36576. */
  36577. interface IDracoCompressionConfiguration {
  36578. /**
  36579. * Configuration for the decoder.
  36580. */
  36581. decoder?: {
  36582. /**
  36583. * The url to the WebAssembly module.
  36584. */
  36585. wasmUrl?: string;
  36586. /**
  36587. * The url to the WebAssembly binary.
  36588. */
  36589. wasmBinaryUrl?: string;
  36590. /**
  36591. * The url to the fallback JavaScript module.
  36592. */
  36593. fallbackUrl?: string;
  36594. };
  36595. }
  36596. /**
  36597. * Draco compression (https://google.github.io/draco/)
  36598. *
  36599. * This class wraps the Draco module.
  36600. *
  36601. * **Encoder**
  36602. *
  36603. * The encoder is not currently implemented.
  36604. *
  36605. * **Decoder**
  36606. *
  36607. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  36608. *
  36609. * To update the configuration, use the following code:
  36610. * ```javascript
  36611. * BABYLON.DracoCompression.Configuration = {
  36612. * decoder: {
  36613. * wasmUrl: "<url to the WebAssembly library>",
  36614. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  36615. * fallbackUrl: "<url to the fallback JavaScript library>",
  36616. * }
  36617. * };
  36618. * ```
  36619. *
  36620. * 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.
  36621. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  36622. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  36623. *
  36624. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  36625. * ```javascript
  36626. * var dracoCompression = new BABYLON.DracoCompression();
  36627. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  36628. * [BABYLON.VertexBuffer.PositionKind]: 0
  36629. * });
  36630. * ```
  36631. *
  36632. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  36633. */
  36634. class DracoCompression implements IDisposable {
  36635. private static _DecoderModulePromise;
  36636. /**
  36637. * The configuration. Defaults to the following urls:
  36638. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  36639. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  36640. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  36641. */
  36642. static Configuration: IDracoCompressionConfiguration;
  36643. /**
  36644. * Returns true if the decoder is available.
  36645. */
  36646. static readonly DecoderAvailable: boolean;
  36647. /**
  36648. * Constructor
  36649. */
  36650. constructor();
  36651. /**
  36652. * Stop all async operations and release resources.
  36653. */
  36654. dispose(): void;
  36655. /**
  36656. * Decode Draco compressed mesh data to vertex data.
  36657. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  36658. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  36659. * @returns A promise that resolves with the decoded vertex data
  36660. */
  36661. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  36662. [kind: string]: number;
  36663. }): Promise<VertexData>;
  36664. private static _GetDecoderModule();
  36665. private static _LoadScriptAsync(url);
  36666. private static _LoadFileAsync(url);
  36667. }
  36668. }
  36669. declare module BABYLON {
  36670. class CannonJSPlugin implements IPhysicsEnginePlugin {
  36671. private _useDeltaForWorldStep;
  36672. world: any;
  36673. name: string;
  36674. private _physicsMaterials;
  36675. private _fixedTimeStep;
  36676. BJSCANNON: any;
  36677. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  36678. setGravity(gravity: Vector3): void;
  36679. setTimeStep(timeStep: number): void;
  36680. getTimeStep(): number;
  36681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36685. private _processChildMeshes(mainImpostor);
  36686. removePhysicsBody(impostor: PhysicsImpostor): void;
  36687. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36688. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36689. private _addMaterial(name, friction, restitution);
  36690. private _checkWithEpsilon(value);
  36691. private _createShape(impostor);
  36692. private _createHeightmap(object, pointDepth?);
  36693. private _minus90X;
  36694. private _plus90X;
  36695. private _tmpPosition;
  36696. private _tmpDeltaPosition;
  36697. private _tmpUnityRotation;
  36698. private _updatePhysicsBodyTransformation(impostor);
  36699. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36700. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36701. isSupported(): boolean;
  36702. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36703. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36704. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36705. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36706. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36707. getBodyMass(impostor: PhysicsImpostor): number;
  36708. getBodyFriction(impostor: PhysicsImpostor): number;
  36709. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36710. getBodyRestitution(impostor: PhysicsImpostor): number;
  36711. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36712. sleepBody(impostor: PhysicsImpostor): void;
  36713. wakeUpBody(impostor: PhysicsImpostor): void;
  36714. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36715. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  36716. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  36717. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36718. getRadius(impostor: PhysicsImpostor): number;
  36719. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36720. dispose(): void;
  36721. private _extendNamespace();
  36722. }
  36723. }
  36724. declare module BABYLON {
  36725. class OimoJSPlugin implements IPhysicsEnginePlugin {
  36726. world: any;
  36727. name: string;
  36728. BJSOIMO: any;
  36729. constructor(iterations?: number);
  36730. setGravity(gravity: Vector3): void;
  36731. setTimeStep(timeStep: number): void;
  36732. getTimeStep(): number;
  36733. private _tmpImpostorsArray;
  36734. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36735. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36736. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36737. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36738. private _tmpPositionVector;
  36739. removePhysicsBody(impostor: PhysicsImpostor): void;
  36740. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36741. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36742. isSupported(): boolean;
  36743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36744. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36745. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36746. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36747. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36748. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36749. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36750. getBodyMass(impostor: PhysicsImpostor): number;
  36751. getBodyFriction(impostor: PhysicsImpostor): number;
  36752. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36753. getBodyRestitution(impostor: PhysicsImpostor): number;
  36754. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36755. sleepBody(impostor: PhysicsImpostor): void;
  36756. wakeUpBody(impostor: PhysicsImpostor): void;
  36757. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36758. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  36759. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  36760. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36761. getRadius(impostor: PhysicsImpostor): number;
  36762. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36763. dispose(): void;
  36764. }
  36765. }
  36766. declare module BABYLON {
  36767. /**
  36768. * This represents a set of one or more post processes in Babylon.
  36769. * A post process can be used to apply a shader to a texture after it is rendered.
  36770. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  36771. */
  36772. class PostProcessRenderEffect {
  36773. private _postProcesses;
  36774. private _getPostProcesses;
  36775. private _singleInstance;
  36776. private _cameras;
  36777. private _indicesForCamera;
  36778. /**
  36779. * Name of the effect
  36780. */
  36781. _name: string;
  36782. /**
  36783. * Instantiates a post process render effect.
  36784. * A post process can be used to apply a shader to a texture after it is rendered.
  36785. * @param engine The engine the effect is tied to
  36786. * @param name The name of the effect
  36787. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  36788. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  36789. */
  36790. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  36791. /**
  36792. * Checks if all the post processes in the effect are supported.
  36793. */
  36794. readonly isSupported: boolean;
  36795. /**
  36796. * Updates the current state of the effect
  36797. */
  36798. _update(): void;
  36799. /**
  36800. * Attaches the effect on cameras
  36801. * @param cameras The camera to attach to.
  36802. */
  36803. _attachCameras(cameras: Camera): void;
  36804. /**
  36805. * Attaches the effect on cameras
  36806. * @param cameras The camera to attach to.
  36807. */
  36808. _attachCameras(cameras: Camera[]): void;
  36809. /**
  36810. * Detatches the effect on cameras
  36811. * @param cameras The camera to detatch from.
  36812. */
  36813. _detachCameras(cameras: Camera): void;
  36814. /**
  36815. * Detatches the effect on cameras
  36816. * @param cameras The camera to detatch from.
  36817. */
  36818. _detachCameras(cameras: Camera[]): void;
  36819. /**
  36820. * Enables the effect on given cameras
  36821. * @param cameras The camera to enable.
  36822. */
  36823. _enable(cameras: Camera): void;
  36824. /**
  36825. * Enables the effect on given cameras
  36826. * @param cameras The camera to enable.
  36827. */
  36828. _enable(cameras: Nullable<Camera[]>): void;
  36829. /**
  36830. * Disables the effect on the given cameras
  36831. * @param cameras The camera to disable.
  36832. */
  36833. _disable(cameras: Camera): void;
  36834. /**
  36835. * Disables the effect on the given cameras
  36836. * @param cameras The camera to disable.
  36837. */
  36838. _disable(cameras: Nullable<Camera[]>): void;
  36839. /**
  36840. * Gets a list of the post processes contained in the effect.
  36841. * @param camera The camera to get the post processes on.
  36842. * @returns The list of the post processes in the effect.
  36843. */
  36844. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  36845. }
  36846. }
  36847. declare module BABYLON {
  36848. class PostProcessRenderPipeline {
  36849. private engine;
  36850. private _renderEffects;
  36851. private _renderEffectsForIsolatedPass;
  36852. protected _cameras: Camera[];
  36853. _name: string;
  36854. constructor(engine: Engine, name: string);
  36855. getClassName(): string;
  36856. readonly isSupported: boolean;
  36857. addEffect(renderEffect: PostProcessRenderEffect): void;
  36858. _rebuild(): void;
  36859. _enableEffect(renderEffectName: string, cameras: Camera): void;
  36860. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  36861. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36862. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36863. _attachCameras(cameras: Camera, unique: boolean): void;
  36864. _attachCameras(cameras: Camera[], unique: boolean): void;
  36865. _detachCameras(cameras: Camera): void;
  36866. _detachCameras(cameras: Nullable<Camera[]>): void;
  36867. _update(): void;
  36868. _reset(): void;
  36869. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  36870. dispose(): void;
  36871. }
  36872. }
  36873. declare module BABYLON {
  36874. class PostProcessRenderPipelineManager {
  36875. private _renderPipelines;
  36876. constructor();
  36877. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  36878. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  36879. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  36880. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  36881. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  36882. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36883. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36884. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36885. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36886. update(): void;
  36887. _rebuild(): void;
  36888. dispose(): void;
  36889. }
  36890. }
  36891. declare module BABYLON {
  36892. /**
  36893. * Helper class dealing with the extraction of spherical polynomial dataArray
  36894. * from a cube map.
  36895. */
  36896. class CubeMapToSphericalPolynomialTools {
  36897. private static FileFaces;
  36898. /**
  36899. * Converts a texture to the according Spherical Polynomial data.
  36900. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36901. *
  36902. * @param texture The texture to extract the information from.
  36903. * @return The Spherical Polynomial data.
  36904. */
  36905. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  36906. /**
  36907. * Converts a cubemap to the according Spherical Polynomial data.
  36908. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36909. *
  36910. * @param cubeInfo The Cube map to extract the information from.
  36911. * @return The Spherical Polynomial data.
  36912. */
  36913. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  36914. }
  36915. }
  36916. declare module BABYLON {
  36917. /**
  36918. * Header information of HDR texture files.
  36919. */
  36920. interface HDRInfo {
  36921. /**
  36922. * The height of the texture in pixels.
  36923. */
  36924. height: number;
  36925. /**
  36926. * The width of the texture in pixels.
  36927. */
  36928. width: number;
  36929. /**
  36930. * The index of the beginning of the data in the binary file.
  36931. */
  36932. dataPosition: number;
  36933. }
  36934. /**
  36935. * This groups tools to convert HDR texture to native colors array.
  36936. */
  36937. class HDRTools {
  36938. private static Ldexp(mantissa, exponent);
  36939. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  36940. private static readStringLine(uint8array, startIndex);
  36941. /**
  36942. * Reads header information from an RGBE texture stored in a native array.
  36943. * More information on this format are available here:
  36944. * https://en.wikipedia.org/wiki/RGBE_image_format
  36945. *
  36946. * @param uint8array The binary file stored in native array.
  36947. * @return The header information.
  36948. */
  36949. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  36950. /**
  36951. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  36952. * This RGBE texture needs to store the information as a panorama.
  36953. *
  36954. * More information on this format are available here:
  36955. * https://en.wikipedia.org/wiki/RGBE_image_format
  36956. *
  36957. * @param buffer The binary file stored in an array buffer.
  36958. * @param size The expected size of the extracted cubemap.
  36959. * @return The Cube Map information.
  36960. */
  36961. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  36962. /**
  36963. * Returns the pixels data extracted from an RGBE texture.
  36964. * This pixels will be stored left to right up to down in the R G B order in one array.
  36965. *
  36966. * More information on this format are available here:
  36967. * https://en.wikipedia.org/wiki/RGBE_image_format
  36968. *
  36969. * @param uint8array The binary file stored in an array buffer.
  36970. * @param hdrInfo The header information of the file.
  36971. * @return The pixels data in RGB right to left up to down order.
  36972. */
  36973. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  36974. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  36975. }
  36976. }
  36977. declare module BABYLON {
  36978. /**
  36979. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  36980. */
  36981. interface CubeMapInfo {
  36982. /**
  36983. * The pixel array for the front face.
  36984. * This is stored in format, left to right, up to down format.
  36985. */
  36986. front: Nullable<ArrayBufferView>;
  36987. /**
  36988. * The pixel array for the back face.
  36989. * This is stored in format, left to right, up to down format.
  36990. */
  36991. back: Nullable<ArrayBufferView>;
  36992. /**
  36993. * The pixel array for the left face.
  36994. * This is stored in format, left to right, up to down format.
  36995. */
  36996. left: Nullable<ArrayBufferView>;
  36997. /**
  36998. * The pixel array for the right face.
  36999. * This is stored in format, left to right, up to down format.
  37000. */
  37001. right: Nullable<ArrayBufferView>;
  37002. /**
  37003. * The pixel array for the up face.
  37004. * This is stored in format, left to right, up to down format.
  37005. */
  37006. up: Nullable<ArrayBufferView>;
  37007. /**
  37008. * The pixel array for the down face.
  37009. * This is stored in format, left to right, up to down format.
  37010. */
  37011. down: Nullable<ArrayBufferView>;
  37012. /**
  37013. * The size of the cubemap stored.
  37014. *
  37015. * Each faces will be size * size pixels.
  37016. */
  37017. size: number;
  37018. /**
  37019. * The format of the texture.
  37020. *
  37021. * RGBA, RGB.
  37022. */
  37023. format: number;
  37024. /**
  37025. * The type of the texture data.
  37026. *
  37027. * UNSIGNED_INT, FLOAT.
  37028. */
  37029. type: number;
  37030. /**
  37031. * Specifies whether the texture is in gamma space.
  37032. */
  37033. gammaSpace: boolean;
  37034. }
  37035. /**
  37036. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  37037. */
  37038. class PanoramaToCubeMapTools {
  37039. private static FACE_FRONT;
  37040. private static FACE_BACK;
  37041. private static FACE_RIGHT;
  37042. private static FACE_LEFT;
  37043. private static FACE_DOWN;
  37044. private static FACE_UP;
  37045. /**
  37046. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  37047. *
  37048. * @param float32Array The source data.
  37049. * @param inputWidth The width of the input panorama.
  37050. * @param inputhHeight The height of the input panorama.
  37051. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  37052. * @return The cubemap data
  37053. */
  37054. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  37055. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  37056. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  37057. }
  37058. }
  37059. declare module BABYLON {
  37060. class CustomProceduralTexture extends ProceduralTexture {
  37061. private _animate;
  37062. private _time;
  37063. private _config;
  37064. private _texturePath;
  37065. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  37066. private loadJson(jsonUrl);
  37067. isReady(): boolean;
  37068. render(useCameraPostProcess?: boolean): void;
  37069. updateTextures(): void;
  37070. updateShaderUniforms(): void;
  37071. animate: boolean;
  37072. }
  37073. }
  37074. declare module BABYLON {
  37075. class ProceduralTexture extends Texture {
  37076. isCube: boolean;
  37077. private _size;
  37078. _generateMipMaps: boolean;
  37079. isEnabled: boolean;
  37080. private _currentRefreshId;
  37081. private _refreshRate;
  37082. onGenerated: () => void;
  37083. private _vertexBuffers;
  37084. private _indexBuffer;
  37085. private _effect;
  37086. private _uniforms;
  37087. private _samplers;
  37088. private _fragment;
  37089. _textures: {
  37090. [key: string]: Texture;
  37091. };
  37092. private _floats;
  37093. private _floatsArrays;
  37094. private _colors3;
  37095. private _colors4;
  37096. private _vectors2;
  37097. private _vectors3;
  37098. private _matrices;
  37099. private _fallbackTexture;
  37100. private _fallbackTextureUsed;
  37101. private _engine;
  37102. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  37103. private _createIndexBuffer();
  37104. _rebuild(): void;
  37105. reset(): void;
  37106. isReady(): boolean;
  37107. resetRefreshCounter(): void;
  37108. setFragment(fragment: any): void;
  37109. refreshRate: number;
  37110. _shouldRender(): boolean;
  37111. getRenderSize(): number;
  37112. resize(size: number, generateMipMaps: boolean): void;
  37113. private _checkUniform(uniformName);
  37114. setTexture(name: string, texture: Texture): ProceduralTexture;
  37115. setFloat(name: string, value: number): ProceduralTexture;
  37116. setFloats(name: string, value: number[]): ProceduralTexture;
  37117. setColor3(name: string, value: Color3): ProceduralTexture;
  37118. setColor4(name: string, value: Color4): ProceduralTexture;
  37119. setVector2(name: string, value: Vector2): ProceduralTexture;
  37120. setVector3(name: string, value: Vector3): ProceduralTexture;
  37121. setMatrix(name: string, value: Matrix): ProceduralTexture;
  37122. render(useCameraPostProcess?: boolean): void;
  37123. clone(): ProceduralTexture;
  37124. dispose(): void;
  37125. }
  37126. }
  37127. declare module BABYLON {
  37128. /**
  37129. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  37130. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  37131. */
  37132. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37133. private _scene;
  37134. private _camerasToBeAttached;
  37135. /**
  37136. * ID of the sharpen post process,
  37137. */
  37138. private readonly SharpenPostProcessId;
  37139. /**
  37140. * ID of the image processing post process;
  37141. */
  37142. readonly ImageProcessingPostProcessId: string;
  37143. /**
  37144. * ID of the Fast Approximate Anti-Aliasing post process;
  37145. */
  37146. readonly FxaaPostProcessId: string;
  37147. /**
  37148. * ID of the chromatic aberration post process,
  37149. */
  37150. private readonly ChromaticAberrationPostProcessId;
  37151. /**
  37152. * ID of the grain post process
  37153. */
  37154. private readonly GrainPostProcessId;
  37155. /**
  37156. * Sharpen post process which will apply a sharpen convolution to enhance edges
  37157. */
  37158. sharpen: SharpenPostProcess;
  37159. private _sharpenEffect;
  37160. private bloom;
  37161. /**
  37162. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  37163. */
  37164. depthOfField: DepthOfFieldEffect;
  37165. /**
  37166. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  37167. */
  37168. fxaa: FxaaPostProcess;
  37169. /**
  37170. * Image post processing pass used to perform operations such as tone mapping or color grading.
  37171. */
  37172. imageProcessing: ImageProcessingPostProcess;
  37173. /**
  37174. * Chromatic aberration post process which will shift rgb colors in the image
  37175. */
  37176. chromaticAberration: ChromaticAberrationPostProcess;
  37177. private _chromaticAberrationEffect;
  37178. /**
  37179. * Grain post process which add noise to the image
  37180. */
  37181. grain: GrainPostProcess;
  37182. private _grainEffect;
  37183. /**
  37184. * Glow post process which adds a glow to emmisive areas of the image
  37185. */
  37186. private _glowLayer;
  37187. /**
  37188. * Animations which can be used to tweak settings over a period of time
  37189. */
  37190. animations: Animation[];
  37191. private _imageProcessingConfigurationObserver;
  37192. private _sharpenEnabled;
  37193. private _bloomEnabled;
  37194. private _depthOfFieldEnabled;
  37195. private _depthOfFieldBlurLevel;
  37196. private _fxaaEnabled;
  37197. private _imageProcessingEnabled;
  37198. private _defaultPipelineTextureType;
  37199. private _bloomScale;
  37200. private _chromaticAberrationEnabled;
  37201. private _grainEnabled;
  37202. private _buildAllowed;
  37203. /**
  37204. * Enable or disable the sharpen process from the pipeline
  37205. */
  37206. sharpenEnabled: boolean;
  37207. private _resizeObserver;
  37208. private _hardwareScaleLevel;
  37209. private _bloomKernel;
  37210. /**
  37211. * Specifies the size of the bloom blur kernel, relative to the final output size
  37212. */
  37213. bloomKernel: number;
  37214. /**
  37215. * Specifies the weight of the bloom in the final rendering
  37216. */
  37217. private _bloomWeight;
  37218. /**
  37219. * Specifies the luma threshold for the area that will be blurred by the bloom
  37220. */
  37221. private _bloomThreshold;
  37222. private _hdr;
  37223. /**
  37224. * The strength of the bloom.
  37225. */
  37226. bloomWeight: number;
  37227. /**
  37228. * The strength of the bloom.
  37229. */
  37230. bloomThreshold: number;
  37231. /**
  37232. * The scale of the bloom, lower value will provide better performance.
  37233. */
  37234. bloomScale: number;
  37235. /**
  37236. * Enable or disable the bloom from the pipeline
  37237. */
  37238. bloomEnabled: boolean;
  37239. private _rebuildBloom();
  37240. /**
  37241. * If the depth of field is enabled.
  37242. */
  37243. depthOfFieldEnabled: boolean;
  37244. /**
  37245. * Blur level of the depth of field effect. (Higher blur will effect performance)
  37246. */
  37247. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  37248. /**
  37249. * If the anti aliasing is enabled.
  37250. */
  37251. fxaaEnabled: boolean;
  37252. private _samples;
  37253. /**
  37254. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  37255. */
  37256. samples: number;
  37257. /**
  37258. * If image processing is enabled.
  37259. */
  37260. imageProcessingEnabled: boolean;
  37261. /**
  37262. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  37263. */
  37264. glowLayerEnabled: boolean;
  37265. /**
  37266. * Enable or disable the chromaticAberration process from the pipeline
  37267. */
  37268. chromaticAberrationEnabled: boolean;
  37269. /**
  37270. * Enable or disable the grain process from the pipeline
  37271. */
  37272. grainEnabled: boolean;
  37273. /**
  37274. * @constructor
  37275. * @param {string} name - The rendering pipeline name (default: "")
  37276. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  37277. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  37278. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  37279. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  37280. */
  37281. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  37282. /**
  37283. * Force the compilation of the entire pipeline.
  37284. */
  37285. prepare(): void;
  37286. private _hasCleared;
  37287. private _prevPostProcess;
  37288. private _prevPrevPostProcess;
  37289. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  37290. private _buildPipeline();
  37291. private _disposePostProcesses(disposeNonRecreated?);
  37292. /**
  37293. * Adds a camera to the pipeline
  37294. * @param camera the camera to be added
  37295. */
  37296. addCamera(camera: Camera): void;
  37297. /**
  37298. * Removes a camera from the pipeline
  37299. * @param camera the camera to remove
  37300. */
  37301. removeCamera(camera: Camera): void;
  37302. /**
  37303. * Dispose of the pipeline and stop all post processes
  37304. */
  37305. dispose(): void;
  37306. /**
  37307. * Serialize the rendering pipeline (Used when exporting)
  37308. * @returns the serialized object
  37309. */
  37310. serialize(): any;
  37311. /**
  37312. * Parse the serialized pipeline
  37313. * @param source Source pipeline.
  37314. * @param scene The scene to load the pipeline to.
  37315. * @param rootUrl The URL of the serialized pipeline.
  37316. * @returns An instantiated pipeline from the serialized object.
  37317. */
  37318. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  37319. }
  37320. }
  37321. declare module BABYLON {
  37322. class LensRenderingPipeline extends PostProcessRenderPipeline {
  37323. /**
  37324. * The chromatic aberration PostProcess id in the pipeline
  37325. */
  37326. LensChromaticAberrationEffect: string;
  37327. /**
  37328. * The highlights enhancing PostProcess id in the pipeline
  37329. */
  37330. HighlightsEnhancingEffect: string;
  37331. /**
  37332. * The depth-of-field PostProcess id in the pipeline
  37333. */
  37334. LensDepthOfFieldEffect: string;
  37335. private _scene;
  37336. private _depthTexture;
  37337. private _grainTexture;
  37338. private _chromaticAberrationPostProcess;
  37339. private _highlightsPostProcess;
  37340. private _depthOfFieldPostProcess;
  37341. private _edgeBlur;
  37342. private _grainAmount;
  37343. private _chromaticAberration;
  37344. private _distortion;
  37345. private _highlightsGain;
  37346. private _highlightsThreshold;
  37347. private _dofDistance;
  37348. private _dofAperture;
  37349. private _dofDarken;
  37350. private _dofPentagon;
  37351. private _blurNoise;
  37352. /**
  37353. * @constructor
  37354. *
  37355. * Effect parameters are as follow:
  37356. * {
  37357. * chromatic_aberration: number; // from 0 to x (1 for realism)
  37358. * edge_blur: number; // from 0 to x (1 for realism)
  37359. * distortion: number; // from 0 to x (1 for realism)
  37360. * grain_amount: number; // from 0 to 1
  37361. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  37362. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  37363. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  37364. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  37365. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  37366. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  37367. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  37368. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  37369. * }
  37370. * Note: if an effect parameter is unset, effect is disabled
  37371. *
  37372. * @param {string} name - The rendering pipeline name
  37373. * @param {object} parameters - An object containing all parameters (see above)
  37374. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37375. * @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)
  37376. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37377. */
  37378. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  37379. setEdgeBlur(amount: number): void;
  37380. disableEdgeBlur(): void;
  37381. setGrainAmount(amount: number): void;
  37382. disableGrain(): void;
  37383. setChromaticAberration(amount: number): void;
  37384. disableChromaticAberration(): void;
  37385. setEdgeDistortion(amount: number): void;
  37386. disableEdgeDistortion(): void;
  37387. setFocusDistance(amount: number): void;
  37388. disableDepthOfField(): void;
  37389. setAperture(amount: number): void;
  37390. setDarkenOutOfFocus(amount: number): void;
  37391. enablePentagonBokeh(): void;
  37392. disablePentagonBokeh(): void;
  37393. enableNoiseBlur(): void;
  37394. disableNoiseBlur(): void;
  37395. setHighlightsGain(amount: number): void;
  37396. setHighlightsThreshold(amount: number): void;
  37397. disableHighlights(): void;
  37398. /**
  37399. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  37400. */
  37401. dispose(disableDepthRender?: boolean): void;
  37402. private _createChromaticAberrationPostProcess(ratio);
  37403. private _createHighlightsPostProcess(ratio);
  37404. private _createDepthOfFieldPostProcess(ratio);
  37405. private _createGrainTexture();
  37406. }
  37407. }
  37408. declare module BABYLON {
  37409. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  37410. /**
  37411. * The PassPostProcess id in the pipeline that contains the original scene color
  37412. */
  37413. SSAOOriginalSceneColorEffect: string;
  37414. /**
  37415. * The SSAO PostProcess id in the pipeline
  37416. */
  37417. SSAORenderEffect: string;
  37418. /**
  37419. * The horizontal blur PostProcess id in the pipeline
  37420. */
  37421. SSAOBlurHRenderEffect: string;
  37422. /**
  37423. * The vertical blur PostProcess id in the pipeline
  37424. */
  37425. SSAOBlurVRenderEffect: string;
  37426. /**
  37427. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37428. */
  37429. SSAOCombineRenderEffect: string;
  37430. /**
  37431. * The output strength of the SSAO post-process. Default value is 1.0.
  37432. */
  37433. totalStrength: number;
  37434. /**
  37435. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  37436. */
  37437. maxZ: number;
  37438. /**
  37439. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  37440. */
  37441. minZAspect: number;
  37442. /**
  37443. * Number of samples used for the SSAO calculations. Default value is 8
  37444. */
  37445. private _samples;
  37446. /**
  37447. * Ratio object used for SSAO ratio and blur ratio
  37448. */
  37449. private _ratio;
  37450. /**
  37451. * Dynamically generated sphere sampler.
  37452. */
  37453. private _sampleSphere;
  37454. /**
  37455. * Blur filter offsets
  37456. */
  37457. private _samplerOffsets;
  37458. samples: number;
  37459. /**
  37460. * Are we using bilateral blur ?
  37461. */
  37462. private _expensiveBlur;
  37463. expensiveBlur: boolean;
  37464. /**
  37465. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  37466. */
  37467. radius: number;
  37468. /**
  37469. * The base color of the SSAO post-process
  37470. * The final result is "base + ssao" between [0, 1]
  37471. */
  37472. base: number;
  37473. /**
  37474. * Support test.
  37475. */
  37476. static readonly IsSupported: boolean;
  37477. private _scene;
  37478. private _depthTexture;
  37479. private _normalTexture;
  37480. private _randomTexture;
  37481. private _originalColorPostProcess;
  37482. private _ssaoPostProcess;
  37483. private _blurHPostProcess;
  37484. private _blurVPostProcess;
  37485. private _ssaoCombinePostProcess;
  37486. private _firstUpdate;
  37487. /**
  37488. * @constructor
  37489. * @param {string} name - The rendering pipeline name
  37490. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37491. * @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 }
  37492. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37493. */
  37494. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  37495. /**
  37496. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  37497. */
  37498. dispose(disableGeometryBufferRenderer?: boolean): void;
  37499. private _createBlurPostProcess(ssaoRatio, blurRatio);
  37500. _rebuild(): void;
  37501. private _generateHemisphere();
  37502. private _createSSAOPostProcess(ratio);
  37503. private _createSSAOCombinePostProcess(ratio);
  37504. private _createRandomTexture();
  37505. /**
  37506. * Serialize the rendering pipeline (Used when exporting)
  37507. * @returns the serialized object
  37508. */
  37509. serialize(): any;
  37510. /**
  37511. * Parse the serialized pipeline
  37512. * @param source Source pipeline.
  37513. * @param scene The scene to load the pipeline to.
  37514. * @param rootUrl The URL of the serialized pipeline.
  37515. * @returns An instantiated pipeline from the serialized object.
  37516. */
  37517. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  37518. }
  37519. }
  37520. declare module BABYLON {
  37521. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  37522. /**
  37523. * The PassPostProcess id in the pipeline that contains the original scene color
  37524. */
  37525. SSAOOriginalSceneColorEffect: string;
  37526. /**
  37527. * The SSAO PostProcess id in the pipeline
  37528. */
  37529. SSAORenderEffect: string;
  37530. /**
  37531. * The horizontal blur PostProcess id in the pipeline
  37532. */
  37533. SSAOBlurHRenderEffect: string;
  37534. /**
  37535. * The vertical blur PostProcess id in the pipeline
  37536. */
  37537. SSAOBlurVRenderEffect: string;
  37538. /**
  37539. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37540. */
  37541. SSAOCombineRenderEffect: string;
  37542. /**
  37543. * The output strength of the SSAO post-process. Default value is 1.0.
  37544. */
  37545. totalStrength: number;
  37546. /**
  37547. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  37548. */
  37549. radius: number;
  37550. /**
  37551. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  37552. * Must not be equal to fallOff and superior to fallOff.
  37553. * Default value is 0.975
  37554. */
  37555. area: number;
  37556. /**
  37557. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  37558. * Must not be equal to area and inferior to area.
  37559. * Default value is 0.0
  37560. */
  37561. fallOff: number;
  37562. /**
  37563. * The base color of the SSAO post-process
  37564. * The final result is "base + ssao" between [0, 1]
  37565. */
  37566. base: number;
  37567. private _scene;
  37568. private _depthTexture;
  37569. private _randomTexture;
  37570. private _originalColorPostProcess;
  37571. private _ssaoPostProcess;
  37572. private _blurHPostProcess;
  37573. private _blurVPostProcess;
  37574. private _ssaoCombinePostProcess;
  37575. private _firstUpdate;
  37576. /**
  37577. * @constructor
  37578. * @param {string} name - The rendering pipeline name
  37579. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37580. * @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 }
  37581. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37582. */
  37583. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  37584. /**
  37585. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  37586. */
  37587. dispose(disableDepthRender?: boolean): void;
  37588. private _createBlurPostProcess(ratio);
  37589. _rebuild(): void;
  37590. private _createSSAOPostProcess(ratio);
  37591. private _createSSAOCombinePostProcess(ratio);
  37592. private _createRandomTexture();
  37593. }
  37594. }
  37595. declare module BABYLON {
  37596. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37597. /**
  37598. * Public members
  37599. */
  37600. originalPostProcess: Nullable<PostProcess>;
  37601. downSampleX4PostProcess: Nullable<PostProcess>;
  37602. brightPassPostProcess: Nullable<PostProcess>;
  37603. blurHPostProcesses: PostProcess[];
  37604. blurVPostProcesses: PostProcess[];
  37605. textureAdderPostProcess: Nullable<PostProcess>;
  37606. volumetricLightPostProcess: Nullable<PostProcess>;
  37607. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  37608. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  37609. volumetricLightMergePostProces: Nullable<PostProcess>;
  37610. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  37611. luminancePostProcess: Nullable<PostProcess>;
  37612. luminanceDownSamplePostProcesses: PostProcess[];
  37613. hdrPostProcess: Nullable<PostProcess>;
  37614. textureAdderFinalPostProcess: Nullable<PostProcess>;
  37615. lensFlareFinalPostProcess: Nullable<PostProcess>;
  37616. hdrFinalPostProcess: Nullable<PostProcess>;
  37617. lensFlarePostProcess: Nullable<PostProcess>;
  37618. lensFlareComposePostProcess: Nullable<PostProcess>;
  37619. motionBlurPostProcess: Nullable<PostProcess>;
  37620. depthOfFieldPostProcess: Nullable<PostProcess>;
  37621. brightThreshold: number;
  37622. blurWidth: number;
  37623. horizontalBlur: boolean;
  37624. exposure: number;
  37625. lensTexture: Nullable<Texture>;
  37626. volumetricLightCoefficient: number;
  37627. volumetricLightPower: number;
  37628. volumetricLightBlurScale: number;
  37629. sourceLight: Nullable<SpotLight | DirectionalLight>;
  37630. hdrMinimumLuminance: number;
  37631. hdrDecreaseRate: number;
  37632. hdrIncreaseRate: number;
  37633. lensColorTexture: Nullable<Texture>;
  37634. lensFlareStrength: number;
  37635. lensFlareGhostDispersal: number;
  37636. lensFlareHaloWidth: number;
  37637. lensFlareDistortionStrength: number;
  37638. lensStarTexture: Nullable<Texture>;
  37639. lensFlareDirtTexture: Nullable<Texture>;
  37640. depthOfFieldDistance: number;
  37641. depthOfFieldBlurWidth: number;
  37642. motionStrength: number;
  37643. animations: Animation[];
  37644. /**
  37645. * Private members
  37646. */
  37647. private _scene;
  37648. private _currentDepthOfFieldSource;
  37649. private _basePostProcess;
  37650. private _hdrCurrentLuminance;
  37651. private _floatTextureType;
  37652. private _ratio;
  37653. private _bloomEnabled;
  37654. private _depthOfFieldEnabled;
  37655. private _vlsEnabled;
  37656. private _lensFlareEnabled;
  37657. private _hdrEnabled;
  37658. private _motionBlurEnabled;
  37659. private _motionBlurSamples;
  37660. private _volumetricLightStepsCount;
  37661. BloomEnabled: boolean;
  37662. DepthOfFieldEnabled: boolean;
  37663. LensFlareEnabled: boolean;
  37664. HDREnabled: boolean;
  37665. VLSEnabled: boolean;
  37666. MotionBlurEnabled: boolean;
  37667. volumetricLightStepsCount: number;
  37668. motionBlurSamples: number;
  37669. /**
  37670. * @constructor
  37671. * @param {string} name - The rendering pipeline name
  37672. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37673. * @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)
  37674. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  37675. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37676. */
  37677. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  37678. private _buildPipeline();
  37679. private _createDownSampleX4PostProcess(scene, ratio);
  37680. private _createBrightPassPostProcess(scene, ratio);
  37681. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  37682. private _createTextureAdderPostProcess(scene, ratio);
  37683. private _createVolumetricLightPostProcess(scene, ratio);
  37684. private _createLuminancePostProcesses(scene, textureType);
  37685. private _createHdrPostProcess(scene, ratio);
  37686. private _createLensFlarePostProcess(scene, ratio);
  37687. private _createDepthOfFieldPostProcess(scene, ratio);
  37688. private _createMotionBlurPostProcess(scene, ratio);
  37689. private _getDepthTexture();
  37690. private _disposePostProcesses();
  37691. /**
  37692. * Dispose of the pipeline and stop all post processes
  37693. */
  37694. dispose(): void;
  37695. /**
  37696. * Serialize the rendering pipeline (Used when exporting)
  37697. * @returns the serialized object
  37698. */
  37699. serialize(): any;
  37700. /**
  37701. * Parse the serialized pipeline
  37702. * @param source Source pipeline.
  37703. * @param scene The scene to load the pipeline to.
  37704. * @param rootUrl The URL of the serialized pipeline.
  37705. * @returns An instantiated pipeline from the serialized object.
  37706. */
  37707. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  37708. static LuminanceSteps: number;
  37709. }
  37710. }